You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

main.js 699KB

2 years ago
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959
  1. /*!
  2. FullCalendar v5.10.1
  3. Docs & License: https://fullcalendar.io/
  4. (c) 2021 Adam Shaw
  5. */
  6. var FullCalendar = (function (exports) {
  7. 'use strict';
  8. /*! *****************************************************************************
  9. Copyright (c) Microsoft Corporation.
  10. Permission to use, copy, modify, and/or distribute this software for any
  11. purpose with or without fee is hereby granted.
  12. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
  13. REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
  14. AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
  15. INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  16. LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
  17. OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  18. PERFORMANCE OF THIS SOFTWARE.
  19. ***************************************************************************** */
  20. /* global Reflect, Promise */
  21. var extendStatics = function(d, b) {
  22. extendStatics = Object.setPrototypeOf ||
  23. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  24. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  25. return extendStatics(d, b);
  26. };
  27. function __extends(d, b) {
  28. if (typeof b !== "function" && b !== null)
  29. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  30. extendStatics(d, b);
  31. function __() { this.constructor = d; }
  32. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  33. }
  34. var __assign = function() {
  35. __assign = Object.assign || function __assign(t) {
  36. for (var s, i = 1, n = arguments.length; i < n; i++) {
  37. s = arguments[i];
  38. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  39. }
  40. return t;
  41. };
  42. return __assign.apply(this, arguments);
  43. };
  44. function __spreadArray(to, from, pack) {
  45. if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
  46. if (ar || !(i in from)) {
  47. if (!ar) ar = Array.prototype.slice.call(from, 0, i);
  48. ar[i] = from[i];
  49. }
  50. }
  51. return to.concat(ar || from);
  52. }
  53. var n,u,i$1,t,o,r$1={},f$1=[],e$1=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i;function c$1(n,l){for(var u in l)n[u]=l[u];return n}function s(n){var l=n.parentNode;l&&l.removeChild(n);}function a$1(n,l,u){var i,t,o,r=arguments,f={};for(o in l)"key"==o?i=l[o]:"ref"==o?t=l[o]:f[o]=l[o];if(arguments.length>3)for(u=[u],o=3;o<arguments.length;o++)u.push(r[o]);if(null!=u&&(f.children=u),"function"==typeof n&&null!=n.defaultProps)for(o in n.defaultProps)void 0===f[o]&&(f[o]=n.defaultProps[o]);return v$1(n,f,i,t,null)}function v$1(l,u,i,t,o){var r={type:l,props:u,key:i,ref:t,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,__h:null,constructor:void 0,__v:null==o?++n.__v:o};return null!=n.vnode&&n.vnode(r),r}function h(){return {current:null}}function y(n){return n.children}function p(n,l){this.props=n,this.context=l;}function d(n,l){if(null==l)return n.__?d(n.__,n.__.__k.indexOf(n)+1):null;for(var u;l<n.__k.length;l++)if(null!=(u=n.__k[l])&&null!=u.__e)return u.__e;return "function"==typeof n.type?d(n):null}function _(n){var l,u;if(null!=(n=n.__)&&null!=n.__c){for(n.__e=n.__c.base=null,l=0;l<n.__k.length;l++)if(null!=(u=n.__k[l])&&null!=u.__e){n.__e=n.__c.base=u.__e;break}return _(n)}}function k(l){(!l.__d&&(l.__d=!0)&&u.push(l)&&!b$1.__r++||t!==n.debounceRendering)&&((t=n.debounceRendering)||i$1)(b$1);}function b$1(){for(var n;b$1.__r=u.length;)n=u.sort(function(n,l){return n.__v.__b-l.__v.__b}),u=[],n.some(function(n){var l,u,i,t,o,r;n.__d&&(o=(t=(l=n).__v).__e,(r=l.__P)&&(u=[],(i=c$1({},t)).__v=t.__v+1,I$1(r,t,i,l.__n,void 0!==r.ownerSVGElement,null!=t.__h?[o]:null,u,null==o?d(t):o,t.__h),T$1(u,t),t.__e!=o&&_(t)));});}function m(n,l,u,i,t,o,e,c,s,a){var h,p,_,k,b,m,w,A=i&&i.__k||f$1,P=A.length;for(u.__k=[],h=0;h<l.length;h++)if(null!=(k=u.__k[h]=null==(k=l[h])||"boolean"==typeof k?null:"string"==typeof k||"number"==typeof k||"bigint"==typeof k?v$1(null,k,null,null,k):Array.isArray(k)?v$1(y,{children:k},null,null,null):k.__b>0?v$1(k.type,k.props,k.key,null,k.__v):k)){if(k.__=u,k.__b=u.__b+1,null===(_=A[h])||_&&k.key==_.key&&k.type===_.type)A[h]=void 0;else for(p=0;p<P;p++){if((_=A[p])&&k.key==_.key&&k.type===_.type){A[p]=void 0;break}_=null;}I$1(n,k,_=_||r$1,t,o,e,c,s,a),b=k.__e,(p=k.ref)&&_.ref!=p&&(w||(w=[]),_.ref&&w.push(_.ref,null,k),w.push(p,k.__c||b,k)),null!=b?(null==m&&(m=b),"function"==typeof k.type&&null!=k.__k&&k.__k===_.__k?k.__d=s=g$1(k,s,n):s=x$1(n,k,_,A,b,s),a||"option"!==u.type?"function"==typeof u.type&&(u.__d=s):n.value=""):s&&_.__e==s&&s.parentNode!=n&&(s=d(_));}for(u.__e=m,h=P;h--;)null!=A[h]&&("function"==typeof u.type&&null!=A[h].__e&&A[h].__e==u.__d&&(u.__d=d(i,h+1)),L$1(A[h],A[h]));if(w)for(h=0;h<w.length;h++)z(w[h],w[++h],w[++h]);}function g$1(n,l,u){var i,t;for(i=0;i<n.__k.length;i++)(t=n.__k[i])&&(t.__=n,l="function"==typeof t.type?g$1(t,l,u):x$1(u,t,t,n.__k,t.__e,l));return l}function w$1(n,l){return l=l||[],null==n||"boolean"==typeof n||(Array.isArray(n)?n.some(function(n){w$1(n,l);}):l.push(n)),l}function x$1(n,l,u,i,t,o){var r,f,e;if(void 0!==l.__d)r=l.__d,l.__d=void 0;else if(null==u||t!=o||null==t.parentNode)n:if(null==o||o.parentNode!==n)n.appendChild(t),r=null;else {for(f=o,e=0;(f=f.nextSibling)&&e<i.length;e+=2)if(f==t)break n;n.insertBefore(t,o),r=o;}return void 0!==r?r:t.nextSibling}function A$1(n,l,u,i,t){var o;for(o in u)"children"===o||"key"===o||o in l||C$1(n,o,null,u[o],i);for(o in l)t&&"function"!=typeof l[o]||"children"===o||"key"===o||"value"===o||"checked"===o||u[o]===l[o]||C$1(n,o,l[o],u[o],i);}function P$1(n,l,u){"-"===l[0]?n.setProperty(l,u):n[l]=null==u?"":"number"!=typeof u||e$1.test(l)?u:u+"px";}function C$1(n,l,u,i,t){var o;n:if("style"===l)if("string"==typeof u)n.style.cssText=u;else {if("string"==typeof i&&(n.style.cssText=i=""),i)for(l in i)u&&l in u||P$1(n.style,l,"");if(u)for(l in u)i&&u[l]===i[l]||P$1(n.style,l,u[l]);}else if("o"===l[0]&&"n"===l[1])o=l!==(l=l.replace(/Capture$/,"")),l=l.toLowerCase()in n?l.toLowerCase().slice(2):l.slice(2),n.l||(n.l={}),n.l[l+o]=u,u?i||n.addEventListener(l,o?H$1:$$1,o):n.removeEventListener(l,o?H$1:$$1,o);else if("dangerouslySetInnerHTML"!==l){if(t)l=l.replace(/xlink[H:h]/,"h").replace(/sName$/,"s");else if("href"!==l&&"list"!==l&&"form"!==l&&"tabIndex"!==l&&"download"!==l&&l in n)try{n[l]=null==u?"":u;break n}catch(n){}"function"==typeof u||(null!=u&&(!1!==u||"a"===l[0]&&"r"===l[1])?n.setAttribute(l,u):n.removeAttribute(l));}}function $$1(l){this.l[l.type+!1](n.event?n.event(l):l);}function H$1(l){this.l[l.type+!0](n.event?n.event(l):l);}function I$1(l,u,i,t,o,r,f,e,s){var a,v,h,d,_,k,b,g,w,x,A,P=u.type;if(void 0!==u.constructor)return null;null!=i.__h&&(s=i.__h,e=u.__e=i.__e,u.__h=null,r=[e]),(a=n.__b)&&a(u);try{n:if("function"==typeof P){if(g=u.props,w=(a=P.contextType)&&t[a.__c],x=a?w?w.props.value:a.__:t,i.__c?b=(v=u.__c=i.__c).__=v.__E:("prototype"in P&&P.prototype.render?u.__c=v=new P(g,x):(u.__c=v=new p(g,x),v.constructor=P,v.render=M$1),w&&w.sub(v),v.props=g,v.state||(v.state={}),v.context=x,v.__n=t,h=v.__d=!0,v.__h=[]),null==v.__s&&(v.__s=v.state),null!=P.getDerivedStateFromProps&&(v.__s==v.state&&(v.__s=c$1({},v.__s)),c$1(v.__s,P.getDerivedStateFromProps(g,v.__s))),d=v.props,_=v.state,h)null==P.getDerivedStateFromProps&&null!=v.componentWillMount&&v.componentWillMount(),null!=v.componentDidMount&&v.__h.push(v.componentDidMount);else {if(null==P.getDerivedStateFromProps&&g!==d&&null!=v.componentWillReceiveProps&&v.componentWillReceiveProps(g,x),!v.__e&&null!=v.shouldComponentUpdate&&!1===v.shouldComponentUpdate(g,v.__s,x)||u.__v===i.__v){v.props=g,v.state=v.__s,u.__v!==i.__v&&(v.__d=!1),v.__v=u,u.__e=i.__e,u.__k=i.__k,u.__k.forEach(function(n){n&&(n.__=u);}),v.__h.length&&f.push(v);break n}null!=v.componentWillUpdate&&v.componentWillUpdate(g,v.__s,x),null!=v.componentDidUpdate&&v.__h.push(function(){v.componentDidUpdate(d,_,k);});}v.context=x,v.props=g,v.state=v.__s,(a=n.__r)&&a(u),v.__d=!1,v.__v=u,v.__P=l,a=v.render(v.props,v.state,v.context),v.state=v.__s,null!=v.getChildContext&&(t=c$1(c$1({},t),v.getChildContext())),h||null==v.getSnapshotBeforeUpdate||(k=v.getSnapshotBeforeUpdate(d,_)),A=null!=a&&a.type===y&&null==a.key?a.props.children:a,m(l,Array.isArray(A)?A:[A],u,i,t,o,r,f,e,s),v.base=u.__e,u.__h=null,v.__h.length&&f.push(v),b&&(v.__E=v.__=null),v.__e=!1;}else null==r&&u.__v===i.__v?(u.__k=i.__k,u.__e=i.__e):u.__e=j$2(i.__e,u,i,t,o,r,f,s);(a=n.diffed)&&a(u);}catch(l){u.__v=null,(s||null!=r)&&(u.__e=e,u.__h=!!s,r[r.indexOf(e)]=null),n.__e(l,u,i);}}function T$1(l,u){n.__c&&n.__c(u,l),l.some(function(u){try{l=u.__h,u.__h=[],l.some(function(n){n.call(u);});}catch(l){n.__e(l,u.__v);}});}function j$2(n,l,u,i,t,o,e,c){var a,v,h,y,p=u.props,d=l.props,_=l.type,k=0;if("svg"===_&&(t=!0),null!=o)for(;k<o.length;k++)if((a=o[k])&&(a===n||(_?a.localName==_:3==a.nodeType))){n=a,o[k]=null;break}if(null==n){if(null===_)return document.createTextNode(d);n=t?document.createElementNS("http://www.w3.org/2000/svg",_):document.createElement(_,d.is&&d),o=null,c=!1;}if(null===_)p===d||c&&n.data===d||(n.data=d);else {if(o=o&&f$1.slice.call(n.childNodes),v=(p=u.props||r$1).dangerouslySetInnerHTML,h=d.dangerouslySetInnerHTML,!c){if(null!=o)for(p={},y=0;y<n.attributes.length;y++)p[n.attributes[y].name]=n.attributes[y].value;(h||v)&&(h&&(v&&h.__html==v.__html||h.__html===n.innerHTML)||(n.innerHTML=h&&h.__html||""));}if(A$1(n,d,p,t,c),h)l.__k=[];else if(k=l.props.children,m(n,Array.isArray(k)?k:[k],l,u,i,t&&"foreignObject"!==_,o,e,n.firstChild,c),null!=o)for(k=o.length;k--;)null!=o[k]&&s(o[k]);c||("value"in d&&void 0!==(k=d.value)&&(k!==n.value||"progress"===_&&!k)&&C$1(n,"value",k,p.value,!1),"checked"in d&&void 0!==(k=d.checked)&&k!==n.checked&&C$1(n,"checked",k,p.checked,!1));}return n}function z(l,u,i){try{"function"==typeof l?l(u):l.current=u;}catch(l){n.__e(l,i);}}function L$1(l,u,i){var t,o,r;if(n.unmount&&n.unmount(l),(t=l.ref)&&(t.current&&t.current!==l.__e||z(t,null,u)),i||"function"==typeof l.type||(i=null!=(o=l.__e)),l.__e=l.__d=void 0,null!=(t=l.__c)){if(t.componentWillUnmount)try{t.componentWillUnmount();}catch(l){n.__e(l,u);}t.base=t.__P=null;}if(t=l.__k)for(r=0;r<t.length;r++)t[r]&&L$1(t[r],u,i);null!=o&&s(o);}function M$1(n,l,u){return this.constructor(n,u)}function N(l,u,i){var t,o,e;n.__&&n.__(l,u),o=(t="function"==typeof i)?null:i&&i.__k||u.__k,e=[],I$1(u,l=(!t&&i||u).__k=a$1(y,null,[l]),o||r$1,r$1,void 0!==u.ownerSVGElement,!t&&i?[i]:o?null:u.firstChild?f$1.slice.call(u.childNodes):null,e,!t&&i?i:o?o.__e:u.firstChild,t),T$1(e,l);}function q(n,l){var u={__c:l="__cC"+o++,__:n,Consumer:function(n,l){return n.children(l)},Provider:function(n){var u,i;return this.getChildContext||(u=[],(i={})[l]=this,this.getChildContext=function(){return i},this.shouldComponentUpdate=function(n){this.props.value!==n.value&&u.some(k);},this.sub=function(n){u.push(n);var l=n.componentWillUnmount;n.componentWillUnmount=function(){u.splice(u.indexOf(n),1),l&&l.call(n);};}),n.children}};return u.Provider.__=u.Consumer.contextType=u}n={__e:function(n,l){for(var u,i,t;l=l.__;)if((u=l.__c)&&!u.__)try{if((i=u.constructor)&&null!=i.getDerivedStateFromError&&(u.setState(i.getDerivedStateFromError(n)),t=u.__d),null!=u.componentDidCatch&&(u.componentDidCatch(n),t=u.__d),t)return u.__E=u}catch(l){n=l;}throw n},__v:0},p.prototype.setState=function(n,l){var u;u=null!=this.__s&&this.__s!==this.state?this.__s:this.__s=c$1({},this.state),"function"==typeof n&&(n=n(c$1({},u),this.props)),n&&c$1(u,n),null!=n&&this.__v&&(l&&this.__h.push(l),k(this));},p.prototype.forceUpdate=function(n){this.__v&&(this.__e=!0,n&&this.__h.push(n),k(this));},p.prototype.render=y,u=[],i$1="function"==typeof Promise?Promise.prototype.then.bind(Promise.resolve()):setTimeout,b$1.__r=0,o=0;
  54. var r,i=[],c=n.__b,f=n.__r,e=n.diffed,a=n.__c,v=n.unmount;function x(){i.forEach(function(t){if(t.__P)try{t.__H.__h.forEach(g),t.__H.__h.forEach(j$1),t.__H.__h=[];}catch(u){t.__H.__h=[],n.__e(u,t.__v);}}),i=[];}n.__b=function(n){c&&c(n);},n.__r=function(n){f&&f(n);var r=(n.__c).__H;r&&(r.__h.forEach(g),r.__h.forEach(j$1),r.__h=[]);},n.diffed=function(t){e&&e(t);var o=t.__c;o&&o.__H&&o.__H.__h.length&&(1!==i.push(o)&&r===n.requestAnimationFrame||((r=n.requestAnimationFrame)||function(n){var t,u=function(){clearTimeout(r),b&&cancelAnimationFrame(t),setTimeout(n);},r=setTimeout(u,100);b&&(t=requestAnimationFrame(u));})(x));},n.__c=function(t,u){u.some(function(t){try{t.__h.forEach(g),t.__h=t.__h.filter(function(n){return !n.__||j$1(n)});}catch(r){u.some(function(n){n.__h&&(n.__h=[]);}),u=[],n.__e(r,t.__v);}}),a&&a(t,u);},n.unmount=function(t){v&&v(t);var u=t.__c;if(u&&u.__H)try{u.__H.__.forEach(g);}catch(t){n.__e(t,u.__v);}};var b="function"==typeof requestAnimationFrame;function g(n){"function"==typeof n.__c&&n.__c();}function j$1(n){n.__c=n.__();}
  55. function C(n,t){for(var e in t)n[e]=t[e];return n}function S(n,t){for(var e in n)if("__source"!==e&&!(e in t))return !0;for(var r in t)if("__source"!==r&&n[r]!==t[r])return !0;return !1}function E(n){this.props=n;}(E.prototype=new p).isPureReactComponent=!0,E.prototype.shouldComponentUpdate=function(n,t){return S(this.props,n)||S(this.state,t)};var w=n.__b;n.__b=function(n){n.type&&n.type.__f&&n.ref&&(n.props.ref=n.ref,n.ref=null),w&&w(n);};var A=n.__e;n.__e=function(n,t,e){if(n.then)for(var r,u=t;u=u.__;)if((r=u.__c)&&r.__c)return null==t.__e&&(t.__e=e.__e,t.__k=e.__k),r.__c(n,t);A(n,t,e);};var O=n.unmount;function L(){this.__u=0,this.t=null,this.__b=null;}function U(n){var t=n.__.__c;return t&&t.__e&&t.__e(n)}function F(){this.u=null,this.o=null;}n.unmount=function(n){var t=n.__c;t&&t.__R&&t.__R(),t&&!0===n.__h&&(n.type=null),O&&O(n);},(L.prototype=new p).__c=function(n,t){var e=t.__c,r=this;null==r.t&&(r.t=[]),r.t.push(e);var u=U(r.__v),o=!1,i=function(){o||(o=!0,e.__R=null,u?u(l):l());};e.__R=i;var l=function(){if(!--r.__u){if(r.state.__e){var n=r.state.__e;r.__v.__k[0]=function n(t,e,r){return t&&(t.__v=null,t.__k=t.__k&&t.__k.map(function(t){return n(t,e,r)}),t.__c&&t.__c.__P===e&&(t.__e&&r.insertBefore(t.__e,t.__d),t.__c.__e=!0,t.__c.__P=r)),t}(n,n.__c.__P,n.__c.__O);}var t;for(r.setState({__e:r.__b=null});t=r.t.pop();)t.forceUpdate();}},f=!0===t.__h;r.__u++||f||r.setState({__e:r.__b=r.__v.__k[0]}),n.then(i,i);},L.prototype.componentWillUnmount=function(){this.t=[];},L.prototype.render=function(n,t){if(this.__b){if(this.__v.__k){var e=document.createElement("div"),r=this.__v.__k[0].__c;this.__v.__k[0]=function n(t,e,r){return t&&(t.__c&&t.__c.__H&&(t.__c.__H.__.forEach(function(n){"function"==typeof n.__c&&n.__c();}),t.__c.__H=null),null!=(t=C({},t)).__c&&(t.__c.__P===r&&(t.__c.__P=e),t.__c=null),t.__k=t.__k&&t.__k.map(function(t){return n(t,e,r)})),t}(this.__b,e,r.__O=r.__P);}this.__b=null;}var u=t.__e&&a$1(y,null,n.fallback);return u&&(u.__h=null),[a$1(y,null,t.__e?null:n.children),u]};var M=function(n,t,e){if(++e[1]===e[0]&&n.o.delete(t),n.props.revealOrder&&("t"!==n.props.revealOrder[0]||!n.o.size))for(e=n.u;e;){for(;e.length>3;)e.pop()();if(e[1]<e[0])break;n.u=e=e[2];}};function T(n){return this.getChildContext=function(){return n.context},n.children}function j(n){var t=this,e=n.i;t.componentWillUnmount=function(){N(null,t.l),t.l=null,t.i=null;},t.i&&t.i!==e&&t.componentWillUnmount(),n.__v?(t.l||(t.i=e,t.l={nodeType:1,parentNode:e,childNodes:[],appendChild:function(n){this.childNodes.push(n),t.i.appendChild(n);},insertBefore:function(n,e){this.childNodes.push(n),t.i.appendChild(n);},removeChild:function(n){this.childNodes.splice(this.childNodes.indexOf(n)>>>1,1),t.i.removeChild(n);}}),N(a$1(T,{context:t.context},n.__v),t.l)):t.l&&t.componentWillUnmount();}function I(n,t){return a$1(j,{__v:n,i:t})}(F.prototype=new p).__e=function(n){var t=this,e=U(t.__v),r=t.o.get(n);return r[0]++,function(u){var o=function(){t.props.revealOrder?(r.push(u),M(t,n,r)):u();};e?e(o):o();}},F.prototype.render=function(n){this.u=null,this.o=new Map;var t=w$1(n.children);n.revealOrder&&"b"===n.revealOrder[0]&&t.reverse();for(var e=t.length;e--;)this.o.set(t[e],this.u=[1,0,this.u]);return n.children},F.prototype.componentDidUpdate=F.prototype.componentDidMount=function(){var n=this;this.o.forEach(function(t,e){M(n,e,t);});};var W="undefined"!=typeof Symbol&&Symbol.for&&Symbol.for("react.element")||60103,P=/^(?:accent|alignment|arabic|baseline|cap|clip(?!PathU)|color|fill|flood|font|glyph(?!R)|horiz|marker(?!H|W|U)|overline|paint|stop|strikethrough|stroke|text(?!L)|underline|unicode|units|v|vector|vert|word|writing|x(?!C))[A-Z]/,V=function(n){return ("undefined"!=typeof Symbol&&"symbol"==typeof Symbol()?/fil|che|rad/i:/fil|che|ra/i).test(n)};p.prototype.isReactComponent={},["componentWillMount","componentWillReceiveProps","componentWillUpdate"].forEach(function(n){Object.defineProperty(p.prototype,n,{configurable:!0,get:function(){return this["UNSAFE_"+n]},set:function(t){Object.defineProperty(this,n,{configurable:!0,writable:!0,value:t});}});});var H=n.event;function Z(){}function Y(){return this.cancelBubble}function $(){return this.defaultPrevented}n.event=function(n){return H&&(n=H(n)),n.persist=Z,n.isPropagationStopped=Y,n.isDefaultPrevented=$,n.nativeEvent=n};var G={configurable:!0,get:function(){return this.class}},J=n.vnode;n.vnode=function(n){var t=n.type,e=n.props,r=e;if("string"==typeof t){for(var u in r={},e){var o=e[u];"value"===u&&"defaultValue"in e&&null==o||("defaultValue"===u&&"value"in e&&null==e.value?u="value":"download"===u&&!0===o?o="":/ondoubleclick/i.test(u)?u="ondblclick":/^onchange(textarea|input)/i.test(u+t)&&!V(e.type)?u="oninput":/^on(Ani|Tra|Tou|BeforeInp)/.test(u)?u=u.toLowerCase():P.test(u)?u=u.replace(/[A-Z0-9]/,"-$&").toLowerCase():null===o&&(o=void 0),r[u]=o);}"select"==t&&r.multiple&&Array.isArray(r.value)&&(r.value=w$1(e.children).forEach(function(n){n.props.selected=-1!=r.value.indexOf(n.props.value);})),"select"==t&&null!=r.defaultValue&&(r.value=w$1(e.children).forEach(function(n){n.props.selected=r.multiple?-1!=r.defaultValue.indexOf(n.props.value):r.defaultValue==n.props.value;})),n.props=r;}t&&e.class!=e.className&&(G.enumerable="className"in e,null!=e.className&&(r.class=e.className),Object.defineProperty(r,"className",G)),n.$$typeof=W,J&&J(n);};var K=n.__r;n.__r=function(n){K&&K(n);};"object"==typeof performance&&"function"==typeof performance.now?performance.now.bind(performance):function(){return Date.now()};
  56. var globalObj = typeof globalThis !== 'undefined' ? globalThis : window; // // TODO: streamline when killing IE11 support
  57. if (globalObj.FullCalendarVDom) {
  58. console.warn('FullCalendar VDOM already loaded');
  59. }
  60. else {
  61. globalObj.FullCalendarVDom = {
  62. Component: p,
  63. createElement: a$1,
  64. render: N,
  65. createRef: h,
  66. Fragment: y,
  67. createContext: createContext$1,
  68. createPortal: I,
  69. flushToDom: flushToDom$1,
  70. unmountComponentAtNode: unmountComponentAtNode$1,
  71. };
  72. }
  73. // HACKS...
  74. // TODO: lock version
  75. // TODO: link gh issues
  76. function flushToDom$1() {
  77. var oldDebounceRendering = n.debounceRendering; // orig
  78. var callbackQ = [];
  79. function execCallbackSync(callback) {
  80. callbackQ.push(callback);
  81. }
  82. n.debounceRendering = execCallbackSync;
  83. N(a$1(FakeComponent, {}), document.createElement('div'));
  84. while (callbackQ.length) {
  85. callbackQ.shift()();
  86. }
  87. n.debounceRendering = oldDebounceRendering;
  88. }
  89. var FakeComponent = /** @class */ (function (_super) {
  90. __extends(FakeComponent, _super);
  91. function FakeComponent() {
  92. return _super !== null && _super.apply(this, arguments) || this;
  93. }
  94. FakeComponent.prototype.render = function () { return a$1('div', {}); };
  95. FakeComponent.prototype.componentDidMount = function () { this.setState({}); };
  96. return FakeComponent;
  97. }(p));
  98. function createContext$1(defaultValue) {
  99. var ContextType = q(defaultValue);
  100. var origProvider = ContextType.Provider;
  101. ContextType.Provider = function () {
  102. var _this = this;
  103. var isNew = !this.getChildContext;
  104. var children = origProvider.apply(this, arguments); // eslint-disable-line prefer-rest-params
  105. if (isNew) {
  106. var subs_1 = [];
  107. this.shouldComponentUpdate = function (_props) {
  108. if (_this.props.value !== _props.value) {
  109. subs_1.forEach(function (c) {
  110. c.context = _props.value;
  111. c.forceUpdate();
  112. });
  113. }
  114. };
  115. this.sub = function (c) {
  116. subs_1.push(c);
  117. var old = c.componentWillUnmount;
  118. c.componentWillUnmount = function () {
  119. subs_1.splice(subs_1.indexOf(c), 1);
  120. old && old.call(c);
  121. };
  122. };
  123. }
  124. return children;
  125. };
  126. return ContextType;
  127. }
  128. function unmountComponentAtNode$1(node) {
  129. N(null, node);
  130. }
  131. // no public types yet. when there are, export from:
  132. // import {} from './api-type-deps'
  133. var EventSourceApi = /** @class */ (function () {
  134. function EventSourceApi(context, internalEventSource) {
  135. this.context = context;
  136. this.internalEventSource = internalEventSource;
  137. }
  138. EventSourceApi.prototype.remove = function () {
  139. this.context.dispatch({
  140. type: 'REMOVE_EVENT_SOURCE',
  141. sourceId: this.internalEventSource.sourceId,
  142. });
  143. };
  144. EventSourceApi.prototype.refetch = function () {
  145. this.context.dispatch({
  146. type: 'FETCH_EVENT_SOURCES',
  147. sourceIds: [this.internalEventSource.sourceId],
  148. isRefetch: true,
  149. });
  150. };
  151. Object.defineProperty(EventSourceApi.prototype, "id", {
  152. get: function () {
  153. return this.internalEventSource.publicId;
  154. },
  155. enumerable: false,
  156. configurable: true
  157. });
  158. Object.defineProperty(EventSourceApi.prototype, "url", {
  159. get: function () {
  160. return this.internalEventSource.meta.url;
  161. },
  162. enumerable: false,
  163. configurable: true
  164. });
  165. Object.defineProperty(EventSourceApi.prototype, "format", {
  166. get: function () {
  167. return this.internalEventSource.meta.format; // TODO: bad. not guaranteed
  168. },
  169. enumerable: false,
  170. configurable: true
  171. });
  172. return EventSourceApi;
  173. }());
  174. function removeElement(el) {
  175. if (el.parentNode) {
  176. el.parentNode.removeChild(el);
  177. }
  178. }
  179. // Querying
  180. // ----------------------------------------------------------------------------------------------------------------
  181. function elementClosest(el, selector) {
  182. if (el.closest) {
  183. return el.closest(selector);
  184. // really bad fallback for IE
  185. // from https://developer.mozilla.org/en-US/docs/Web/API/Element/closest
  186. }
  187. if (!document.documentElement.contains(el)) {
  188. return null;
  189. }
  190. do {
  191. if (elementMatches(el, selector)) {
  192. return el;
  193. }
  194. el = (el.parentElement || el.parentNode);
  195. } while (el !== null && el.nodeType === 1);
  196. return null;
  197. }
  198. function elementMatches(el, selector) {
  199. var method = el.matches || el.matchesSelector || el.msMatchesSelector;
  200. return method.call(el, selector);
  201. }
  202. // accepts multiple subject els
  203. // returns a real array. good for methods like forEach
  204. // TODO: accept the document
  205. function findElements(container, selector) {
  206. var containers = container instanceof HTMLElement ? [container] : container;
  207. var allMatches = [];
  208. for (var i = 0; i < containers.length; i += 1) {
  209. var matches = containers[i].querySelectorAll(selector);
  210. for (var j = 0; j < matches.length; j += 1) {
  211. allMatches.push(matches[j]);
  212. }
  213. }
  214. return allMatches;
  215. }
  216. // accepts multiple subject els
  217. // only queries direct child elements // TODO: rename to findDirectChildren!
  218. function findDirectChildren(parent, selector) {
  219. var parents = parent instanceof HTMLElement ? [parent] : parent;
  220. var allMatches = [];
  221. for (var i = 0; i < parents.length; i += 1) {
  222. var childNodes = parents[i].children; // only ever elements
  223. for (var j = 0; j < childNodes.length; j += 1) {
  224. var childNode = childNodes[j];
  225. if (!selector || elementMatches(childNode, selector)) {
  226. allMatches.push(childNode);
  227. }
  228. }
  229. }
  230. return allMatches;
  231. }
  232. // Style
  233. // ----------------------------------------------------------------------------------------------------------------
  234. var PIXEL_PROP_RE = /(top|left|right|bottom|width|height)$/i;
  235. function applyStyle(el, props) {
  236. for (var propName in props) {
  237. applyStyleProp(el, propName, props[propName]);
  238. }
  239. }
  240. function applyStyleProp(el, name, val) {
  241. if (val == null) {
  242. el.style[name] = '';
  243. }
  244. else if (typeof val === 'number' && PIXEL_PROP_RE.test(name)) {
  245. el.style[name] = val + "px";
  246. }
  247. else {
  248. el.style[name] = val;
  249. }
  250. }
  251. // Event Handling
  252. // ----------------------------------------------------------------------------------------------------------------
  253. // if intercepting bubbled events at the document/window/body level,
  254. // and want to see originating element (the 'target'), use this util instead
  255. // of `ev.target` because it goes within web-component boundaries.
  256. function getEventTargetViaRoot(ev) {
  257. var _a, _b;
  258. return (_b = (_a = ev.composedPath) === null || _a === void 0 ? void 0 : _a.call(ev)[0]) !== null && _b !== void 0 ? _b : ev.target;
  259. }
  260. // Shadow DOM consuderations
  261. // ----------------------------------------------------------------------------------------------------------------
  262. function getElRoot(el) {
  263. return el.getRootNode ? el.getRootNode() : document;
  264. }
  265. // Unique ID for DOM attribute
  266. var guid$1 = 0;
  267. function getUniqueDomId() {
  268. guid$1 += 1;
  269. return 'fc-dom-' + guid$1;
  270. }
  271. // Stops a mouse/touch event from doing it's native browser action
  272. function preventDefault(ev) {
  273. ev.preventDefault();
  274. }
  275. // Event Delegation
  276. // ----------------------------------------------------------------------------------------------------------------
  277. function buildDelegationHandler(selector, handler) {
  278. return function (ev) {
  279. var matchedChild = elementClosest(ev.target, selector);
  280. if (matchedChild) {
  281. handler.call(matchedChild, ev, matchedChild);
  282. }
  283. };
  284. }
  285. function listenBySelector(container, eventType, selector, handler) {
  286. var attachedHandler = buildDelegationHandler(selector, handler);
  287. container.addEventListener(eventType, attachedHandler);
  288. return function () {
  289. container.removeEventListener(eventType, attachedHandler);
  290. };
  291. }
  292. function listenToHoverBySelector(container, selector, onMouseEnter, onMouseLeave) {
  293. var currentMatchedChild;
  294. return listenBySelector(container, 'mouseover', selector, function (mouseOverEv, matchedChild) {
  295. if (matchedChild !== currentMatchedChild) {
  296. currentMatchedChild = matchedChild;
  297. onMouseEnter(mouseOverEv, matchedChild);
  298. var realOnMouseLeave_1 = function (mouseLeaveEv) {
  299. currentMatchedChild = null;
  300. onMouseLeave(mouseLeaveEv, matchedChild);
  301. matchedChild.removeEventListener('mouseleave', realOnMouseLeave_1);
  302. };
  303. // listen to the next mouseleave, and then unattach
  304. matchedChild.addEventListener('mouseleave', realOnMouseLeave_1);
  305. }
  306. });
  307. }
  308. // Animation
  309. // ----------------------------------------------------------------------------------------------------------------
  310. var transitionEventNames = [
  311. 'webkitTransitionEnd',
  312. 'otransitionend',
  313. 'oTransitionEnd',
  314. 'msTransitionEnd',
  315. 'transitionend',
  316. ];
  317. // triggered only when the next single subsequent transition finishes
  318. function whenTransitionDone(el, callback) {
  319. var realCallback = function (ev) {
  320. callback(ev);
  321. transitionEventNames.forEach(function (eventName) {
  322. el.removeEventListener(eventName, realCallback);
  323. });
  324. };
  325. transitionEventNames.forEach(function (eventName) {
  326. el.addEventListener(eventName, realCallback); // cross-browser way to determine when the transition finishes
  327. });
  328. }
  329. // ARIA workarounds
  330. // ----------------------------------------------------------------------------------------------------------------
  331. function createAriaClickAttrs(handler) {
  332. return __assign({ onClick: handler }, createAriaKeyboardAttrs(handler));
  333. }
  334. function createAriaKeyboardAttrs(handler) {
  335. return {
  336. tabIndex: 0,
  337. onKeyDown: function (ev) {
  338. if (ev.key === 'Enter' || ev.key === ' ') {
  339. handler(ev);
  340. ev.preventDefault(); // if space, don't scroll down page
  341. }
  342. },
  343. };
  344. }
  345. var guidNumber = 0;
  346. function guid() {
  347. guidNumber += 1;
  348. return String(guidNumber);
  349. }
  350. /* FullCalendar-specific DOM Utilities
  351. ----------------------------------------------------------------------------------------------------------------------*/
  352. // Make the mouse cursor express that an event is not allowed in the current area
  353. function disableCursor() {
  354. document.body.classList.add('fc-not-allowed');
  355. }
  356. // Returns the mouse cursor to its original look
  357. function enableCursor() {
  358. document.body.classList.remove('fc-not-allowed');
  359. }
  360. /* Selection
  361. ----------------------------------------------------------------------------------------------------------------------*/
  362. function preventSelection(el) {
  363. el.classList.add('fc-unselectable');
  364. el.addEventListener('selectstart', preventDefault);
  365. }
  366. function allowSelection(el) {
  367. el.classList.remove('fc-unselectable');
  368. el.removeEventListener('selectstart', preventDefault);
  369. }
  370. /* Context Menu
  371. ----------------------------------------------------------------------------------------------------------------------*/
  372. function preventContextMenu(el) {
  373. el.addEventListener('contextmenu', preventDefault);
  374. }
  375. function allowContextMenu(el) {
  376. el.removeEventListener('contextmenu', preventDefault);
  377. }
  378. function parseFieldSpecs(input) {
  379. var specs = [];
  380. var tokens = [];
  381. var i;
  382. var token;
  383. if (typeof input === 'string') {
  384. tokens = input.split(/\s*,\s*/);
  385. }
  386. else if (typeof input === 'function') {
  387. tokens = [input];
  388. }
  389. else if (Array.isArray(input)) {
  390. tokens = input;
  391. }
  392. for (i = 0; i < tokens.length; i += 1) {
  393. token = tokens[i];
  394. if (typeof token === 'string') {
  395. specs.push(token.charAt(0) === '-' ?
  396. { field: token.substring(1), order: -1 } :
  397. { field: token, order: 1 });
  398. }
  399. else if (typeof token === 'function') {
  400. specs.push({ func: token });
  401. }
  402. }
  403. return specs;
  404. }
  405. function compareByFieldSpecs(obj0, obj1, fieldSpecs) {
  406. var i;
  407. var cmp;
  408. for (i = 0; i < fieldSpecs.length; i += 1) {
  409. cmp = compareByFieldSpec(obj0, obj1, fieldSpecs[i]);
  410. if (cmp) {
  411. return cmp;
  412. }
  413. }
  414. return 0;
  415. }
  416. function compareByFieldSpec(obj0, obj1, fieldSpec) {
  417. if (fieldSpec.func) {
  418. return fieldSpec.func(obj0, obj1);
  419. }
  420. return flexibleCompare(obj0[fieldSpec.field], obj1[fieldSpec.field])
  421. * (fieldSpec.order || 1);
  422. }
  423. function flexibleCompare(a, b) {
  424. if (!a && !b) {
  425. return 0;
  426. }
  427. if (b == null) {
  428. return -1;
  429. }
  430. if (a == null) {
  431. return 1;
  432. }
  433. if (typeof a === 'string' || typeof b === 'string') {
  434. return String(a).localeCompare(String(b));
  435. }
  436. return a - b;
  437. }
  438. /* String Utilities
  439. ----------------------------------------------------------------------------------------------------------------------*/
  440. function padStart(val, len) {
  441. var s = String(val);
  442. return '000'.substr(0, len - s.length) + s;
  443. }
  444. function formatWithOrdinals(formatter, args, fallbackText) {
  445. if (typeof formatter === 'function') {
  446. return formatter.apply(void 0, args);
  447. }
  448. if (typeof formatter === 'string') { // non-blank string
  449. return args.reduce(function (str, arg, index) { return (str.replace('$' + index, arg || '')); }, formatter);
  450. }
  451. return fallbackText;
  452. }
  453. /* Number Utilities
  454. ----------------------------------------------------------------------------------------------------------------------*/
  455. function compareNumbers(a, b) {
  456. return a - b;
  457. }
  458. function isInt(n) {
  459. return n % 1 === 0;
  460. }
  461. /* FC-specific DOM dimension stuff
  462. ----------------------------------------------------------------------------------------------------------------------*/
  463. function computeSmallestCellWidth(cellEl) {
  464. var allWidthEl = cellEl.querySelector('.fc-scrollgrid-shrink-frame');
  465. var contentWidthEl = cellEl.querySelector('.fc-scrollgrid-shrink-cushion');
  466. if (!allWidthEl) {
  467. throw new Error('needs fc-scrollgrid-shrink-frame className'); // TODO: use const
  468. }
  469. if (!contentWidthEl) {
  470. throw new Error('needs fc-scrollgrid-shrink-cushion className');
  471. }
  472. return cellEl.getBoundingClientRect().width - allWidthEl.getBoundingClientRect().width + // the cell padding+border
  473. contentWidthEl.getBoundingClientRect().width;
  474. }
  475. var DAY_IDS = ['sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat'];
  476. // Adding
  477. function addWeeks(m, n) {
  478. var a = dateToUtcArray(m);
  479. a[2] += n * 7;
  480. return arrayToUtcDate(a);
  481. }
  482. function addDays(m, n) {
  483. var a = dateToUtcArray(m);
  484. a[2] += n;
  485. return arrayToUtcDate(a);
  486. }
  487. function addMs(m, n) {
  488. var a = dateToUtcArray(m);
  489. a[6] += n;
  490. return arrayToUtcDate(a);
  491. }
  492. // Diffing (all return floats)
  493. // TODO: why not use ranges?
  494. function diffWeeks(m0, m1) {
  495. return diffDays(m0, m1) / 7;
  496. }
  497. function diffDays(m0, m1) {
  498. return (m1.valueOf() - m0.valueOf()) / (1000 * 60 * 60 * 24);
  499. }
  500. function diffHours(m0, m1) {
  501. return (m1.valueOf() - m0.valueOf()) / (1000 * 60 * 60);
  502. }
  503. function diffMinutes(m0, m1) {
  504. return (m1.valueOf() - m0.valueOf()) / (1000 * 60);
  505. }
  506. function diffSeconds(m0, m1) {
  507. return (m1.valueOf() - m0.valueOf()) / 1000;
  508. }
  509. function diffDayAndTime(m0, m1) {
  510. var m0day = startOfDay(m0);
  511. var m1day = startOfDay(m1);
  512. return {
  513. years: 0,
  514. months: 0,
  515. days: Math.round(diffDays(m0day, m1day)),
  516. milliseconds: (m1.valueOf() - m1day.valueOf()) - (m0.valueOf() - m0day.valueOf()),
  517. };
  518. }
  519. // Diffing Whole Units
  520. function diffWholeWeeks(m0, m1) {
  521. var d = diffWholeDays(m0, m1);
  522. if (d !== null && d % 7 === 0) {
  523. return d / 7;
  524. }
  525. return null;
  526. }
  527. function diffWholeDays(m0, m1) {
  528. if (timeAsMs(m0) === timeAsMs(m1)) {
  529. return Math.round(diffDays(m0, m1));
  530. }
  531. return null;
  532. }
  533. // Start-Of
  534. function startOfDay(m) {
  535. return arrayToUtcDate([
  536. m.getUTCFullYear(),
  537. m.getUTCMonth(),
  538. m.getUTCDate(),
  539. ]);
  540. }
  541. function startOfHour(m) {
  542. return arrayToUtcDate([
  543. m.getUTCFullYear(),
  544. m.getUTCMonth(),
  545. m.getUTCDate(),
  546. m.getUTCHours(),
  547. ]);
  548. }
  549. function startOfMinute(m) {
  550. return arrayToUtcDate([
  551. m.getUTCFullYear(),
  552. m.getUTCMonth(),
  553. m.getUTCDate(),
  554. m.getUTCHours(),
  555. m.getUTCMinutes(),
  556. ]);
  557. }
  558. function startOfSecond(m) {
  559. return arrayToUtcDate([
  560. m.getUTCFullYear(),
  561. m.getUTCMonth(),
  562. m.getUTCDate(),
  563. m.getUTCHours(),
  564. m.getUTCMinutes(),
  565. m.getUTCSeconds(),
  566. ]);
  567. }
  568. // Week Computation
  569. function weekOfYear(marker, dow, doy) {
  570. var y = marker.getUTCFullYear();
  571. var w = weekOfGivenYear(marker, y, dow, doy);
  572. if (w < 1) {
  573. return weekOfGivenYear(marker, y - 1, dow, doy);
  574. }
  575. var nextW = weekOfGivenYear(marker, y + 1, dow, doy);
  576. if (nextW >= 1) {
  577. return Math.min(w, nextW);
  578. }
  579. return w;
  580. }
  581. function weekOfGivenYear(marker, year, dow, doy) {
  582. var firstWeekStart = arrayToUtcDate([year, 0, 1 + firstWeekOffset(year, dow, doy)]);
  583. var dayStart = startOfDay(marker);
  584. var days = Math.round(diffDays(firstWeekStart, dayStart));
  585. return Math.floor(days / 7) + 1; // zero-indexed
  586. }
  587. // start-of-first-week - start-of-year
  588. function firstWeekOffset(year, dow, doy) {
  589. // first-week day -- which january is always in the first week (4 for iso, 1 for other)
  590. var fwd = 7 + dow - doy;
  591. // first-week day local weekday -- which local weekday is fwd
  592. var fwdlw = (7 + arrayToUtcDate([year, 0, fwd]).getUTCDay() - dow) % 7;
  593. return -fwdlw + fwd - 1;
  594. }
  595. // Array Conversion
  596. function dateToLocalArray(date) {
  597. return [
  598. date.getFullYear(),
  599. date.getMonth(),
  600. date.getDate(),
  601. date.getHours(),
  602. date.getMinutes(),
  603. date.getSeconds(),
  604. date.getMilliseconds(),
  605. ];
  606. }
  607. function arrayToLocalDate(a) {
  608. return new Date(a[0], a[1] || 0, a[2] == null ? 1 : a[2], // day of month
  609. a[3] || 0, a[4] || 0, a[5] || 0);
  610. }
  611. function dateToUtcArray(date) {
  612. return [
  613. date.getUTCFullYear(),
  614. date.getUTCMonth(),
  615. date.getUTCDate(),
  616. date.getUTCHours(),
  617. date.getUTCMinutes(),
  618. date.getUTCSeconds(),
  619. date.getUTCMilliseconds(),
  620. ];
  621. }
  622. function arrayToUtcDate(a) {
  623. // according to web standards (and Safari), a month index is required.
  624. // massage if only given a year.
  625. if (a.length === 1) {
  626. a = a.concat([0]);
  627. }
  628. return new Date(Date.UTC.apply(Date, a));
  629. }
  630. // Other Utils
  631. function isValidDate(m) {
  632. return !isNaN(m.valueOf());
  633. }
  634. function timeAsMs(m) {
  635. return m.getUTCHours() * 1000 * 60 * 60 +
  636. m.getUTCMinutes() * 1000 * 60 +
  637. m.getUTCSeconds() * 1000 +
  638. m.getUTCMilliseconds();
  639. }
  640. function createEventInstance(defId, range, forcedStartTzo, forcedEndTzo) {
  641. return {
  642. instanceId: guid(),
  643. defId: defId,
  644. range: range,
  645. forcedStartTzo: forcedStartTzo == null ? null : forcedStartTzo,
  646. forcedEndTzo: forcedEndTzo == null ? null : forcedEndTzo,
  647. };
  648. }
  649. var hasOwnProperty = Object.prototype.hasOwnProperty;
  650. // Merges an array of objects into a single object.
  651. // The second argument allows for an array of property names who's object values will be merged together.
  652. function mergeProps(propObjs, complexPropsMap) {
  653. var dest = {};
  654. if (complexPropsMap) {
  655. for (var name_1 in complexPropsMap) {
  656. var complexObjs = [];
  657. // collect the trailing object values, stopping when a non-object is discovered
  658. for (var i = propObjs.length - 1; i >= 0; i -= 1) {
  659. var val = propObjs[i][name_1];
  660. if (typeof val === 'object' && val) { // non-null object
  661. complexObjs.unshift(val);
  662. }
  663. else if (val !== undefined) {
  664. dest[name_1] = val; // if there were no objects, this value will be used
  665. break;
  666. }
  667. }
  668. // if the trailing values were objects, use the merged value
  669. if (complexObjs.length) {
  670. dest[name_1] = mergeProps(complexObjs);
  671. }
  672. }
  673. }
  674. // copy values into the destination, going from last to first
  675. for (var i = propObjs.length - 1; i >= 0; i -= 1) {
  676. var props = propObjs[i];
  677. for (var name_2 in props) {
  678. if (!(name_2 in dest)) { // if already assigned by previous props or complex props, don't reassign
  679. dest[name_2] = props[name_2];
  680. }
  681. }
  682. }
  683. return dest;
  684. }
  685. function filterHash(hash, func) {
  686. var filtered = {};
  687. for (var key in hash) {
  688. if (func(hash[key], key)) {
  689. filtered[key] = hash[key];
  690. }
  691. }
  692. return filtered;
  693. }
  694. function mapHash(hash, func) {
  695. var newHash = {};
  696. for (var key in hash) {
  697. newHash[key] = func(hash[key], key);
  698. }
  699. return newHash;
  700. }
  701. function arrayToHash(a) {
  702. var hash = {};
  703. for (var _i = 0, a_1 = a; _i < a_1.length; _i++) {
  704. var item = a_1[_i];
  705. hash[item] = true;
  706. }
  707. return hash;
  708. }
  709. function buildHashFromArray(a, func) {
  710. var hash = {};
  711. for (var i = 0; i < a.length; i += 1) {
  712. var tuple = func(a[i], i);
  713. hash[tuple[0]] = tuple[1];
  714. }
  715. return hash;
  716. }
  717. function hashValuesToArray(obj) {
  718. var a = [];
  719. for (var key in obj) {
  720. a.push(obj[key]);
  721. }
  722. return a;
  723. }
  724. function isPropsEqual(obj0, obj1) {
  725. if (obj0 === obj1) {
  726. return true;
  727. }
  728. for (var key in obj0) {
  729. if (hasOwnProperty.call(obj0, key)) {
  730. if (!(key in obj1)) {
  731. return false;
  732. }
  733. }
  734. }
  735. for (var key in obj1) {
  736. if (hasOwnProperty.call(obj1, key)) {
  737. if (obj0[key] !== obj1[key]) {
  738. return false;
  739. }
  740. }
  741. }
  742. return true;
  743. }
  744. function getUnequalProps(obj0, obj1) {
  745. var keys = [];
  746. for (var key in obj0) {
  747. if (hasOwnProperty.call(obj0, key)) {
  748. if (!(key in obj1)) {
  749. keys.push(key);
  750. }
  751. }
  752. }
  753. for (var key in obj1) {
  754. if (hasOwnProperty.call(obj1, key)) {
  755. if (obj0[key] !== obj1[key]) {
  756. keys.push(key);
  757. }
  758. }
  759. }
  760. return keys;
  761. }
  762. function compareObjs(oldProps, newProps, equalityFuncs) {
  763. if (equalityFuncs === void 0) { equalityFuncs = {}; }
  764. if (oldProps === newProps) {
  765. return true;
  766. }
  767. for (var key in newProps) {
  768. if (key in oldProps && isObjValsEqual(oldProps[key], newProps[key], equalityFuncs[key])) ;
  769. else {
  770. return false;
  771. }
  772. }
  773. // check for props that were omitted in the new
  774. for (var key in oldProps) {
  775. if (!(key in newProps)) {
  776. return false;
  777. }
  778. }
  779. return true;
  780. }
  781. /*
  782. assumed "true" equality for handler names like "onReceiveSomething"
  783. */
  784. function isObjValsEqual(val0, val1, comparator) {
  785. if (val0 === val1 || comparator === true) {
  786. return true;
  787. }
  788. if (comparator) {
  789. return comparator(val0, val1);
  790. }
  791. return false;
  792. }
  793. function collectFromHash(hash, startIndex, endIndex, step) {
  794. if (startIndex === void 0) { startIndex = 0; }
  795. if (step === void 0) { step = 1; }
  796. var res = [];
  797. if (endIndex == null) {
  798. endIndex = Object.keys(hash).length;
  799. }
  800. for (var i = startIndex; i < endIndex; i += step) {
  801. var val = hash[i];
  802. if (val !== undefined) { // will disregard undefined for sparse arrays
  803. res.push(val);
  804. }
  805. }
  806. return res;
  807. }
  808. function parseRecurring(refined, defaultAllDay, dateEnv, recurringTypes) {
  809. for (var i = 0; i < recurringTypes.length; i += 1) {
  810. var parsed = recurringTypes[i].parse(refined, dateEnv);
  811. if (parsed) {
  812. var allDay = refined.allDay;
  813. if (allDay == null) {
  814. allDay = defaultAllDay;
  815. if (allDay == null) {
  816. allDay = parsed.allDayGuess;
  817. if (allDay == null) {
  818. allDay = false;
  819. }
  820. }
  821. }
  822. return {
  823. allDay: allDay,
  824. duration: parsed.duration,
  825. typeData: parsed.typeData,
  826. typeId: i,
  827. };
  828. }
  829. }
  830. return null;
  831. }
  832. function expandRecurring(eventStore, framingRange, context) {
  833. var dateEnv = context.dateEnv, pluginHooks = context.pluginHooks, options = context.options;
  834. var defs = eventStore.defs, instances = eventStore.instances;
  835. // remove existing recurring instances
  836. // TODO: bad. always expand events as a second step
  837. instances = filterHash(instances, function (instance) { return !defs[instance.defId].recurringDef; });
  838. for (var defId in defs) {
  839. var def = defs[defId];
  840. if (def.recurringDef) {
  841. var duration = def.recurringDef.duration;
  842. if (!duration) {
  843. duration = def.allDay ?
  844. options.defaultAllDayEventDuration :
  845. options.defaultTimedEventDuration;
  846. }
  847. var starts = expandRecurringRanges(def, duration, framingRange, dateEnv, pluginHooks.recurringTypes);
  848. for (var _i = 0, starts_1 = starts; _i < starts_1.length; _i++) {
  849. var start = starts_1[_i];
  850. var instance = createEventInstance(defId, {
  851. start: start,
  852. end: dateEnv.add(start, duration),
  853. });
  854. instances[instance.instanceId] = instance;
  855. }
  856. }
  857. }
  858. return { defs: defs, instances: instances };
  859. }
  860. /*
  861. Event MUST have a recurringDef
  862. */
  863. function expandRecurringRanges(eventDef, duration, framingRange, dateEnv, recurringTypes) {
  864. var typeDef = recurringTypes[eventDef.recurringDef.typeId];
  865. var markers = typeDef.expand(eventDef.recurringDef.typeData, {
  866. start: dateEnv.subtract(framingRange.start, duration),
  867. end: framingRange.end,
  868. }, dateEnv);
  869. // the recurrence plugins don't guarantee that all-day events are start-of-day, so we have to
  870. if (eventDef.allDay) {
  871. markers = markers.map(startOfDay);
  872. }
  873. return markers;
  874. }
  875. var INTERNAL_UNITS = ['years', 'months', 'days', 'milliseconds'];
  876. var PARSE_RE = /^(-?)(?:(\d+)\.)?(\d+):(\d\d)(?::(\d\d)(?:\.(\d\d\d))?)?/;
  877. // Parsing and Creation
  878. function createDuration(input, unit) {
  879. var _a;
  880. if (typeof input === 'string') {
  881. return parseString(input);
  882. }
  883. if (typeof input === 'object' && input) { // non-null object
  884. return parseObject(input);
  885. }
  886. if (typeof input === 'number') {
  887. return parseObject((_a = {}, _a[unit || 'milliseconds'] = input, _a));
  888. }
  889. return null;
  890. }
  891. function parseString(s) {
  892. var m = PARSE_RE.exec(s);
  893. if (m) {
  894. var sign = m[1] ? -1 : 1;
  895. return {
  896. years: 0,
  897. months: 0,
  898. days: sign * (m[2] ? parseInt(m[2], 10) : 0),
  899. milliseconds: sign * ((m[3] ? parseInt(m[3], 10) : 0) * 60 * 60 * 1000 + // hours
  900. (m[4] ? parseInt(m[4], 10) : 0) * 60 * 1000 + // minutes
  901. (m[5] ? parseInt(m[5], 10) : 0) * 1000 + // seconds
  902. (m[6] ? parseInt(m[6], 10) : 0) // ms
  903. ),
  904. };
  905. }
  906. return null;
  907. }
  908. function parseObject(obj) {
  909. var duration = {
  910. years: obj.years || obj.year || 0,
  911. months: obj.months || obj.month || 0,
  912. days: obj.days || obj.day || 0,
  913. milliseconds: (obj.hours || obj.hour || 0) * 60 * 60 * 1000 + // hours
  914. (obj.minutes || obj.minute || 0) * 60 * 1000 + // minutes
  915. (obj.seconds || obj.second || 0) * 1000 + // seconds
  916. (obj.milliseconds || obj.millisecond || obj.ms || 0), // ms
  917. };
  918. var weeks = obj.weeks || obj.week;
  919. if (weeks) {
  920. duration.days += weeks * 7;
  921. duration.specifiedWeeks = true;
  922. }
  923. return duration;
  924. }
  925. // Equality
  926. function durationsEqual(d0, d1) {
  927. return d0.years === d1.years &&
  928. d0.months === d1.months &&
  929. d0.days === d1.days &&
  930. d0.milliseconds === d1.milliseconds;
  931. }
  932. function asCleanDays(dur) {
  933. if (!dur.years && !dur.months && !dur.milliseconds) {
  934. return dur.days;
  935. }
  936. return 0;
  937. }
  938. // Simple Math
  939. function addDurations(d0, d1) {
  940. return {
  941. years: d0.years + d1.years,
  942. months: d0.months + d1.months,
  943. days: d0.days + d1.days,
  944. milliseconds: d0.milliseconds + d1.milliseconds,
  945. };
  946. }
  947. function subtractDurations(d1, d0) {
  948. return {
  949. years: d1.years - d0.years,
  950. months: d1.months - d0.months,
  951. days: d1.days - d0.days,
  952. milliseconds: d1.milliseconds - d0.milliseconds,
  953. };
  954. }
  955. function multiplyDuration(d, n) {
  956. return {
  957. years: d.years * n,
  958. months: d.months * n,
  959. days: d.days * n,
  960. milliseconds: d.milliseconds * n,
  961. };
  962. }
  963. // Conversions
  964. // "Rough" because they are based on average-case Gregorian months/years
  965. function asRoughYears(dur) {
  966. return asRoughDays(dur) / 365;
  967. }
  968. function asRoughMonths(dur) {
  969. return asRoughDays(dur) / 30;
  970. }
  971. function asRoughDays(dur) {
  972. return asRoughMs(dur) / 864e5;
  973. }
  974. function asRoughMinutes(dur) {
  975. return asRoughMs(dur) / (1000 * 60);
  976. }
  977. function asRoughSeconds(dur) {
  978. return asRoughMs(dur) / 1000;
  979. }
  980. function asRoughMs(dur) {
  981. return dur.years * (365 * 864e5) +
  982. dur.months * (30 * 864e5) +
  983. dur.days * 864e5 +
  984. dur.milliseconds;
  985. }
  986. // Advanced Math
  987. function wholeDivideDurations(numerator, denominator) {
  988. var res = null;
  989. for (var i = 0; i < INTERNAL_UNITS.length; i += 1) {
  990. var unit = INTERNAL_UNITS[i];
  991. if (denominator[unit]) {
  992. var localRes = numerator[unit] / denominator[unit];
  993. if (!isInt(localRes) || (res !== null && res !== localRes)) {
  994. return null;
  995. }
  996. res = localRes;
  997. }
  998. else if (numerator[unit]) {
  999. // needs to divide by something but can't!
  1000. return null;
  1001. }
  1002. }
  1003. return res;
  1004. }
  1005. function greatestDurationDenominator(dur) {
  1006. var ms = dur.milliseconds;
  1007. if (ms) {
  1008. if (ms % 1000 !== 0) {
  1009. return { unit: 'millisecond', value: ms };
  1010. }
  1011. if (ms % (1000 * 60) !== 0) {
  1012. return { unit: 'second', value: ms / 1000 };
  1013. }
  1014. if (ms % (1000 * 60 * 60) !== 0) {
  1015. return { unit: 'minute', value: ms / (1000 * 60) };
  1016. }
  1017. if (ms) {
  1018. return { unit: 'hour', value: ms / (1000 * 60 * 60) };
  1019. }
  1020. }
  1021. if (dur.days) {
  1022. if (dur.specifiedWeeks && dur.days % 7 === 0) {
  1023. return { unit: 'week', value: dur.days / 7 };
  1024. }
  1025. return { unit: 'day', value: dur.days };
  1026. }
  1027. if (dur.months) {
  1028. return { unit: 'month', value: dur.months };
  1029. }
  1030. if (dur.years) {
  1031. return { unit: 'year', value: dur.years };
  1032. }
  1033. return { unit: 'millisecond', value: 0 };
  1034. }
  1035. // timeZoneOffset is in minutes
  1036. function buildIsoString(marker, timeZoneOffset, stripZeroTime) {
  1037. if (stripZeroTime === void 0) { stripZeroTime = false; }
  1038. var s = marker.toISOString();
  1039. s = s.replace('.000', '');
  1040. if (stripZeroTime) {
  1041. s = s.replace('T00:00:00Z', '');
  1042. }
  1043. if (s.length > 10) { // time part wasn't stripped, can add timezone info
  1044. if (timeZoneOffset == null) {
  1045. s = s.replace('Z', '');
  1046. }
  1047. else if (timeZoneOffset !== 0) {
  1048. s = s.replace('Z', formatTimeZoneOffset(timeZoneOffset, true));
  1049. }
  1050. // otherwise, its UTC-0 and we want to keep the Z
  1051. }
  1052. return s;
  1053. }
  1054. // formats the date, but with no time part
  1055. // TODO: somehow merge with buildIsoString and stripZeroTime
  1056. // TODO: rename. omit "string"
  1057. function formatDayString(marker) {
  1058. return marker.toISOString().replace(/T.*$/, '');
  1059. }
  1060. // TODO: use Date::toISOString and use everything after the T?
  1061. function formatIsoTimeString(marker) {
  1062. return padStart(marker.getUTCHours(), 2) + ':' +
  1063. padStart(marker.getUTCMinutes(), 2) + ':' +
  1064. padStart(marker.getUTCSeconds(), 2);
  1065. }
  1066. function formatTimeZoneOffset(minutes, doIso) {
  1067. if (doIso === void 0) { doIso = false; }
  1068. var sign = minutes < 0 ? '-' : '+';
  1069. var abs = Math.abs(minutes);
  1070. var hours = Math.floor(abs / 60);
  1071. var mins = Math.round(abs % 60);
  1072. if (doIso) {
  1073. return sign + padStart(hours, 2) + ":" + padStart(mins, 2);
  1074. }
  1075. return "GMT" + sign + hours + (mins ? ":" + padStart(mins, 2) : '');
  1076. }
  1077. // TODO: new util arrayify?
  1078. function removeExact(array, exactVal) {
  1079. var removeCnt = 0;
  1080. var i = 0;
  1081. while (i < array.length) {
  1082. if (array[i] === exactVal) {
  1083. array.splice(i, 1);
  1084. removeCnt += 1;
  1085. }
  1086. else {
  1087. i += 1;
  1088. }
  1089. }
  1090. return removeCnt;
  1091. }
  1092. function isArraysEqual(a0, a1, equalityFunc) {
  1093. if (a0 === a1) {
  1094. return true;
  1095. }
  1096. var len = a0.length;
  1097. var i;
  1098. if (len !== a1.length) { // not array? or not same length?
  1099. return false;
  1100. }
  1101. for (i = 0; i < len; i += 1) {
  1102. if (!(equalityFunc ? equalityFunc(a0[i], a1[i]) : a0[i] === a1[i])) {
  1103. return false;
  1104. }
  1105. }
  1106. return true;
  1107. }
  1108. function memoize(workerFunc, resEquality, teardownFunc) {
  1109. var currentArgs;
  1110. var currentRes;
  1111. return function () {
  1112. var newArgs = [];
  1113. for (var _i = 0; _i < arguments.length; _i++) {
  1114. newArgs[_i] = arguments[_i];
  1115. }
  1116. if (!currentArgs) {
  1117. currentRes = workerFunc.apply(this, newArgs);
  1118. }
  1119. else if (!isArraysEqual(currentArgs, newArgs)) {
  1120. if (teardownFunc) {
  1121. teardownFunc(currentRes);
  1122. }
  1123. var res = workerFunc.apply(this, newArgs);
  1124. if (!resEquality || !resEquality(res, currentRes)) {
  1125. currentRes = res;
  1126. }
  1127. }
  1128. currentArgs = newArgs;
  1129. return currentRes;
  1130. };
  1131. }
  1132. function memoizeObjArg(workerFunc, resEquality, teardownFunc) {
  1133. var _this = this;
  1134. var currentArg;
  1135. var currentRes;
  1136. return function (newArg) {
  1137. if (!currentArg) {
  1138. currentRes = workerFunc.call(_this, newArg);
  1139. }
  1140. else if (!isPropsEqual(currentArg, newArg)) {
  1141. if (teardownFunc) {
  1142. teardownFunc(currentRes);
  1143. }
  1144. var res = workerFunc.call(_this, newArg);
  1145. if (!resEquality || !resEquality(res, currentRes)) {
  1146. currentRes = res;
  1147. }
  1148. }
  1149. currentArg = newArg;
  1150. return currentRes;
  1151. };
  1152. }
  1153. function memoizeArraylike(// used at all?
  1154. workerFunc, resEquality, teardownFunc) {
  1155. var _this = this;
  1156. var currentArgSets = [];
  1157. var currentResults = [];
  1158. return function (newArgSets) {
  1159. var currentLen = currentArgSets.length;
  1160. var newLen = newArgSets.length;
  1161. var i = 0;
  1162. for (; i < currentLen; i += 1) {
  1163. if (!newArgSets[i]) { // one of the old sets no longer exists
  1164. if (teardownFunc) {
  1165. teardownFunc(currentResults[i]);
  1166. }
  1167. }
  1168. else if (!isArraysEqual(currentArgSets[i], newArgSets[i])) {
  1169. if (teardownFunc) {
  1170. teardownFunc(currentResults[i]);
  1171. }
  1172. var res = workerFunc.apply(_this, newArgSets[i]);
  1173. if (!resEquality || !resEquality(res, currentResults[i])) {
  1174. currentResults[i] = res;
  1175. }
  1176. }
  1177. }
  1178. for (; i < newLen; i += 1) {
  1179. currentResults[i] = workerFunc.apply(_this, newArgSets[i]);
  1180. }
  1181. currentArgSets = newArgSets;
  1182. currentResults.splice(newLen); // remove excess
  1183. return currentResults;
  1184. };
  1185. }
  1186. function memoizeHashlike(// used?
  1187. workerFunc, resEquality, teardownFunc) {
  1188. var _this = this;
  1189. var currentArgHash = {};
  1190. var currentResHash = {};
  1191. return function (newArgHash) {
  1192. var newResHash = {};
  1193. for (var key in newArgHash) {
  1194. if (!currentResHash[key]) {
  1195. newResHash[key] = workerFunc.apply(_this, newArgHash[key]);
  1196. }
  1197. else if (!isArraysEqual(currentArgHash[key], newArgHash[key])) {
  1198. if (teardownFunc) {
  1199. teardownFunc(currentResHash[key]);
  1200. }
  1201. var res = workerFunc.apply(_this, newArgHash[key]);
  1202. newResHash[key] = (resEquality && resEquality(res, currentResHash[key]))
  1203. ? currentResHash[key]
  1204. : res;
  1205. }
  1206. else {
  1207. newResHash[key] = currentResHash[key];
  1208. }
  1209. }
  1210. currentArgHash = newArgHash;
  1211. currentResHash = newResHash;
  1212. return newResHash;
  1213. };
  1214. }
  1215. var EXTENDED_SETTINGS_AND_SEVERITIES = {
  1216. week: 3,
  1217. separator: 0,
  1218. omitZeroMinute: 0,
  1219. meridiem: 0,
  1220. omitCommas: 0,
  1221. };
  1222. var STANDARD_DATE_PROP_SEVERITIES = {
  1223. timeZoneName: 7,
  1224. era: 6,
  1225. year: 5,
  1226. month: 4,
  1227. day: 2,
  1228. weekday: 2,
  1229. hour: 1,
  1230. minute: 1,
  1231. second: 1,
  1232. };
  1233. var MERIDIEM_RE = /\s*([ap])\.?m\.?/i; // eats up leading spaces too
  1234. var COMMA_RE = /,/g; // we need re for globalness
  1235. var MULTI_SPACE_RE = /\s+/g;
  1236. var LTR_RE = /\u200e/g; // control character
  1237. var UTC_RE = /UTC|GMT/;
  1238. var NativeFormatter = /** @class */ (function () {
  1239. function NativeFormatter(formatSettings) {
  1240. var standardDateProps = {};
  1241. var extendedSettings = {};
  1242. var severity = 0;
  1243. for (var name_1 in formatSettings) {
  1244. if (name_1 in EXTENDED_SETTINGS_AND_SEVERITIES) {
  1245. extendedSettings[name_1] = formatSettings[name_1];
  1246. severity = Math.max(EXTENDED_SETTINGS_AND_SEVERITIES[name_1], severity);
  1247. }
  1248. else {
  1249. standardDateProps[name_1] = formatSettings[name_1];
  1250. if (name_1 in STANDARD_DATE_PROP_SEVERITIES) { // TODO: what about hour12? no severity
  1251. severity = Math.max(STANDARD_DATE_PROP_SEVERITIES[name_1], severity);
  1252. }
  1253. }
  1254. }
  1255. this.standardDateProps = standardDateProps;
  1256. this.extendedSettings = extendedSettings;
  1257. this.severity = severity;
  1258. this.buildFormattingFunc = memoize(buildFormattingFunc);
  1259. }
  1260. NativeFormatter.prototype.format = function (date, context) {
  1261. return this.buildFormattingFunc(this.standardDateProps, this.extendedSettings, context)(date);
  1262. };
  1263. NativeFormatter.prototype.formatRange = function (start, end, context, betterDefaultSeparator) {
  1264. var _a = this, standardDateProps = _a.standardDateProps, extendedSettings = _a.extendedSettings;
  1265. var diffSeverity = computeMarkerDiffSeverity(start.marker, end.marker, context.calendarSystem);
  1266. if (!diffSeverity) {
  1267. return this.format(start, context);
  1268. }
  1269. var biggestUnitForPartial = diffSeverity;
  1270. if (biggestUnitForPartial > 1 && // the two dates are different in a way that's larger scale than time
  1271. (standardDateProps.year === 'numeric' || standardDateProps.year === '2-digit') &&
  1272. (standardDateProps.month === 'numeric' || standardDateProps.month === '2-digit') &&
  1273. (standardDateProps.day === 'numeric' || standardDateProps.day === '2-digit')) {
  1274. biggestUnitForPartial = 1; // make it look like the dates are only different in terms of time
  1275. }
  1276. var full0 = this.format(start, context);
  1277. var full1 = this.format(end, context);
  1278. if (full0 === full1) {
  1279. return full0;
  1280. }
  1281. var partialDateProps = computePartialFormattingOptions(standardDateProps, biggestUnitForPartial);
  1282. var partialFormattingFunc = buildFormattingFunc(partialDateProps, extendedSettings, context);
  1283. var partial0 = partialFormattingFunc(start);
  1284. var partial1 = partialFormattingFunc(end);
  1285. var insertion = findCommonInsertion(full0, partial0, full1, partial1);
  1286. var separator = extendedSettings.separator || betterDefaultSeparator || context.defaultSeparator || '';
  1287. if (insertion) {
  1288. return insertion.before + partial0 + separator + partial1 + insertion.after;
  1289. }
  1290. return full0 + separator + full1;
  1291. };
  1292. NativeFormatter.prototype.getLargestUnit = function () {
  1293. switch (this.severity) {
  1294. case 7:
  1295. case 6:
  1296. case 5:
  1297. return 'year';
  1298. case 4:
  1299. return 'month';
  1300. case 3:
  1301. return 'week';
  1302. case 2:
  1303. return 'day';
  1304. default:
  1305. return 'time'; // really?
  1306. }
  1307. };
  1308. return NativeFormatter;
  1309. }());
  1310. function buildFormattingFunc(standardDateProps, extendedSettings, context) {
  1311. var standardDatePropCnt = Object.keys(standardDateProps).length;
  1312. if (standardDatePropCnt === 1 && standardDateProps.timeZoneName === 'short') {
  1313. return function (date) { return (formatTimeZoneOffset(date.timeZoneOffset)); };
  1314. }
  1315. if (standardDatePropCnt === 0 && extendedSettings.week) {
  1316. return function (date) { return (formatWeekNumber(context.computeWeekNumber(date.marker), context.weekText, context.weekTextLong, context.locale, extendedSettings.week)); };
  1317. }
  1318. return buildNativeFormattingFunc(standardDateProps, extendedSettings, context);
  1319. }
  1320. function buildNativeFormattingFunc(standardDateProps, extendedSettings, context) {
  1321. standardDateProps = __assign({}, standardDateProps); // copy
  1322. extendedSettings = __assign({}, extendedSettings); // copy
  1323. sanitizeSettings(standardDateProps, extendedSettings);
  1324. standardDateProps.timeZone = 'UTC'; // we leverage the only guaranteed timeZone for our UTC markers
  1325. var normalFormat = new Intl.DateTimeFormat(context.locale.codes, standardDateProps);
  1326. var zeroFormat; // needed?
  1327. if (extendedSettings.omitZeroMinute) {
  1328. var zeroProps = __assign({}, standardDateProps);
  1329. delete zeroProps.minute; // seconds and ms were already considered in sanitizeSettings
  1330. zeroFormat = new Intl.DateTimeFormat(context.locale.codes, zeroProps);
  1331. }
  1332. return function (date) {
  1333. var marker = date.marker;
  1334. var format;
  1335. if (zeroFormat && !marker.getUTCMinutes()) {
  1336. format = zeroFormat;
  1337. }
  1338. else {
  1339. format = normalFormat;
  1340. }
  1341. var s = format.format(marker);
  1342. return postProcess(s, date, standardDateProps, extendedSettings, context);
  1343. };
  1344. }
  1345. function sanitizeSettings(standardDateProps, extendedSettings) {
  1346. // deal with a browser inconsistency where formatting the timezone
  1347. // requires that the hour/minute be present.
  1348. if (standardDateProps.timeZoneName) {
  1349. if (!standardDateProps.hour) {
  1350. standardDateProps.hour = '2-digit';
  1351. }
  1352. if (!standardDateProps.minute) {
  1353. standardDateProps.minute = '2-digit';
  1354. }
  1355. }
  1356. // only support short timezone names
  1357. if (standardDateProps.timeZoneName === 'long') {
  1358. standardDateProps.timeZoneName = 'short';
  1359. }
  1360. // if requesting to display seconds, MUST display minutes
  1361. if (extendedSettings.omitZeroMinute && (standardDateProps.second || standardDateProps.millisecond)) {
  1362. delete extendedSettings.omitZeroMinute;
  1363. }
  1364. }
  1365. function postProcess(s, date, standardDateProps, extendedSettings, context) {
  1366. s = s.replace(LTR_RE, ''); // remove left-to-right control chars. do first. good for other regexes
  1367. if (standardDateProps.timeZoneName === 'short') {
  1368. s = injectTzoStr(s, (context.timeZone === 'UTC' || date.timeZoneOffset == null) ?
  1369. 'UTC' : // important to normalize for IE, which does "GMT"
  1370. formatTimeZoneOffset(date.timeZoneOffset));
  1371. }
  1372. if (extendedSettings.omitCommas) {
  1373. s = s.replace(COMMA_RE, '').trim();
  1374. }
  1375. if (extendedSettings.omitZeroMinute) {
  1376. s = s.replace(':00', ''); // zeroFormat doesn't always achieve this
  1377. }
  1378. // ^ do anything that might create adjacent spaces before this point,
  1379. // because MERIDIEM_RE likes to eat up loading spaces
  1380. if (extendedSettings.meridiem === false) {
  1381. s = s.replace(MERIDIEM_RE, '').trim();
  1382. }
  1383. else if (extendedSettings.meridiem === 'narrow') { // a/p
  1384. s = s.replace(MERIDIEM_RE, function (m0, m1) { return m1.toLocaleLowerCase(); });
  1385. }
  1386. else if (extendedSettings.meridiem === 'short') { // am/pm
  1387. s = s.replace(MERIDIEM_RE, function (m0, m1) { return m1.toLocaleLowerCase() + "m"; });
  1388. }
  1389. else if (extendedSettings.meridiem === 'lowercase') { // other meridiem transformers already converted to lowercase
  1390. s = s.replace(MERIDIEM_RE, function (m0) { return m0.toLocaleLowerCase(); });
  1391. }
  1392. s = s.replace(MULTI_SPACE_RE, ' ');
  1393. s = s.trim();
  1394. return s;
  1395. }
  1396. function injectTzoStr(s, tzoStr) {
  1397. var replaced = false;
  1398. s = s.replace(UTC_RE, function () {
  1399. replaced = true;
  1400. return tzoStr;
  1401. });
  1402. // IE11 doesn't include UTC/GMT in the original string, so append to end
  1403. if (!replaced) {
  1404. s += " " + tzoStr;
  1405. }
  1406. return s;
  1407. }
  1408. function formatWeekNumber(num, weekText, weekTextLong, locale, display) {
  1409. var parts = [];
  1410. if (display === 'long') {
  1411. parts.push(weekTextLong);
  1412. }
  1413. else if (display === 'short' || display === 'narrow') {
  1414. parts.push(weekText);
  1415. }
  1416. if (display === 'long' || display === 'short') {
  1417. parts.push(' ');
  1418. }
  1419. parts.push(locale.simpleNumberFormat.format(num));
  1420. if (locale.options.direction === 'rtl') { // TODO: use control characters instead?
  1421. parts.reverse();
  1422. }
  1423. return parts.join('');
  1424. }
  1425. // Range Formatting Utils
  1426. // 0 = exactly the same
  1427. // 1 = different by time
  1428. // and bigger
  1429. function computeMarkerDiffSeverity(d0, d1, ca) {
  1430. if (ca.getMarkerYear(d0) !== ca.getMarkerYear(d1)) {
  1431. return 5;
  1432. }
  1433. if (ca.getMarkerMonth(d0) !== ca.getMarkerMonth(d1)) {
  1434. return 4;
  1435. }
  1436. if (ca.getMarkerDay(d0) !== ca.getMarkerDay(d1)) {
  1437. return 2;
  1438. }
  1439. if (timeAsMs(d0) !== timeAsMs(d1)) {
  1440. return 1;
  1441. }
  1442. return 0;
  1443. }
  1444. function computePartialFormattingOptions(options, biggestUnit) {
  1445. var partialOptions = {};
  1446. for (var name_2 in options) {
  1447. if (!(name_2 in STANDARD_DATE_PROP_SEVERITIES) || // not a date part prop (like timeZone)
  1448. STANDARD_DATE_PROP_SEVERITIES[name_2] <= biggestUnit) {
  1449. partialOptions[name_2] = options[name_2];
  1450. }
  1451. }
  1452. return partialOptions;
  1453. }
  1454. function findCommonInsertion(full0, partial0, full1, partial1) {
  1455. var i0 = 0;
  1456. while (i0 < full0.length) {
  1457. var found0 = full0.indexOf(partial0, i0);
  1458. if (found0 === -1) {
  1459. break;
  1460. }
  1461. var before0 = full0.substr(0, found0);
  1462. i0 = found0 + partial0.length;
  1463. var after0 = full0.substr(i0);
  1464. var i1 = 0;
  1465. while (i1 < full1.length) {
  1466. var found1 = full1.indexOf(partial1, i1);
  1467. if (found1 === -1) {
  1468. break;
  1469. }
  1470. var before1 = full1.substr(0, found1);
  1471. i1 = found1 + partial1.length;
  1472. var after1 = full1.substr(i1);
  1473. if (before0 === before1 && after0 === after1) {
  1474. return {
  1475. before: before0,
  1476. after: after0,
  1477. };
  1478. }
  1479. }
  1480. }
  1481. return null;
  1482. }
  1483. function expandZonedMarker(dateInfo, calendarSystem) {
  1484. var a = calendarSystem.markerToArray(dateInfo.marker);
  1485. return {
  1486. marker: dateInfo.marker,
  1487. timeZoneOffset: dateInfo.timeZoneOffset,
  1488. array: a,
  1489. year: a[0],
  1490. month: a[1],
  1491. day: a[2],
  1492. hour: a[3],
  1493. minute: a[4],
  1494. second: a[5],
  1495. millisecond: a[6],
  1496. };
  1497. }
  1498. function createVerboseFormattingArg(start, end, context, betterDefaultSeparator) {
  1499. var startInfo = expandZonedMarker(start, context.calendarSystem);
  1500. var endInfo = end ? expandZonedMarker(end, context.calendarSystem) : null;
  1501. return {
  1502. date: startInfo,
  1503. start: startInfo,
  1504. end: endInfo,
  1505. timeZone: context.timeZone,
  1506. localeCodes: context.locale.codes,
  1507. defaultSeparator: betterDefaultSeparator || context.defaultSeparator,
  1508. };
  1509. }
  1510. /*
  1511. TODO: fix the terminology of "formatter" vs "formatting func"
  1512. */
  1513. /*
  1514. At the time of instantiation, this object does not know which cmd-formatting system it will use.
  1515. It receives this at the time of formatting, as a setting.
  1516. */
  1517. var CmdFormatter = /** @class */ (function () {
  1518. function CmdFormatter(cmdStr) {
  1519. this.cmdStr = cmdStr;
  1520. }
  1521. CmdFormatter.prototype.format = function (date, context, betterDefaultSeparator) {
  1522. return context.cmdFormatter(this.cmdStr, createVerboseFormattingArg(date, null, context, betterDefaultSeparator));
  1523. };
  1524. CmdFormatter.prototype.formatRange = function (start, end, context, betterDefaultSeparator) {
  1525. return context.cmdFormatter(this.cmdStr, createVerboseFormattingArg(start, end, context, betterDefaultSeparator));
  1526. };
  1527. return CmdFormatter;
  1528. }());
  1529. var FuncFormatter = /** @class */ (function () {
  1530. function FuncFormatter(func) {
  1531. this.func = func;
  1532. }
  1533. FuncFormatter.prototype.format = function (date, context, betterDefaultSeparator) {
  1534. return this.func(createVerboseFormattingArg(date, null, context, betterDefaultSeparator));
  1535. };
  1536. FuncFormatter.prototype.formatRange = function (start, end, context, betterDefaultSeparator) {
  1537. return this.func(createVerboseFormattingArg(start, end, context, betterDefaultSeparator));
  1538. };
  1539. return FuncFormatter;
  1540. }());
  1541. function createFormatter(input) {
  1542. if (typeof input === 'object' && input) { // non-null object
  1543. return new NativeFormatter(input);
  1544. }
  1545. if (typeof input === 'string') {
  1546. return new CmdFormatter(input);
  1547. }
  1548. if (typeof input === 'function') {
  1549. return new FuncFormatter(input);
  1550. }
  1551. return null;
  1552. }
  1553. // base options
  1554. // ------------
  1555. var BASE_OPTION_REFINERS = {
  1556. navLinkDayClick: identity,
  1557. navLinkWeekClick: identity,
  1558. duration: createDuration,
  1559. bootstrapFontAwesome: identity,
  1560. buttonIcons: identity,
  1561. customButtons: identity,
  1562. defaultAllDayEventDuration: createDuration,
  1563. defaultTimedEventDuration: createDuration,
  1564. nextDayThreshold: createDuration,
  1565. scrollTime: createDuration,
  1566. scrollTimeReset: Boolean,
  1567. slotMinTime: createDuration,
  1568. slotMaxTime: createDuration,
  1569. dayPopoverFormat: createFormatter,
  1570. slotDuration: createDuration,
  1571. snapDuration: createDuration,
  1572. headerToolbar: identity,
  1573. footerToolbar: identity,
  1574. defaultRangeSeparator: String,
  1575. titleRangeSeparator: String,
  1576. forceEventDuration: Boolean,
  1577. dayHeaders: Boolean,
  1578. dayHeaderFormat: createFormatter,
  1579. dayHeaderClassNames: identity,
  1580. dayHeaderContent: identity,
  1581. dayHeaderDidMount: identity,
  1582. dayHeaderWillUnmount: identity,
  1583. dayCellClassNames: identity,
  1584. dayCellContent: identity,
  1585. dayCellDidMount: identity,
  1586. dayCellWillUnmount: identity,
  1587. initialView: String,
  1588. aspectRatio: Number,
  1589. weekends: Boolean,
  1590. weekNumberCalculation: identity,
  1591. weekNumbers: Boolean,
  1592. weekNumberClassNames: identity,
  1593. weekNumberContent: identity,
  1594. weekNumberDidMount: identity,
  1595. weekNumberWillUnmount: identity,
  1596. editable: Boolean,
  1597. viewClassNames: identity,
  1598. viewDidMount: identity,
  1599. viewWillUnmount: identity,
  1600. nowIndicator: Boolean,
  1601. nowIndicatorClassNames: identity,
  1602. nowIndicatorContent: identity,
  1603. nowIndicatorDidMount: identity,
  1604. nowIndicatorWillUnmount: identity,
  1605. showNonCurrentDates: Boolean,
  1606. lazyFetching: Boolean,
  1607. startParam: String,
  1608. endParam: String,
  1609. timeZoneParam: String,
  1610. timeZone: String,
  1611. locales: identity,
  1612. locale: identity,
  1613. themeSystem: String,
  1614. dragRevertDuration: Number,
  1615. dragScroll: Boolean,
  1616. allDayMaintainDuration: Boolean,
  1617. unselectAuto: Boolean,
  1618. dropAccept: identity,
  1619. eventOrder: parseFieldSpecs,
  1620. eventOrderStrict: Boolean,
  1621. handleWindowResize: Boolean,
  1622. windowResizeDelay: Number,
  1623. longPressDelay: Number,
  1624. eventDragMinDistance: Number,
  1625. expandRows: Boolean,
  1626. height: identity,
  1627. contentHeight: identity,
  1628. direction: String,
  1629. weekNumberFormat: createFormatter,
  1630. eventResizableFromStart: Boolean,
  1631. displayEventTime: Boolean,
  1632. displayEventEnd: Boolean,
  1633. weekText: String,
  1634. weekTextLong: String,
  1635. progressiveEventRendering: Boolean,
  1636. businessHours: identity,
  1637. initialDate: identity,
  1638. now: identity,
  1639. eventDataTransform: identity,
  1640. stickyHeaderDates: identity,
  1641. stickyFooterScrollbar: identity,
  1642. viewHeight: identity,
  1643. defaultAllDay: Boolean,
  1644. eventSourceFailure: identity,
  1645. eventSourceSuccess: identity,
  1646. eventDisplay: String,
  1647. eventStartEditable: Boolean,
  1648. eventDurationEditable: Boolean,
  1649. eventOverlap: identity,
  1650. eventConstraint: identity,
  1651. eventAllow: identity,
  1652. eventBackgroundColor: String,
  1653. eventBorderColor: String,
  1654. eventTextColor: String,
  1655. eventColor: String,
  1656. eventClassNames: identity,
  1657. eventContent: identity,
  1658. eventDidMount: identity,
  1659. eventWillUnmount: identity,
  1660. selectConstraint: identity,
  1661. selectOverlap: identity,
  1662. selectAllow: identity,
  1663. droppable: Boolean,
  1664. unselectCancel: String,
  1665. slotLabelFormat: identity,
  1666. slotLaneClassNames: identity,
  1667. slotLaneContent: identity,
  1668. slotLaneDidMount: identity,
  1669. slotLaneWillUnmount: identity,
  1670. slotLabelClassNames: identity,
  1671. slotLabelContent: identity,
  1672. slotLabelDidMount: identity,
  1673. slotLabelWillUnmount: identity,
  1674. dayMaxEvents: identity,
  1675. dayMaxEventRows: identity,
  1676. dayMinWidth: Number,
  1677. slotLabelInterval: createDuration,
  1678. allDayText: String,
  1679. allDayClassNames: identity,
  1680. allDayContent: identity,
  1681. allDayDidMount: identity,
  1682. allDayWillUnmount: identity,
  1683. slotMinWidth: Number,
  1684. navLinks: Boolean,
  1685. eventTimeFormat: createFormatter,
  1686. rerenderDelay: Number,
  1687. moreLinkText: identity,
  1688. moreLinkHint: identity,
  1689. selectMinDistance: Number,
  1690. selectable: Boolean,
  1691. selectLongPressDelay: Number,
  1692. eventLongPressDelay: Number,
  1693. selectMirror: Boolean,
  1694. eventMaxStack: Number,
  1695. eventMinHeight: Number,
  1696. eventMinWidth: Number,
  1697. eventShortHeight: Number,
  1698. slotEventOverlap: Boolean,
  1699. plugins: identity,
  1700. firstDay: Number,
  1701. dayCount: Number,
  1702. dateAlignment: String,
  1703. dateIncrement: createDuration,
  1704. hiddenDays: identity,
  1705. monthMode: Boolean,
  1706. fixedWeekCount: Boolean,
  1707. validRange: identity,
  1708. visibleRange: identity,
  1709. titleFormat: identity,
  1710. eventInteractive: Boolean,
  1711. // only used by list-view, but languages define the value, so we need it in base options
  1712. noEventsText: String,
  1713. viewHint: identity,
  1714. navLinkHint: identity,
  1715. closeHint: String,
  1716. timeHint: String,
  1717. eventHint: String,
  1718. moreLinkClick: identity,
  1719. moreLinkClassNames: identity,
  1720. moreLinkContent: identity,
  1721. moreLinkDidMount: identity,
  1722. moreLinkWillUnmount: identity,
  1723. };
  1724. // do NOT give a type here. need `typeof BASE_OPTION_DEFAULTS` to give real results.
  1725. // raw values.
  1726. var BASE_OPTION_DEFAULTS = {
  1727. eventDisplay: 'auto',
  1728. defaultRangeSeparator: ' - ',
  1729. titleRangeSeparator: ' \u2013 ',
  1730. defaultTimedEventDuration: '01:00:00',
  1731. defaultAllDayEventDuration: { day: 1 },
  1732. forceEventDuration: false,
  1733. nextDayThreshold: '00:00:00',
  1734. dayHeaders: true,
  1735. initialView: '',
  1736. aspectRatio: 1.35,
  1737. headerToolbar: {
  1738. start: 'title',
  1739. center: '',
  1740. end: 'today prev,next',
  1741. },
  1742. weekends: true,
  1743. weekNumbers: false,
  1744. weekNumberCalculation: 'local',
  1745. editable: false,
  1746. nowIndicator: false,
  1747. scrollTime: '06:00:00',
  1748. scrollTimeReset: true,
  1749. slotMinTime: '00:00:00',
  1750. slotMaxTime: '24:00:00',
  1751. showNonCurrentDates: true,
  1752. lazyFetching: true,
  1753. startParam: 'start',
  1754. endParam: 'end',
  1755. timeZoneParam: 'timeZone',
  1756. timeZone: 'local',
  1757. locales: [],
  1758. locale: '',
  1759. themeSystem: 'standard',
  1760. dragRevertDuration: 500,
  1761. dragScroll: true,
  1762. allDayMaintainDuration: false,
  1763. unselectAuto: true,
  1764. dropAccept: '*',
  1765. eventOrder: 'start,-duration,allDay,title',
  1766. dayPopoverFormat: { month: 'long', day: 'numeric', year: 'numeric' },
  1767. handleWindowResize: true,
  1768. windowResizeDelay: 100,
  1769. longPressDelay: 1000,
  1770. eventDragMinDistance: 5,
  1771. expandRows: false,
  1772. navLinks: false,
  1773. selectable: false,
  1774. eventMinHeight: 15,
  1775. eventMinWidth: 30,
  1776. eventShortHeight: 30,
  1777. };
  1778. // calendar listeners
  1779. // ------------------
  1780. var CALENDAR_LISTENER_REFINERS = {
  1781. datesSet: identity,
  1782. eventsSet: identity,
  1783. eventAdd: identity,
  1784. eventChange: identity,
  1785. eventRemove: identity,
  1786. windowResize: identity,
  1787. eventClick: identity,
  1788. eventMouseEnter: identity,
  1789. eventMouseLeave: identity,
  1790. select: identity,
  1791. unselect: identity,
  1792. loading: identity,
  1793. // internal
  1794. _unmount: identity,
  1795. _beforeprint: identity,
  1796. _afterprint: identity,
  1797. _noEventDrop: identity,
  1798. _noEventResize: identity,
  1799. _resize: identity,
  1800. _scrollRequest: identity,
  1801. };
  1802. // calendar-specific options
  1803. // -------------------------
  1804. var CALENDAR_OPTION_REFINERS = {
  1805. buttonText: identity,
  1806. buttonHints: identity,
  1807. views: identity,
  1808. plugins: identity,
  1809. initialEvents: identity,
  1810. events: identity,
  1811. eventSources: identity,
  1812. };
  1813. var COMPLEX_OPTION_COMPARATORS = {
  1814. headerToolbar: isBoolComplexEqual,
  1815. footerToolbar: isBoolComplexEqual,
  1816. buttonText: isBoolComplexEqual,
  1817. buttonHints: isBoolComplexEqual,
  1818. buttonIcons: isBoolComplexEqual,
  1819. };
  1820. function isBoolComplexEqual(a, b) {
  1821. if (typeof a === 'object' && typeof b === 'object' && a && b) { // both non-null objects
  1822. return isPropsEqual(a, b);
  1823. }
  1824. return a === b;
  1825. }
  1826. // view-specific options
  1827. // ---------------------
  1828. var VIEW_OPTION_REFINERS = {
  1829. type: String,
  1830. component: identity,
  1831. buttonText: String,
  1832. buttonTextKey: String,
  1833. dateProfileGeneratorClass: identity,
  1834. usesMinMaxTime: Boolean,
  1835. classNames: identity,
  1836. content: identity,
  1837. didMount: identity,
  1838. willUnmount: identity,
  1839. };
  1840. // util funcs
  1841. // ----------------------------------------------------------------------------------------------------
  1842. function mergeRawOptions(optionSets) {
  1843. return mergeProps(optionSets, COMPLEX_OPTION_COMPARATORS);
  1844. }
  1845. function refineProps(input, refiners) {
  1846. var refined = {};
  1847. var extra = {};
  1848. for (var propName in refiners) {
  1849. if (propName in input) {
  1850. refined[propName] = refiners[propName](input[propName]);
  1851. }
  1852. }
  1853. for (var propName in input) {
  1854. if (!(propName in refiners)) {
  1855. extra[propName] = input[propName];
  1856. }
  1857. }
  1858. return { refined: refined, extra: extra };
  1859. }
  1860. function identity(raw) {
  1861. return raw;
  1862. }
  1863. function parseEvents(rawEvents, eventSource, context, allowOpenRange) {
  1864. var eventStore = createEmptyEventStore();
  1865. var eventRefiners = buildEventRefiners(context);
  1866. for (var _i = 0, rawEvents_1 = rawEvents; _i < rawEvents_1.length; _i++) {
  1867. var rawEvent = rawEvents_1[_i];
  1868. var tuple = parseEvent(rawEvent, eventSource, context, allowOpenRange, eventRefiners);
  1869. if (tuple) {
  1870. eventTupleToStore(tuple, eventStore);
  1871. }
  1872. }
  1873. return eventStore;
  1874. }
  1875. function eventTupleToStore(tuple, eventStore) {
  1876. if (eventStore === void 0) { eventStore = createEmptyEventStore(); }
  1877. eventStore.defs[tuple.def.defId] = tuple.def;
  1878. if (tuple.instance) {
  1879. eventStore.instances[tuple.instance.instanceId] = tuple.instance;
  1880. }
  1881. return eventStore;
  1882. }
  1883. // retrieves events that have the same groupId as the instance specified by `instanceId`
  1884. // or they are the same as the instance.
  1885. // why might instanceId not be in the store? an event from another calendar?
  1886. function getRelevantEvents(eventStore, instanceId) {
  1887. var instance = eventStore.instances[instanceId];
  1888. if (instance) {
  1889. var def_1 = eventStore.defs[instance.defId];
  1890. // get events/instances with same group
  1891. var newStore = filterEventStoreDefs(eventStore, function (lookDef) { return isEventDefsGrouped(def_1, lookDef); });
  1892. // add the original
  1893. // TODO: wish we could use eventTupleToStore or something like it
  1894. newStore.defs[def_1.defId] = def_1;
  1895. newStore.instances[instance.instanceId] = instance;
  1896. return newStore;
  1897. }
  1898. return createEmptyEventStore();
  1899. }
  1900. function isEventDefsGrouped(def0, def1) {
  1901. return Boolean(def0.groupId && def0.groupId === def1.groupId);
  1902. }
  1903. function createEmptyEventStore() {
  1904. return { defs: {}, instances: {} };
  1905. }
  1906. function mergeEventStores(store0, store1) {
  1907. return {
  1908. defs: __assign(__assign({}, store0.defs), store1.defs),
  1909. instances: __assign(__assign({}, store0.instances), store1.instances),
  1910. };
  1911. }
  1912. function filterEventStoreDefs(eventStore, filterFunc) {
  1913. var defs = filterHash(eventStore.defs, filterFunc);
  1914. var instances = filterHash(eventStore.instances, function (instance) { return (defs[instance.defId] // still exists?
  1915. ); });
  1916. return { defs: defs, instances: instances };
  1917. }
  1918. function excludeSubEventStore(master, sub) {
  1919. var defs = master.defs, instances = master.instances;
  1920. var filteredDefs = {};
  1921. var filteredInstances = {};
  1922. for (var defId in defs) {
  1923. if (!sub.defs[defId]) { // not explicitly excluded
  1924. filteredDefs[defId] = defs[defId];
  1925. }
  1926. }
  1927. for (var instanceId in instances) {
  1928. if (!sub.instances[instanceId] && // not explicitly excluded
  1929. filteredDefs[instances[instanceId].defId] // def wasn't filtered away
  1930. ) {
  1931. filteredInstances[instanceId] = instances[instanceId];
  1932. }
  1933. }
  1934. return {
  1935. defs: filteredDefs,
  1936. instances: filteredInstances,
  1937. };
  1938. }
  1939. function normalizeConstraint(input, context) {
  1940. if (Array.isArray(input)) {
  1941. return parseEvents(input, null, context, true); // allowOpenRange=true
  1942. }
  1943. if (typeof input === 'object' && input) { // non-null object
  1944. return parseEvents([input], null, context, true); // allowOpenRange=true
  1945. }
  1946. if (input != null) {
  1947. return String(input);
  1948. }
  1949. return null;
  1950. }
  1951. function parseClassNames(raw) {
  1952. if (Array.isArray(raw)) {
  1953. return raw;
  1954. }
  1955. if (typeof raw === 'string') {
  1956. return raw.split(/\s+/);
  1957. }
  1958. return [];
  1959. }
  1960. // TODO: better called "EventSettings" or "EventConfig"
  1961. // TODO: move this file into structs
  1962. // TODO: separate constraint/overlap/allow, because selection uses only that, not other props
  1963. var EVENT_UI_REFINERS = {
  1964. display: String,
  1965. editable: Boolean,
  1966. startEditable: Boolean,
  1967. durationEditable: Boolean,
  1968. constraint: identity,
  1969. overlap: identity,
  1970. allow: identity,
  1971. className: parseClassNames,
  1972. classNames: parseClassNames,
  1973. color: String,
  1974. backgroundColor: String,
  1975. borderColor: String,
  1976. textColor: String,
  1977. };
  1978. var EMPTY_EVENT_UI = {
  1979. display: null,
  1980. startEditable: null,
  1981. durationEditable: null,
  1982. constraints: [],
  1983. overlap: null,
  1984. allows: [],
  1985. backgroundColor: '',
  1986. borderColor: '',
  1987. textColor: '',
  1988. classNames: [],
  1989. };
  1990. function createEventUi(refined, context) {
  1991. var constraint = normalizeConstraint(refined.constraint, context);
  1992. return {
  1993. display: refined.display || null,
  1994. startEditable: refined.startEditable != null ? refined.startEditable : refined.editable,
  1995. durationEditable: refined.durationEditable != null ? refined.durationEditable : refined.editable,
  1996. constraints: constraint != null ? [constraint] : [],
  1997. overlap: refined.overlap != null ? refined.overlap : null,
  1998. allows: refined.allow != null ? [refined.allow] : [],
  1999. backgroundColor: refined.backgroundColor || refined.color || '',
  2000. borderColor: refined.borderColor || refined.color || '',
  2001. textColor: refined.textColor || '',
  2002. classNames: (refined.className || []).concat(refined.classNames || []), // join singular and plural
  2003. };
  2004. }
  2005. // TODO: prevent against problems with <2 args!
  2006. function combineEventUis(uis) {
  2007. return uis.reduce(combineTwoEventUis, EMPTY_EVENT_UI);
  2008. }
  2009. function combineTwoEventUis(item0, item1) {
  2010. return {
  2011. display: item1.display != null ? item1.display : item0.display,
  2012. startEditable: item1.startEditable != null ? item1.startEditable : item0.startEditable,
  2013. durationEditable: item1.durationEditable != null ? item1.durationEditable : item0.durationEditable,
  2014. constraints: item0.constraints.concat(item1.constraints),
  2015. overlap: typeof item1.overlap === 'boolean' ? item1.overlap : item0.overlap,
  2016. allows: item0.allows.concat(item1.allows),
  2017. backgroundColor: item1.backgroundColor || item0.backgroundColor,
  2018. borderColor: item1.borderColor || item0.borderColor,
  2019. textColor: item1.textColor || item0.textColor,
  2020. classNames: item0.classNames.concat(item1.classNames),
  2021. };
  2022. }
  2023. var EVENT_NON_DATE_REFINERS = {
  2024. id: String,
  2025. groupId: String,
  2026. title: String,
  2027. url: String,
  2028. interactive: Boolean,
  2029. };
  2030. var EVENT_DATE_REFINERS = {
  2031. start: identity,
  2032. end: identity,
  2033. date: identity,
  2034. allDay: Boolean,
  2035. };
  2036. var EVENT_REFINERS = __assign(__assign(__assign({}, EVENT_NON_DATE_REFINERS), EVENT_DATE_REFINERS), { extendedProps: identity });
  2037. function parseEvent(raw, eventSource, context, allowOpenRange, refiners) {
  2038. if (refiners === void 0) { refiners = buildEventRefiners(context); }
  2039. var _a = refineEventDef(raw, context, refiners), refined = _a.refined, extra = _a.extra;
  2040. var defaultAllDay = computeIsDefaultAllDay(eventSource, context);
  2041. var recurringRes = parseRecurring(refined, defaultAllDay, context.dateEnv, context.pluginHooks.recurringTypes);
  2042. if (recurringRes) {
  2043. var def = parseEventDef(refined, extra, eventSource ? eventSource.sourceId : '', recurringRes.allDay, Boolean(recurringRes.duration), context);
  2044. def.recurringDef = {
  2045. typeId: recurringRes.typeId,
  2046. typeData: recurringRes.typeData,
  2047. duration: recurringRes.duration,
  2048. };
  2049. return { def: def, instance: null };
  2050. }
  2051. var singleRes = parseSingle(refined, defaultAllDay, context, allowOpenRange);
  2052. if (singleRes) {
  2053. var def = parseEventDef(refined, extra, eventSource ? eventSource.sourceId : '', singleRes.allDay, singleRes.hasEnd, context);
  2054. var instance = createEventInstance(def.defId, singleRes.range, singleRes.forcedStartTzo, singleRes.forcedEndTzo);
  2055. return { def: def, instance: instance };
  2056. }
  2057. return null;
  2058. }
  2059. function refineEventDef(raw, context, refiners) {
  2060. if (refiners === void 0) { refiners = buildEventRefiners(context); }
  2061. return refineProps(raw, refiners);
  2062. }
  2063. function buildEventRefiners(context) {
  2064. return __assign(__assign(__assign({}, EVENT_UI_REFINERS), EVENT_REFINERS), context.pluginHooks.eventRefiners);
  2065. }
  2066. /*
  2067. Will NOT populate extendedProps with the leftover properties.
  2068. Will NOT populate date-related props.
  2069. */
  2070. function parseEventDef(refined, extra, sourceId, allDay, hasEnd, context) {
  2071. var def = {
  2072. title: refined.title || '',
  2073. groupId: refined.groupId || '',
  2074. publicId: refined.id || '',
  2075. url: refined.url || '',
  2076. recurringDef: null,
  2077. defId: guid(),
  2078. sourceId: sourceId,
  2079. allDay: allDay,
  2080. hasEnd: hasEnd,
  2081. interactive: refined.interactive,
  2082. ui: createEventUi(refined, context),
  2083. extendedProps: __assign(__assign({}, (refined.extendedProps || {})), extra),
  2084. };
  2085. for (var _i = 0, _a = context.pluginHooks.eventDefMemberAdders; _i < _a.length; _i++) {
  2086. var memberAdder = _a[_i];
  2087. __assign(def, memberAdder(refined));
  2088. }
  2089. // help out EventApi from having user modify props
  2090. Object.freeze(def.ui.classNames);
  2091. Object.freeze(def.extendedProps);
  2092. return def;
  2093. }
  2094. function parseSingle(refined, defaultAllDay, context, allowOpenRange) {
  2095. var allDay = refined.allDay;
  2096. var startMeta;
  2097. var startMarker = null;
  2098. var hasEnd = false;
  2099. var endMeta;
  2100. var endMarker = null;
  2101. var startInput = refined.start != null ? refined.start : refined.date;
  2102. startMeta = context.dateEnv.createMarkerMeta(startInput);
  2103. if (startMeta) {
  2104. startMarker = startMeta.marker;
  2105. }
  2106. else if (!allowOpenRange) {
  2107. return null;
  2108. }
  2109. if (refined.end != null) {
  2110. endMeta = context.dateEnv.createMarkerMeta(refined.end);
  2111. }
  2112. if (allDay == null) {
  2113. if (defaultAllDay != null) {
  2114. allDay = defaultAllDay;
  2115. }
  2116. else {
  2117. // fall back to the date props LAST
  2118. allDay = (!startMeta || startMeta.isTimeUnspecified) &&
  2119. (!endMeta || endMeta.isTimeUnspecified);
  2120. }
  2121. }
  2122. if (allDay && startMarker) {
  2123. startMarker = startOfDay(startMarker);
  2124. }
  2125. if (endMeta) {
  2126. endMarker = endMeta.marker;
  2127. if (allDay) {
  2128. endMarker = startOfDay(endMarker);
  2129. }
  2130. if (startMarker && endMarker <= startMarker) {
  2131. endMarker = null;
  2132. }
  2133. }
  2134. if (endMarker) {
  2135. hasEnd = true;
  2136. }
  2137. else if (!allowOpenRange) {
  2138. hasEnd = context.options.forceEventDuration || false;
  2139. endMarker = context.dateEnv.add(startMarker, allDay ?
  2140. context.options.defaultAllDayEventDuration :
  2141. context.options.defaultTimedEventDuration);
  2142. }
  2143. return {
  2144. allDay: allDay,
  2145. hasEnd: hasEnd,
  2146. range: { start: startMarker, end: endMarker },
  2147. forcedStartTzo: startMeta ? startMeta.forcedTzo : null,
  2148. forcedEndTzo: endMeta ? endMeta.forcedTzo : null,
  2149. };
  2150. }
  2151. function computeIsDefaultAllDay(eventSource, context) {
  2152. var res = null;
  2153. if (eventSource) {
  2154. res = eventSource.defaultAllDay;
  2155. }
  2156. if (res == null) {
  2157. res = context.options.defaultAllDay;
  2158. }
  2159. return res;
  2160. }
  2161. /* Date stuff that doesn't belong in datelib core
  2162. ----------------------------------------------------------------------------------------------------------------------*/
  2163. // given a timed range, computes an all-day range that has the same exact duration,
  2164. // but whose start time is aligned with the start of the day.
  2165. function computeAlignedDayRange(timedRange) {
  2166. var dayCnt = Math.floor(diffDays(timedRange.start, timedRange.end)) || 1;
  2167. var start = startOfDay(timedRange.start);
  2168. var end = addDays(start, dayCnt);
  2169. return { start: start, end: end };
  2170. }
  2171. // given a timed range, computes an all-day range based on how for the end date bleeds into the next day
  2172. // TODO: give nextDayThreshold a default arg
  2173. function computeVisibleDayRange(timedRange, nextDayThreshold) {
  2174. if (nextDayThreshold === void 0) { nextDayThreshold = createDuration(0); }
  2175. var startDay = null;
  2176. var endDay = null;
  2177. if (timedRange.end) {
  2178. endDay = startOfDay(timedRange.end);
  2179. var endTimeMS = timedRange.end.valueOf() - endDay.valueOf(); // # of milliseconds into `endDay`
  2180. // If the end time is actually inclusively part of the next day and is equal to or
  2181. // beyond the next day threshold, adjust the end to be the exclusive end of `endDay`.
  2182. // Otherwise, leaving it as inclusive will cause it to exclude `endDay`.
  2183. if (endTimeMS && endTimeMS >= asRoughMs(nextDayThreshold)) {
  2184. endDay = addDays(endDay, 1);
  2185. }
  2186. }
  2187. if (timedRange.start) {
  2188. startDay = startOfDay(timedRange.start); // the beginning of the day the range starts
  2189. // If end is within `startDay` but not past nextDayThreshold, assign the default duration of one day.
  2190. if (endDay && endDay <= startDay) {
  2191. endDay = addDays(startDay, 1);
  2192. }
  2193. }
  2194. return { start: startDay, end: endDay };
  2195. }
  2196. // spans from one day into another?
  2197. function isMultiDayRange(range) {
  2198. var visibleRange = computeVisibleDayRange(range);
  2199. return diffDays(visibleRange.start, visibleRange.end) > 1;
  2200. }
  2201. function diffDates(date0, date1, dateEnv, largeUnit) {
  2202. if (largeUnit === 'year') {
  2203. return createDuration(dateEnv.diffWholeYears(date0, date1), 'year');
  2204. }
  2205. if (largeUnit === 'month') {
  2206. return createDuration(dateEnv.diffWholeMonths(date0, date1), 'month');
  2207. }
  2208. return diffDayAndTime(date0, date1); // returns a duration
  2209. }
  2210. function parseRange(input, dateEnv) {
  2211. var start = null;
  2212. var end = null;
  2213. if (input.start) {
  2214. start = dateEnv.createMarker(input.start);
  2215. }
  2216. if (input.end) {
  2217. end = dateEnv.createMarker(input.end);
  2218. }
  2219. if (!start && !end) {
  2220. return null;
  2221. }
  2222. if (start && end && end < start) {
  2223. return null;
  2224. }
  2225. return { start: start, end: end };
  2226. }
  2227. // SIDE-EFFECT: will mutate ranges.
  2228. // Will return a new array result.
  2229. function invertRanges(ranges, constraintRange) {
  2230. var invertedRanges = [];
  2231. var start = constraintRange.start; // the end of the previous range. the start of the new range
  2232. var i;
  2233. var dateRange;
  2234. // ranges need to be in order. required for our date-walking algorithm
  2235. ranges.sort(compareRanges);
  2236. for (i = 0; i < ranges.length; i += 1) {
  2237. dateRange = ranges[i];
  2238. // add the span of time before the event (if there is any)
  2239. if (dateRange.start > start) { // compare millisecond time (skip any ambig logic)
  2240. invertedRanges.push({ start: start, end: dateRange.start });
  2241. }
  2242. if (dateRange.end > start) {
  2243. start = dateRange.end;
  2244. }
  2245. }
  2246. // add the span of time after the last event (if there is any)
  2247. if (start < constraintRange.end) { // compare millisecond time (skip any ambig logic)
  2248. invertedRanges.push({ start: start, end: constraintRange.end });
  2249. }
  2250. return invertedRanges;
  2251. }
  2252. function compareRanges(range0, range1) {
  2253. return range0.start.valueOf() - range1.start.valueOf(); // earlier ranges go first
  2254. }
  2255. function intersectRanges(range0, range1) {
  2256. var start = range0.start, end = range0.end;
  2257. var newRange = null;
  2258. if (range1.start !== null) {
  2259. if (start === null) {
  2260. start = range1.start;
  2261. }
  2262. else {
  2263. start = new Date(Math.max(start.valueOf(), range1.start.valueOf()));
  2264. }
  2265. }
  2266. if (range1.end != null) {
  2267. if (end === null) {
  2268. end = range1.end;
  2269. }
  2270. else {
  2271. end = new Date(Math.min(end.valueOf(), range1.end.valueOf()));
  2272. }
  2273. }
  2274. if (start === null || end === null || start < end) {
  2275. newRange = { start: start, end: end };
  2276. }
  2277. return newRange;
  2278. }
  2279. function rangesEqual(range0, range1) {
  2280. return (range0.start === null ? null : range0.start.valueOf()) === (range1.start === null ? null : range1.start.valueOf()) &&
  2281. (range0.end === null ? null : range0.end.valueOf()) === (range1.end === null ? null : range1.end.valueOf());
  2282. }
  2283. function rangesIntersect(range0, range1) {
  2284. return (range0.end === null || range1.start === null || range0.end > range1.start) &&
  2285. (range0.start === null || range1.end === null || range0.start < range1.end);
  2286. }
  2287. function rangeContainsRange(outerRange, innerRange) {
  2288. return (outerRange.start === null || (innerRange.start !== null && innerRange.start >= outerRange.start)) &&
  2289. (outerRange.end === null || (innerRange.end !== null && innerRange.end <= outerRange.end));
  2290. }
  2291. function rangeContainsMarker(range, date) {
  2292. return (range.start === null || date >= range.start) &&
  2293. (range.end === null || date < range.end);
  2294. }
  2295. // If the given date is not within the given range, move it inside.
  2296. // (If it's past the end, make it one millisecond before the end).
  2297. function constrainMarkerToRange(date, range) {
  2298. if (range.start != null && date < range.start) {
  2299. return range.start;
  2300. }
  2301. if (range.end != null && date >= range.end) {
  2302. return new Date(range.end.valueOf() - 1);
  2303. }
  2304. return date;
  2305. }
  2306. /*
  2307. Specifying nextDayThreshold signals that all-day ranges should be sliced.
  2308. */
  2309. function sliceEventStore(eventStore, eventUiBases, framingRange, nextDayThreshold) {
  2310. var inverseBgByGroupId = {};
  2311. var inverseBgByDefId = {};
  2312. var defByGroupId = {};
  2313. var bgRanges = [];
  2314. var fgRanges = [];
  2315. var eventUis = compileEventUis(eventStore.defs, eventUiBases);
  2316. for (var defId in eventStore.defs) {
  2317. var def = eventStore.defs[defId];
  2318. var ui = eventUis[def.defId];
  2319. if (ui.display === 'inverse-background') {
  2320. if (def.groupId) {
  2321. inverseBgByGroupId[def.groupId] = [];
  2322. if (!defByGroupId[def.groupId]) {
  2323. defByGroupId[def.groupId] = def;
  2324. }
  2325. }
  2326. else {
  2327. inverseBgByDefId[defId] = [];
  2328. }
  2329. }
  2330. }
  2331. for (var instanceId in eventStore.instances) {
  2332. var instance = eventStore.instances[instanceId];
  2333. var def = eventStore.defs[instance.defId];
  2334. var ui = eventUis[def.defId];
  2335. var origRange = instance.range;
  2336. var normalRange = (!def.allDay && nextDayThreshold) ?
  2337. computeVisibleDayRange(origRange, nextDayThreshold) :
  2338. origRange;
  2339. var slicedRange = intersectRanges(normalRange, framingRange);
  2340. if (slicedRange) {
  2341. if (ui.display === 'inverse-background') {
  2342. if (def.groupId) {
  2343. inverseBgByGroupId[def.groupId].push(slicedRange);
  2344. }
  2345. else {
  2346. inverseBgByDefId[instance.defId].push(slicedRange);
  2347. }
  2348. }
  2349. else if (ui.display !== 'none') {
  2350. (ui.display === 'background' ? bgRanges : fgRanges).push({
  2351. def: def,
  2352. ui: ui,
  2353. instance: instance,
  2354. range: slicedRange,
  2355. isStart: normalRange.start && normalRange.start.valueOf() === slicedRange.start.valueOf(),
  2356. isEnd: normalRange.end && normalRange.end.valueOf() === slicedRange.end.valueOf(),
  2357. });
  2358. }
  2359. }
  2360. }
  2361. for (var groupId in inverseBgByGroupId) { // BY GROUP
  2362. var ranges = inverseBgByGroupId[groupId];
  2363. var invertedRanges = invertRanges(ranges, framingRange);
  2364. for (var _i = 0, invertedRanges_1 = invertedRanges; _i < invertedRanges_1.length; _i++) {
  2365. var invertedRange = invertedRanges_1[_i];
  2366. var def = defByGroupId[groupId];
  2367. var ui = eventUis[def.defId];
  2368. bgRanges.push({
  2369. def: def,
  2370. ui: ui,
  2371. instance: null,
  2372. range: invertedRange,
  2373. isStart: false,
  2374. isEnd: false,
  2375. });
  2376. }
  2377. }
  2378. for (var defId in inverseBgByDefId) {
  2379. var ranges = inverseBgByDefId[defId];
  2380. var invertedRanges = invertRanges(ranges, framingRange);
  2381. for (var _a = 0, invertedRanges_2 = invertedRanges; _a < invertedRanges_2.length; _a++) {
  2382. var invertedRange = invertedRanges_2[_a];
  2383. bgRanges.push({
  2384. def: eventStore.defs[defId],
  2385. ui: eventUis[defId],
  2386. instance: null,
  2387. range: invertedRange,
  2388. isStart: false,
  2389. isEnd: false,
  2390. });
  2391. }
  2392. }
  2393. return { bg: bgRanges, fg: fgRanges };
  2394. }
  2395. function hasBgRendering(def) {
  2396. return def.ui.display === 'background' || def.ui.display === 'inverse-background';
  2397. }
  2398. function setElSeg(el, seg) {
  2399. el.fcSeg = seg;
  2400. }
  2401. function getElSeg(el) {
  2402. return el.fcSeg ||
  2403. el.parentNode.fcSeg || // for the harness
  2404. null;
  2405. }
  2406. // event ui computation
  2407. function compileEventUis(eventDefs, eventUiBases) {
  2408. return mapHash(eventDefs, function (eventDef) { return compileEventUi(eventDef, eventUiBases); });
  2409. }
  2410. function compileEventUi(eventDef, eventUiBases) {
  2411. var uis = [];
  2412. if (eventUiBases['']) {
  2413. uis.push(eventUiBases['']);
  2414. }
  2415. if (eventUiBases[eventDef.defId]) {
  2416. uis.push(eventUiBases[eventDef.defId]);
  2417. }
  2418. uis.push(eventDef.ui);
  2419. return combineEventUis(uis);
  2420. }
  2421. function sortEventSegs(segs, eventOrderSpecs) {
  2422. var objs = segs.map(buildSegCompareObj);
  2423. objs.sort(function (obj0, obj1) { return compareByFieldSpecs(obj0, obj1, eventOrderSpecs); });
  2424. return objs.map(function (c) { return c._seg; });
  2425. }
  2426. // returns a object with all primitive props that can be compared
  2427. function buildSegCompareObj(seg) {
  2428. var eventRange = seg.eventRange;
  2429. var eventDef = eventRange.def;
  2430. var range = eventRange.instance ? eventRange.instance.range : eventRange.range;
  2431. var start = range.start ? range.start.valueOf() : 0; // TODO: better support for open-range events
  2432. var end = range.end ? range.end.valueOf() : 0; // "
  2433. return __assign(__assign(__assign({}, eventDef.extendedProps), eventDef), { id: eventDef.publicId, start: start,
  2434. end: end, duration: end - start, allDay: Number(eventDef.allDay), _seg: seg });
  2435. }
  2436. function computeSegDraggable(seg, context) {
  2437. var pluginHooks = context.pluginHooks;
  2438. var transformers = pluginHooks.isDraggableTransformers;
  2439. var _a = seg.eventRange, def = _a.def, ui = _a.ui;
  2440. var val = ui.startEditable;
  2441. for (var _i = 0, transformers_1 = transformers; _i < transformers_1.length; _i++) {
  2442. var transformer = transformers_1[_i];
  2443. val = transformer(val, def, ui, context);
  2444. }
  2445. return val;
  2446. }
  2447. function computeSegStartResizable(seg, context) {
  2448. return seg.isStart && seg.eventRange.ui.durationEditable && context.options.eventResizableFromStart;
  2449. }
  2450. function computeSegEndResizable(seg, context) {
  2451. return seg.isEnd && seg.eventRange.ui.durationEditable;
  2452. }
  2453. function buildSegTimeText(seg, timeFormat, context, defaultDisplayEventTime, // defaults to true
  2454. defaultDisplayEventEnd, // defaults to true
  2455. startOverride, endOverride) {
  2456. var dateEnv = context.dateEnv, options = context.options;
  2457. var displayEventTime = options.displayEventTime, displayEventEnd = options.displayEventEnd;
  2458. var eventDef = seg.eventRange.def;
  2459. var eventInstance = seg.eventRange.instance;
  2460. if (displayEventTime == null) {
  2461. displayEventTime = defaultDisplayEventTime !== false;
  2462. }
  2463. if (displayEventEnd == null) {
  2464. displayEventEnd = defaultDisplayEventEnd !== false;
  2465. }
  2466. var wholeEventStart = eventInstance.range.start;
  2467. var wholeEventEnd = eventInstance.range.end;
  2468. var segStart = startOverride || seg.start || seg.eventRange.range.start;
  2469. var segEnd = endOverride || seg.end || seg.eventRange.range.end;
  2470. var isStartDay = startOfDay(wholeEventStart).valueOf() === startOfDay(segStart).valueOf();
  2471. var isEndDay = startOfDay(addMs(wholeEventEnd, -1)).valueOf() === startOfDay(addMs(segEnd, -1)).valueOf();
  2472. if (displayEventTime && !eventDef.allDay && (isStartDay || isEndDay)) {
  2473. segStart = isStartDay ? wholeEventStart : segStart;
  2474. segEnd = isEndDay ? wholeEventEnd : segEnd;
  2475. if (displayEventEnd && eventDef.hasEnd) {
  2476. return dateEnv.formatRange(segStart, segEnd, timeFormat, {
  2477. forcedStartTzo: startOverride ? null : eventInstance.forcedStartTzo,
  2478. forcedEndTzo: endOverride ? null : eventInstance.forcedEndTzo,
  2479. });
  2480. }
  2481. return dateEnv.format(segStart, timeFormat, {
  2482. forcedTzo: startOverride ? null : eventInstance.forcedStartTzo, // nooooo, same
  2483. });
  2484. }
  2485. return '';
  2486. }
  2487. function getSegMeta(seg, todayRange, nowDate) {
  2488. var segRange = seg.eventRange.range;
  2489. return {
  2490. isPast: segRange.end < (nowDate || todayRange.start),
  2491. isFuture: segRange.start >= (nowDate || todayRange.end),
  2492. isToday: todayRange && rangeContainsMarker(todayRange, segRange.start),
  2493. };
  2494. }
  2495. function getEventClassNames(props) {
  2496. var classNames = ['fc-event'];
  2497. if (props.isMirror) {
  2498. classNames.push('fc-event-mirror');
  2499. }
  2500. if (props.isDraggable) {
  2501. classNames.push('fc-event-draggable');
  2502. }
  2503. if (props.isStartResizable || props.isEndResizable) {
  2504. classNames.push('fc-event-resizable');
  2505. }
  2506. if (props.isDragging) {
  2507. classNames.push('fc-event-dragging');
  2508. }
  2509. if (props.isResizing) {
  2510. classNames.push('fc-event-resizing');
  2511. }
  2512. if (props.isSelected) {
  2513. classNames.push('fc-event-selected');
  2514. }
  2515. if (props.isStart) {
  2516. classNames.push('fc-event-start');
  2517. }
  2518. if (props.isEnd) {
  2519. classNames.push('fc-event-end');
  2520. }
  2521. if (props.isPast) {
  2522. classNames.push('fc-event-past');
  2523. }
  2524. if (props.isToday) {
  2525. classNames.push('fc-event-today');
  2526. }
  2527. if (props.isFuture) {
  2528. classNames.push('fc-event-future');
  2529. }
  2530. return classNames;
  2531. }
  2532. function buildEventRangeKey(eventRange) {
  2533. return eventRange.instance
  2534. ? eventRange.instance.instanceId
  2535. : eventRange.def.defId + ":" + eventRange.range.start.toISOString();
  2536. // inverse-background events don't have specific instances. TODO: better solution
  2537. }
  2538. function getSegAnchorAttrs(seg, context) {
  2539. var _a = seg.eventRange, def = _a.def, instance = _a.instance;
  2540. var url = def.url;
  2541. if (url) {
  2542. return { href: url };
  2543. }
  2544. var emitter = context.emitter, options = context.options;
  2545. var eventInteractive = options.eventInteractive;
  2546. if (eventInteractive == null) {
  2547. eventInteractive = def.interactive;
  2548. if (eventInteractive == null) {
  2549. eventInteractive = Boolean(emitter.hasHandlers('eventClick'));
  2550. }
  2551. }
  2552. // mock what happens in EventClicking
  2553. if (eventInteractive) {
  2554. // only attach keyboard-related handlers because click handler is already done in EventClicking
  2555. return createAriaKeyboardAttrs(function (ev) {
  2556. emitter.trigger('eventClick', {
  2557. el: ev.target,
  2558. event: new EventApi(context, def, instance),
  2559. jsEvent: ev,
  2560. view: context.viewApi,
  2561. });
  2562. });
  2563. }
  2564. return {};
  2565. }
  2566. var STANDARD_PROPS = {
  2567. start: identity,
  2568. end: identity,
  2569. allDay: Boolean,
  2570. };
  2571. function parseDateSpan(raw, dateEnv, defaultDuration) {
  2572. var span = parseOpenDateSpan(raw, dateEnv);
  2573. var range = span.range;
  2574. if (!range.start) {
  2575. return null;
  2576. }
  2577. if (!range.end) {
  2578. if (defaultDuration == null) {
  2579. return null;
  2580. }
  2581. range.end = dateEnv.add(range.start, defaultDuration);
  2582. }
  2583. return span;
  2584. }
  2585. /*
  2586. TODO: somehow combine with parseRange?
  2587. Will return null if the start/end props were present but parsed invalidly.
  2588. */
  2589. function parseOpenDateSpan(raw, dateEnv) {
  2590. var _a = refineProps(raw, STANDARD_PROPS), standardProps = _a.refined, extra = _a.extra;
  2591. var startMeta = standardProps.start ? dateEnv.createMarkerMeta(standardProps.start) : null;
  2592. var endMeta = standardProps.end ? dateEnv.createMarkerMeta(standardProps.end) : null;
  2593. var allDay = standardProps.allDay;
  2594. if (allDay == null) {
  2595. allDay = (startMeta && startMeta.isTimeUnspecified) &&
  2596. (!endMeta || endMeta.isTimeUnspecified);
  2597. }
  2598. return __assign({ range: {
  2599. start: startMeta ? startMeta.marker : null,
  2600. end: endMeta ? endMeta.marker : null,
  2601. }, allDay: allDay }, extra);
  2602. }
  2603. function isDateSpansEqual(span0, span1) {
  2604. return rangesEqual(span0.range, span1.range) &&
  2605. span0.allDay === span1.allDay &&
  2606. isSpanPropsEqual(span0, span1);
  2607. }
  2608. // the NON-DATE-RELATED props
  2609. function isSpanPropsEqual(span0, span1) {
  2610. for (var propName in span1) {
  2611. if (propName !== 'range' && propName !== 'allDay') {
  2612. if (span0[propName] !== span1[propName]) {
  2613. return false;
  2614. }
  2615. }
  2616. }
  2617. // are there any props that span0 has that span1 DOESN'T have?
  2618. // both have range/allDay, so no need to special-case.
  2619. for (var propName in span0) {
  2620. if (!(propName in span1)) {
  2621. return false;
  2622. }
  2623. }
  2624. return true;
  2625. }
  2626. function buildDateSpanApi(span, dateEnv) {
  2627. return __assign(__assign({}, buildRangeApi(span.range, dateEnv, span.allDay)), { allDay: span.allDay });
  2628. }
  2629. function buildRangeApiWithTimeZone(range, dateEnv, omitTime) {
  2630. return __assign(__assign({}, buildRangeApi(range, dateEnv, omitTime)), { timeZone: dateEnv.timeZone });
  2631. }
  2632. function buildRangeApi(range, dateEnv, omitTime) {
  2633. return {
  2634. start: dateEnv.toDate(range.start),
  2635. end: dateEnv.toDate(range.end),
  2636. startStr: dateEnv.formatIso(range.start, { omitTime: omitTime }),
  2637. endStr: dateEnv.formatIso(range.end, { omitTime: omitTime }),
  2638. };
  2639. }
  2640. function fabricateEventRange(dateSpan, eventUiBases, context) {
  2641. var res = refineEventDef({ editable: false }, context);
  2642. var def = parseEventDef(res.refined, res.extra, '', // sourceId
  2643. dateSpan.allDay, true, // hasEnd
  2644. context);
  2645. return {
  2646. def: def,
  2647. ui: compileEventUi(def, eventUiBases),
  2648. instance: createEventInstance(def.defId, dateSpan.range),
  2649. range: dateSpan.range,
  2650. isStart: true,
  2651. isEnd: true,
  2652. };
  2653. }
  2654. function triggerDateSelect(selection, pev, context) {
  2655. context.emitter.trigger('select', __assign(__assign({}, buildDateSpanApiWithContext(selection, context)), { jsEvent: pev ? pev.origEvent : null, view: context.viewApi || context.calendarApi.view }));
  2656. }
  2657. function triggerDateUnselect(pev, context) {
  2658. context.emitter.trigger('unselect', {
  2659. jsEvent: pev ? pev.origEvent : null,
  2660. view: context.viewApi || context.calendarApi.view,
  2661. });
  2662. }
  2663. function buildDateSpanApiWithContext(dateSpan, context) {
  2664. var props = {};
  2665. for (var _i = 0, _a = context.pluginHooks.dateSpanTransforms; _i < _a.length; _i++) {
  2666. var transform = _a[_i];
  2667. __assign(props, transform(dateSpan, context));
  2668. }
  2669. __assign(props, buildDateSpanApi(dateSpan, context.dateEnv));
  2670. return props;
  2671. }
  2672. // Given an event's allDay status and start date, return what its fallback end date should be.
  2673. // TODO: rename to computeDefaultEventEnd
  2674. function getDefaultEventEnd(allDay, marker, context) {
  2675. var dateEnv = context.dateEnv, options = context.options;
  2676. var end = marker;
  2677. if (allDay) {
  2678. end = startOfDay(end);
  2679. end = dateEnv.add(end, options.defaultAllDayEventDuration);
  2680. }
  2681. else {
  2682. end = dateEnv.add(end, options.defaultTimedEventDuration);
  2683. }
  2684. return end;
  2685. }
  2686. // applies the mutation to ALL defs/instances within the event store
  2687. function applyMutationToEventStore(eventStore, eventConfigBase, mutation, context) {
  2688. var eventConfigs = compileEventUis(eventStore.defs, eventConfigBase);
  2689. var dest = createEmptyEventStore();
  2690. for (var defId in eventStore.defs) {
  2691. var def = eventStore.defs[defId];
  2692. dest.defs[defId] = applyMutationToEventDef(def, eventConfigs[defId], mutation, context);
  2693. }
  2694. for (var instanceId in eventStore.instances) {
  2695. var instance = eventStore.instances[instanceId];
  2696. var def = dest.defs[instance.defId]; // important to grab the newly modified def
  2697. dest.instances[instanceId] = applyMutationToEventInstance(instance, def, eventConfigs[instance.defId], mutation, context);
  2698. }
  2699. return dest;
  2700. }
  2701. function applyMutationToEventDef(eventDef, eventConfig, mutation, context) {
  2702. var standardProps = mutation.standardProps || {};
  2703. // if hasEnd has not been specified, guess a good value based on deltas.
  2704. // if duration will change, there's no way the default duration will persist,
  2705. // and thus, we need to mark the event as having a real end
  2706. if (standardProps.hasEnd == null &&
  2707. eventConfig.durationEditable &&
  2708. (mutation.startDelta || mutation.endDelta)) {
  2709. standardProps.hasEnd = true; // TODO: is this mutation okay?
  2710. }
  2711. var copy = __assign(__assign(__assign({}, eventDef), standardProps), { ui: __assign(__assign({}, eventDef.ui), standardProps.ui) });
  2712. if (mutation.extendedProps) {
  2713. copy.extendedProps = __assign(__assign({}, copy.extendedProps), mutation.extendedProps);
  2714. }
  2715. for (var _i = 0, _a = context.pluginHooks.eventDefMutationAppliers; _i < _a.length; _i++) {
  2716. var applier = _a[_i];
  2717. applier(copy, mutation, context);
  2718. }
  2719. if (!copy.hasEnd && context.options.forceEventDuration) {
  2720. copy.hasEnd = true;
  2721. }
  2722. return copy;
  2723. }
  2724. function applyMutationToEventInstance(eventInstance, eventDef, // must first be modified by applyMutationToEventDef
  2725. eventConfig, mutation, context) {
  2726. var dateEnv = context.dateEnv;
  2727. var forceAllDay = mutation.standardProps && mutation.standardProps.allDay === true;
  2728. var clearEnd = mutation.standardProps && mutation.standardProps.hasEnd === false;
  2729. var copy = __assign({}, eventInstance);
  2730. if (forceAllDay) {
  2731. copy.range = computeAlignedDayRange(copy.range);
  2732. }
  2733. if (mutation.datesDelta && eventConfig.startEditable) {
  2734. copy.range = {
  2735. start: dateEnv.add(copy.range.start, mutation.datesDelta),
  2736. end: dateEnv.add(copy.range.end, mutation.datesDelta),
  2737. };
  2738. }
  2739. if (mutation.startDelta && eventConfig.durationEditable) {
  2740. copy.range = {
  2741. start: dateEnv.add(copy.range.start, mutation.startDelta),
  2742. end: copy.range.end,
  2743. };
  2744. }
  2745. if (mutation.endDelta && eventConfig.durationEditable) {
  2746. copy.range = {
  2747. start: copy.range.start,
  2748. end: dateEnv.add(copy.range.end, mutation.endDelta),
  2749. };
  2750. }
  2751. if (clearEnd) {
  2752. copy.range = {
  2753. start: copy.range.start,
  2754. end: getDefaultEventEnd(eventDef.allDay, copy.range.start, context),
  2755. };
  2756. }
  2757. // in case event was all-day but the supplied deltas were not
  2758. // better util for this?
  2759. if (eventDef.allDay) {
  2760. copy.range = {
  2761. start: startOfDay(copy.range.start),
  2762. end: startOfDay(copy.range.end),
  2763. };
  2764. }
  2765. // handle invalid durations
  2766. if (copy.range.end < copy.range.start) {
  2767. copy.range.end = getDefaultEventEnd(eventDef.allDay, copy.range.start, context);
  2768. }
  2769. return copy;
  2770. }
  2771. // no public types yet. when there are, export from:
  2772. // import {} from './api-type-deps'
  2773. var ViewApi = /** @class */ (function () {
  2774. function ViewApi(type, getCurrentData, dateEnv) {
  2775. this.type = type;
  2776. this.getCurrentData = getCurrentData;
  2777. this.dateEnv = dateEnv;
  2778. }
  2779. Object.defineProperty(ViewApi.prototype, "calendar", {
  2780. get: function () {
  2781. return this.getCurrentData().calendarApi;
  2782. },
  2783. enumerable: false,
  2784. configurable: true
  2785. });
  2786. Object.defineProperty(ViewApi.prototype, "title", {
  2787. get: function () {
  2788. return this.getCurrentData().viewTitle;
  2789. },
  2790. enumerable: false,
  2791. configurable: true
  2792. });
  2793. Object.defineProperty(ViewApi.prototype, "activeStart", {
  2794. get: function () {
  2795. return this.dateEnv.toDate(this.getCurrentData().dateProfile.activeRange.start);
  2796. },
  2797. enumerable: false,
  2798. configurable: true
  2799. });
  2800. Object.defineProperty(ViewApi.prototype, "activeEnd", {
  2801. get: function () {
  2802. return this.dateEnv.toDate(this.getCurrentData().dateProfile.activeRange.end);
  2803. },
  2804. enumerable: false,
  2805. configurable: true
  2806. });
  2807. Object.defineProperty(ViewApi.prototype, "currentStart", {
  2808. get: function () {
  2809. return this.dateEnv.toDate(this.getCurrentData().dateProfile.currentRange.start);
  2810. },
  2811. enumerable: false,
  2812. configurable: true
  2813. });
  2814. Object.defineProperty(ViewApi.prototype, "currentEnd", {
  2815. get: function () {
  2816. return this.dateEnv.toDate(this.getCurrentData().dateProfile.currentRange.end);
  2817. },
  2818. enumerable: false,
  2819. configurable: true
  2820. });
  2821. ViewApi.prototype.getOption = function (name) {
  2822. return this.getCurrentData().options[name]; // are the view-specific options
  2823. };
  2824. return ViewApi;
  2825. }());
  2826. var EVENT_SOURCE_REFINERS$1 = {
  2827. id: String,
  2828. defaultAllDay: Boolean,
  2829. url: String,
  2830. format: String,
  2831. events: identity,
  2832. eventDataTransform: identity,
  2833. // for any network-related sources
  2834. success: identity,
  2835. failure: identity,
  2836. };
  2837. function parseEventSource(raw, context, refiners) {
  2838. if (refiners === void 0) { refiners = buildEventSourceRefiners(context); }
  2839. var rawObj;
  2840. if (typeof raw === 'string') {
  2841. rawObj = { url: raw };
  2842. }
  2843. else if (typeof raw === 'function' || Array.isArray(raw)) {
  2844. rawObj = { events: raw };
  2845. }
  2846. else if (typeof raw === 'object' && raw) { // not null
  2847. rawObj = raw;
  2848. }
  2849. if (rawObj) {
  2850. var _a = refineProps(rawObj, refiners), refined = _a.refined, extra = _a.extra;
  2851. var metaRes = buildEventSourceMeta(refined, context);
  2852. if (metaRes) {
  2853. return {
  2854. _raw: raw,
  2855. isFetching: false,
  2856. latestFetchId: '',
  2857. fetchRange: null,
  2858. defaultAllDay: refined.defaultAllDay,
  2859. eventDataTransform: refined.eventDataTransform,
  2860. success: refined.success,
  2861. failure: refined.failure,
  2862. publicId: refined.id || '',
  2863. sourceId: guid(),
  2864. sourceDefId: metaRes.sourceDefId,
  2865. meta: metaRes.meta,
  2866. ui: createEventUi(refined, context),
  2867. extendedProps: extra,
  2868. };
  2869. }
  2870. }
  2871. return null;
  2872. }
  2873. function buildEventSourceRefiners(context) {
  2874. return __assign(__assign(__assign({}, EVENT_UI_REFINERS), EVENT_SOURCE_REFINERS$1), context.pluginHooks.eventSourceRefiners);
  2875. }
  2876. function buildEventSourceMeta(raw, context) {
  2877. var defs = context.pluginHooks.eventSourceDefs;
  2878. for (var i = defs.length - 1; i >= 0; i -= 1) { // later-added plugins take precedence
  2879. var def = defs[i];
  2880. var meta = def.parseMeta(raw);
  2881. if (meta) {
  2882. return { sourceDefId: i, meta: meta };
  2883. }
  2884. }
  2885. return null;
  2886. }
  2887. function reduceCurrentDate(currentDate, action) {
  2888. switch (action.type) {
  2889. case 'CHANGE_DATE':
  2890. return action.dateMarker;
  2891. default:
  2892. return currentDate;
  2893. }
  2894. }
  2895. function getInitialDate(options, dateEnv) {
  2896. var initialDateInput = options.initialDate;
  2897. // compute the initial ambig-timezone date
  2898. if (initialDateInput != null) {
  2899. return dateEnv.createMarker(initialDateInput);
  2900. }
  2901. return getNow(options.now, dateEnv); // getNow already returns unzoned
  2902. }
  2903. function getNow(nowInput, dateEnv) {
  2904. if (typeof nowInput === 'function') {
  2905. nowInput = nowInput();
  2906. }
  2907. if (nowInput == null) {
  2908. return dateEnv.createNowMarker();
  2909. }
  2910. return dateEnv.createMarker(nowInput);
  2911. }
  2912. var CalendarApi = /** @class */ (function () {
  2913. function CalendarApi() {
  2914. }
  2915. CalendarApi.prototype.getCurrentData = function () {
  2916. return this.currentDataManager.getCurrentData();
  2917. };
  2918. CalendarApi.prototype.dispatch = function (action) {
  2919. return this.currentDataManager.dispatch(action);
  2920. };
  2921. Object.defineProperty(CalendarApi.prototype, "view", {
  2922. get: function () { return this.getCurrentData().viewApi; } // for public API
  2923. ,
  2924. enumerable: false,
  2925. configurable: true
  2926. });
  2927. CalendarApi.prototype.batchRendering = function (callback) {
  2928. callback();
  2929. };
  2930. CalendarApi.prototype.updateSize = function () {
  2931. this.trigger('_resize', true);
  2932. };
  2933. // Options
  2934. // -----------------------------------------------------------------------------------------------------------------
  2935. CalendarApi.prototype.setOption = function (name, val) {
  2936. this.dispatch({
  2937. type: 'SET_OPTION',
  2938. optionName: name,
  2939. rawOptionValue: val,
  2940. });
  2941. };
  2942. CalendarApi.prototype.getOption = function (name) {
  2943. return this.currentDataManager.currentCalendarOptionsInput[name];
  2944. };
  2945. CalendarApi.prototype.getAvailableLocaleCodes = function () {
  2946. return Object.keys(this.getCurrentData().availableRawLocales);
  2947. };
  2948. // Trigger
  2949. // -----------------------------------------------------------------------------------------------------------------
  2950. CalendarApi.prototype.on = function (handlerName, handler) {
  2951. var currentDataManager = this.currentDataManager;
  2952. if (currentDataManager.currentCalendarOptionsRefiners[handlerName]) {
  2953. currentDataManager.emitter.on(handlerName, handler);
  2954. }
  2955. else {
  2956. console.warn("Unknown listener name '" + handlerName + "'");
  2957. }
  2958. };
  2959. CalendarApi.prototype.off = function (handlerName, handler) {
  2960. this.currentDataManager.emitter.off(handlerName, handler);
  2961. };
  2962. // not meant for public use
  2963. CalendarApi.prototype.trigger = function (handlerName) {
  2964. var _a;
  2965. var args = [];
  2966. for (var _i = 1; _i < arguments.length; _i++) {
  2967. args[_i - 1] = arguments[_i];
  2968. }
  2969. (_a = this.currentDataManager.emitter).trigger.apply(_a, __spreadArray([handlerName], args));
  2970. };
  2971. // View
  2972. // -----------------------------------------------------------------------------------------------------------------
  2973. CalendarApi.prototype.changeView = function (viewType, dateOrRange) {
  2974. var _this = this;
  2975. this.batchRendering(function () {
  2976. _this.unselect();
  2977. if (dateOrRange) {
  2978. if (dateOrRange.start && dateOrRange.end) { // a range
  2979. _this.dispatch({
  2980. type: 'CHANGE_VIEW_TYPE',
  2981. viewType: viewType,
  2982. });
  2983. _this.dispatch({
  2984. type: 'SET_OPTION',
  2985. optionName: 'visibleRange',
  2986. rawOptionValue: dateOrRange,
  2987. });
  2988. }
  2989. else {
  2990. var dateEnv = _this.getCurrentData().dateEnv;
  2991. _this.dispatch({
  2992. type: 'CHANGE_VIEW_TYPE',
  2993. viewType: viewType,
  2994. dateMarker: dateEnv.createMarker(dateOrRange),
  2995. });
  2996. }
  2997. }
  2998. else {
  2999. _this.dispatch({
  3000. type: 'CHANGE_VIEW_TYPE',
  3001. viewType: viewType,
  3002. });
  3003. }
  3004. });
  3005. };
  3006. // Forces navigation to a view for the given date.
  3007. // `viewType` can be a specific view name or a generic one like "week" or "day".
  3008. // needs to change
  3009. CalendarApi.prototype.zoomTo = function (dateMarker, viewType) {
  3010. var state = this.getCurrentData();
  3011. var spec;
  3012. viewType = viewType || 'day'; // day is default zoom
  3013. spec = state.viewSpecs[viewType] || this.getUnitViewSpec(viewType);
  3014. this.unselect();
  3015. if (spec) {
  3016. this.dispatch({
  3017. type: 'CHANGE_VIEW_TYPE',
  3018. viewType: spec.type,
  3019. dateMarker: dateMarker,
  3020. });
  3021. }
  3022. else {
  3023. this.dispatch({
  3024. type: 'CHANGE_DATE',
  3025. dateMarker: dateMarker,
  3026. });
  3027. }
  3028. };
  3029. // Given a duration singular unit, like "week" or "day", finds a matching view spec.
  3030. // Preference is given to views that have corresponding buttons.
  3031. CalendarApi.prototype.getUnitViewSpec = function (unit) {
  3032. var _a = this.getCurrentData(), viewSpecs = _a.viewSpecs, toolbarConfig = _a.toolbarConfig;
  3033. var viewTypes = [].concat(toolbarConfig.header ? toolbarConfig.header.viewsWithButtons : [], toolbarConfig.footer ? toolbarConfig.footer.viewsWithButtons : []);
  3034. var i;
  3035. var spec;
  3036. for (var viewType in viewSpecs) {
  3037. viewTypes.push(viewType);
  3038. }
  3039. for (i = 0; i < viewTypes.length; i += 1) {
  3040. spec = viewSpecs[viewTypes[i]];
  3041. if (spec) {
  3042. if (spec.singleUnit === unit) {
  3043. return spec;
  3044. }
  3045. }
  3046. }
  3047. return null;
  3048. };
  3049. // Current Date
  3050. // -----------------------------------------------------------------------------------------------------------------
  3051. CalendarApi.prototype.prev = function () {
  3052. this.unselect();
  3053. this.dispatch({ type: 'PREV' });
  3054. };
  3055. CalendarApi.prototype.next = function () {
  3056. this.unselect();
  3057. this.dispatch({ type: 'NEXT' });
  3058. };
  3059. CalendarApi.prototype.prevYear = function () {
  3060. var state = this.getCurrentData();
  3061. this.unselect();
  3062. this.dispatch({
  3063. type: 'CHANGE_DATE',
  3064. dateMarker: state.dateEnv.addYears(state.currentDate, -1),
  3065. });
  3066. };
  3067. CalendarApi.prototype.nextYear = function () {
  3068. var state = this.getCurrentData();
  3069. this.unselect();
  3070. this.dispatch({
  3071. type: 'CHANGE_DATE',
  3072. dateMarker: state.dateEnv.addYears(state.currentDate, 1),
  3073. });
  3074. };
  3075. CalendarApi.prototype.today = function () {
  3076. var state = this.getCurrentData();
  3077. this.unselect();
  3078. this.dispatch({
  3079. type: 'CHANGE_DATE',
  3080. dateMarker: getNow(state.calendarOptions.now, state.dateEnv),
  3081. });
  3082. };
  3083. CalendarApi.prototype.gotoDate = function (zonedDateInput) {
  3084. var state = this.getCurrentData();
  3085. this.unselect();
  3086. this.dispatch({
  3087. type: 'CHANGE_DATE',
  3088. dateMarker: state.dateEnv.createMarker(zonedDateInput),
  3089. });
  3090. };
  3091. CalendarApi.prototype.incrementDate = function (deltaInput) {
  3092. var state = this.getCurrentData();
  3093. var delta = createDuration(deltaInput);
  3094. if (delta) { // else, warn about invalid input?
  3095. this.unselect();
  3096. this.dispatch({
  3097. type: 'CHANGE_DATE',
  3098. dateMarker: state.dateEnv.add(state.currentDate, delta),
  3099. });
  3100. }
  3101. };
  3102. // for external API
  3103. CalendarApi.prototype.getDate = function () {
  3104. var state = this.getCurrentData();
  3105. return state.dateEnv.toDate(state.currentDate);
  3106. };
  3107. // Date Formatting Utils
  3108. // -----------------------------------------------------------------------------------------------------------------
  3109. CalendarApi.prototype.formatDate = function (d, formatter) {
  3110. var dateEnv = this.getCurrentData().dateEnv;
  3111. return dateEnv.format(dateEnv.createMarker(d), createFormatter(formatter));
  3112. };
  3113. // `settings` is for formatter AND isEndExclusive
  3114. CalendarApi.prototype.formatRange = function (d0, d1, settings) {
  3115. var dateEnv = this.getCurrentData().dateEnv;
  3116. return dateEnv.formatRange(dateEnv.createMarker(d0), dateEnv.createMarker(d1), createFormatter(settings), settings);
  3117. };
  3118. CalendarApi.prototype.formatIso = function (d, omitTime) {
  3119. var dateEnv = this.getCurrentData().dateEnv;
  3120. return dateEnv.formatIso(dateEnv.createMarker(d), { omitTime: omitTime });
  3121. };
  3122. // Date Selection / Event Selection / DayClick
  3123. // -----------------------------------------------------------------------------------------------------------------
  3124. // this public method receives start/end dates in any format, with any timezone
  3125. // NOTE: args were changed from v3
  3126. CalendarApi.prototype.select = function (dateOrObj, endDate) {
  3127. var selectionInput;
  3128. if (endDate == null) {
  3129. if (dateOrObj.start != null) {
  3130. selectionInput = dateOrObj;
  3131. }
  3132. else {
  3133. selectionInput = {
  3134. start: dateOrObj,
  3135. end: null,
  3136. };
  3137. }
  3138. }
  3139. else {
  3140. selectionInput = {
  3141. start: dateOrObj,
  3142. end: endDate,
  3143. };
  3144. }
  3145. var state = this.getCurrentData();
  3146. var selection = parseDateSpan(selectionInput, state.dateEnv, createDuration({ days: 1 }));
  3147. if (selection) { // throw parse error otherwise?
  3148. this.dispatch({ type: 'SELECT_DATES', selection: selection });
  3149. triggerDateSelect(selection, null, state);
  3150. }
  3151. };
  3152. // public method
  3153. CalendarApi.prototype.unselect = function (pev) {
  3154. var state = this.getCurrentData();
  3155. if (state.dateSelection) {
  3156. this.dispatch({ type: 'UNSELECT_DATES' });
  3157. triggerDateUnselect(pev, state);
  3158. }
  3159. };
  3160. // Public Events API
  3161. // -----------------------------------------------------------------------------------------------------------------
  3162. CalendarApi.prototype.addEvent = function (eventInput, sourceInput) {
  3163. if (eventInput instanceof EventApi) {
  3164. var def = eventInput._def;
  3165. var instance = eventInput._instance;
  3166. var currentData = this.getCurrentData();
  3167. // not already present? don't want to add an old snapshot
  3168. if (!currentData.eventStore.defs[def.defId]) {
  3169. this.dispatch({
  3170. type: 'ADD_EVENTS',
  3171. eventStore: eventTupleToStore({ def: def, instance: instance }), // TODO: better util for two args?
  3172. });
  3173. this.triggerEventAdd(eventInput);
  3174. }
  3175. return eventInput;
  3176. }
  3177. var state = this.getCurrentData();
  3178. var eventSource;
  3179. if (sourceInput instanceof EventSourceApi) {
  3180. eventSource = sourceInput.internalEventSource;
  3181. }
  3182. else if (typeof sourceInput === 'boolean') {
  3183. if (sourceInput) { // true. part of the first event source
  3184. eventSource = hashValuesToArray(state.eventSources)[0];
  3185. }
  3186. }
  3187. else if (sourceInput != null) { // an ID. accepts a number too
  3188. var sourceApi = this.getEventSourceById(sourceInput); // TODO: use an internal function
  3189. if (!sourceApi) {
  3190. console.warn("Could not find an event source with ID \"" + sourceInput + "\""); // TODO: test
  3191. return null;
  3192. }
  3193. eventSource = sourceApi.internalEventSource;
  3194. }
  3195. var tuple = parseEvent(eventInput, eventSource, state, false);
  3196. if (tuple) {
  3197. var newEventApi = new EventApi(state, tuple.def, tuple.def.recurringDef ? null : tuple.instance);
  3198. this.dispatch({
  3199. type: 'ADD_EVENTS',
  3200. eventStore: eventTupleToStore(tuple),
  3201. });
  3202. this.triggerEventAdd(newEventApi);
  3203. return newEventApi;
  3204. }
  3205. return null;
  3206. };
  3207. CalendarApi.prototype.triggerEventAdd = function (eventApi) {
  3208. var _this = this;
  3209. var emitter = this.getCurrentData().emitter;
  3210. emitter.trigger('eventAdd', {
  3211. event: eventApi,
  3212. relatedEvents: [],
  3213. revert: function () {
  3214. _this.dispatch({
  3215. type: 'REMOVE_EVENTS',
  3216. eventStore: eventApiToStore(eventApi),
  3217. });
  3218. },
  3219. });
  3220. };
  3221. // TODO: optimize
  3222. CalendarApi.prototype.getEventById = function (id) {
  3223. var state = this.getCurrentData();
  3224. var _a = state.eventStore, defs = _a.defs, instances = _a.instances;
  3225. id = String(id);
  3226. for (var defId in defs) {
  3227. var def = defs[defId];
  3228. if (def.publicId === id) {
  3229. if (def.recurringDef) {
  3230. return new EventApi(state, def, null);
  3231. }
  3232. for (var instanceId in instances) {
  3233. var instance = instances[instanceId];
  3234. if (instance.defId === def.defId) {
  3235. return new EventApi(state, def, instance);
  3236. }
  3237. }
  3238. }
  3239. }
  3240. return null;
  3241. };
  3242. CalendarApi.prototype.getEvents = function () {
  3243. var currentData = this.getCurrentData();
  3244. return buildEventApis(currentData.eventStore, currentData);
  3245. };
  3246. CalendarApi.prototype.removeAllEvents = function () {
  3247. this.dispatch({ type: 'REMOVE_ALL_EVENTS' });
  3248. };
  3249. // Public Event Sources API
  3250. // -----------------------------------------------------------------------------------------------------------------
  3251. CalendarApi.prototype.getEventSources = function () {
  3252. var state = this.getCurrentData();
  3253. var sourceHash = state.eventSources;
  3254. var sourceApis = [];
  3255. for (var internalId in sourceHash) {
  3256. sourceApis.push(new EventSourceApi(state, sourceHash[internalId]));
  3257. }
  3258. return sourceApis;
  3259. };
  3260. CalendarApi.prototype.getEventSourceById = function (id) {
  3261. var state = this.getCurrentData();
  3262. var sourceHash = state.eventSources;
  3263. id = String(id);
  3264. for (var sourceId in sourceHash) {
  3265. if (sourceHash[sourceId].publicId === id) {
  3266. return new EventSourceApi(state, sourceHash[sourceId]);
  3267. }
  3268. }
  3269. return null;
  3270. };
  3271. CalendarApi.prototype.addEventSource = function (sourceInput) {
  3272. var state = this.getCurrentData();
  3273. if (sourceInput instanceof EventSourceApi) {
  3274. // not already present? don't want to add an old snapshot
  3275. if (!state.eventSources[sourceInput.internalEventSource.sourceId]) {
  3276. this.dispatch({
  3277. type: 'ADD_EVENT_SOURCES',
  3278. sources: [sourceInput.internalEventSource],
  3279. });
  3280. }
  3281. return sourceInput;
  3282. }
  3283. var eventSource = parseEventSource(sourceInput, state);
  3284. if (eventSource) { // TODO: error otherwise?
  3285. this.dispatch({ type: 'ADD_EVENT_SOURCES', sources: [eventSource] });
  3286. return new EventSourceApi(state, eventSource);
  3287. }
  3288. return null;
  3289. };
  3290. CalendarApi.prototype.removeAllEventSources = function () {
  3291. this.dispatch({ type: 'REMOVE_ALL_EVENT_SOURCES' });
  3292. };
  3293. CalendarApi.prototype.refetchEvents = function () {
  3294. this.dispatch({ type: 'FETCH_EVENT_SOURCES', isRefetch: true });
  3295. };
  3296. // Scroll
  3297. // -----------------------------------------------------------------------------------------------------------------
  3298. CalendarApi.prototype.scrollToTime = function (timeInput) {
  3299. var time = createDuration(timeInput);
  3300. if (time) {
  3301. this.trigger('_scrollRequest', { time: time });
  3302. }
  3303. };
  3304. return CalendarApi;
  3305. }());
  3306. var EventApi = /** @class */ (function () {
  3307. // instance will be null if expressing a recurring event that has no current instances,
  3308. // OR if trying to validate an incoming external event that has no dates assigned
  3309. function EventApi(context, def, instance) {
  3310. this._context = context;
  3311. this._def = def;
  3312. this._instance = instance || null;
  3313. }
  3314. /*
  3315. TODO: make event struct more responsible for this
  3316. */
  3317. EventApi.prototype.setProp = function (name, val) {
  3318. var _a, _b;
  3319. if (name in EVENT_DATE_REFINERS) {
  3320. console.warn('Could not set date-related prop \'name\'. Use one of the date-related methods instead.');
  3321. // TODO: make proper aliasing system?
  3322. }
  3323. else if (name === 'id') {
  3324. val = EVENT_NON_DATE_REFINERS[name](val);
  3325. this.mutate({
  3326. standardProps: { publicId: val }, // hardcoded internal name
  3327. });
  3328. }
  3329. else if (name in EVENT_NON_DATE_REFINERS) {
  3330. val = EVENT_NON_DATE_REFINERS[name](val);
  3331. this.mutate({
  3332. standardProps: (_a = {}, _a[name] = val, _a),
  3333. });
  3334. }
  3335. else if (name in EVENT_UI_REFINERS) {
  3336. var ui = EVENT_UI_REFINERS[name](val);
  3337. if (name === 'color') {
  3338. ui = { backgroundColor: val, borderColor: val };
  3339. }
  3340. else if (name === 'editable') {
  3341. ui = { startEditable: val, durationEditable: val };
  3342. }
  3343. else {
  3344. ui = (_b = {}, _b[name] = val, _b);
  3345. }
  3346. this.mutate({
  3347. standardProps: { ui: ui },
  3348. });
  3349. }
  3350. else {
  3351. console.warn("Could not set prop '" + name + "'. Use setExtendedProp instead.");
  3352. }
  3353. };
  3354. EventApi.prototype.setExtendedProp = function (name, val) {
  3355. var _a;
  3356. this.mutate({
  3357. extendedProps: (_a = {}, _a[name] = val, _a),
  3358. });
  3359. };
  3360. EventApi.prototype.setStart = function (startInput, options) {
  3361. if (options === void 0) { options = {}; }
  3362. var dateEnv = this._context.dateEnv;
  3363. var start = dateEnv.createMarker(startInput);
  3364. if (start && this._instance) { // TODO: warning if parsed bad
  3365. var instanceRange = this._instance.range;
  3366. var startDelta = diffDates(instanceRange.start, start, dateEnv, options.granularity); // what if parsed bad!?
  3367. if (options.maintainDuration) {
  3368. this.mutate({ datesDelta: startDelta });
  3369. }
  3370. else {
  3371. this.mutate({ startDelta: startDelta });
  3372. }
  3373. }
  3374. };
  3375. EventApi.prototype.setEnd = function (endInput, options) {
  3376. if (options === void 0) { options = {}; }
  3377. var dateEnv = this._context.dateEnv;
  3378. var end;
  3379. if (endInput != null) {
  3380. end = dateEnv.createMarker(endInput);
  3381. if (!end) {
  3382. return; // TODO: warning if parsed bad
  3383. }
  3384. }
  3385. if (this._instance) {
  3386. if (end) {
  3387. var endDelta = diffDates(this._instance.range.end, end, dateEnv, options.granularity);
  3388. this.mutate({ endDelta: endDelta });
  3389. }
  3390. else {
  3391. this.mutate({ standardProps: { hasEnd: false } });
  3392. }
  3393. }
  3394. };
  3395. EventApi.prototype.setDates = function (startInput, endInput, options) {
  3396. if (options === void 0) { options = {}; }
  3397. var dateEnv = this._context.dateEnv;
  3398. var standardProps = { allDay: options.allDay };
  3399. var start = dateEnv.createMarker(startInput);
  3400. var end;
  3401. if (!start) {
  3402. return; // TODO: warning if parsed bad
  3403. }
  3404. if (endInput != null) {
  3405. end = dateEnv.createMarker(endInput);
  3406. if (!end) { // TODO: warning if parsed bad
  3407. return;
  3408. }
  3409. }
  3410. if (this._instance) {
  3411. var instanceRange = this._instance.range;
  3412. // when computing the diff for an event being converted to all-day,
  3413. // compute diff off of the all-day values the way event-mutation does.
  3414. if (options.allDay === true) {
  3415. instanceRange = computeAlignedDayRange(instanceRange);
  3416. }
  3417. var startDelta = diffDates(instanceRange.start, start, dateEnv, options.granularity);
  3418. if (end) {
  3419. var endDelta = diffDates(instanceRange.end, end, dateEnv, options.granularity);
  3420. if (durationsEqual(startDelta, endDelta)) {
  3421. this.mutate({ datesDelta: startDelta, standardProps: standardProps });
  3422. }
  3423. else {
  3424. this.mutate({ startDelta: startDelta, endDelta: endDelta, standardProps: standardProps });
  3425. }
  3426. }
  3427. else { // means "clear the end"
  3428. standardProps.hasEnd = false;
  3429. this.mutate({ datesDelta: startDelta, standardProps: standardProps });
  3430. }
  3431. }
  3432. };
  3433. EventApi.prototype.moveStart = function (deltaInput) {
  3434. var delta = createDuration(deltaInput);
  3435. if (delta) { // TODO: warning if parsed bad
  3436. this.mutate({ startDelta: delta });
  3437. }
  3438. };
  3439. EventApi.prototype.moveEnd = function (deltaInput) {
  3440. var delta = createDuration(deltaInput);
  3441. if (delta) { // TODO: warning if parsed bad
  3442. this.mutate({ endDelta: delta });
  3443. }
  3444. };
  3445. EventApi.prototype.moveDates = function (deltaInput) {
  3446. var delta = createDuration(deltaInput);
  3447. if (delta) { // TODO: warning if parsed bad
  3448. this.mutate({ datesDelta: delta });
  3449. }
  3450. };
  3451. EventApi.prototype.setAllDay = function (allDay, options) {
  3452. if (options === void 0) { options = {}; }
  3453. var standardProps = { allDay: allDay };
  3454. var maintainDuration = options.maintainDuration;
  3455. if (maintainDuration == null) {
  3456. maintainDuration = this._context.options.allDayMaintainDuration;
  3457. }
  3458. if (this._def.allDay !== allDay) {
  3459. standardProps.hasEnd = maintainDuration;
  3460. }
  3461. this.mutate({ standardProps: standardProps });
  3462. };
  3463. EventApi.prototype.formatRange = function (formatInput) {
  3464. var dateEnv = this._context.dateEnv;
  3465. var instance = this._instance;
  3466. var formatter = createFormatter(formatInput);
  3467. if (this._def.hasEnd) {
  3468. return dateEnv.formatRange(instance.range.start, instance.range.end, formatter, {
  3469. forcedStartTzo: instance.forcedStartTzo,
  3470. forcedEndTzo: instance.forcedEndTzo,
  3471. });
  3472. }
  3473. return dateEnv.format(instance.range.start, formatter, {
  3474. forcedTzo: instance.forcedStartTzo,
  3475. });
  3476. };
  3477. EventApi.prototype.mutate = function (mutation) {
  3478. var instance = this._instance;
  3479. if (instance) {
  3480. var def = this._def;
  3481. var context_1 = this._context;
  3482. var eventStore_1 = context_1.getCurrentData().eventStore;
  3483. var relevantEvents = getRelevantEvents(eventStore_1, instance.instanceId);
  3484. var eventConfigBase = {
  3485. '': {
  3486. display: '',
  3487. startEditable: true,
  3488. durationEditable: true,
  3489. constraints: [],
  3490. overlap: null,
  3491. allows: [],
  3492. backgroundColor: '',
  3493. borderColor: '',
  3494. textColor: '',
  3495. classNames: [],
  3496. },
  3497. };
  3498. relevantEvents = applyMutationToEventStore(relevantEvents, eventConfigBase, mutation, context_1);
  3499. var oldEvent = new EventApi(context_1, def, instance); // snapshot
  3500. this._def = relevantEvents.defs[def.defId];
  3501. this._instance = relevantEvents.instances[instance.instanceId];
  3502. context_1.dispatch({
  3503. type: 'MERGE_EVENTS',
  3504. eventStore: relevantEvents,
  3505. });
  3506. context_1.emitter.trigger('eventChange', {
  3507. oldEvent: oldEvent,
  3508. event: this,
  3509. relatedEvents: buildEventApis(relevantEvents, context_1, instance),
  3510. revert: function () {
  3511. context_1.dispatch({
  3512. type: 'RESET_EVENTS',
  3513. eventStore: eventStore_1,
  3514. });
  3515. },
  3516. });
  3517. }
  3518. };
  3519. EventApi.prototype.remove = function () {
  3520. var context = this._context;
  3521. var asStore = eventApiToStore(this);
  3522. context.dispatch({
  3523. type: 'REMOVE_EVENTS',
  3524. eventStore: asStore,
  3525. });
  3526. context.emitter.trigger('eventRemove', {
  3527. event: this,
  3528. relatedEvents: [],
  3529. revert: function () {
  3530. context.dispatch({
  3531. type: 'MERGE_EVENTS',
  3532. eventStore: asStore,
  3533. });
  3534. },
  3535. });
  3536. };
  3537. Object.defineProperty(EventApi.prototype, "source", {
  3538. get: function () {
  3539. var sourceId = this._def.sourceId;
  3540. if (sourceId) {
  3541. return new EventSourceApi(this._context, this._context.getCurrentData().eventSources[sourceId]);
  3542. }
  3543. return null;
  3544. },
  3545. enumerable: false,
  3546. configurable: true
  3547. });
  3548. Object.defineProperty(EventApi.prototype, "start", {
  3549. get: function () {
  3550. return this._instance ?
  3551. this._context.dateEnv.toDate(this._instance.range.start) :
  3552. null;
  3553. },
  3554. enumerable: false,
  3555. configurable: true
  3556. });
  3557. Object.defineProperty(EventApi.prototype, "end", {
  3558. get: function () {
  3559. return (this._instance && this._def.hasEnd) ?
  3560. this._context.dateEnv.toDate(this._instance.range.end) :
  3561. null;
  3562. },
  3563. enumerable: false,
  3564. configurable: true
  3565. });
  3566. Object.defineProperty(EventApi.prototype, "startStr", {
  3567. get: function () {
  3568. var instance = this._instance;
  3569. if (instance) {
  3570. return this._context.dateEnv.formatIso(instance.range.start, {
  3571. omitTime: this._def.allDay,
  3572. forcedTzo: instance.forcedStartTzo,
  3573. });
  3574. }
  3575. return '';
  3576. },
  3577. enumerable: false,
  3578. configurable: true
  3579. });
  3580. Object.defineProperty(EventApi.prototype, "endStr", {
  3581. get: function () {
  3582. var instance = this._instance;
  3583. if (instance && this._def.hasEnd) {
  3584. return this._context.dateEnv.formatIso(instance.range.end, {
  3585. omitTime: this._def.allDay,
  3586. forcedTzo: instance.forcedEndTzo,
  3587. });
  3588. }
  3589. return '';
  3590. },
  3591. enumerable: false,
  3592. configurable: true
  3593. });
  3594. Object.defineProperty(EventApi.prototype, "id", {
  3595. // computable props that all access the def
  3596. // TODO: find a TypeScript-compatible way to do this at scale
  3597. get: function () { return this._def.publicId; },
  3598. enumerable: false,
  3599. configurable: true
  3600. });
  3601. Object.defineProperty(EventApi.prototype, "groupId", {
  3602. get: function () { return this._def.groupId; },
  3603. enumerable: false,
  3604. configurable: true
  3605. });
  3606. Object.defineProperty(EventApi.prototype, "allDay", {
  3607. get: function () { return this._def.allDay; },
  3608. enumerable: false,
  3609. configurable: true
  3610. });
  3611. Object.defineProperty(EventApi.prototype, "title", {
  3612. get: function () { return this._def.title; },
  3613. enumerable: false,
  3614. configurable: true
  3615. });
  3616. Object.defineProperty(EventApi.prototype, "url", {
  3617. get: function () { return this._def.url; },
  3618. enumerable: false,
  3619. configurable: true
  3620. });
  3621. Object.defineProperty(EventApi.prototype, "display", {
  3622. get: function () { return this._def.ui.display || 'auto'; } // bad. just normalize the type earlier
  3623. ,
  3624. enumerable: false,
  3625. configurable: true
  3626. });
  3627. Object.defineProperty(EventApi.prototype, "startEditable", {
  3628. get: function () { return this._def.ui.startEditable; },
  3629. enumerable: false,
  3630. configurable: true
  3631. });
  3632. Object.defineProperty(EventApi.prototype, "durationEditable", {
  3633. get: function () { return this._def.ui.durationEditable; },
  3634. enumerable: false,
  3635. configurable: true
  3636. });
  3637. Object.defineProperty(EventApi.prototype, "constraint", {
  3638. get: function () { return this._def.ui.constraints[0] || null; },
  3639. enumerable: false,
  3640. configurable: true
  3641. });
  3642. Object.defineProperty(EventApi.prototype, "overlap", {
  3643. get: function () { return this._def.ui.overlap; },
  3644. enumerable: false,
  3645. configurable: true
  3646. });
  3647. Object.defineProperty(EventApi.prototype, "allow", {
  3648. get: function () { return this._def.ui.allows[0] || null; },
  3649. enumerable: false,
  3650. configurable: true
  3651. });
  3652. Object.defineProperty(EventApi.prototype, "backgroundColor", {
  3653. get: function () { return this._def.ui.backgroundColor; },
  3654. enumerable: false,
  3655. configurable: true
  3656. });
  3657. Object.defineProperty(EventApi.prototype, "borderColor", {
  3658. get: function () { return this._def.ui.borderColor; },
  3659. enumerable: false,
  3660. configurable: true
  3661. });
  3662. Object.defineProperty(EventApi.prototype, "textColor", {
  3663. get: function () { return this._def.ui.textColor; },
  3664. enumerable: false,
  3665. configurable: true
  3666. });
  3667. Object.defineProperty(EventApi.prototype, "classNames", {
  3668. // NOTE: user can't modify these because Object.freeze was called in event-def parsing
  3669. get: function () { return this._def.ui.classNames; },
  3670. enumerable: false,
  3671. configurable: true
  3672. });
  3673. Object.defineProperty(EventApi.prototype, "extendedProps", {
  3674. get: function () { return this._def.extendedProps; },
  3675. enumerable: false,
  3676. configurable: true
  3677. });
  3678. EventApi.prototype.toPlainObject = function (settings) {
  3679. if (settings === void 0) { settings = {}; }
  3680. var def = this._def;
  3681. var ui = def.ui;
  3682. var _a = this, startStr = _a.startStr, endStr = _a.endStr;
  3683. var res = {};
  3684. if (def.title) {
  3685. res.title = def.title;
  3686. }
  3687. if (startStr) {
  3688. res.start = startStr;
  3689. }
  3690. if (endStr) {
  3691. res.end = endStr;
  3692. }
  3693. if (def.publicId) {
  3694. res.id = def.publicId;
  3695. }
  3696. if (def.groupId) {
  3697. res.groupId = def.groupId;
  3698. }
  3699. if (def.url) {
  3700. res.url = def.url;
  3701. }
  3702. if (ui.display && ui.display !== 'auto') {
  3703. res.display = ui.display;
  3704. }
  3705. // TODO: what about recurring-event properties???
  3706. // TODO: include startEditable/durationEditable/constraint/overlap/allow
  3707. if (settings.collapseColor && ui.backgroundColor && ui.backgroundColor === ui.borderColor) {
  3708. res.color = ui.backgroundColor;
  3709. }
  3710. else {
  3711. if (ui.backgroundColor) {
  3712. res.backgroundColor = ui.backgroundColor;
  3713. }
  3714. if (ui.borderColor) {
  3715. res.borderColor = ui.borderColor;
  3716. }
  3717. }
  3718. if (ui.textColor) {
  3719. res.textColor = ui.textColor;
  3720. }
  3721. if (ui.classNames.length) {
  3722. res.classNames = ui.classNames;
  3723. }
  3724. if (Object.keys(def.extendedProps).length) {
  3725. if (settings.collapseExtendedProps) {
  3726. __assign(res, def.extendedProps);
  3727. }
  3728. else {
  3729. res.extendedProps = def.extendedProps;
  3730. }
  3731. }
  3732. return res;
  3733. };
  3734. EventApi.prototype.toJSON = function () {
  3735. return this.toPlainObject();
  3736. };
  3737. return EventApi;
  3738. }());
  3739. function eventApiToStore(eventApi) {
  3740. var _a, _b;
  3741. var def = eventApi._def;
  3742. var instance = eventApi._instance;
  3743. return {
  3744. defs: (_a = {}, _a[def.defId] = def, _a),
  3745. instances: instance
  3746. ? (_b = {}, _b[instance.instanceId] = instance, _b) : {},
  3747. };
  3748. }
  3749. function buildEventApis(eventStore, context, excludeInstance) {
  3750. var defs = eventStore.defs, instances = eventStore.instances;
  3751. var eventApis = [];
  3752. var excludeInstanceId = excludeInstance ? excludeInstance.instanceId : '';
  3753. for (var id in instances) {
  3754. var instance = instances[id];
  3755. var def = defs[instance.defId];
  3756. if (instance.instanceId !== excludeInstanceId) {
  3757. eventApis.push(new EventApi(context, def, instance));
  3758. }
  3759. }
  3760. return eventApis;
  3761. }
  3762. var calendarSystemClassMap = {};
  3763. function registerCalendarSystem(name, theClass) {
  3764. calendarSystemClassMap[name] = theClass;
  3765. }
  3766. function createCalendarSystem(name) {
  3767. return new calendarSystemClassMap[name]();
  3768. }
  3769. var GregorianCalendarSystem = /** @class */ (function () {
  3770. function GregorianCalendarSystem() {
  3771. }
  3772. GregorianCalendarSystem.prototype.getMarkerYear = function (d) {
  3773. return d.getUTCFullYear();
  3774. };
  3775. GregorianCalendarSystem.prototype.getMarkerMonth = function (d) {
  3776. return d.getUTCMonth();
  3777. };
  3778. GregorianCalendarSystem.prototype.getMarkerDay = function (d) {
  3779. return d.getUTCDate();
  3780. };
  3781. GregorianCalendarSystem.prototype.arrayToMarker = function (arr) {
  3782. return arrayToUtcDate(arr);
  3783. };
  3784. GregorianCalendarSystem.prototype.markerToArray = function (marker) {
  3785. return dateToUtcArray(marker);
  3786. };
  3787. return GregorianCalendarSystem;
  3788. }());
  3789. registerCalendarSystem('gregory', GregorianCalendarSystem);
  3790. var ISO_RE = /^\s*(\d{4})(-?(\d{2})(-?(\d{2})([T ](\d{2}):?(\d{2})(:?(\d{2})(\.(\d+))?)?(Z|(([-+])(\d{2})(:?(\d{2}))?))?)?)?)?$/;
  3791. function parse(str) {
  3792. var m = ISO_RE.exec(str);
  3793. if (m) {
  3794. 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));
  3795. if (isValidDate(marker)) {
  3796. var timeZoneOffset = null;
  3797. if (m[13]) {
  3798. timeZoneOffset = (m[15] === '-' ? -1 : 1) * (Number(m[16] || 0) * 60 +
  3799. Number(m[18] || 0));
  3800. }
  3801. return {
  3802. marker: marker,
  3803. isTimeUnspecified: !m[6],
  3804. timeZoneOffset: timeZoneOffset,
  3805. };
  3806. }
  3807. }
  3808. return null;
  3809. }
  3810. var DateEnv = /** @class */ (function () {
  3811. function DateEnv(settings) {
  3812. var timeZone = this.timeZone = settings.timeZone;
  3813. var isNamedTimeZone = timeZone !== 'local' && timeZone !== 'UTC';
  3814. if (settings.namedTimeZoneImpl && isNamedTimeZone) {
  3815. this.namedTimeZoneImpl = new settings.namedTimeZoneImpl(timeZone);
  3816. }
  3817. this.canComputeOffset = Boolean(!isNamedTimeZone || this.namedTimeZoneImpl);
  3818. this.calendarSystem = createCalendarSystem(settings.calendarSystem);
  3819. this.locale = settings.locale;
  3820. this.weekDow = settings.locale.week.dow;
  3821. this.weekDoy = settings.locale.week.doy;
  3822. if (settings.weekNumberCalculation === 'ISO') {
  3823. this.weekDow = 1;
  3824. this.weekDoy = 4;
  3825. }
  3826. if (typeof settings.firstDay === 'number') {
  3827. this.weekDow = settings.firstDay;
  3828. }
  3829. if (typeof settings.weekNumberCalculation === 'function') {
  3830. this.weekNumberFunc = settings.weekNumberCalculation;
  3831. }
  3832. this.weekText = settings.weekText != null ? settings.weekText : settings.locale.options.weekText;
  3833. this.weekTextLong = (settings.weekTextLong != null ? settings.weekTextLong : settings.locale.options.weekTextLong) || this.weekText;
  3834. this.cmdFormatter = settings.cmdFormatter;
  3835. this.defaultSeparator = settings.defaultSeparator;
  3836. }
  3837. // Creating / Parsing
  3838. DateEnv.prototype.createMarker = function (input) {
  3839. var meta = this.createMarkerMeta(input);
  3840. if (meta === null) {
  3841. return null;
  3842. }
  3843. return meta.marker;
  3844. };
  3845. DateEnv.prototype.createNowMarker = function () {
  3846. if (this.canComputeOffset) {
  3847. return this.timestampToMarker(new Date().valueOf());
  3848. }
  3849. // if we can't compute the current date val for a timezone,
  3850. // better to give the current local date vals than UTC
  3851. return arrayToUtcDate(dateToLocalArray(new Date()));
  3852. };
  3853. DateEnv.prototype.createMarkerMeta = function (input) {
  3854. if (typeof input === 'string') {
  3855. return this.parse(input);
  3856. }
  3857. var marker = null;
  3858. if (typeof input === 'number') {
  3859. marker = this.timestampToMarker(input);
  3860. }
  3861. else if (input instanceof Date) {
  3862. input = input.valueOf();
  3863. if (!isNaN(input)) {
  3864. marker = this.timestampToMarker(input);
  3865. }
  3866. }
  3867. else if (Array.isArray(input)) {
  3868. marker = arrayToUtcDate(input);
  3869. }
  3870. if (marker === null || !isValidDate(marker)) {
  3871. return null;
  3872. }
  3873. return { marker: marker, isTimeUnspecified: false, forcedTzo: null };
  3874. };
  3875. DateEnv.prototype.parse = function (s) {
  3876. var parts = parse(s);
  3877. if (parts === null) {
  3878. return null;
  3879. }
  3880. var marker = parts.marker;
  3881. var forcedTzo = null;
  3882. if (parts.timeZoneOffset !== null) {
  3883. if (this.canComputeOffset) {
  3884. marker = this.timestampToMarker(marker.valueOf() - parts.timeZoneOffset * 60 * 1000);
  3885. }
  3886. else {
  3887. forcedTzo = parts.timeZoneOffset;
  3888. }
  3889. }
  3890. return { marker: marker, isTimeUnspecified: parts.isTimeUnspecified, forcedTzo: forcedTzo };
  3891. };
  3892. // Accessors
  3893. DateEnv.prototype.getYear = function (marker) {
  3894. return this.calendarSystem.getMarkerYear(marker);
  3895. };
  3896. DateEnv.prototype.getMonth = function (marker) {
  3897. return this.calendarSystem.getMarkerMonth(marker);
  3898. };
  3899. // Adding / Subtracting
  3900. DateEnv.prototype.add = function (marker, dur) {
  3901. var a = this.calendarSystem.markerToArray(marker);
  3902. a[0] += dur.years;
  3903. a[1] += dur.months;
  3904. a[2] += dur.days;
  3905. a[6] += dur.milliseconds;
  3906. return this.calendarSystem.arrayToMarker(a);
  3907. };
  3908. DateEnv.prototype.subtract = function (marker, dur) {
  3909. var a = this.calendarSystem.markerToArray(marker);
  3910. a[0] -= dur.years;
  3911. a[1] -= dur.months;
  3912. a[2] -= dur.days;
  3913. a[6] -= dur.milliseconds;
  3914. return this.calendarSystem.arrayToMarker(a);
  3915. };
  3916. DateEnv.prototype.addYears = function (marker, n) {
  3917. var a = this.calendarSystem.markerToArray(marker);
  3918. a[0] += n;
  3919. return this.calendarSystem.arrayToMarker(a);
  3920. };
  3921. DateEnv.prototype.addMonths = function (marker, n) {
  3922. var a = this.calendarSystem.markerToArray(marker);
  3923. a[1] += n;
  3924. return this.calendarSystem.arrayToMarker(a);
  3925. };
  3926. // Diffing Whole Units
  3927. DateEnv.prototype.diffWholeYears = function (m0, m1) {
  3928. var calendarSystem = this.calendarSystem;
  3929. if (timeAsMs(m0) === timeAsMs(m1) &&
  3930. calendarSystem.getMarkerDay(m0) === calendarSystem.getMarkerDay(m1) &&
  3931. calendarSystem.getMarkerMonth(m0) === calendarSystem.getMarkerMonth(m1)) {
  3932. return calendarSystem.getMarkerYear(m1) - calendarSystem.getMarkerYear(m0);
  3933. }
  3934. return null;
  3935. };
  3936. DateEnv.prototype.diffWholeMonths = function (m0, m1) {
  3937. var calendarSystem = this.calendarSystem;
  3938. if (timeAsMs(m0) === timeAsMs(m1) &&
  3939. calendarSystem.getMarkerDay(m0) === calendarSystem.getMarkerDay(m1)) {
  3940. return (calendarSystem.getMarkerMonth(m1) - calendarSystem.getMarkerMonth(m0)) +
  3941. (calendarSystem.getMarkerYear(m1) - calendarSystem.getMarkerYear(m0)) * 12;
  3942. }
  3943. return null;
  3944. };
  3945. // Range / Duration
  3946. DateEnv.prototype.greatestWholeUnit = function (m0, m1) {
  3947. var n = this.diffWholeYears(m0, m1);
  3948. if (n !== null) {
  3949. return { unit: 'year', value: n };
  3950. }
  3951. n = this.diffWholeMonths(m0, m1);
  3952. if (n !== null) {
  3953. return { unit: 'month', value: n };
  3954. }
  3955. n = diffWholeWeeks(m0, m1);
  3956. if (n !== null) {
  3957. return { unit: 'week', value: n };
  3958. }
  3959. n = diffWholeDays(m0, m1);
  3960. if (n !== null) {
  3961. return { unit: 'day', value: n };
  3962. }
  3963. n = diffHours(m0, m1);
  3964. if (isInt(n)) {
  3965. return { unit: 'hour', value: n };
  3966. }
  3967. n = diffMinutes(m0, m1);
  3968. if (isInt(n)) {
  3969. return { unit: 'minute', value: n };
  3970. }
  3971. n = diffSeconds(m0, m1);
  3972. if (isInt(n)) {
  3973. return { unit: 'second', value: n };
  3974. }
  3975. return { unit: 'millisecond', value: m1.valueOf() - m0.valueOf() };
  3976. };
  3977. DateEnv.prototype.countDurationsBetween = function (m0, m1, d) {
  3978. // TODO: can use greatestWholeUnit
  3979. var diff;
  3980. if (d.years) {
  3981. diff = this.diffWholeYears(m0, m1);
  3982. if (diff !== null) {
  3983. return diff / asRoughYears(d);
  3984. }
  3985. }
  3986. if (d.months) {
  3987. diff = this.diffWholeMonths(m0, m1);
  3988. if (diff !== null) {
  3989. return diff / asRoughMonths(d);
  3990. }
  3991. }
  3992. if (d.days) {
  3993. diff = diffWholeDays(m0, m1);
  3994. if (diff !== null) {
  3995. return diff / asRoughDays(d);
  3996. }
  3997. }
  3998. return (m1.valueOf() - m0.valueOf()) / asRoughMs(d);
  3999. };
  4000. // Start-Of
  4001. // these DON'T return zoned-dates. only UTC start-of dates
  4002. DateEnv.prototype.startOf = function (m, unit) {
  4003. if (unit === 'year') {
  4004. return this.startOfYear(m);
  4005. }
  4006. if (unit === 'month') {
  4007. return this.startOfMonth(m);
  4008. }
  4009. if (unit === 'week') {
  4010. return this.startOfWeek(m);
  4011. }
  4012. if (unit === 'day') {
  4013. return startOfDay(m);
  4014. }
  4015. if (unit === 'hour') {
  4016. return startOfHour(m);
  4017. }
  4018. if (unit === 'minute') {
  4019. return startOfMinute(m);
  4020. }
  4021. if (unit === 'second') {
  4022. return startOfSecond(m);
  4023. }
  4024. return null;
  4025. };
  4026. DateEnv.prototype.startOfYear = function (m) {
  4027. return this.calendarSystem.arrayToMarker([
  4028. this.calendarSystem.getMarkerYear(m),
  4029. ]);
  4030. };
  4031. DateEnv.prototype.startOfMonth = function (m) {
  4032. return this.calendarSystem.arrayToMarker([
  4033. this.calendarSystem.getMarkerYear(m),
  4034. this.calendarSystem.getMarkerMonth(m),
  4035. ]);
  4036. };
  4037. DateEnv.prototype.startOfWeek = function (m) {
  4038. return this.calendarSystem.arrayToMarker([
  4039. this.calendarSystem.getMarkerYear(m),
  4040. this.calendarSystem.getMarkerMonth(m),
  4041. m.getUTCDate() - ((m.getUTCDay() - this.weekDow + 7) % 7),
  4042. ]);
  4043. };
  4044. // Week Number
  4045. DateEnv.prototype.computeWeekNumber = function (marker) {
  4046. if (this.weekNumberFunc) {
  4047. return this.weekNumberFunc(this.toDate(marker));
  4048. }
  4049. return weekOfYear(marker, this.weekDow, this.weekDoy);
  4050. };
  4051. // TODO: choke on timeZoneName: long
  4052. DateEnv.prototype.format = function (marker, formatter, dateOptions) {
  4053. if (dateOptions === void 0) { dateOptions = {}; }
  4054. return formatter.format({
  4055. marker: marker,
  4056. timeZoneOffset: dateOptions.forcedTzo != null ?
  4057. dateOptions.forcedTzo :
  4058. this.offsetForMarker(marker),
  4059. }, this);
  4060. };
  4061. DateEnv.prototype.formatRange = function (start, end, formatter, dateOptions) {
  4062. if (dateOptions === void 0) { dateOptions = {}; }
  4063. if (dateOptions.isEndExclusive) {
  4064. end = addMs(end, -1);
  4065. }
  4066. return formatter.formatRange({
  4067. marker: start,
  4068. timeZoneOffset: dateOptions.forcedStartTzo != null ?
  4069. dateOptions.forcedStartTzo :
  4070. this.offsetForMarker(start),
  4071. }, {
  4072. marker: end,
  4073. timeZoneOffset: dateOptions.forcedEndTzo != null ?
  4074. dateOptions.forcedEndTzo :
  4075. this.offsetForMarker(end),
  4076. }, this, dateOptions.defaultSeparator);
  4077. };
  4078. /*
  4079. DUMB: the omitTime arg is dumb. if we omit the time, we want to omit the timezone offset. and if we do that,
  4080. might as well use buildIsoString or some other util directly
  4081. */
  4082. DateEnv.prototype.formatIso = function (marker, extraOptions) {
  4083. if (extraOptions === void 0) { extraOptions = {}; }
  4084. var timeZoneOffset = null;
  4085. if (!extraOptions.omitTimeZoneOffset) {
  4086. if (extraOptions.forcedTzo != null) {
  4087. timeZoneOffset = extraOptions.forcedTzo;
  4088. }
  4089. else {
  4090. timeZoneOffset = this.offsetForMarker(marker);
  4091. }
  4092. }
  4093. return buildIsoString(marker, timeZoneOffset, extraOptions.omitTime);
  4094. };
  4095. // TimeZone
  4096. DateEnv.prototype.timestampToMarker = function (ms) {
  4097. if (this.timeZone === 'local') {
  4098. return arrayToUtcDate(dateToLocalArray(new Date(ms)));
  4099. }
  4100. if (this.timeZone === 'UTC' || !this.namedTimeZoneImpl) {
  4101. return new Date(ms);
  4102. }
  4103. return arrayToUtcDate(this.namedTimeZoneImpl.timestampToArray(ms));
  4104. };
  4105. DateEnv.prototype.offsetForMarker = function (m) {
  4106. if (this.timeZone === 'local') {
  4107. return -arrayToLocalDate(dateToUtcArray(m)).getTimezoneOffset(); // convert "inverse" offset to "normal" offset
  4108. }
  4109. if (this.timeZone === 'UTC') {
  4110. return 0;
  4111. }
  4112. if (this.namedTimeZoneImpl) {
  4113. return this.namedTimeZoneImpl.offsetForArray(dateToUtcArray(m));
  4114. }
  4115. return null;
  4116. };
  4117. // Conversion
  4118. DateEnv.prototype.toDate = function (m, forcedTzo) {
  4119. if (this.timeZone === 'local') {
  4120. return arrayToLocalDate(dateToUtcArray(m));
  4121. }
  4122. if (this.timeZone === 'UTC') {
  4123. return new Date(m.valueOf()); // make sure it's a copy
  4124. }
  4125. if (!this.namedTimeZoneImpl) {
  4126. return new Date(m.valueOf() - (forcedTzo || 0));
  4127. }
  4128. return new Date(m.valueOf() -
  4129. this.namedTimeZoneImpl.offsetForArray(dateToUtcArray(m)) * 1000 * 60);
  4130. };
  4131. return DateEnv;
  4132. }());
  4133. var globalLocales = [];
  4134. var MINIMAL_RAW_EN_LOCALE = {
  4135. code: 'en',
  4136. week: {
  4137. dow: 0,
  4138. doy: 4, // 4 days need to be within the year to be considered the first week
  4139. },
  4140. direction: 'ltr',
  4141. buttonText: {
  4142. prev: 'prev',
  4143. next: 'next',
  4144. prevYear: 'prev year',
  4145. nextYear: 'next year',
  4146. year: 'year',
  4147. today: 'today',
  4148. month: 'month',
  4149. week: 'week',
  4150. day: 'day',
  4151. list: 'list',
  4152. },
  4153. weekText: 'W',
  4154. weekTextLong: 'Week',
  4155. closeHint: 'Close',
  4156. timeHint: 'Time',
  4157. eventHint: 'Event',
  4158. allDayText: 'all-day',
  4159. moreLinkText: 'more',
  4160. noEventsText: 'No events to display',
  4161. };
  4162. var RAW_EN_LOCALE = __assign(__assign({}, MINIMAL_RAW_EN_LOCALE), {
  4163. // Includes things we don't want other locales to inherit,
  4164. // things that derive from other translatable strings.
  4165. buttonHints: {
  4166. prev: 'Previous $0',
  4167. next: 'Next $0',
  4168. today: function (buttonText, unit) {
  4169. return (unit === 'day')
  4170. ? 'Today'
  4171. : "This " + buttonText;
  4172. },
  4173. }, viewHint: '$0 view', navLinkHint: 'Go to $0', moreLinkHint: function (eventCnt) {
  4174. return "Show " + eventCnt + " more event" + (eventCnt === 1 ? '' : 's');
  4175. } });
  4176. function organizeRawLocales(explicitRawLocales) {
  4177. var defaultCode = explicitRawLocales.length > 0 ? explicitRawLocales[0].code : 'en';
  4178. var allRawLocales = globalLocales.concat(explicitRawLocales);
  4179. var rawLocaleMap = {
  4180. en: RAW_EN_LOCALE,
  4181. };
  4182. for (var _i = 0, allRawLocales_1 = allRawLocales; _i < allRawLocales_1.length; _i++) {
  4183. var rawLocale = allRawLocales_1[_i];
  4184. rawLocaleMap[rawLocale.code] = rawLocale;
  4185. }
  4186. return {
  4187. map: rawLocaleMap,
  4188. defaultCode: defaultCode,
  4189. };
  4190. }
  4191. function buildLocale(inputSingular, available) {
  4192. if (typeof inputSingular === 'object' && !Array.isArray(inputSingular)) {
  4193. return parseLocale(inputSingular.code, [inputSingular.code], inputSingular);
  4194. }
  4195. return queryLocale(inputSingular, available);
  4196. }
  4197. function queryLocale(codeArg, available) {
  4198. var codes = [].concat(codeArg || []); // will convert to array
  4199. var raw = queryRawLocale(codes, available) || RAW_EN_LOCALE;
  4200. return parseLocale(codeArg, codes, raw);
  4201. }
  4202. function queryRawLocale(codes, available) {
  4203. for (var i = 0; i < codes.length; i += 1) {
  4204. var parts = codes[i].toLocaleLowerCase().split('-');
  4205. for (var j = parts.length; j > 0; j -= 1) {
  4206. var simpleId = parts.slice(0, j).join('-');
  4207. if (available[simpleId]) {
  4208. return available[simpleId];
  4209. }
  4210. }
  4211. }
  4212. return null;
  4213. }
  4214. function parseLocale(codeArg, codes, raw) {
  4215. var merged = mergeProps([MINIMAL_RAW_EN_LOCALE, raw], ['buttonText']);
  4216. delete merged.code; // don't want this part of the options
  4217. var week = merged.week;
  4218. delete merged.week;
  4219. return {
  4220. codeArg: codeArg,
  4221. codes: codes,
  4222. week: week,
  4223. simpleNumberFormat: new Intl.NumberFormat(codeArg),
  4224. options: merged,
  4225. };
  4226. }
  4227. function formatDate(dateInput, options) {
  4228. if (options === void 0) { options = {}; }
  4229. var dateEnv = buildDateEnv$1(options);
  4230. var formatter = createFormatter(options);
  4231. var dateMeta = dateEnv.createMarkerMeta(dateInput);
  4232. if (!dateMeta) { // TODO: warning?
  4233. return '';
  4234. }
  4235. return dateEnv.format(dateMeta.marker, formatter, {
  4236. forcedTzo: dateMeta.forcedTzo,
  4237. });
  4238. }
  4239. function formatRange(startInput, endInput, options) {
  4240. var dateEnv = buildDateEnv$1(typeof options === 'object' && options ? options : {}); // pass in if non-null object
  4241. var formatter = createFormatter(options);
  4242. var startMeta = dateEnv.createMarkerMeta(startInput);
  4243. var endMeta = dateEnv.createMarkerMeta(endInput);
  4244. if (!startMeta || !endMeta) { // TODO: warning?
  4245. return '';
  4246. }
  4247. return dateEnv.formatRange(startMeta.marker, endMeta.marker, formatter, {
  4248. forcedStartTzo: startMeta.forcedTzo,
  4249. forcedEndTzo: endMeta.forcedTzo,
  4250. isEndExclusive: options.isEndExclusive,
  4251. defaultSeparator: BASE_OPTION_DEFAULTS.defaultRangeSeparator,
  4252. });
  4253. }
  4254. // TODO: more DRY and optimized
  4255. function buildDateEnv$1(settings) {
  4256. var locale = buildLocale(settings.locale || 'en', organizeRawLocales([]).map); // TODO: don't hardcode 'en' everywhere
  4257. return new DateEnv(__assign(__assign({ timeZone: BASE_OPTION_DEFAULTS.timeZone, calendarSystem: 'gregory' }, settings), { locale: locale }));
  4258. }
  4259. var DEF_DEFAULTS = {
  4260. startTime: '09:00',
  4261. endTime: '17:00',
  4262. daysOfWeek: [1, 2, 3, 4, 5],
  4263. display: 'inverse-background',
  4264. classNames: 'fc-non-business',
  4265. groupId: '_businessHours', // so multiple defs get grouped
  4266. };
  4267. /*
  4268. TODO: pass around as EventDefHash!!!
  4269. */
  4270. function parseBusinessHours(input, context) {
  4271. return parseEvents(refineInputs(input), null, context);
  4272. }
  4273. function refineInputs(input) {
  4274. var rawDefs;
  4275. if (input === true) {
  4276. rawDefs = [{}]; // will get DEF_DEFAULTS verbatim
  4277. }
  4278. else if (Array.isArray(input)) {
  4279. // if specifying an array, every sub-definition NEEDS a day-of-week
  4280. rawDefs = input.filter(function (rawDef) { return rawDef.daysOfWeek; });
  4281. }
  4282. else if (typeof input === 'object' && input) { // non-null object
  4283. rawDefs = [input];
  4284. }
  4285. else { // is probably false
  4286. rawDefs = [];
  4287. }
  4288. rawDefs = rawDefs.map(function (rawDef) { return (__assign(__assign({}, DEF_DEFAULTS), rawDef)); });
  4289. return rawDefs;
  4290. }
  4291. function pointInsideRect(point, rect) {
  4292. return point.left >= rect.left &&
  4293. point.left < rect.right &&
  4294. point.top >= rect.top &&
  4295. point.top < rect.bottom;
  4296. }
  4297. // Returns a new rectangle that is the intersection of the two rectangles. If they don't intersect, returns false
  4298. function intersectRects(rect1, rect2) {
  4299. var res = {
  4300. left: Math.max(rect1.left, rect2.left),
  4301. right: Math.min(rect1.right, rect2.right),
  4302. top: Math.max(rect1.top, rect2.top),
  4303. bottom: Math.min(rect1.bottom, rect2.bottom),
  4304. };
  4305. if (res.left < res.right && res.top < res.bottom) {
  4306. return res;
  4307. }
  4308. return false;
  4309. }
  4310. function translateRect(rect, deltaX, deltaY) {
  4311. return {
  4312. left: rect.left + deltaX,
  4313. right: rect.right + deltaX,
  4314. top: rect.top + deltaY,
  4315. bottom: rect.bottom + deltaY,
  4316. };
  4317. }
  4318. // Returns a new point that will have been moved to reside within the given rectangle
  4319. function constrainPoint(point, rect) {
  4320. return {
  4321. left: Math.min(Math.max(point.left, rect.left), rect.right),
  4322. top: Math.min(Math.max(point.top, rect.top), rect.bottom),
  4323. };
  4324. }
  4325. // Returns a point that is the center of the given rectangle
  4326. function getRectCenter(rect) {
  4327. return {
  4328. left: (rect.left + rect.right) / 2,
  4329. top: (rect.top + rect.bottom) / 2,
  4330. };
  4331. }
  4332. // Subtracts point2's coordinates from point1's coordinates, returning a delta
  4333. function diffPoints(point1, point2) {
  4334. return {
  4335. left: point1.left - point2.left,
  4336. top: point1.top - point2.top,
  4337. };
  4338. }
  4339. var canVGrowWithinCell;
  4340. function getCanVGrowWithinCell() {
  4341. if (canVGrowWithinCell == null) {
  4342. canVGrowWithinCell = computeCanVGrowWithinCell();
  4343. }
  4344. return canVGrowWithinCell;
  4345. }
  4346. function computeCanVGrowWithinCell() {
  4347. // for SSR, because this function is call immediately at top-level
  4348. // TODO: just make this logic execute top-level, immediately, instead of doing lazily
  4349. if (typeof document === 'undefined') {
  4350. return true;
  4351. }
  4352. var el = document.createElement('div');
  4353. el.style.position = 'absolute';
  4354. el.style.top = '0px';
  4355. el.style.left = '0px';
  4356. el.innerHTML = '<table><tr><td><div></div></td></tr></table>';
  4357. el.querySelector('table').style.height = '100px';
  4358. el.querySelector('div').style.height = '100%';
  4359. document.body.appendChild(el);
  4360. var div = el.querySelector('div');
  4361. var possible = div.offsetHeight > 0;
  4362. document.body.removeChild(el);
  4363. return possible;
  4364. }
  4365. var EMPTY_EVENT_STORE = createEmptyEventStore(); // for purecomponents. TODO: keep elsewhere
  4366. var Splitter = /** @class */ (function () {
  4367. function Splitter() {
  4368. this.getKeysForEventDefs = memoize(this._getKeysForEventDefs);
  4369. this.splitDateSelection = memoize(this._splitDateSpan);
  4370. this.splitEventStore = memoize(this._splitEventStore);
  4371. this.splitIndividualUi = memoize(this._splitIndividualUi);
  4372. this.splitEventDrag = memoize(this._splitInteraction);
  4373. this.splitEventResize = memoize(this._splitInteraction);
  4374. this.eventUiBuilders = {}; // TODO: typescript protection
  4375. }
  4376. Splitter.prototype.splitProps = function (props) {
  4377. var _this = this;
  4378. var keyInfos = this.getKeyInfo(props);
  4379. var defKeys = this.getKeysForEventDefs(props.eventStore);
  4380. var dateSelections = this.splitDateSelection(props.dateSelection);
  4381. var individualUi = this.splitIndividualUi(props.eventUiBases, defKeys); // the individual *bases*
  4382. var eventStores = this.splitEventStore(props.eventStore, defKeys);
  4383. var eventDrags = this.splitEventDrag(props.eventDrag);
  4384. var eventResizes = this.splitEventResize(props.eventResize);
  4385. var splitProps = {};
  4386. this.eventUiBuilders = mapHash(keyInfos, function (info, key) { return _this.eventUiBuilders[key] || memoize(buildEventUiForKey); });
  4387. for (var key in keyInfos) {
  4388. var keyInfo = keyInfos[key];
  4389. var eventStore = eventStores[key] || EMPTY_EVENT_STORE;
  4390. var buildEventUi = this.eventUiBuilders[key];
  4391. splitProps[key] = {
  4392. businessHours: keyInfo.businessHours || props.businessHours,
  4393. dateSelection: dateSelections[key] || null,
  4394. eventStore: eventStore,
  4395. eventUiBases: buildEventUi(props.eventUiBases[''], keyInfo.ui, individualUi[key]),
  4396. eventSelection: eventStore.instances[props.eventSelection] ? props.eventSelection : '',
  4397. eventDrag: eventDrags[key] || null,
  4398. eventResize: eventResizes[key] || null,
  4399. };
  4400. }
  4401. return splitProps;
  4402. };
  4403. Splitter.prototype._splitDateSpan = function (dateSpan) {
  4404. var dateSpans = {};
  4405. if (dateSpan) {
  4406. var keys = this.getKeysForDateSpan(dateSpan);
  4407. for (var _i = 0, keys_1 = keys; _i < keys_1.length; _i++) {
  4408. var key = keys_1[_i];
  4409. dateSpans[key] = dateSpan;
  4410. }
  4411. }
  4412. return dateSpans;
  4413. };
  4414. Splitter.prototype._getKeysForEventDefs = function (eventStore) {
  4415. var _this = this;
  4416. return mapHash(eventStore.defs, function (eventDef) { return _this.getKeysForEventDef(eventDef); });
  4417. };
  4418. Splitter.prototype._splitEventStore = function (eventStore, defKeys) {
  4419. var defs = eventStore.defs, instances = eventStore.instances;
  4420. var splitStores = {};
  4421. for (var defId in defs) {
  4422. for (var _i = 0, _a = defKeys[defId]; _i < _a.length; _i++) {
  4423. var key = _a[_i];
  4424. if (!splitStores[key]) {
  4425. splitStores[key] = createEmptyEventStore();
  4426. }
  4427. splitStores[key].defs[defId] = defs[defId];
  4428. }
  4429. }
  4430. for (var instanceId in instances) {
  4431. var instance = instances[instanceId];
  4432. for (var _b = 0, _c = defKeys[instance.defId]; _b < _c.length; _b++) {
  4433. var key = _c[_b];
  4434. if (splitStores[key]) { // must have already been created
  4435. splitStores[key].instances[instanceId] = instance;
  4436. }
  4437. }
  4438. }
  4439. return splitStores;
  4440. };
  4441. Splitter.prototype._splitIndividualUi = function (eventUiBases, defKeys) {
  4442. var splitHashes = {};
  4443. for (var defId in eventUiBases) {
  4444. if (defId) { // not the '' key
  4445. for (var _i = 0, _a = defKeys[defId]; _i < _a.length; _i++) {
  4446. var key = _a[_i];
  4447. if (!splitHashes[key]) {
  4448. splitHashes[key] = {};
  4449. }
  4450. splitHashes[key][defId] = eventUiBases[defId];
  4451. }
  4452. }
  4453. }
  4454. return splitHashes;
  4455. };
  4456. Splitter.prototype._splitInteraction = function (interaction) {
  4457. var splitStates = {};
  4458. if (interaction) {
  4459. var affectedStores_1 = this._splitEventStore(interaction.affectedEvents, this._getKeysForEventDefs(interaction.affectedEvents));
  4460. // can't rely on defKeys because event data is mutated
  4461. var mutatedKeysByDefId = this._getKeysForEventDefs(interaction.mutatedEvents);
  4462. var mutatedStores_1 = this._splitEventStore(interaction.mutatedEvents, mutatedKeysByDefId);
  4463. var populate = function (key) {
  4464. if (!splitStates[key]) {
  4465. splitStates[key] = {
  4466. affectedEvents: affectedStores_1[key] || EMPTY_EVENT_STORE,
  4467. mutatedEvents: mutatedStores_1[key] || EMPTY_EVENT_STORE,
  4468. isEvent: interaction.isEvent,
  4469. };
  4470. }
  4471. };
  4472. for (var key in affectedStores_1) {
  4473. populate(key);
  4474. }
  4475. for (var key in mutatedStores_1) {
  4476. populate(key);
  4477. }
  4478. }
  4479. return splitStates;
  4480. };
  4481. return Splitter;
  4482. }());
  4483. function buildEventUiForKey(allUi, eventUiForKey, individualUi) {
  4484. var baseParts = [];
  4485. if (allUi) {
  4486. baseParts.push(allUi);
  4487. }
  4488. if (eventUiForKey) {
  4489. baseParts.push(eventUiForKey);
  4490. }
  4491. var stuff = {
  4492. '': combineEventUis(baseParts),
  4493. };
  4494. if (individualUi) {
  4495. __assign(stuff, individualUi);
  4496. }
  4497. return stuff;
  4498. }
  4499. function getDateMeta(date, todayRange, nowDate, dateProfile) {
  4500. return {
  4501. dow: date.getUTCDay(),
  4502. isDisabled: Boolean(dateProfile && !rangeContainsMarker(dateProfile.activeRange, date)),
  4503. isOther: Boolean(dateProfile && !rangeContainsMarker(dateProfile.currentRange, date)),
  4504. isToday: Boolean(todayRange && rangeContainsMarker(todayRange, date)),
  4505. isPast: Boolean(nowDate ? (date < nowDate) : todayRange ? (date < todayRange.start) : false),
  4506. isFuture: Boolean(nowDate ? (date > nowDate) : todayRange ? (date >= todayRange.end) : false),
  4507. };
  4508. }
  4509. function getDayClassNames(meta, theme) {
  4510. var classNames = [
  4511. 'fc-day',
  4512. "fc-day-" + DAY_IDS[meta.dow],
  4513. ];
  4514. if (meta.isDisabled) {
  4515. classNames.push('fc-day-disabled');
  4516. }
  4517. else {
  4518. if (meta.isToday) {
  4519. classNames.push('fc-day-today');
  4520. classNames.push(theme.getClass('today'));
  4521. }
  4522. if (meta.isPast) {
  4523. classNames.push('fc-day-past');
  4524. }
  4525. if (meta.isFuture) {
  4526. classNames.push('fc-day-future');
  4527. }
  4528. if (meta.isOther) {
  4529. classNames.push('fc-day-other');
  4530. }
  4531. }
  4532. return classNames;
  4533. }
  4534. function getSlotClassNames(meta, theme) {
  4535. var classNames = [
  4536. 'fc-slot',
  4537. "fc-slot-" + DAY_IDS[meta.dow],
  4538. ];
  4539. if (meta.isDisabled) {
  4540. classNames.push('fc-slot-disabled');
  4541. }
  4542. else {
  4543. if (meta.isToday) {
  4544. classNames.push('fc-slot-today');
  4545. classNames.push(theme.getClass('today'));
  4546. }
  4547. if (meta.isPast) {
  4548. classNames.push('fc-slot-past');
  4549. }
  4550. if (meta.isFuture) {
  4551. classNames.push('fc-slot-future');
  4552. }
  4553. }
  4554. return classNames;
  4555. }
  4556. var DAY_FORMAT = createFormatter({ year: 'numeric', month: 'long', day: 'numeric' });
  4557. var WEEK_FORMAT = createFormatter({ week: 'long' });
  4558. function buildNavLinkAttrs(context, dateMarker, viewType, isTabbable) {
  4559. if (viewType === void 0) { viewType = 'day'; }
  4560. if (isTabbable === void 0) { isTabbable = true; }
  4561. var dateEnv = context.dateEnv, options = context.options, calendarApi = context.calendarApi;
  4562. var dateStr = dateEnv.format(dateMarker, viewType === 'week' ? WEEK_FORMAT : DAY_FORMAT);
  4563. if (options.navLinks) {
  4564. var zonedDate = dateEnv.toDate(dateMarker);
  4565. var handleInteraction = function (ev) {
  4566. var customAction = viewType === 'day' ? options.navLinkDayClick :
  4567. viewType === 'week' ? options.navLinkWeekClick : null;
  4568. if (typeof customAction === 'function') {
  4569. customAction.call(calendarApi, dateEnv.toDate(dateMarker), ev);
  4570. }
  4571. else {
  4572. if (typeof customAction === 'string') {
  4573. viewType = customAction;
  4574. }
  4575. calendarApi.zoomTo(dateMarker, viewType);
  4576. }
  4577. };
  4578. return __assign({ title: formatWithOrdinals(options.navLinkHint, [dateStr, zonedDate], dateStr), 'data-navlink': '' }, (isTabbable
  4579. ? createAriaClickAttrs(handleInteraction)
  4580. : { onClick: handleInteraction }));
  4581. }
  4582. return { 'aria-label': dateStr };
  4583. }
  4584. var _isRtlScrollbarOnLeft = null;
  4585. function getIsRtlScrollbarOnLeft() {
  4586. if (_isRtlScrollbarOnLeft === null) {
  4587. _isRtlScrollbarOnLeft = computeIsRtlScrollbarOnLeft();
  4588. }
  4589. return _isRtlScrollbarOnLeft;
  4590. }
  4591. function computeIsRtlScrollbarOnLeft() {
  4592. var outerEl = document.createElement('div');
  4593. applyStyle(outerEl, {
  4594. position: 'absolute',
  4595. top: -1000,
  4596. left: 0,
  4597. border: 0,
  4598. padding: 0,
  4599. overflow: 'scroll',
  4600. direction: 'rtl',
  4601. });
  4602. outerEl.innerHTML = '<div></div>';
  4603. document.body.appendChild(outerEl);
  4604. var innerEl = outerEl.firstChild;
  4605. var res = innerEl.getBoundingClientRect().left > outerEl.getBoundingClientRect().left;
  4606. removeElement(outerEl);
  4607. return res;
  4608. }
  4609. var _scrollbarWidths;
  4610. function getScrollbarWidths() {
  4611. if (!_scrollbarWidths) {
  4612. _scrollbarWidths = computeScrollbarWidths();
  4613. }
  4614. return _scrollbarWidths;
  4615. }
  4616. function computeScrollbarWidths() {
  4617. var el = document.createElement('div');
  4618. el.style.overflow = 'scroll';
  4619. el.style.position = 'absolute';
  4620. el.style.top = '-9999px';
  4621. el.style.left = '-9999px';
  4622. document.body.appendChild(el);
  4623. var res = computeScrollbarWidthsForEl(el);
  4624. document.body.removeChild(el);
  4625. return res;
  4626. }
  4627. // WARNING: will include border
  4628. function computeScrollbarWidthsForEl(el) {
  4629. return {
  4630. x: el.offsetHeight - el.clientHeight,
  4631. y: el.offsetWidth - el.clientWidth,
  4632. };
  4633. }
  4634. function computeEdges(el, getPadding) {
  4635. if (getPadding === void 0) { getPadding = false; }
  4636. var computedStyle = window.getComputedStyle(el);
  4637. var borderLeft = parseInt(computedStyle.borderLeftWidth, 10) || 0;
  4638. var borderRight = parseInt(computedStyle.borderRightWidth, 10) || 0;
  4639. var borderTop = parseInt(computedStyle.borderTopWidth, 10) || 0;
  4640. var borderBottom = parseInt(computedStyle.borderBottomWidth, 10) || 0;
  4641. var badScrollbarWidths = computeScrollbarWidthsForEl(el); // includes border!
  4642. var scrollbarLeftRight = badScrollbarWidths.y - borderLeft - borderRight;
  4643. var scrollbarBottom = badScrollbarWidths.x - borderTop - borderBottom;
  4644. var res = {
  4645. borderLeft: borderLeft,
  4646. borderRight: borderRight,
  4647. borderTop: borderTop,
  4648. borderBottom: borderBottom,
  4649. scrollbarBottom: scrollbarBottom,
  4650. scrollbarLeft: 0,
  4651. scrollbarRight: 0,
  4652. };
  4653. if (getIsRtlScrollbarOnLeft() && computedStyle.direction === 'rtl') { // is the scrollbar on the left side?
  4654. res.scrollbarLeft = scrollbarLeftRight;
  4655. }
  4656. else {
  4657. res.scrollbarRight = scrollbarLeftRight;
  4658. }
  4659. if (getPadding) {
  4660. res.paddingLeft = parseInt(computedStyle.paddingLeft, 10) || 0;
  4661. res.paddingRight = parseInt(computedStyle.paddingRight, 10) || 0;
  4662. res.paddingTop = parseInt(computedStyle.paddingTop, 10) || 0;
  4663. res.paddingBottom = parseInt(computedStyle.paddingBottom, 10) || 0;
  4664. }
  4665. return res;
  4666. }
  4667. function computeInnerRect(el, goWithinPadding, doFromWindowViewport) {
  4668. if (goWithinPadding === void 0) { goWithinPadding = false; }
  4669. var outerRect = doFromWindowViewport ? el.getBoundingClientRect() : computeRect(el);
  4670. var edges = computeEdges(el, goWithinPadding);
  4671. var res = {
  4672. left: outerRect.left + edges.borderLeft + edges.scrollbarLeft,
  4673. right: outerRect.right - edges.borderRight - edges.scrollbarRight,
  4674. top: outerRect.top + edges.borderTop,
  4675. bottom: outerRect.bottom - edges.borderBottom - edges.scrollbarBottom,
  4676. };
  4677. if (goWithinPadding) {
  4678. res.left += edges.paddingLeft;
  4679. res.right -= edges.paddingRight;
  4680. res.top += edges.paddingTop;
  4681. res.bottom -= edges.paddingBottom;
  4682. }
  4683. return res;
  4684. }
  4685. function computeRect(el) {
  4686. var rect = el.getBoundingClientRect();
  4687. return {
  4688. left: rect.left + window.pageXOffset,
  4689. top: rect.top + window.pageYOffset,
  4690. right: rect.right + window.pageXOffset,
  4691. bottom: rect.bottom + window.pageYOffset,
  4692. };
  4693. }
  4694. function computeClippedClientRect(el) {
  4695. var clippingParents = getClippingParents(el);
  4696. var rect = el.getBoundingClientRect();
  4697. for (var _i = 0, clippingParents_1 = clippingParents; _i < clippingParents_1.length; _i++) {
  4698. var clippingParent = clippingParents_1[_i];
  4699. var intersection = intersectRects(rect, clippingParent.getBoundingClientRect());
  4700. if (intersection) {
  4701. rect = intersection;
  4702. }
  4703. else {
  4704. return null;
  4705. }
  4706. }
  4707. return rect;
  4708. }
  4709. function computeHeightAndMargins(el) {
  4710. return el.getBoundingClientRect().height + computeVMargins(el);
  4711. }
  4712. function computeVMargins(el) {
  4713. var computed = window.getComputedStyle(el);
  4714. return parseInt(computed.marginTop, 10) +
  4715. parseInt(computed.marginBottom, 10);
  4716. }
  4717. // does not return window
  4718. function getClippingParents(el) {
  4719. var parents = [];
  4720. while (el instanceof HTMLElement) { // will stop when gets to document or null
  4721. var computedStyle = window.getComputedStyle(el);
  4722. if (computedStyle.position === 'fixed') {
  4723. break;
  4724. }
  4725. if ((/(auto|scroll)/).test(computedStyle.overflow + computedStyle.overflowY + computedStyle.overflowX)) {
  4726. parents.push(el);
  4727. }
  4728. el = el.parentNode;
  4729. }
  4730. return parents;
  4731. }
  4732. // given a function that resolves a result asynchronously.
  4733. // the function can either call passed-in success and failure callbacks,
  4734. // or it can return a promise.
  4735. // if you need to pass additional params to func, bind them first.
  4736. function unpromisify(func, success, failure) {
  4737. // guard against success/failure callbacks being called more than once
  4738. // and guard against a promise AND callback being used together.
  4739. var isResolved = false;
  4740. var wrappedSuccess = function () {
  4741. if (!isResolved) {
  4742. isResolved = true;
  4743. success.apply(this, arguments); // eslint-disable-line prefer-rest-params
  4744. }
  4745. };
  4746. var wrappedFailure = function () {
  4747. if (!isResolved) {
  4748. isResolved = true;
  4749. if (failure) {
  4750. failure.apply(this, arguments); // eslint-disable-line prefer-rest-params
  4751. }
  4752. }
  4753. };
  4754. var res = func(wrappedSuccess, wrappedFailure);
  4755. if (res && typeof res.then === 'function') {
  4756. res.then(wrappedSuccess, wrappedFailure);
  4757. }
  4758. }
  4759. var Emitter = /** @class */ (function () {
  4760. function Emitter() {
  4761. this.handlers = {};
  4762. this.thisContext = null;
  4763. }
  4764. Emitter.prototype.setThisContext = function (thisContext) {
  4765. this.thisContext = thisContext;
  4766. };
  4767. Emitter.prototype.setOptions = function (options) {
  4768. this.options = options;
  4769. };
  4770. Emitter.prototype.on = function (type, handler) {
  4771. addToHash(this.handlers, type, handler);
  4772. };
  4773. Emitter.prototype.off = function (type, handler) {
  4774. removeFromHash(this.handlers, type, handler);
  4775. };
  4776. Emitter.prototype.trigger = function (type) {
  4777. var args = [];
  4778. for (var _i = 1; _i < arguments.length; _i++) {
  4779. args[_i - 1] = arguments[_i];
  4780. }
  4781. var attachedHandlers = this.handlers[type] || [];
  4782. var optionHandler = this.options && this.options[type];
  4783. var handlers = [].concat(optionHandler || [], attachedHandlers);
  4784. for (var _a = 0, handlers_1 = handlers; _a < handlers_1.length; _a++) {
  4785. var handler = handlers_1[_a];
  4786. handler.apply(this.thisContext, args);
  4787. }
  4788. };
  4789. Emitter.prototype.hasHandlers = function (type) {
  4790. return Boolean((this.handlers[type] && this.handlers[type].length) ||
  4791. (this.options && this.options[type]));
  4792. };
  4793. return Emitter;
  4794. }());
  4795. function addToHash(hash, type, handler) {
  4796. (hash[type] || (hash[type] = []))
  4797. .push(handler);
  4798. }
  4799. function removeFromHash(hash, type, handler) {
  4800. if (handler) {
  4801. if (hash[type]) {
  4802. hash[type] = hash[type].filter(function (func) { return func !== handler; });
  4803. }
  4804. }
  4805. else {
  4806. delete hash[type]; // remove all handler funcs for this type
  4807. }
  4808. }
  4809. /*
  4810. Records offset information for a set of elements, relative to an origin element.
  4811. Can record the left/right OR the top/bottom OR both.
  4812. Provides methods for querying the cache by position.
  4813. */
  4814. var PositionCache = /** @class */ (function () {
  4815. function PositionCache(originEl, els, isHorizontal, isVertical) {
  4816. this.els = els;
  4817. var originClientRect = this.originClientRect = originEl.getBoundingClientRect(); // relative to viewport top-left
  4818. if (isHorizontal) {
  4819. this.buildElHorizontals(originClientRect.left);
  4820. }
  4821. if (isVertical) {
  4822. this.buildElVerticals(originClientRect.top);
  4823. }
  4824. }
  4825. // Populates the left/right internal coordinate arrays
  4826. PositionCache.prototype.buildElHorizontals = function (originClientLeft) {
  4827. var lefts = [];
  4828. var rights = [];
  4829. for (var _i = 0, _a = this.els; _i < _a.length; _i++) {
  4830. var el = _a[_i];
  4831. var rect = el.getBoundingClientRect();
  4832. lefts.push(rect.left - originClientLeft);
  4833. rights.push(rect.right - originClientLeft);
  4834. }
  4835. this.lefts = lefts;
  4836. this.rights = rights;
  4837. };
  4838. // Populates the top/bottom internal coordinate arrays
  4839. PositionCache.prototype.buildElVerticals = function (originClientTop) {
  4840. var tops = [];
  4841. var bottoms = [];
  4842. for (var _i = 0, _a = this.els; _i < _a.length; _i++) {
  4843. var el = _a[_i];
  4844. var rect = el.getBoundingClientRect();
  4845. tops.push(rect.top - originClientTop);
  4846. bottoms.push(rect.bottom - originClientTop);
  4847. }
  4848. this.tops = tops;
  4849. this.bottoms = bottoms;
  4850. };
  4851. // Given a left offset (from document left), returns the index of the el that it horizontally intersects.
  4852. // If no intersection is made, returns undefined.
  4853. PositionCache.prototype.leftToIndex = function (leftPosition) {
  4854. var _a = this, lefts = _a.lefts, rights = _a.rights;
  4855. var len = lefts.length;
  4856. var i;
  4857. for (i = 0; i < len; i += 1) {
  4858. if (leftPosition >= lefts[i] && leftPosition < rights[i]) {
  4859. return i;
  4860. }
  4861. }
  4862. return undefined; // TODO: better
  4863. };
  4864. // Given a top offset (from document top), returns the index of the el that it vertically intersects.
  4865. // If no intersection is made, returns undefined.
  4866. PositionCache.prototype.topToIndex = function (topPosition) {
  4867. var _a = this, tops = _a.tops, bottoms = _a.bottoms;
  4868. var len = tops.length;
  4869. var i;
  4870. for (i = 0; i < len; i += 1) {
  4871. if (topPosition >= tops[i] && topPosition < bottoms[i]) {
  4872. return i;
  4873. }
  4874. }
  4875. return undefined; // TODO: better
  4876. };
  4877. // Gets the width of the element at the given index
  4878. PositionCache.prototype.getWidth = function (leftIndex) {
  4879. return this.rights[leftIndex] - this.lefts[leftIndex];
  4880. };
  4881. // Gets the height of the element at the given index
  4882. PositionCache.prototype.getHeight = function (topIndex) {
  4883. return this.bottoms[topIndex] - this.tops[topIndex];
  4884. };
  4885. return PositionCache;
  4886. }());
  4887. /* eslint max-classes-per-file: "off" */
  4888. /*
  4889. An object for getting/setting scroll-related information for an element.
  4890. Internally, this is done very differently for window versus DOM element,
  4891. so this object serves as a common interface.
  4892. */
  4893. var ScrollController = /** @class */ (function () {
  4894. function ScrollController() {
  4895. }
  4896. ScrollController.prototype.getMaxScrollTop = function () {
  4897. return this.getScrollHeight() - this.getClientHeight();
  4898. };
  4899. ScrollController.prototype.getMaxScrollLeft = function () {
  4900. return this.getScrollWidth() - this.getClientWidth();
  4901. };
  4902. ScrollController.prototype.canScrollVertically = function () {
  4903. return this.getMaxScrollTop() > 0;
  4904. };
  4905. ScrollController.prototype.canScrollHorizontally = function () {
  4906. return this.getMaxScrollLeft() > 0;
  4907. };
  4908. ScrollController.prototype.canScrollUp = function () {
  4909. return this.getScrollTop() > 0;
  4910. };
  4911. ScrollController.prototype.canScrollDown = function () {
  4912. return this.getScrollTop() < this.getMaxScrollTop();
  4913. };
  4914. ScrollController.prototype.canScrollLeft = function () {
  4915. return this.getScrollLeft() > 0;
  4916. };
  4917. ScrollController.prototype.canScrollRight = function () {
  4918. return this.getScrollLeft() < this.getMaxScrollLeft();
  4919. };
  4920. return ScrollController;
  4921. }());
  4922. var ElementScrollController = /** @class */ (function (_super) {
  4923. __extends(ElementScrollController, _super);
  4924. function ElementScrollController(el) {
  4925. var _this = _super.call(this) || this;
  4926. _this.el = el;
  4927. return _this;
  4928. }
  4929. ElementScrollController.prototype.getScrollTop = function () {
  4930. return this.el.scrollTop;
  4931. };
  4932. ElementScrollController.prototype.getScrollLeft = function () {
  4933. return this.el.scrollLeft;
  4934. };
  4935. ElementScrollController.prototype.setScrollTop = function (top) {
  4936. this.el.scrollTop = top;
  4937. };
  4938. ElementScrollController.prototype.setScrollLeft = function (left) {
  4939. this.el.scrollLeft = left;
  4940. };
  4941. ElementScrollController.prototype.getScrollWidth = function () {
  4942. return this.el.scrollWidth;
  4943. };
  4944. ElementScrollController.prototype.getScrollHeight = function () {
  4945. return this.el.scrollHeight;
  4946. };
  4947. ElementScrollController.prototype.getClientHeight = function () {
  4948. return this.el.clientHeight;
  4949. };
  4950. ElementScrollController.prototype.getClientWidth = function () {
  4951. return this.el.clientWidth;
  4952. };
  4953. return ElementScrollController;
  4954. }(ScrollController));
  4955. var WindowScrollController = /** @class */ (function (_super) {
  4956. __extends(WindowScrollController, _super);
  4957. function WindowScrollController() {
  4958. return _super !== null && _super.apply(this, arguments) || this;
  4959. }
  4960. WindowScrollController.prototype.getScrollTop = function () {
  4961. return window.pageYOffset;
  4962. };
  4963. WindowScrollController.prototype.getScrollLeft = function () {
  4964. return window.pageXOffset;
  4965. };
  4966. WindowScrollController.prototype.setScrollTop = function (n) {
  4967. window.scroll(window.pageXOffset, n);
  4968. };
  4969. WindowScrollController.prototype.setScrollLeft = function (n) {
  4970. window.scroll(n, window.pageYOffset);
  4971. };
  4972. WindowScrollController.prototype.getScrollWidth = function () {
  4973. return document.documentElement.scrollWidth;
  4974. };
  4975. WindowScrollController.prototype.getScrollHeight = function () {
  4976. return document.documentElement.scrollHeight;
  4977. };
  4978. WindowScrollController.prototype.getClientHeight = function () {
  4979. return document.documentElement.clientHeight;
  4980. };
  4981. WindowScrollController.prototype.getClientWidth = function () {
  4982. return document.documentElement.clientWidth;
  4983. };
  4984. return WindowScrollController;
  4985. }(ScrollController));
  4986. var Theme = /** @class */ (function () {
  4987. function Theme(calendarOptions) {
  4988. if (this.iconOverrideOption) {
  4989. this.setIconOverride(calendarOptions[this.iconOverrideOption]);
  4990. }
  4991. }
  4992. Theme.prototype.setIconOverride = function (iconOverrideHash) {
  4993. var iconClassesCopy;
  4994. var buttonName;
  4995. if (typeof iconOverrideHash === 'object' && iconOverrideHash) { // non-null object
  4996. iconClassesCopy = __assign({}, this.iconClasses);
  4997. for (buttonName in iconOverrideHash) {
  4998. iconClassesCopy[buttonName] = this.applyIconOverridePrefix(iconOverrideHash[buttonName]);
  4999. }
  5000. this.iconClasses = iconClassesCopy;
  5001. }
  5002. else if (iconOverrideHash === false) {
  5003. this.iconClasses = {};
  5004. }
  5005. };
  5006. Theme.prototype.applyIconOverridePrefix = function (className) {
  5007. var prefix = this.iconOverridePrefix;
  5008. if (prefix && className.indexOf(prefix) !== 0) { // if not already present
  5009. className = prefix + className;
  5010. }
  5011. return className;
  5012. };
  5013. Theme.prototype.getClass = function (key) {
  5014. return this.classes[key] || '';
  5015. };
  5016. Theme.prototype.getIconClass = function (buttonName, isRtl) {
  5017. var className;
  5018. if (isRtl && this.rtlIconClasses) {
  5019. className = this.rtlIconClasses[buttonName] || this.iconClasses[buttonName];
  5020. }
  5021. else {
  5022. className = this.iconClasses[buttonName];
  5023. }
  5024. if (className) {
  5025. return this.baseIconClass + " " + className;
  5026. }
  5027. return '';
  5028. };
  5029. Theme.prototype.getCustomButtonIconClass = function (customButtonProps) {
  5030. var className;
  5031. if (this.iconOverrideCustomButtonOption) {
  5032. className = customButtonProps[this.iconOverrideCustomButtonOption];
  5033. if (className) {
  5034. return this.baseIconClass + " " + this.applyIconOverridePrefix(className);
  5035. }
  5036. }
  5037. return '';
  5038. };
  5039. return Theme;
  5040. }());
  5041. Theme.prototype.classes = {};
  5042. Theme.prototype.iconClasses = {};
  5043. Theme.prototype.baseIconClass = '';
  5044. Theme.prototype.iconOverridePrefix = '';
  5045. /// <reference types="@fullcalendar/core-preact" />
  5046. if (typeof FullCalendarVDom === 'undefined') {
  5047. throw new Error('Please import the top-level fullcalendar lib before attempting to import a plugin.');
  5048. }
  5049. var Component = FullCalendarVDom.Component;
  5050. var createElement = FullCalendarVDom.createElement;
  5051. var render = FullCalendarVDom.render;
  5052. var createRef = FullCalendarVDom.createRef;
  5053. var Fragment = FullCalendarVDom.Fragment;
  5054. var createContext = FullCalendarVDom.createContext;
  5055. var createPortal = FullCalendarVDom.createPortal;
  5056. var flushToDom = FullCalendarVDom.flushToDom;
  5057. var unmountComponentAtNode = FullCalendarVDom.unmountComponentAtNode;
  5058. /* eslint-enable */
  5059. var ScrollResponder = /** @class */ (function () {
  5060. function ScrollResponder(execFunc, emitter, scrollTime, scrollTimeReset) {
  5061. var _this = this;
  5062. this.execFunc = execFunc;
  5063. this.emitter = emitter;
  5064. this.scrollTime = scrollTime;
  5065. this.scrollTimeReset = scrollTimeReset;
  5066. this.handleScrollRequest = function (request) {
  5067. _this.queuedRequest = __assign({}, _this.queuedRequest || {}, request);
  5068. _this.drain();
  5069. };
  5070. emitter.on('_scrollRequest', this.handleScrollRequest);
  5071. this.fireInitialScroll();
  5072. }
  5073. ScrollResponder.prototype.detach = function () {
  5074. this.emitter.off('_scrollRequest', this.handleScrollRequest);
  5075. };
  5076. ScrollResponder.prototype.update = function (isDatesNew) {
  5077. if (isDatesNew && this.scrollTimeReset) {
  5078. this.fireInitialScroll(); // will drain
  5079. }
  5080. else {
  5081. this.drain();
  5082. }
  5083. };
  5084. ScrollResponder.prototype.fireInitialScroll = function () {
  5085. this.handleScrollRequest({
  5086. time: this.scrollTime,
  5087. });
  5088. };
  5089. ScrollResponder.prototype.drain = function () {
  5090. if (this.queuedRequest && this.execFunc(this.queuedRequest)) {
  5091. this.queuedRequest = null;
  5092. }
  5093. };
  5094. return ScrollResponder;
  5095. }());
  5096. var ViewContextType = createContext({}); // for Components
  5097. function buildViewContext(viewSpec, viewApi, viewOptions, dateProfileGenerator, dateEnv, theme, pluginHooks, dispatch, getCurrentData, emitter, calendarApi, registerInteractiveComponent, unregisterInteractiveComponent) {
  5098. return {
  5099. dateEnv: dateEnv,
  5100. options: viewOptions,
  5101. pluginHooks: pluginHooks,
  5102. emitter: emitter,
  5103. dispatch: dispatch,
  5104. getCurrentData: getCurrentData,
  5105. calendarApi: calendarApi,
  5106. viewSpec: viewSpec,
  5107. viewApi: viewApi,
  5108. dateProfileGenerator: dateProfileGenerator,
  5109. theme: theme,
  5110. isRtl: viewOptions.direction === 'rtl',
  5111. addResizeHandler: function (handler) {
  5112. emitter.on('_resize', handler);
  5113. },
  5114. removeResizeHandler: function (handler) {
  5115. emitter.off('_resize', handler);
  5116. },
  5117. createScrollResponder: function (execFunc) {
  5118. return new ScrollResponder(execFunc, emitter, createDuration(viewOptions.scrollTime), viewOptions.scrollTimeReset);
  5119. },
  5120. registerInteractiveComponent: registerInteractiveComponent,
  5121. unregisterInteractiveComponent: unregisterInteractiveComponent,
  5122. };
  5123. }
  5124. /* eslint max-classes-per-file: off */
  5125. var PureComponent = /** @class */ (function (_super) {
  5126. __extends(PureComponent, _super);
  5127. function PureComponent() {
  5128. return _super !== null && _super.apply(this, arguments) || this;
  5129. }
  5130. PureComponent.prototype.shouldComponentUpdate = function (nextProps, nextState) {
  5131. if (this.debug) {
  5132. // eslint-disable-next-line no-console
  5133. console.log(getUnequalProps(nextProps, this.props), getUnequalProps(nextState, this.state));
  5134. }
  5135. return !compareObjs(this.props, nextProps, this.propEquality) ||
  5136. !compareObjs(this.state, nextState, this.stateEquality);
  5137. };
  5138. PureComponent.addPropsEquality = addPropsEquality;
  5139. PureComponent.addStateEquality = addStateEquality;
  5140. PureComponent.contextType = ViewContextType;
  5141. return PureComponent;
  5142. }(Component));
  5143. PureComponent.prototype.propEquality = {};
  5144. PureComponent.prototype.stateEquality = {};
  5145. var BaseComponent = /** @class */ (function (_super) {
  5146. __extends(BaseComponent, _super);
  5147. function BaseComponent() {
  5148. return _super !== null && _super.apply(this, arguments) || this;
  5149. }
  5150. BaseComponent.contextType = ViewContextType;
  5151. return BaseComponent;
  5152. }(PureComponent));
  5153. function addPropsEquality(propEquality) {
  5154. var hash = Object.create(this.prototype.propEquality);
  5155. __assign(hash, propEquality);
  5156. this.prototype.propEquality = hash;
  5157. }
  5158. function addStateEquality(stateEquality) {
  5159. var hash = Object.create(this.prototype.stateEquality);
  5160. __assign(hash, stateEquality);
  5161. this.prototype.stateEquality = hash;
  5162. }
  5163. // use other one
  5164. function setRef(ref, current) {
  5165. if (typeof ref === 'function') {
  5166. ref(current);
  5167. }
  5168. else if (ref) {
  5169. // see https://github.com/facebook/react/issues/13029
  5170. ref.current = current;
  5171. }
  5172. }
  5173. /*
  5174. an INTERACTABLE date component
  5175. PURPOSES:
  5176. - hook up to fg, fill, and mirror renderers
  5177. - interface for dragging and hits
  5178. */
  5179. var DateComponent = /** @class */ (function (_super) {
  5180. __extends(DateComponent, _super);
  5181. function DateComponent() {
  5182. var _this = _super !== null && _super.apply(this, arguments) || this;
  5183. _this.uid = guid();
  5184. return _this;
  5185. }
  5186. // Hit System
  5187. // -----------------------------------------------------------------------------------------------------------------
  5188. DateComponent.prototype.prepareHits = function () {
  5189. };
  5190. DateComponent.prototype.queryHit = function (positionLeft, positionTop, elWidth, elHeight) {
  5191. return null; // this should be abstract
  5192. };
  5193. // Pointer Interaction Utils
  5194. // -----------------------------------------------------------------------------------------------------------------
  5195. DateComponent.prototype.isValidSegDownEl = function (el) {
  5196. return !this.props.eventDrag && // HACK
  5197. !this.props.eventResize && // HACK
  5198. !elementClosest(el, '.fc-event-mirror');
  5199. };
  5200. DateComponent.prototype.isValidDateDownEl = function (el) {
  5201. return !elementClosest(el, '.fc-event:not(.fc-bg-event)') &&
  5202. !elementClosest(el, '.fc-more-link') && // a "more.." link
  5203. !elementClosest(el, 'a[data-navlink]') && // a clickable nav link
  5204. !elementClosest(el, '.fc-popover'); // hack
  5205. };
  5206. return DateComponent;
  5207. }(BaseComponent));
  5208. // TODO: easier way to add new hooks? need to update a million things
  5209. function createPlugin(input) {
  5210. return {
  5211. id: guid(),
  5212. deps: input.deps || [],
  5213. reducers: input.reducers || [],
  5214. isLoadingFuncs: input.isLoadingFuncs || [],
  5215. contextInit: [].concat(input.contextInit || []),
  5216. eventRefiners: input.eventRefiners || {},
  5217. eventDefMemberAdders: input.eventDefMemberAdders || [],
  5218. eventSourceRefiners: input.eventSourceRefiners || {},
  5219. isDraggableTransformers: input.isDraggableTransformers || [],
  5220. eventDragMutationMassagers: input.eventDragMutationMassagers || [],
  5221. eventDefMutationAppliers: input.eventDefMutationAppliers || [],
  5222. dateSelectionTransformers: input.dateSelectionTransformers || [],
  5223. datePointTransforms: input.datePointTransforms || [],
  5224. dateSpanTransforms: input.dateSpanTransforms || [],
  5225. views: input.views || {},
  5226. viewPropsTransformers: input.viewPropsTransformers || [],
  5227. isPropsValid: input.isPropsValid || null,
  5228. externalDefTransforms: input.externalDefTransforms || [],
  5229. viewContainerAppends: input.viewContainerAppends || [],
  5230. eventDropTransformers: input.eventDropTransformers || [],
  5231. componentInteractions: input.componentInteractions || [],
  5232. calendarInteractions: input.calendarInteractions || [],
  5233. themeClasses: input.themeClasses || {},
  5234. eventSourceDefs: input.eventSourceDefs || [],
  5235. cmdFormatter: input.cmdFormatter,
  5236. recurringTypes: input.recurringTypes || [],
  5237. namedTimeZonedImpl: input.namedTimeZonedImpl,
  5238. initialView: input.initialView || '',
  5239. elementDraggingImpl: input.elementDraggingImpl,
  5240. optionChangeHandlers: input.optionChangeHandlers || {},
  5241. scrollGridImpl: input.scrollGridImpl || null,
  5242. contentTypeHandlers: input.contentTypeHandlers || {},
  5243. listenerRefiners: input.listenerRefiners || {},
  5244. optionRefiners: input.optionRefiners || {},
  5245. propSetHandlers: input.propSetHandlers || {},
  5246. };
  5247. }
  5248. function buildPluginHooks(pluginDefs, globalDefs) {
  5249. var isAdded = {};
  5250. var hooks = {
  5251. reducers: [],
  5252. isLoadingFuncs: [],
  5253. contextInit: [],
  5254. eventRefiners: {},
  5255. eventDefMemberAdders: [],
  5256. eventSourceRefiners: {},
  5257. isDraggableTransformers: [],
  5258. eventDragMutationMassagers: [],
  5259. eventDefMutationAppliers: [],
  5260. dateSelectionTransformers: [],
  5261. datePointTransforms: [],
  5262. dateSpanTransforms: [],
  5263. views: {},
  5264. viewPropsTransformers: [],
  5265. isPropsValid: null,
  5266. externalDefTransforms: [],
  5267. viewContainerAppends: [],
  5268. eventDropTransformers: [],
  5269. componentInteractions: [],
  5270. calendarInteractions: [],
  5271. themeClasses: {},
  5272. eventSourceDefs: [],
  5273. cmdFormatter: null,
  5274. recurringTypes: [],
  5275. namedTimeZonedImpl: null,
  5276. initialView: '',
  5277. elementDraggingImpl: null,
  5278. optionChangeHandlers: {},
  5279. scrollGridImpl: null,
  5280. contentTypeHandlers: {},
  5281. listenerRefiners: {},
  5282. optionRefiners: {},
  5283. propSetHandlers: {},
  5284. };
  5285. function addDefs(defs) {
  5286. for (var _i = 0, defs_1 = defs; _i < defs_1.length; _i++) {
  5287. var def = defs_1[_i];
  5288. if (!isAdded[def.id]) {
  5289. isAdded[def.id] = true;
  5290. addDefs(def.deps);
  5291. hooks = combineHooks(hooks, def);
  5292. }
  5293. }
  5294. }
  5295. if (pluginDefs) {
  5296. addDefs(pluginDefs);
  5297. }
  5298. addDefs(globalDefs);
  5299. return hooks;
  5300. }
  5301. function buildBuildPluginHooks() {
  5302. var currentOverrideDefs = [];
  5303. var currentGlobalDefs = [];
  5304. var currentHooks;
  5305. return function (overrideDefs, globalDefs) {
  5306. if (!currentHooks || !isArraysEqual(overrideDefs, currentOverrideDefs) || !isArraysEqual(globalDefs, currentGlobalDefs)) {
  5307. currentHooks = buildPluginHooks(overrideDefs, globalDefs);
  5308. }
  5309. currentOverrideDefs = overrideDefs;
  5310. currentGlobalDefs = globalDefs;
  5311. return currentHooks;
  5312. };
  5313. }
  5314. function combineHooks(hooks0, hooks1) {
  5315. return {
  5316. reducers: hooks0.reducers.concat(hooks1.reducers),
  5317. isLoadingFuncs: hooks0.isLoadingFuncs.concat(hooks1.isLoadingFuncs),
  5318. contextInit: hooks0.contextInit.concat(hooks1.contextInit),
  5319. eventRefiners: __assign(__assign({}, hooks0.eventRefiners), hooks1.eventRefiners),
  5320. eventDefMemberAdders: hooks0.eventDefMemberAdders.concat(hooks1.eventDefMemberAdders),
  5321. eventSourceRefiners: __assign(__assign({}, hooks0.eventSourceRefiners), hooks1.eventSourceRefiners),
  5322. isDraggableTransformers: hooks0.isDraggableTransformers.concat(hooks1.isDraggableTransformers),
  5323. eventDragMutationMassagers: hooks0.eventDragMutationMassagers.concat(hooks1.eventDragMutationMassagers),
  5324. eventDefMutationAppliers: hooks0.eventDefMutationAppliers.concat(hooks1.eventDefMutationAppliers),
  5325. dateSelectionTransformers: hooks0.dateSelectionTransformers.concat(hooks1.dateSelectionTransformers),
  5326. datePointTransforms: hooks0.datePointTransforms.concat(hooks1.datePointTransforms),
  5327. dateSpanTransforms: hooks0.dateSpanTransforms.concat(hooks1.dateSpanTransforms),
  5328. views: __assign(__assign({}, hooks0.views), hooks1.views),
  5329. viewPropsTransformers: hooks0.viewPropsTransformers.concat(hooks1.viewPropsTransformers),
  5330. isPropsValid: hooks1.isPropsValid || hooks0.isPropsValid,
  5331. externalDefTransforms: hooks0.externalDefTransforms.concat(hooks1.externalDefTransforms),
  5332. viewContainerAppends: hooks0.viewContainerAppends.concat(hooks1.viewContainerAppends),
  5333. eventDropTransformers: hooks0.eventDropTransformers.concat(hooks1.eventDropTransformers),
  5334. calendarInteractions: hooks0.calendarInteractions.concat(hooks1.calendarInteractions),
  5335. componentInteractions: hooks0.componentInteractions.concat(hooks1.componentInteractions),
  5336. themeClasses: __assign(__assign({}, hooks0.themeClasses), hooks1.themeClasses),
  5337. eventSourceDefs: hooks0.eventSourceDefs.concat(hooks1.eventSourceDefs),
  5338. cmdFormatter: hooks1.cmdFormatter || hooks0.cmdFormatter,
  5339. recurringTypes: hooks0.recurringTypes.concat(hooks1.recurringTypes),
  5340. namedTimeZonedImpl: hooks1.namedTimeZonedImpl || hooks0.namedTimeZonedImpl,
  5341. initialView: hooks0.initialView || hooks1.initialView,
  5342. elementDraggingImpl: hooks0.elementDraggingImpl || hooks1.elementDraggingImpl,
  5343. optionChangeHandlers: __assign(__assign({}, hooks0.optionChangeHandlers), hooks1.optionChangeHandlers),
  5344. scrollGridImpl: hooks1.scrollGridImpl || hooks0.scrollGridImpl,
  5345. contentTypeHandlers: __assign(__assign({}, hooks0.contentTypeHandlers), hooks1.contentTypeHandlers),
  5346. listenerRefiners: __assign(__assign({}, hooks0.listenerRefiners), hooks1.listenerRefiners),
  5347. optionRefiners: __assign(__assign({}, hooks0.optionRefiners), hooks1.optionRefiners),
  5348. propSetHandlers: __assign(__assign({}, hooks0.propSetHandlers), hooks1.propSetHandlers),
  5349. };
  5350. }
  5351. var StandardTheme = /** @class */ (function (_super) {
  5352. __extends(StandardTheme, _super);
  5353. function StandardTheme() {
  5354. return _super !== null && _super.apply(this, arguments) || this;
  5355. }
  5356. return StandardTheme;
  5357. }(Theme));
  5358. StandardTheme.prototype.classes = {
  5359. root: 'fc-theme-standard',
  5360. tableCellShaded: 'fc-cell-shaded',
  5361. buttonGroup: 'fc-button-group',
  5362. button: 'fc-button fc-button-primary',
  5363. buttonActive: 'fc-button-active',
  5364. };
  5365. StandardTheme.prototype.baseIconClass = 'fc-icon';
  5366. StandardTheme.prototype.iconClasses = {
  5367. close: 'fc-icon-x',
  5368. prev: 'fc-icon-chevron-left',
  5369. next: 'fc-icon-chevron-right',
  5370. prevYear: 'fc-icon-chevrons-left',
  5371. nextYear: 'fc-icon-chevrons-right',
  5372. };
  5373. StandardTheme.prototype.rtlIconClasses = {
  5374. prev: 'fc-icon-chevron-right',
  5375. next: 'fc-icon-chevron-left',
  5376. prevYear: 'fc-icon-chevrons-right',
  5377. nextYear: 'fc-icon-chevrons-left',
  5378. };
  5379. StandardTheme.prototype.iconOverrideOption = 'buttonIcons'; // TODO: make TS-friendly
  5380. StandardTheme.prototype.iconOverrideCustomButtonOption = 'icon';
  5381. StandardTheme.prototype.iconOverridePrefix = 'fc-icon-';
  5382. function compileViewDefs(defaultConfigs, overrideConfigs) {
  5383. var hash = {};
  5384. var viewType;
  5385. for (viewType in defaultConfigs) {
  5386. ensureViewDef(viewType, hash, defaultConfigs, overrideConfigs);
  5387. }
  5388. for (viewType in overrideConfigs) {
  5389. ensureViewDef(viewType, hash, defaultConfigs, overrideConfigs);
  5390. }
  5391. return hash;
  5392. }
  5393. function ensureViewDef(viewType, hash, defaultConfigs, overrideConfigs) {
  5394. if (hash[viewType]) {
  5395. return hash[viewType];
  5396. }
  5397. var viewDef = buildViewDef(viewType, hash, defaultConfigs, overrideConfigs);
  5398. if (viewDef) {
  5399. hash[viewType] = viewDef;
  5400. }
  5401. return viewDef;
  5402. }
  5403. function buildViewDef(viewType, hash, defaultConfigs, overrideConfigs) {
  5404. var defaultConfig = defaultConfigs[viewType];
  5405. var overrideConfig = overrideConfigs[viewType];
  5406. var queryProp = function (name) { return ((defaultConfig && defaultConfig[name] !== null) ? defaultConfig[name] :
  5407. ((overrideConfig && overrideConfig[name] !== null) ? overrideConfig[name] : null)); };
  5408. var theComponent = queryProp('component');
  5409. var superType = queryProp('superType');
  5410. var superDef = null;
  5411. if (superType) {
  5412. if (superType === viewType) {
  5413. throw new Error('Can\'t have a custom view type that references itself');
  5414. }
  5415. superDef = ensureViewDef(superType, hash, defaultConfigs, overrideConfigs);
  5416. }
  5417. if (!theComponent && superDef) {
  5418. theComponent = superDef.component;
  5419. }
  5420. if (!theComponent) {
  5421. return null; // don't throw a warning, might be settings for a single-unit view
  5422. }
  5423. return {
  5424. type: viewType,
  5425. component: theComponent,
  5426. defaults: __assign(__assign({}, (superDef ? superDef.defaults : {})), (defaultConfig ? defaultConfig.rawOptions : {})),
  5427. overrides: __assign(__assign({}, (superDef ? superDef.overrides : {})), (overrideConfig ? overrideConfig.rawOptions : {})),
  5428. };
  5429. }
  5430. /* eslint max-classes-per-file: off */
  5431. // NOTE: in JSX, you should always use this class with <HookProps> arg. otherwise, will default to any???
  5432. var RenderHook = /** @class */ (function (_super) {
  5433. __extends(RenderHook, _super);
  5434. function RenderHook() {
  5435. var _this = _super !== null && _super.apply(this, arguments) || this;
  5436. _this.rootElRef = createRef();
  5437. _this.handleRootEl = function (el) {
  5438. setRef(_this.rootElRef, el);
  5439. if (_this.props.elRef) {
  5440. setRef(_this.props.elRef, el);
  5441. }
  5442. };
  5443. return _this;
  5444. }
  5445. RenderHook.prototype.render = function () {
  5446. var _this = this;
  5447. var props = this.props;
  5448. var hookProps = props.hookProps;
  5449. return (createElement(MountHook, { hookProps: hookProps, didMount: props.didMount, willUnmount: props.willUnmount, elRef: this.handleRootEl }, function (rootElRef) { return (createElement(ContentHook, { hookProps: hookProps, content: props.content, defaultContent: props.defaultContent, backupElRef: _this.rootElRef }, function (innerElRef, innerContent) { return props.children(rootElRef, normalizeClassNames(props.classNames, hookProps), innerElRef, innerContent); })); }));
  5450. };
  5451. return RenderHook;
  5452. }(BaseComponent));
  5453. // TODO: rename to be about function, not default. use in above type
  5454. // for forcing rerender of components that use the ContentHook
  5455. var CustomContentRenderContext = createContext(0);
  5456. function ContentHook(props) {
  5457. return (createElement(CustomContentRenderContext.Consumer, null, function (renderId) { return (createElement(ContentHookInner, __assign({ renderId: renderId }, props))); }));
  5458. }
  5459. var ContentHookInner = /** @class */ (function (_super) {
  5460. __extends(ContentHookInner, _super);
  5461. function ContentHookInner() {
  5462. var _this = _super !== null && _super.apply(this, arguments) || this;
  5463. _this.innerElRef = createRef();
  5464. return _this;
  5465. }
  5466. ContentHookInner.prototype.render = function () {
  5467. return this.props.children(this.innerElRef, this.renderInnerContent());
  5468. };
  5469. ContentHookInner.prototype.componentDidMount = function () {
  5470. this.updateCustomContent();
  5471. };
  5472. ContentHookInner.prototype.componentDidUpdate = function () {
  5473. this.updateCustomContent();
  5474. };
  5475. ContentHookInner.prototype.componentWillUnmount = function () {
  5476. if (this.customContentInfo && this.customContentInfo.destroy) {
  5477. this.customContentInfo.destroy();
  5478. }
  5479. };
  5480. ContentHookInner.prototype.renderInnerContent = function () {
  5481. var customContentInfo = this.customContentInfo; // only populated if using non-[p]react node(s)
  5482. var innerContent = this.getInnerContent();
  5483. var meta = this.getContentMeta(innerContent);
  5484. // initial run, or content-type changing? (from vue -> react for example)
  5485. if (!customContentInfo || customContentInfo.contentKey !== meta.contentKey) {
  5486. // clearing old value
  5487. if (customContentInfo) {
  5488. if (customContentInfo.destroy) {
  5489. customContentInfo.destroy();
  5490. }
  5491. customContentInfo = this.customContentInfo = null;
  5492. }
  5493. // assigning new value
  5494. if (meta.contentKey) {
  5495. customContentInfo = this.customContentInfo = __assign({ contentKey: meta.contentKey, contentVal: innerContent[meta.contentKey] }, meta.buildLifecycleFuncs());
  5496. }
  5497. // updating
  5498. }
  5499. else if (customContentInfo) {
  5500. customContentInfo.contentVal = innerContent[meta.contentKey];
  5501. }
  5502. return customContentInfo
  5503. ? [] // signal that something was specified
  5504. : innerContent; // assume a [p]react vdom node. use it
  5505. };
  5506. ContentHookInner.prototype.getInnerContent = function () {
  5507. var props = this.props;
  5508. var innerContent = normalizeContent(props.content, props.hookProps);
  5509. if (innerContent === undefined) { // use the default
  5510. innerContent = normalizeContent(props.defaultContent, props.hookProps);
  5511. }
  5512. return innerContent == null ? null : innerContent; // convert undefined to null (better for React)
  5513. };
  5514. ContentHookInner.prototype.getContentMeta = function (innerContent) {
  5515. var contentTypeHandlers = this.context.pluginHooks.contentTypeHandlers;
  5516. var contentKey = '';
  5517. var buildLifecycleFuncs = null;
  5518. if (innerContent) { // allowed to be null, for convenience to caller
  5519. for (var searchKey in contentTypeHandlers) {
  5520. if (innerContent[searchKey] !== undefined) {
  5521. contentKey = searchKey;
  5522. buildLifecycleFuncs = contentTypeHandlers[searchKey];
  5523. break;
  5524. }
  5525. }
  5526. }
  5527. return { contentKey: contentKey, buildLifecycleFuncs: buildLifecycleFuncs };
  5528. };
  5529. ContentHookInner.prototype.updateCustomContent = function () {
  5530. if (this.customContentInfo) { // for non-[p]react
  5531. this.customContentInfo.render(this.innerElRef.current || this.props.backupElRef.current, // the element to render into
  5532. this.customContentInfo.contentVal);
  5533. }
  5534. };
  5535. return ContentHookInner;
  5536. }(BaseComponent));
  5537. var MountHook = /** @class */ (function (_super) {
  5538. __extends(MountHook, _super);
  5539. function MountHook() {
  5540. var _this = _super !== null && _super.apply(this, arguments) || this;
  5541. _this.handleRootEl = function (rootEl) {
  5542. _this.rootEl = rootEl;
  5543. if (_this.props.elRef) {
  5544. setRef(_this.props.elRef, rootEl);
  5545. }
  5546. };
  5547. return _this;
  5548. }
  5549. MountHook.prototype.render = function () {
  5550. return this.props.children(this.handleRootEl);
  5551. };
  5552. MountHook.prototype.componentDidMount = function () {
  5553. var callback = this.props.didMount;
  5554. if (callback) {
  5555. callback(__assign(__assign({}, this.props.hookProps), { el: this.rootEl }));
  5556. }
  5557. };
  5558. MountHook.prototype.componentWillUnmount = function () {
  5559. var callback = this.props.willUnmount;
  5560. if (callback) {
  5561. callback(__assign(__assign({}, this.props.hookProps), { el: this.rootEl }));
  5562. }
  5563. };
  5564. return MountHook;
  5565. }(BaseComponent));
  5566. function buildClassNameNormalizer() {
  5567. var currentGenerator;
  5568. var currentHookProps;
  5569. var currentClassNames = [];
  5570. return function (generator, hookProps) {
  5571. if (!currentHookProps || !isPropsEqual(currentHookProps, hookProps) || generator !== currentGenerator) {
  5572. currentGenerator = generator;
  5573. currentHookProps = hookProps;
  5574. currentClassNames = normalizeClassNames(generator, hookProps);
  5575. }
  5576. return currentClassNames;
  5577. };
  5578. }
  5579. function normalizeClassNames(classNames, hookProps) {
  5580. if (typeof classNames === 'function') {
  5581. classNames = classNames(hookProps);
  5582. }
  5583. return parseClassNames(classNames);
  5584. }
  5585. function normalizeContent(input, hookProps) {
  5586. if (typeof input === 'function') {
  5587. return input(hookProps, createElement); // give the function the vdom-creation func
  5588. }
  5589. return input;
  5590. }
  5591. var ViewRoot = /** @class */ (function (_super) {
  5592. __extends(ViewRoot, _super);
  5593. function ViewRoot() {
  5594. var _this = _super !== null && _super.apply(this, arguments) || this;
  5595. _this.normalizeClassNames = buildClassNameNormalizer();
  5596. return _this;
  5597. }
  5598. ViewRoot.prototype.render = function () {
  5599. var _a = this, props = _a.props, context = _a.context;
  5600. var options = context.options;
  5601. var hookProps = { view: context.viewApi };
  5602. var customClassNames = this.normalizeClassNames(options.viewClassNames, hookProps);
  5603. return (createElement(MountHook, { hookProps: hookProps, didMount: options.viewDidMount, willUnmount: options.viewWillUnmount, elRef: props.elRef }, function (rootElRef) { return props.children(rootElRef, ["fc-" + props.viewSpec.type + "-view", 'fc-view'].concat(customClassNames)); }));
  5604. };
  5605. return ViewRoot;
  5606. }(BaseComponent));
  5607. function parseViewConfigs(inputs) {
  5608. return mapHash(inputs, parseViewConfig);
  5609. }
  5610. function parseViewConfig(input) {
  5611. var rawOptions = typeof input === 'function' ?
  5612. { component: input } :
  5613. input;
  5614. var component = rawOptions.component;
  5615. if (rawOptions.content) {
  5616. component = createViewHookComponent(rawOptions);
  5617. // TODO: remove content/classNames/didMount/etc from options?
  5618. }
  5619. return {
  5620. superType: rawOptions.type,
  5621. component: component,
  5622. rawOptions: rawOptions,
  5623. };
  5624. }
  5625. function createViewHookComponent(options) {
  5626. return function (viewProps) { return (createElement(ViewContextType.Consumer, null, function (context) { return (createElement(ViewRoot, { viewSpec: context.viewSpec }, function (viewElRef, viewClassNames) {
  5627. var hookProps = __assign(__assign({}, viewProps), { nextDayThreshold: context.options.nextDayThreshold });
  5628. return (createElement(RenderHook, { hookProps: hookProps, classNames: options.classNames, content: options.content, didMount: options.didMount, willUnmount: options.willUnmount, elRef: viewElRef }, function (rootElRef, customClassNames, innerElRef, innerContent) { return (createElement("div", { className: viewClassNames.concat(customClassNames).join(' '), ref: rootElRef }, innerContent)); }));
  5629. })); })); };
  5630. }
  5631. function buildViewSpecs(defaultInputs, optionOverrides, dynamicOptionOverrides, localeDefaults) {
  5632. var defaultConfigs = parseViewConfigs(defaultInputs);
  5633. var overrideConfigs = parseViewConfigs(optionOverrides.views);
  5634. var viewDefs = compileViewDefs(defaultConfigs, overrideConfigs);
  5635. return mapHash(viewDefs, function (viewDef) { return buildViewSpec(viewDef, overrideConfigs, optionOverrides, dynamicOptionOverrides, localeDefaults); });
  5636. }
  5637. function buildViewSpec(viewDef, overrideConfigs, optionOverrides, dynamicOptionOverrides, localeDefaults) {
  5638. var durationInput = viewDef.overrides.duration ||
  5639. viewDef.defaults.duration ||
  5640. dynamicOptionOverrides.duration ||
  5641. optionOverrides.duration;
  5642. var duration = null;
  5643. var durationUnit = '';
  5644. var singleUnit = '';
  5645. var singleUnitOverrides = {};
  5646. if (durationInput) {
  5647. duration = createDurationCached(durationInput);
  5648. if (duration) { // valid?
  5649. var denom = greatestDurationDenominator(duration);
  5650. durationUnit = denom.unit;
  5651. if (denom.value === 1) {
  5652. singleUnit = durationUnit;
  5653. singleUnitOverrides = overrideConfigs[durationUnit] ? overrideConfigs[durationUnit].rawOptions : {};
  5654. }
  5655. }
  5656. }
  5657. var queryButtonText = function (optionsSubset) {
  5658. var buttonTextMap = optionsSubset.buttonText || {};
  5659. var buttonTextKey = viewDef.defaults.buttonTextKey;
  5660. if (buttonTextKey != null && buttonTextMap[buttonTextKey] != null) {
  5661. return buttonTextMap[buttonTextKey];
  5662. }
  5663. if (buttonTextMap[viewDef.type] != null) {
  5664. return buttonTextMap[viewDef.type];
  5665. }
  5666. if (buttonTextMap[singleUnit] != null) {
  5667. return buttonTextMap[singleUnit];
  5668. }
  5669. return null;
  5670. };
  5671. var queryButtonTitle = function (optionsSubset) {
  5672. var buttonHints = optionsSubset.buttonHints || {};
  5673. var buttonKey = viewDef.defaults.buttonTextKey; // use same key as text
  5674. if (buttonKey != null && buttonHints[buttonKey] != null) {
  5675. return buttonHints[buttonKey];
  5676. }
  5677. if (buttonHints[viewDef.type] != null) {
  5678. return buttonHints[viewDef.type];
  5679. }
  5680. if (buttonHints[singleUnit] != null) {
  5681. return buttonHints[singleUnit];
  5682. }
  5683. return null;
  5684. };
  5685. return {
  5686. type: viewDef.type,
  5687. component: viewDef.component,
  5688. duration: duration,
  5689. durationUnit: durationUnit,
  5690. singleUnit: singleUnit,
  5691. optionDefaults: viewDef.defaults,
  5692. optionOverrides: __assign(__assign({}, singleUnitOverrides), viewDef.overrides),
  5693. buttonTextOverride: queryButtonText(dynamicOptionOverrides) ||
  5694. queryButtonText(optionOverrides) || // constructor-specified buttonText lookup hash takes precedence
  5695. viewDef.overrides.buttonText,
  5696. buttonTextDefault: queryButtonText(localeDefaults) ||
  5697. viewDef.defaults.buttonText ||
  5698. queryButtonText(BASE_OPTION_DEFAULTS) ||
  5699. viewDef.type,
  5700. // not DRY
  5701. buttonTitleOverride: queryButtonTitle(dynamicOptionOverrides) ||
  5702. queryButtonTitle(optionOverrides) ||
  5703. viewDef.overrides.buttonHint,
  5704. buttonTitleDefault: queryButtonTitle(localeDefaults) ||
  5705. viewDef.defaults.buttonHint ||
  5706. queryButtonTitle(BASE_OPTION_DEFAULTS),
  5707. // will eventually fall back to buttonText
  5708. };
  5709. }
  5710. // hack to get memoization working
  5711. var durationInputMap = {};
  5712. function createDurationCached(durationInput) {
  5713. var json = JSON.stringify(durationInput);
  5714. var res = durationInputMap[json];
  5715. if (res === undefined) {
  5716. res = createDuration(durationInput);
  5717. durationInputMap[json] = res;
  5718. }
  5719. return res;
  5720. }
  5721. var DateProfileGenerator = /** @class */ (function () {
  5722. function DateProfileGenerator(props) {
  5723. this.props = props;
  5724. this.nowDate = getNow(props.nowInput, props.dateEnv);
  5725. this.initHiddenDays();
  5726. }
  5727. /* Date Range Computation
  5728. ------------------------------------------------------------------------------------------------------------------*/
  5729. // Builds a structure with info about what the dates/ranges will be for the "prev" view.
  5730. DateProfileGenerator.prototype.buildPrev = function (currentDateProfile, currentDate, forceToValid) {
  5731. var dateEnv = this.props.dateEnv;
  5732. var prevDate = dateEnv.subtract(dateEnv.startOf(currentDate, currentDateProfile.currentRangeUnit), // important for start-of-month
  5733. currentDateProfile.dateIncrement);
  5734. return this.build(prevDate, -1, forceToValid);
  5735. };
  5736. // Builds a structure with info about what the dates/ranges will be for the "next" view.
  5737. DateProfileGenerator.prototype.buildNext = function (currentDateProfile, currentDate, forceToValid) {
  5738. var dateEnv = this.props.dateEnv;
  5739. var nextDate = dateEnv.add(dateEnv.startOf(currentDate, currentDateProfile.currentRangeUnit), // important for start-of-month
  5740. currentDateProfile.dateIncrement);
  5741. return this.build(nextDate, 1, forceToValid);
  5742. };
  5743. // Builds a structure holding dates/ranges for rendering around the given date.
  5744. // Optional direction param indicates whether the date is being incremented/decremented
  5745. // from its previous value. decremented = -1, incremented = 1 (default).
  5746. DateProfileGenerator.prototype.build = function (currentDate, direction, forceToValid) {
  5747. if (forceToValid === void 0) { forceToValid = true; }
  5748. var props = this.props;
  5749. var validRange;
  5750. var currentInfo;
  5751. var isRangeAllDay;
  5752. var renderRange;
  5753. var activeRange;
  5754. var isValid;
  5755. validRange = this.buildValidRange();
  5756. validRange = this.trimHiddenDays(validRange);
  5757. if (forceToValid) {
  5758. currentDate = constrainMarkerToRange(currentDate, validRange);
  5759. }
  5760. currentInfo = this.buildCurrentRangeInfo(currentDate, direction);
  5761. isRangeAllDay = /^(year|month|week|day)$/.test(currentInfo.unit);
  5762. renderRange = this.buildRenderRange(this.trimHiddenDays(currentInfo.range), currentInfo.unit, isRangeAllDay);
  5763. renderRange = this.trimHiddenDays(renderRange);
  5764. activeRange = renderRange;
  5765. if (!props.showNonCurrentDates) {
  5766. activeRange = intersectRanges(activeRange, currentInfo.range);
  5767. }
  5768. activeRange = this.adjustActiveRange(activeRange);
  5769. activeRange = intersectRanges(activeRange, validRange); // might return null
  5770. // it's invalid if the originally requested date is not contained,
  5771. // or if the range is completely outside of the valid range.
  5772. isValid = rangesIntersect(currentInfo.range, validRange);
  5773. return {
  5774. // constraint for where prev/next operations can go and where events can be dragged/resized to.
  5775. // an object with optional start and end properties.
  5776. validRange: validRange,
  5777. // range the view is formally responsible for.
  5778. // for example, a month view might have 1st-31st, excluding padded dates
  5779. currentRange: currentInfo.range,
  5780. // name of largest unit being displayed, like "month" or "week"
  5781. currentRangeUnit: currentInfo.unit,
  5782. isRangeAllDay: isRangeAllDay,
  5783. // dates that display events and accept drag-n-drop
  5784. // will be `null` if no dates accept events
  5785. activeRange: activeRange,
  5786. // date range with a rendered skeleton
  5787. // includes not-active days that need some sort of DOM
  5788. renderRange: renderRange,
  5789. // Duration object that denotes the first visible time of any given day
  5790. slotMinTime: props.slotMinTime,
  5791. // Duration object that denotes the exclusive visible end time of any given day
  5792. slotMaxTime: props.slotMaxTime,
  5793. isValid: isValid,
  5794. // how far the current date will move for a prev/next operation
  5795. dateIncrement: this.buildDateIncrement(currentInfo.duration),
  5796. // pass a fallback (might be null) ^
  5797. };
  5798. };
  5799. // Builds an object with optional start/end properties.
  5800. // Indicates the minimum/maximum dates to display.
  5801. // not responsible for trimming hidden days.
  5802. DateProfileGenerator.prototype.buildValidRange = function () {
  5803. var input = this.props.validRangeInput;
  5804. var simpleInput = typeof input === 'function'
  5805. ? input.call(this.props.calendarApi, this.nowDate)
  5806. : input;
  5807. return this.refineRange(simpleInput) ||
  5808. { start: null, end: null }; // completely open-ended
  5809. };
  5810. // Builds a structure with info about the "current" range, the range that is
  5811. // highlighted as being the current month for example.
  5812. // See build() for a description of `direction`.
  5813. // Guaranteed to have `range` and `unit` properties. `duration` is optional.
  5814. DateProfileGenerator.prototype.buildCurrentRangeInfo = function (date, direction) {
  5815. var props = this.props;
  5816. var duration = null;
  5817. var unit = null;
  5818. var range = null;
  5819. var dayCount;
  5820. if (props.duration) {
  5821. duration = props.duration;
  5822. unit = props.durationUnit;
  5823. range = this.buildRangeFromDuration(date, direction, duration, unit);
  5824. }
  5825. else if ((dayCount = this.props.dayCount)) {
  5826. unit = 'day';
  5827. range = this.buildRangeFromDayCount(date, direction, dayCount);
  5828. }
  5829. else if ((range = this.buildCustomVisibleRange(date))) {
  5830. unit = props.dateEnv.greatestWholeUnit(range.start, range.end).unit;
  5831. }
  5832. else {
  5833. duration = this.getFallbackDuration();
  5834. unit = greatestDurationDenominator(duration).unit;
  5835. range = this.buildRangeFromDuration(date, direction, duration, unit);
  5836. }
  5837. return { duration: duration, unit: unit, range: range };
  5838. };
  5839. DateProfileGenerator.prototype.getFallbackDuration = function () {
  5840. return createDuration({ day: 1 });
  5841. };
  5842. // Returns a new activeRange to have time values (un-ambiguate)
  5843. // slotMinTime or slotMaxTime causes the range to expand.
  5844. DateProfileGenerator.prototype.adjustActiveRange = function (range) {
  5845. var _a = this.props, dateEnv = _a.dateEnv, usesMinMaxTime = _a.usesMinMaxTime, slotMinTime = _a.slotMinTime, slotMaxTime = _a.slotMaxTime;
  5846. var start = range.start, end = range.end;
  5847. if (usesMinMaxTime) {
  5848. // expand active range if slotMinTime is negative (why not when positive?)
  5849. if (asRoughDays(slotMinTime) < 0) {
  5850. start = startOfDay(start); // necessary?
  5851. start = dateEnv.add(start, slotMinTime);
  5852. }
  5853. // expand active range if slotMaxTime is beyond one day (why not when negative?)
  5854. if (asRoughDays(slotMaxTime) > 1) {
  5855. end = startOfDay(end); // necessary?
  5856. end = addDays(end, -1);
  5857. end = dateEnv.add(end, slotMaxTime);
  5858. }
  5859. }
  5860. return { start: start, end: end };
  5861. };
  5862. // Builds the "current" range when it is specified as an explicit duration.
  5863. // `unit` is the already-computed greatestDurationDenominator unit of duration.
  5864. DateProfileGenerator.prototype.buildRangeFromDuration = function (date, direction, duration, unit) {
  5865. var _a = this.props, dateEnv = _a.dateEnv, dateAlignment = _a.dateAlignment;
  5866. var start;
  5867. var end;
  5868. var res;
  5869. // compute what the alignment should be
  5870. if (!dateAlignment) {
  5871. var dateIncrement = this.props.dateIncrement;
  5872. if (dateIncrement) {
  5873. // use the smaller of the two units
  5874. if (asRoughMs(dateIncrement) < asRoughMs(duration)) {
  5875. dateAlignment = greatestDurationDenominator(dateIncrement).unit;
  5876. }
  5877. else {
  5878. dateAlignment = unit;
  5879. }
  5880. }
  5881. else {
  5882. dateAlignment = unit;
  5883. }
  5884. }
  5885. // if the view displays a single day or smaller
  5886. if (asRoughDays(duration) <= 1) {
  5887. if (this.isHiddenDay(start)) {
  5888. start = this.skipHiddenDays(start, direction);
  5889. start = startOfDay(start);
  5890. }
  5891. }
  5892. function computeRes() {
  5893. start = dateEnv.startOf(date, dateAlignment);
  5894. end = dateEnv.add(start, duration);
  5895. res = { start: start, end: end };
  5896. }
  5897. computeRes();
  5898. // if range is completely enveloped by hidden days, go past the hidden days
  5899. if (!this.trimHiddenDays(res)) {
  5900. date = this.skipHiddenDays(date, direction);
  5901. computeRes();
  5902. }
  5903. return res;
  5904. };
  5905. // Builds the "current" range when a dayCount is specified.
  5906. DateProfileGenerator.prototype.buildRangeFromDayCount = function (date, direction, dayCount) {
  5907. var _a = this.props, dateEnv = _a.dateEnv, dateAlignment = _a.dateAlignment;
  5908. var runningCount = 0;
  5909. var start = date;
  5910. var end;
  5911. if (dateAlignment) {
  5912. start = dateEnv.startOf(start, dateAlignment);
  5913. }
  5914. start = startOfDay(start);
  5915. start = this.skipHiddenDays(start, direction);
  5916. end = start;
  5917. do {
  5918. end = addDays(end, 1);
  5919. if (!this.isHiddenDay(end)) {
  5920. runningCount += 1;
  5921. }
  5922. } while (runningCount < dayCount);
  5923. return { start: start, end: end };
  5924. };
  5925. // Builds a normalized range object for the "visible" range,
  5926. // which is a way to define the currentRange and activeRange at the same time.
  5927. DateProfileGenerator.prototype.buildCustomVisibleRange = function (date) {
  5928. var props = this.props;
  5929. var input = props.visibleRangeInput;
  5930. var simpleInput = typeof input === 'function'
  5931. ? input.call(props.calendarApi, props.dateEnv.toDate(date))
  5932. : input;
  5933. var range = this.refineRange(simpleInput);
  5934. if (range && (range.start == null || range.end == null)) {
  5935. return null;
  5936. }
  5937. return range;
  5938. };
  5939. // Computes the range that will represent the element/cells for *rendering*,
  5940. // but which may have voided days/times.
  5941. // not responsible for trimming hidden days.
  5942. DateProfileGenerator.prototype.buildRenderRange = function (currentRange, currentRangeUnit, isRangeAllDay) {
  5943. return currentRange;
  5944. };
  5945. // Compute the duration value that should be added/substracted to the current date
  5946. // when a prev/next operation happens.
  5947. DateProfileGenerator.prototype.buildDateIncrement = function (fallback) {
  5948. var dateIncrement = this.props.dateIncrement;
  5949. var customAlignment;
  5950. if (dateIncrement) {
  5951. return dateIncrement;
  5952. }
  5953. if ((customAlignment = this.props.dateAlignment)) {
  5954. return createDuration(1, customAlignment);
  5955. }
  5956. if (fallback) {
  5957. return fallback;
  5958. }
  5959. return createDuration({ days: 1 });
  5960. };
  5961. DateProfileGenerator.prototype.refineRange = function (rangeInput) {
  5962. if (rangeInput) {
  5963. var range = parseRange(rangeInput, this.props.dateEnv);
  5964. if (range) {
  5965. range = computeVisibleDayRange(range);
  5966. }
  5967. return range;
  5968. }
  5969. return null;
  5970. };
  5971. /* Hidden Days
  5972. ------------------------------------------------------------------------------------------------------------------*/
  5973. // Initializes internal variables related to calculating hidden days-of-week
  5974. DateProfileGenerator.prototype.initHiddenDays = function () {
  5975. var hiddenDays = this.props.hiddenDays || []; // array of day-of-week indices that are hidden
  5976. var isHiddenDayHash = []; // is the day-of-week hidden? (hash with day-of-week-index -> bool)
  5977. var dayCnt = 0;
  5978. var i;
  5979. if (this.props.weekends === false) {
  5980. hiddenDays.push(0, 6); // 0=sunday, 6=saturday
  5981. }
  5982. for (i = 0; i < 7; i += 1) {
  5983. if (!(isHiddenDayHash[i] = hiddenDays.indexOf(i) !== -1)) {
  5984. dayCnt += 1;
  5985. }
  5986. }
  5987. if (!dayCnt) {
  5988. throw new Error('invalid hiddenDays'); // all days were hidden? bad.
  5989. }
  5990. this.isHiddenDayHash = isHiddenDayHash;
  5991. };
  5992. // Remove days from the beginning and end of the range that are computed as hidden.
  5993. // If the whole range is trimmed off, returns null
  5994. DateProfileGenerator.prototype.trimHiddenDays = function (range) {
  5995. var start = range.start, end = range.end;
  5996. if (start) {
  5997. start = this.skipHiddenDays(start);
  5998. }
  5999. if (end) {
  6000. end = this.skipHiddenDays(end, -1, true);
  6001. }
  6002. if (start == null || end == null || start < end) {
  6003. return { start: start, end: end };
  6004. }
  6005. return null;
  6006. };
  6007. // Is the current day hidden?
  6008. // `day` is a day-of-week index (0-6), or a Date (used for UTC)
  6009. DateProfileGenerator.prototype.isHiddenDay = function (day) {
  6010. if (day instanceof Date) {
  6011. day = day.getUTCDay();
  6012. }
  6013. return this.isHiddenDayHash[day];
  6014. };
  6015. // Incrementing the current day until it is no longer a hidden day, returning a copy.
  6016. // DOES NOT CONSIDER validRange!
  6017. // If the initial value of `date` is not a hidden day, don't do anything.
  6018. // Pass `isExclusive` as `true` if you are dealing with an end date.
  6019. // `inc` defaults to `1` (increment one day forward each time)
  6020. DateProfileGenerator.prototype.skipHiddenDays = function (date, inc, isExclusive) {
  6021. if (inc === void 0) { inc = 1; }
  6022. if (isExclusive === void 0) { isExclusive = false; }
  6023. while (this.isHiddenDayHash[(date.getUTCDay() + (isExclusive ? inc : 0) + 7) % 7]) {
  6024. date = addDays(date, inc);
  6025. }
  6026. return date;
  6027. };
  6028. return DateProfileGenerator;
  6029. }());
  6030. function reduceViewType(viewType, action) {
  6031. switch (action.type) {
  6032. case 'CHANGE_VIEW_TYPE':
  6033. viewType = action.viewType;
  6034. }
  6035. return viewType;
  6036. }
  6037. function reduceDynamicOptionOverrides(dynamicOptionOverrides, action) {
  6038. var _a;
  6039. switch (action.type) {
  6040. case 'SET_OPTION':
  6041. return __assign(__assign({}, dynamicOptionOverrides), (_a = {}, _a[action.optionName] = action.rawOptionValue, _a));
  6042. default:
  6043. return dynamicOptionOverrides;
  6044. }
  6045. }
  6046. function reduceDateProfile(currentDateProfile, action, currentDate, dateProfileGenerator) {
  6047. var dp;
  6048. switch (action.type) {
  6049. case 'CHANGE_VIEW_TYPE':
  6050. return dateProfileGenerator.build(action.dateMarker || currentDate);
  6051. case 'CHANGE_DATE':
  6052. return dateProfileGenerator.build(action.dateMarker);
  6053. case 'PREV':
  6054. dp = dateProfileGenerator.buildPrev(currentDateProfile, currentDate);
  6055. if (dp.isValid) {
  6056. return dp;
  6057. }
  6058. break;
  6059. case 'NEXT':
  6060. dp = dateProfileGenerator.buildNext(currentDateProfile, currentDate);
  6061. if (dp.isValid) {
  6062. return dp;
  6063. }
  6064. break;
  6065. }
  6066. return currentDateProfile;
  6067. }
  6068. function initEventSources(calendarOptions, dateProfile, context) {
  6069. var activeRange = dateProfile ? dateProfile.activeRange : null;
  6070. return addSources({}, parseInitialSources(calendarOptions, context), activeRange, context);
  6071. }
  6072. function reduceEventSources(eventSources, action, dateProfile, context) {
  6073. var activeRange = dateProfile ? dateProfile.activeRange : null; // need this check?
  6074. switch (action.type) {
  6075. case 'ADD_EVENT_SOURCES': // already parsed
  6076. return addSources(eventSources, action.sources, activeRange, context);
  6077. case 'REMOVE_EVENT_SOURCE':
  6078. return removeSource(eventSources, action.sourceId);
  6079. case 'PREV': // TODO: how do we track all actions that affect dateProfile :(
  6080. case 'NEXT':
  6081. case 'CHANGE_DATE':
  6082. case 'CHANGE_VIEW_TYPE':
  6083. if (dateProfile) {
  6084. return fetchDirtySources(eventSources, activeRange, context);
  6085. }
  6086. return eventSources;
  6087. case 'FETCH_EVENT_SOURCES':
  6088. return fetchSourcesByIds(eventSources, action.sourceIds ? // why no type?
  6089. arrayToHash(action.sourceIds) :
  6090. excludeStaticSources(eventSources, context), activeRange, action.isRefetch || false, context);
  6091. case 'RECEIVE_EVENTS':
  6092. case 'RECEIVE_EVENT_ERROR':
  6093. return receiveResponse(eventSources, action.sourceId, action.fetchId, action.fetchRange);
  6094. case 'REMOVE_ALL_EVENT_SOURCES':
  6095. return {};
  6096. default:
  6097. return eventSources;
  6098. }
  6099. }
  6100. function reduceEventSourcesNewTimeZone(eventSources, dateProfile, context) {
  6101. var activeRange = dateProfile ? dateProfile.activeRange : null; // need this check?
  6102. return fetchSourcesByIds(eventSources, excludeStaticSources(eventSources, context), activeRange, true, context);
  6103. }
  6104. function computeEventSourcesLoading(eventSources) {
  6105. for (var sourceId in eventSources) {
  6106. if (eventSources[sourceId].isFetching) {
  6107. return true;
  6108. }
  6109. }
  6110. return false;
  6111. }
  6112. function addSources(eventSourceHash, sources, fetchRange, context) {
  6113. var hash = {};
  6114. for (var _i = 0, sources_1 = sources; _i < sources_1.length; _i++) {
  6115. var source = sources_1[_i];
  6116. hash[source.sourceId] = source;
  6117. }
  6118. if (fetchRange) {
  6119. hash = fetchDirtySources(hash, fetchRange, context);
  6120. }
  6121. return __assign(__assign({}, eventSourceHash), hash);
  6122. }
  6123. function removeSource(eventSourceHash, sourceId) {
  6124. return filterHash(eventSourceHash, function (eventSource) { return eventSource.sourceId !== sourceId; });
  6125. }
  6126. function fetchDirtySources(sourceHash, fetchRange, context) {
  6127. return fetchSourcesByIds(sourceHash, filterHash(sourceHash, function (eventSource) { return isSourceDirty(eventSource, fetchRange, context); }), fetchRange, false, context);
  6128. }
  6129. function isSourceDirty(eventSource, fetchRange, context) {
  6130. if (!doesSourceNeedRange(eventSource, context)) {
  6131. return !eventSource.latestFetchId;
  6132. }
  6133. return !context.options.lazyFetching ||
  6134. !eventSource.fetchRange ||
  6135. eventSource.isFetching || // always cancel outdated in-progress fetches
  6136. fetchRange.start < eventSource.fetchRange.start ||
  6137. fetchRange.end > eventSource.fetchRange.end;
  6138. }
  6139. function fetchSourcesByIds(prevSources, sourceIdHash, fetchRange, isRefetch, context) {
  6140. var nextSources = {};
  6141. for (var sourceId in prevSources) {
  6142. var source = prevSources[sourceId];
  6143. if (sourceIdHash[sourceId]) {
  6144. nextSources[sourceId] = fetchSource(source, fetchRange, isRefetch, context);
  6145. }
  6146. else {
  6147. nextSources[sourceId] = source;
  6148. }
  6149. }
  6150. return nextSources;
  6151. }
  6152. function fetchSource(eventSource, fetchRange, isRefetch, context) {
  6153. var options = context.options, calendarApi = context.calendarApi;
  6154. var sourceDef = context.pluginHooks.eventSourceDefs[eventSource.sourceDefId];
  6155. var fetchId = guid();
  6156. sourceDef.fetch({
  6157. eventSource: eventSource,
  6158. range: fetchRange,
  6159. isRefetch: isRefetch,
  6160. context: context,
  6161. }, function (res) {
  6162. var rawEvents = res.rawEvents;
  6163. if (options.eventSourceSuccess) {
  6164. rawEvents = options.eventSourceSuccess.call(calendarApi, rawEvents, res.xhr) || rawEvents;
  6165. }
  6166. if (eventSource.success) {
  6167. rawEvents = eventSource.success.call(calendarApi, rawEvents, res.xhr) || rawEvents;
  6168. }
  6169. context.dispatch({
  6170. type: 'RECEIVE_EVENTS',
  6171. sourceId: eventSource.sourceId,
  6172. fetchId: fetchId,
  6173. fetchRange: fetchRange,
  6174. rawEvents: rawEvents,
  6175. });
  6176. }, function (error) {
  6177. console.warn(error.message, error);
  6178. if (options.eventSourceFailure) {
  6179. options.eventSourceFailure.call(calendarApi, error);
  6180. }
  6181. if (eventSource.failure) {
  6182. eventSource.failure(error);
  6183. }
  6184. context.dispatch({
  6185. type: 'RECEIVE_EVENT_ERROR',
  6186. sourceId: eventSource.sourceId,
  6187. fetchId: fetchId,
  6188. fetchRange: fetchRange,
  6189. error: error,
  6190. });
  6191. });
  6192. return __assign(__assign({}, eventSource), { isFetching: true, latestFetchId: fetchId });
  6193. }
  6194. function receiveResponse(sourceHash, sourceId, fetchId, fetchRange) {
  6195. var _a;
  6196. var eventSource = sourceHash[sourceId];
  6197. if (eventSource && // not already removed
  6198. fetchId === eventSource.latestFetchId) {
  6199. return __assign(__assign({}, sourceHash), (_a = {}, _a[sourceId] = __assign(__assign({}, eventSource), { isFetching: false, fetchRange: fetchRange }), _a));
  6200. }
  6201. return sourceHash;
  6202. }
  6203. function excludeStaticSources(eventSources, context) {
  6204. return filterHash(eventSources, function (eventSource) { return doesSourceNeedRange(eventSource, context); });
  6205. }
  6206. function parseInitialSources(rawOptions, context) {
  6207. var refiners = buildEventSourceRefiners(context);
  6208. var rawSources = [].concat(rawOptions.eventSources || []);
  6209. var sources = []; // parsed
  6210. if (rawOptions.initialEvents) {
  6211. rawSources.unshift(rawOptions.initialEvents);
  6212. }
  6213. if (rawOptions.events) {
  6214. rawSources.unshift(rawOptions.events);
  6215. }
  6216. for (var _i = 0, rawSources_1 = rawSources; _i < rawSources_1.length; _i++) {
  6217. var rawSource = rawSources_1[_i];
  6218. var source = parseEventSource(rawSource, context, refiners);
  6219. if (source) {
  6220. sources.push(source);
  6221. }
  6222. }
  6223. return sources;
  6224. }
  6225. function doesSourceNeedRange(eventSource, context) {
  6226. var defs = context.pluginHooks.eventSourceDefs;
  6227. return !defs[eventSource.sourceDefId].ignoreRange;
  6228. }
  6229. function reduceEventStore(eventStore, action, eventSources, dateProfile, context) {
  6230. switch (action.type) {
  6231. case 'RECEIVE_EVENTS': // raw
  6232. return receiveRawEvents(eventStore, eventSources[action.sourceId], action.fetchId, action.fetchRange, action.rawEvents, context);
  6233. case 'ADD_EVENTS': // already parsed, but not expanded
  6234. return addEvent(eventStore, action.eventStore, // new ones
  6235. dateProfile ? dateProfile.activeRange : null, context);
  6236. case 'RESET_EVENTS':
  6237. return action.eventStore;
  6238. case 'MERGE_EVENTS': // already parsed and expanded
  6239. return mergeEventStores(eventStore, action.eventStore);
  6240. case 'PREV': // TODO: how do we track all actions that affect dateProfile :(
  6241. case 'NEXT':
  6242. case 'CHANGE_DATE':
  6243. case 'CHANGE_VIEW_TYPE':
  6244. if (dateProfile) {
  6245. return expandRecurring(eventStore, dateProfile.activeRange, context);
  6246. }
  6247. return eventStore;
  6248. case 'REMOVE_EVENTS':
  6249. return excludeSubEventStore(eventStore, action.eventStore);
  6250. case 'REMOVE_EVENT_SOURCE':
  6251. return excludeEventsBySourceId(eventStore, action.sourceId);
  6252. case 'REMOVE_ALL_EVENT_SOURCES':
  6253. return filterEventStoreDefs(eventStore, function (eventDef) { return (!eventDef.sourceId // only keep events with no source id
  6254. ); });
  6255. case 'REMOVE_ALL_EVENTS':
  6256. return createEmptyEventStore();
  6257. default:
  6258. return eventStore;
  6259. }
  6260. }
  6261. function receiveRawEvents(eventStore, eventSource, fetchId, fetchRange, rawEvents, context) {
  6262. if (eventSource && // not already removed
  6263. fetchId === eventSource.latestFetchId // TODO: wish this logic was always in event-sources
  6264. ) {
  6265. var subset = parseEvents(transformRawEvents(rawEvents, eventSource, context), eventSource, context);
  6266. if (fetchRange) {
  6267. subset = expandRecurring(subset, fetchRange, context);
  6268. }
  6269. return mergeEventStores(excludeEventsBySourceId(eventStore, eventSource.sourceId), subset);
  6270. }
  6271. return eventStore;
  6272. }
  6273. function transformRawEvents(rawEvents, eventSource, context) {
  6274. var calEachTransform = context.options.eventDataTransform;
  6275. var sourceEachTransform = eventSource ? eventSource.eventDataTransform : null;
  6276. if (sourceEachTransform) {
  6277. rawEvents = transformEachRawEvent(rawEvents, sourceEachTransform);
  6278. }
  6279. if (calEachTransform) {
  6280. rawEvents = transformEachRawEvent(rawEvents, calEachTransform);
  6281. }
  6282. return rawEvents;
  6283. }
  6284. function transformEachRawEvent(rawEvents, func) {
  6285. var refinedEvents;
  6286. if (!func) {
  6287. refinedEvents = rawEvents;
  6288. }
  6289. else {
  6290. refinedEvents = [];
  6291. for (var _i = 0, rawEvents_1 = rawEvents; _i < rawEvents_1.length; _i++) {
  6292. var rawEvent = rawEvents_1[_i];
  6293. var refinedEvent = func(rawEvent);
  6294. if (refinedEvent) {
  6295. refinedEvents.push(refinedEvent);
  6296. }
  6297. else if (refinedEvent == null) {
  6298. refinedEvents.push(rawEvent);
  6299. } // if a different falsy value, do nothing
  6300. }
  6301. }
  6302. return refinedEvents;
  6303. }
  6304. function addEvent(eventStore, subset, expandRange, context) {
  6305. if (expandRange) {
  6306. subset = expandRecurring(subset, expandRange, context);
  6307. }
  6308. return mergeEventStores(eventStore, subset);
  6309. }
  6310. function rezoneEventStoreDates(eventStore, oldDateEnv, newDateEnv) {
  6311. var defs = eventStore.defs;
  6312. var instances = mapHash(eventStore.instances, function (instance) {
  6313. var def = defs[instance.defId];
  6314. if (def.allDay || def.recurringDef) {
  6315. return instance; // isn't dependent on timezone
  6316. }
  6317. return __assign(__assign({}, instance), { range: {
  6318. start: newDateEnv.createMarker(oldDateEnv.toDate(instance.range.start, instance.forcedStartTzo)),
  6319. end: newDateEnv.createMarker(oldDateEnv.toDate(instance.range.end, instance.forcedEndTzo)),
  6320. }, forcedStartTzo: newDateEnv.canComputeOffset ? null : instance.forcedStartTzo, forcedEndTzo: newDateEnv.canComputeOffset ? null : instance.forcedEndTzo });
  6321. });
  6322. return { defs: defs, instances: instances };
  6323. }
  6324. function excludeEventsBySourceId(eventStore, sourceId) {
  6325. return filterEventStoreDefs(eventStore, function (eventDef) { return eventDef.sourceId !== sourceId; });
  6326. }
  6327. // QUESTION: why not just return instances? do a general object-property-exclusion util
  6328. function excludeInstances(eventStore, removals) {
  6329. return {
  6330. defs: eventStore.defs,
  6331. instances: filterHash(eventStore.instances, function (instance) { return !removals[instance.instanceId]; }),
  6332. };
  6333. }
  6334. function reduceDateSelection(currentSelection, action) {
  6335. switch (action.type) {
  6336. case 'UNSELECT_DATES':
  6337. return null;
  6338. case 'SELECT_DATES':
  6339. return action.selection;
  6340. default:
  6341. return currentSelection;
  6342. }
  6343. }
  6344. function reduceSelectedEvent(currentInstanceId, action) {
  6345. switch (action.type) {
  6346. case 'UNSELECT_EVENT':
  6347. return '';
  6348. case 'SELECT_EVENT':
  6349. return action.eventInstanceId;
  6350. default:
  6351. return currentInstanceId;
  6352. }
  6353. }
  6354. function reduceEventDrag(currentDrag, action) {
  6355. var newDrag;
  6356. switch (action.type) {
  6357. case 'UNSET_EVENT_DRAG':
  6358. return null;
  6359. case 'SET_EVENT_DRAG':
  6360. newDrag = action.state;
  6361. return {
  6362. affectedEvents: newDrag.affectedEvents,
  6363. mutatedEvents: newDrag.mutatedEvents,
  6364. isEvent: newDrag.isEvent,
  6365. };
  6366. default:
  6367. return currentDrag;
  6368. }
  6369. }
  6370. function reduceEventResize(currentResize, action) {
  6371. var newResize;
  6372. switch (action.type) {
  6373. case 'UNSET_EVENT_RESIZE':
  6374. return null;
  6375. case 'SET_EVENT_RESIZE':
  6376. newResize = action.state;
  6377. return {
  6378. affectedEvents: newResize.affectedEvents,
  6379. mutatedEvents: newResize.mutatedEvents,
  6380. isEvent: newResize.isEvent,
  6381. };
  6382. default:
  6383. return currentResize;
  6384. }
  6385. }
  6386. function parseToolbars(calendarOptions, calendarOptionOverrides, theme, viewSpecs, calendarApi) {
  6387. var header = calendarOptions.headerToolbar ? parseToolbar(calendarOptions.headerToolbar, calendarOptions, calendarOptionOverrides, theme, viewSpecs, calendarApi) : null;
  6388. var footer = calendarOptions.footerToolbar ? parseToolbar(calendarOptions.footerToolbar, calendarOptions, calendarOptionOverrides, theme, viewSpecs, calendarApi) : null;
  6389. return { header: header, footer: footer };
  6390. }
  6391. function parseToolbar(sectionStrHash, calendarOptions, calendarOptionOverrides, theme, viewSpecs, calendarApi) {
  6392. var sectionWidgets = {};
  6393. var viewsWithButtons = [];
  6394. var hasTitle = false;
  6395. for (var sectionName in sectionStrHash) {
  6396. var sectionStr = sectionStrHash[sectionName];
  6397. var sectionRes = parseSection(sectionStr, calendarOptions, calendarOptionOverrides, theme, viewSpecs, calendarApi);
  6398. sectionWidgets[sectionName] = sectionRes.widgets;
  6399. viewsWithButtons.push.apply(viewsWithButtons, sectionRes.viewsWithButtons);
  6400. hasTitle = hasTitle || sectionRes.hasTitle;
  6401. }
  6402. return { sectionWidgets: sectionWidgets, viewsWithButtons: viewsWithButtons, hasTitle: hasTitle };
  6403. }
  6404. /*
  6405. BAD: querying icons and text here. should be done at render time
  6406. */
  6407. function parseSection(sectionStr, calendarOptions, // defaults+overrides, then refined
  6408. calendarOptionOverrides, // overrides only!, unrefined :(
  6409. theme, viewSpecs, calendarApi) {
  6410. var isRtl = calendarOptions.direction === 'rtl';
  6411. var calendarCustomButtons = calendarOptions.customButtons || {};
  6412. var calendarButtonTextOverrides = calendarOptionOverrides.buttonText || {};
  6413. var calendarButtonText = calendarOptions.buttonText || {};
  6414. var calendarButtonHintOverrides = calendarOptionOverrides.buttonHints || {};
  6415. var calendarButtonHints = calendarOptions.buttonHints || {};
  6416. var sectionSubstrs = sectionStr ? sectionStr.split(' ') : [];
  6417. var viewsWithButtons = [];
  6418. var hasTitle = false;
  6419. var widgets = sectionSubstrs.map(function (buttonGroupStr) { return (buttonGroupStr.split(',').map(function (buttonName) {
  6420. if (buttonName === 'title') {
  6421. hasTitle = true;
  6422. return { buttonName: buttonName };
  6423. }
  6424. var customButtonProps;
  6425. var viewSpec;
  6426. var buttonClick;
  6427. var buttonIcon; // only one of these will be set
  6428. var buttonText; // "
  6429. var buttonHint;
  6430. // ^ for the title="" attribute, for accessibility
  6431. if ((customButtonProps = calendarCustomButtons[buttonName])) {
  6432. buttonClick = function (ev) {
  6433. if (customButtonProps.click) {
  6434. customButtonProps.click.call(ev.target, ev, ev.target); // TODO: use Calendar this context?
  6435. }
  6436. };
  6437. (buttonIcon = theme.getCustomButtonIconClass(customButtonProps)) ||
  6438. (buttonIcon = theme.getIconClass(buttonName, isRtl)) ||
  6439. (buttonText = customButtonProps.text);
  6440. buttonHint = customButtonProps.hint || customButtonProps.text;
  6441. }
  6442. else if ((viewSpec = viewSpecs[buttonName])) {
  6443. viewsWithButtons.push(buttonName);
  6444. buttonClick = function () {
  6445. calendarApi.changeView(buttonName);
  6446. };
  6447. (buttonText = viewSpec.buttonTextOverride) ||
  6448. (buttonIcon = theme.getIconClass(buttonName, isRtl)) ||
  6449. (buttonText = viewSpec.buttonTextDefault);
  6450. var textFallback = viewSpec.buttonTextOverride ||
  6451. viewSpec.buttonTextDefault;
  6452. buttonHint = formatWithOrdinals(viewSpec.buttonTitleOverride ||
  6453. viewSpec.buttonTitleDefault ||
  6454. calendarOptions.viewHint, [textFallback, buttonName], // view-name = buttonName
  6455. textFallback);
  6456. }
  6457. else if (calendarApi[buttonName]) { // a calendarApi method
  6458. buttonClick = function () {
  6459. calendarApi[buttonName]();
  6460. };
  6461. (buttonText = calendarButtonTextOverrides[buttonName]) ||
  6462. (buttonIcon = theme.getIconClass(buttonName, isRtl)) ||
  6463. (buttonText = calendarButtonText[buttonName]); // everything else is considered default
  6464. if (buttonName === 'prevYear' || buttonName === 'nextYear') {
  6465. var prevOrNext = buttonName === 'prevYear' ? 'prev' : 'next';
  6466. buttonHint = formatWithOrdinals(calendarButtonHintOverrides[prevOrNext] ||
  6467. calendarButtonHints[prevOrNext], [
  6468. calendarButtonText.year || 'year',
  6469. 'year',
  6470. ], calendarButtonText[buttonName]);
  6471. }
  6472. else {
  6473. buttonHint = function (navUnit) { return formatWithOrdinals(calendarButtonHintOverrides[buttonName] ||
  6474. calendarButtonHints[buttonName], [
  6475. calendarButtonText[navUnit] || navUnit,
  6476. navUnit,
  6477. ], calendarButtonText[buttonName]); };
  6478. }
  6479. }
  6480. return { buttonName: buttonName, buttonClick: buttonClick, buttonIcon: buttonIcon, buttonText: buttonText, buttonHint: buttonHint };
  6481. })); });
  6482. return { widgets: widgets, viewsWithButtons: viewsWithButtons, hasTitle: hasTitle };
  6483. }
  6484. var eventSourceDef$3 = {
  6485. ignoreRange: true,
  6486. parseMeta: function (refined) {
  6487. if (Array.isArray(refined.events)) {
  6488. return refined.events;
  6489. }
  6490. return null;
  6491. },
  6492. fetch: function (arg, success) {
  6493. success({
  6494. rawEvents: arg.eventSource.meta,
  6495. });
  6496. },
  6497. };
  6498. var arrayEventSourcePlugin = createPlugin({
  6499. eventSourceDefs: [eventSourceDef$3],
  6500. });
  6501. var eventSourceDef$2 = {
  6502. parseMeta: function (refined) {
  6503. if (typeof refined.events === 'function') {
  6504. return refined.events;
  6505. }
  6506. return null;
  6507. },
  6508. fetch: function (arg, success, failure) {
  6509. var dateEnv = arg.context.dateEnv;
  6510. var func = arg.eventSource.meta;
  6511. unpromisify(func.bind(null, buildRangeApiWithTimeZone(arg.range, dateEnv)), function (rawEvents) {
  6512. success({ rawEvents: rawEvents }); // needs an object response
  6513. }, failure);
  6514. },
  6515. };
  6516. var funcEventSourcePlugin = createPlugin({
  6517. eventSourceDefs: [eventSourceDef$2],
  6518. });
  6519. function requestJson(method, url, params, successCallback, failureCallback) {
  6520. method = method.toUpperCase();
  6521. var body = null;
  6522. if (method === 'GET') {
  6523. url = injectQueryStringParams(url, params);
  6524. }
  6525. else {
  6526. body = encodeParams(params);
  6527. }
  6528. var xhr = new XMLHttpRequest();
  6529. xhr.open(method, url, true);
  6530. if (method !== 'GET') {
  6531. xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
  6532. }
  6533. xhr.onload = function () {
  6534. if (xhr.status >= 200 && xhr.status < 400) {
  6535. var parsed = false;
  6536. var res = void 0;
  6537. try {
  6538. res = JSON.parse(xhr.responseText);
  6539. parsed = true;
  6540. }
  6541. catch (err) {
  6542. // will handle parsed=false
  6543. }
  6544. if (parsed) {
  6545. successCallback(res, xhr);
  6546. }
  6547. else {
  6548. failureCallback('Failure parsing JSON', xhr);
  6549. }
  6550. }
  6551. else {
  6552. failureCallback('Request failed', xhr);
  6553. }
  6554. };
  6555. xhr.onerror = function () {
  6556. failureCallback('Request failed', xhr);
  6557. };
  6558. xhr.send(body);
  6559. }
  6560. function injectQueryStringParams(url, params) {
  6561. return url +
  6562. (url.indexOf('?') === -1 ? '?' : '&') +
  6563. encodeParams(params);
  6564. }
  6565. function encodeParams(params) {
  6566. var parts = [];
  6567. for (var key in params) {
  6568. parts.push(encodeURIComponent(key) + "=" + encodeURIComponent(params[key]));
  6569. }
  6570. return parts.join('&');
  6571. }
  6572. var JSON_FEED_EVENT_SOURCE_REFINERS = {
  6573. method: String,
  6574. extraParams: identity,
  6575. startParam: String,
  6576. endParam: String,
  6577. timeZoneParam: String,
  6578. };
  6579. var eventSourceDef$1 = {
  6580. parseMeta: function (refined) {
  6581. if (refined.url && (refined.format === 'json' || !refined.format)) {
  6582. return {
  6583. url: refined.url,
  6584. format: 'json',
  6585. method: (refined.method || 'GET').toUpperCase(),
  6586. extraParams: refined.extraParams,
  6587. startParam: refined.startParam,
  6588. endParam: refined.endParam,
  6589. timeZoneParam: refined.timeZoneParam,
  6590. };
  6591. }
  6592. return null;
  6593. },
  6594. fetch: function (arg, success, failure) {
  6595. var meta = arg.eventSource.meta;
  6596. var requestParams = buildRequestParams$1(meta, arg.range, arg.context);
  6597. requestJson(meta.method, meta.url, requestParams, function (rawEvents, xhr) {
  6598. success({ rawEvents: rawEvents, xhr: xhr });
  6599. }, function (errorMessage, xhr) {
  6600. failure({ message: errorMessage, xhr: xhr });
  6601. });
  6602. },
  6603. };
  6604. var jsonFeedEventSourcePlugin = createPlugin({
  6605. eventSourceRefiners: JSON_FEED_EVENT_SOURCE_REFINERS,
  6606. eventSourceDefs: [eventSourceDef$1],
  6607. });
  6608. function buildRequestParams$1(meta, range, context) {
  6609. var dateEnv = context.dateEnv, options = context.options;
  6610. var startParam;
  6611. var endParam;
  6612. var timeZoneParam;
  6613. var customRequestParams;
  6614. var params = {};
  6615. startParam = meta.startParam;
  6616. if (startParam == null) {
  6617. startParam = options.startParam;
  6618. }
  6619. endParam = meta.endParam;
  6620. if (endParam == null) {
  6621. endParam = options.endParam;
  6622. }
  6623. timeZoneParam = meta.timeZoneParam;
  6624. if (timeZoneParam == null) {
  6625. timeZoneParam = options.timeZoneParam;
  6626. }
  6627. // retrieve any outbound GET/POST data from the options
  6628. if (typeof meta.extraParams === 'function') {
  6629. // supplied as a function that returns a key/value object
  6630. customRequestParams = meta.extraParams();
  6631. }
  6632. else {
  6633. // probably supplied as a straight key/value object
  6634. customRequestParams = meta.extraParams || {};
  6635. }
  6636. __assign(params, customRequestParams);
  6637. params[startParam] = dateEnv.formatIso(range.start);
  6638. params[endParam] = dateEnv.formatIso(range.end);
  6639. if (dateEnv.timeZone !== 'local') {
  6640. params[timeZoneParam] = dateEnv.timeZone;
  6641. }
  6642. return params;
  6643. }
  6644. var SIMPLE_RECURRING_REFINERS = {
  6645. daysOfWeek: identity,
  6646. startTime: createDuration,
  6647. endTime: createDuration,
  6648. duration: createDuration,
  6649. startRecur: identity,
  6650. endRecur: identity,
  6651. };
  6652. var recurring = {
  6653. parse: function (refined, dateEnv) {
  6654. if (refined.daysOfWeek || refined.startTime || refined.endTime || refined.startRecur || refined.endRecur) {
  6655. var recurringData = {
  6656. daysOfWeek: refined.daysOfWeek || null,
  6657. startTime: refined.startTime || null,
  6658. endTime: refined.endTime || null,
  6659. startRecur: refined.startRecur ? dateEnv.createMarker(refined.startRecur) : null,
  6660. endRecur: refined.endRecur ? dateEnv.createMarker(refined.endRecur) : null,
  6661. };
  6662. var duration = void 0;
  6663. if (refined.duration) {
  6664. duration = refined.duration;
  6665. }
  6666. if (!duration && refined.startTime && refined.endTime) {
  6667. duration = subtractDurations(refined.endTime, refined.startTime);
  6668. }
  6669. return {
  6670. allDayGuess: Boolean(!refined.startTime && !refined.endTime),
  6671. duration: duration,
  6672. typeData: recurringData, // doesn't need endTime anymore but oh well
  6673. };
  6674. }
  6675. return null;
  6676. },
  6677. expand: function (typeData, framingRange, dateEnv) {
  6678. var clippedFramingRange = intersectRanges(framingRange, { start: typeData.startRecur, end: typeData.endRecur });
  6679. if (clippedFramingRange) {
  6680. return expandRanges(typeData.daysOfWeek, typeData.startTime, clippedFramingRange, dateEnv);
  6681. }
  6682. return [];
  6683. },
  6684. };
  6685. var simpleRecurringEventsPlugin = createPlugin({
  6686. recurringTypes: [recurring],
  6687. eventRefiners: SIMPLE_RECURRING_REFINERS,
  6688. });
  6689. function expandRanges(daysOfWeek, startTime, framingRange, dateEnv) {
  6690. var dowHash = daysOfWeek ? arrayToHash(daysOfWeek) : null;
  6691. var dayMarker = startOfDay(framingRange.start);
  6692. var endMarker = framingRange.end;
  6693. var instanceStarts = [];
  6694. while (dayMarker < endMarker) {
  6695. var instanceStart
  6696. // if everyday, or this particular day-of-week
  6697. = void 0;
  6698. // if everyday, or this particular day-of-week
  6699. if (!dowHash || dowHash[dayMarker.getUTCDay()]) {
  6700. if (startTime) {
  6701. instanceStart = dateEnv.add(dayMarker, startTime);
  6702. }
  6703. else {
  6704. instanceStart = dayMarker;
  6705. }
  6706. instanceStarts.push(instanceStart);
  6707. }
  6708. dayMarker = addDays(dayMarker, 1);
  6709. }
  6710. return instanceStarts;
  6711. }
  6712. var changeHandlerPlugin = createPlugin({
  6713. optionChangeHandlers: {
  6714. events: function (events, context) {
  6715. handleEventSources([events], context);
  6716. },
  6717. eventSources: handleEventSources,
  6718. },
  6719. });
  6720. /*
  6721. BUG: if `event` was supplied, all previously-given `eventSources` will be wiped out
  6722. */
  6723. function handleEventSources(inputs, context) {
  6724. var unfoundSources = hashValuesToArray(context.getCurrentData().eventSources);
  6725. var newInputs = [];
  6726. for (var _i = 0, inputs_1 = inputs; _i < inputs_1.length; _i++) {
  6727. var input = inputs_1[_i];
  6728. var inputFound = false;
  6729. for (var i = 0; i < unfoundSources.length; i += 1) {
  6730. if (unfoundSources[i]._raw === input) {
  6731. unfoundSources.splice(i, 1); // delete
  6732. inputFound = true;
  6733. break;
  6734. }
  6735. }
  6736. if (!inputFound) {
  6737. newInputs.push(input);
  6738. }
  6739. }
  6740. for (var _a = 0, unfoundSources_1 = unfoundSources; _a < unfoundSources_1.length; _a++) {
  6741. var unfoundSource = unfoundSources_1[_a];
  6742. context.dispatch({
  6743. type: 'REMOVE_EVENT_SOURCE',
  6744. sourceId: unfoundSource.sourceId,
  6745. });
  6746. }
  6747. for (var _b = 0, newInputs_1 = newInputs; _b < newInputs_1.length; _b++) {
  6748. var newInput = newInputs_1[_b];
  6749. context.calendarApi.addEventSource(newInput);
  6750. }
  6751. }
  6752. function handleDateProfile(dateProfile, context) {
  6753. context.emitter.trigger('datesSet', __assign(__assign({}, buildRangeApiWithTimeZone(dateProfile.activeRange, context.dateEnv)), { view: context.viewApi }));
  6754. }
  6755. function handleEventStore(eventStore, context) {
  6756. var emitter = context.emitter;
  6757. if (emitter.hasHandlers('eventsSet')) {
  6758. emitter.trigger('eventsSet', buildEventApis(eventStore, context));
  6759. }
  6760. }
  6761. /*
  6762. this array is exposed on the root namespace so that UMD plugins can add to it.
  6763. see the rollup-bundles script.
  6764. */
  6765. var globalPlugins = [
  6766. arrayEventSourcePlugin,
  6767. funcEventSourcePlugin,
  6768. jsonFeedEventSourcePlugin,
  6769. simpleRecurringEventsPlugin,
  6770. changeHandlerPlugin,
  6771. createPlugin({
  6772. isLoadingFuncs: [
  6773. function (state) { return computeEventSourcesLoading(state.eventSources); },
  6774. ],
  6775. contentTypeHandlers: {
  6776. html: buildHtmlRenderer,
  6777. domNodes: buildDomNodeRenderer,
  6778. },
  6779. propSetHandlers: {
  6780. dateProfile: handleDateProfile,
  6781. eventStore: handleEventStore,
  6782. },
  6783. }),
  6784. ];
  6785. function buildHtmlRenderer() {
  6786. var currentEl = null;
  6787. var currentHtml = '';
  6788. function render(el, html) {
  6789. if (el !== currentEl || html !== currentHtml) {
  6790. el.innerHTML = html;
  6791. }
  6792. currentEl = el;
  6793. currentHtml = html;
  6794. }
  6795. function destroy() {
  6796. currentEl.innerHTML = '';
  6797. currentEl = null;
  6798. currentHtml = '';
  6799. }
  6800. return { render: render, destroy: destroy };
  6801. }
  6802. function buildDomNodeRenderer() {
  6803. var currentEl = null;
  6804. var currentDomNodes = [];
  6805. function render(el, domNodes) {
  6806. var newDomNodes = Array.prototype.slice.call(domNodes);
  6807. if (el !== currentEl || !isArraysEqual(currentDomNodes, newDomNodes)) {
  6808. // append first, remove second (for scroll resetting)
  6809. for (var _i = 0, newDomNodes_1 = newDomNodes; _i < newDomNodes_1.length; _i++) {
  6810. var newNode = newDomNodes_1[_i];
  6811. el.appendChild(newNode);
  6812. }
  6813. destroy();
  6814. }
  6815. currentEl = el;
  6816. currentDomNodes = newDomNodes;
  6817. }
  6818. function destroy() {
  6819. currentDomNodes.forEach(removeElement);
  6820. currentDomNodes = [];
  6821. currentEl = null;
  6822. }
  6823. return { render: render, destroy: destroy };
  6824. }
  6825. var DelayedRunner = /** @class */ (function () {
  6826. function DelayedRunner(drainedOption) {
  6827. this.drainedOption = drainedOption;
  6828. this.isRunning = false;
  6829. this.isDirty = false;
  6830. this.pauseDepths = {};
  6831. this.timeoutId = 0;
  6832. }
  6833. DelayedRunner.prototype.request = function (delay) {
  6834. this.isDirty = true;
  6835. if (!this.isPaused()) {
  6836. this.clearTimeout();
  6837. if (delay == null) {
  6838. this.tryDrain();
  6839. }
  6840. else {
  6841. this.timeoutId = setTimeout(// NOT OPTIMAL! TODO: look at debounce
  6842. this.tryDrain.bind(this), delay);
  6843. }
  6844. }
  6845. };
  6846. DelayedRunner.prototype.pause = function (scope) {
  6847. if (scope === void 0) { scope = ''; }
  6848. var pauseDepths = this.pauseDepths;
  6849. pauseDepths[scope] = (pauseDepths[scope] || 0) + 1;
  6850. this.clearTimeout();
  6851. };
  6852. DelayedRunner.prototype.resume = function (scope, force) {
  6853. if (scope === void 0) { scope = ''; }
  6854. var pauseDepths = this.pauseDepths;
  6855. if (scope in pauseDepths) {
  6856. if (force) {
  6857. delete pauseDepths[scope];
  6858. }
  6859. else {
  6860. pauseDepths[scope] -= 1;
  6861. var depth = pauseDepths[scope];
  6862. if (depth <= 0) {
  6863. delete pauseDepths[scope];
  6864. }
  6865. }
  6866. this.tryDrain();
  6867. }
  6868. };
  6869. DelayedRunner.prototype.isPaused = function () {
  6870. return Object.keys(this.pauseDepths).length;
  6871. };
  6872. DelayedRunner.prototype.tryDrain = function () {
  6873. if (!this.isRunning && !this.isPaused()) {
  6874. this.isRunning = true;
  6875. while (this.isDirty) {
  6876. this.isDirty = false;
  6877. this.drained(); // might set isDirty to true again
  6878. }
  6879. this.isRunning = false;
  6880. }
  6881. };
  6882. DelayedRunner.prototype.clear = function () {
  6883. this.clearTimeout();
  6884. this.isDirty = false;
  6885. this.pauseDepths = {};
  6886. };
  6887. DelayedRunner.prototype.clearTimeout = function () {
  6888. if (this.timeoutId) {
  6889. clearTimeout(this.timeoutId);
  6890. this.timeoutId = 0;
  6891. }
  6892. };
  6893. DelayedRunner.prototype.drained = function () {
  6894. if (this.drainedOption) {
  6895. this.drainedOption();
  6896. }
  6897. };
  6898. return DelayedRunner;
  6899. }());
  6900. var TaskRunner = /** @class */ (function () {
  6901. function TaskRunner(runTaskOption, drainedOption) {
  6902. this.runTaskOption = runTaskOption;
  6903. this.drainedOption = drainedOption;
  6904. this.queue = [];
  6905. this.delayedRunner = new DelayedRunner(this.drain.bind(this));
  6906. }
  6907. TaskRunner.prototype.request = function (task, delay) {
  6908. this.queue.push(task);
  6909. this.delayedRunner.request(delay);
  6910. };
  6911. TaskRunner.prototype.pause = function (scope) {
  6912. this.delayedRunner.pause(scope);
  6913. };
  6914. TaskRunner.prototype.resume = function (scope, force) {
  6915. this.delayedRunner.resume(scope, force);
  6916. };
  6917. TaskRunner.prototype.drain = function () {
  6918. var queue = this.queue;
  6919. while (queue.length) {
  6920. var completedTasks = [];
  6921. var task = void 0;
  6922. while ((task = queue.shift())) {
  6923. this.runTask(task);
  6924. completedTasks.push(task);
  6925. }
  6926. this.drained(completedTasks);
  6927. } // keep going, in case new tasks were added in the drained handler
  6928. };
  6929. TaskRunner.prototype.runTask = function (task) {
  6930. if (this.runTaskOption) {
  6931. this.runTaskOption(task);
  6932. }
  6933. };
  6934. TaskRunner.prototype.drained = function (completedTasks) {
  6935. if (this.drainedOption) {
  6936. this.drainedOption(completedTasks);
  6937. }
  6938. };
  6939. return TaskRunner;
  6940. }());
  6941. // Computes what the title at the top of the calendarApi should be for this view
  6942. function buildTitle(dateProfile, viewOptions, dateEnv) {
  6943. var range;
  6944. // for views that span a large unit of time, show the proper interval, ignoring stray days before and after
  6945. if (/^(year|month)$/.test(dateProfile.currentRangeUnit)) {
  6946. range = dateProfile.currentRange;
  6947. }
  6948. else { // for day units or smaller, use the actual day range
  6949. range = dateProfile.activeRange;
  6950. }
  6951. return dateEnv.formatRange(range.start, range.end, createFormatter(viewOptions.titleFormat || buildTitleFormat(dateProfile)), {
  6952. isEndExclusive: dateProfile.isRangeAllDay,
  6953. defaultSeparator: viewOptions.titleRangeSeparator,
  6954. });
  6955. }
  6956. // Generates the format string that should be used to generate the title for the current date range.
  6957. // Attempts to compute the most appropriate format if not explicitly specified with `titleFormat`.
  6958. function buildTitleFormat(dateProfile) {
  6959. var currentRangeUnit = dateProfile.currentRangeUnit;
  6960. if (currentRangeUnit === 'year') {
  6961. return { year: 'numeric' };
  6962. }
  6963. if (currentRangeUnit === 'month') {
  6964. return { year: 'numeric', month: 'long' }; // like "September 2014"
  6965. }
  6966. var days = diffWholeDays(dateProfile.currentRange.start, dateProfile.currentRange.end);
  6967. if (days !== null && days > 1) {
  6968. // multi-day range. shorter, like "Sep 9 - 10 2014"
  6969. return { year: 'numeric', month: 'short', day: 'numeric' };
  6970. }
  6971. // one day. longer, like "September 9 2014"
  6972. return { year: 'numeric', month: 'long', day: 'numeric' };
  6973. }
  6974. // in future refactor, do the redux-style function(state=initial) for initial-state
  6975. // also, whatever is happening in constructor, have it happen in action queue too
  6976. var CalendarDataManager = /** @class */ (function () {
  6977. function CalendarDataManager(props) {
  6978. var _this = this;
  6979. this.computeOptionsData = memoize(this._computeOptionsData);
  6980. this.computeCurrentViewData = memoize(this._computeCurrentViewData);
  6981. this.organizeRawLocales = memoize(organizeRawLocales);
  6982. this.buildLocale = memoize(buildLocale);
  6983. this.buildPluginHooks = buildBuildPluginHooks();
  6984. this.buildDateEnv = memoize(buildDateEnv);
  6985. this.buildTheme = memoize(buildTheme);
  6986. this.parseToolbars = memoize(parseToolbars);
  6987. this.buildViewSpecs = memoize(buildViewSpecs);
  6988. this.buildDateProfileGenerator = memoizeObjArg(buildDateProfileGenerator);
  6989. this.buildViewApi = memoize(buildViewApi);
  6990. this.buildViewUiProps = memoizeObjArg(buildViewUiProps);
  6991. this.buildEventUiBySource = memoize(buildEventUiBySource, isPropsEqual);
  6992. this.buildEventUiBases = memoize(buildEventUiBases);
  6993. this.parseContextBusinessHours = memoizeObjArg(parseContextBusinessHours);
  6994. this.buildTitle = memoize(buildTitle);
  6995. this.emitter = new Emitter();
  6996. this.actionRunner = new TaskRunner(this._handleAction.bind(this), this.updateData.bind(this));
  6997. this.currentCalendarOptionsInput = {};
  6998. this.currentCalendarOptionsRefined = {};
  6999. this.currentViewOptionsInput = {};
  7000. this.currentViewOptionsRefined = {};
  7001. this.currentCalendarOptionsRefiners = {};
  7002. this.getCurrentData = function () { return _this.data; };
  7003. this.dispatch = function (action) {
  7004. _this.actionRunner.request(action); // protects against recursive calls to _handleAction
  7005. };
  7006. this.props = props;
  7007. this.actionRunner.pause();
  7008. var dynamicOptionOverrides = {};
  7009. var optionsData = this.computeOptionsData(props.optionOverrides, dynamicOptionOverrides, props.calendarApi);
  7010. var currentViewType = optionsData.calendarOptions.initialView || optionsData.pluginHooks.initialView;
  7011. var currentViewData = this.computeCurrentViewData(currentViewType, optionsData, props.optionOverrides, dynamicOptionOverrides);
  7012. // wire things up
  7013. // TODO: not DRY
  7014. props.calendarApi.currentDataManager = this;
  7015. this.emitter.setThisContext(props.calendarApi);
  7016. this.emitter.setOptions(currentViewData.options);
  7017. var currentDate = getInitialDate(optionsData.calendarOptions, optionsData.dateEnv);
  7018. var dateProfile = currentViewData.dateProfileGenerator.build(currentDate);
  7019. if (!rangeContainsMarker(dateProfile.activeRange, currentDate)) {
  7020. currentDate = dateProfile.currentRange.start;
  7021. }
  7022. var calendarContext = {
  7023. dateEnv: optionsData.dateEnv,
  7024. options: optionsData.calendarOptions,
  7025. pluginHooks: optionsData.pluginHooks,
  7026. calendarApi: props.calendarApi,
  7027. dispatch: this.dispatch,
  7028. emitter: this.emitter,
  7029. getCurrentData: this.getCurrentData,
  7030. };
  7031. // needs to be after setThisContext
  7032. for (var _i = 0, _a = optionsData.pluginHooks.contextInit; _i < _a.length; _i++) {
  7033. var callback = _a[_i];
  7034. callback(calendarContext);
  7035. }
  7036. // NOT DRY
  7037. var eventSources = initEventSources(optionsData.calendarOptions, dateProfile, calendarContext);
  7038. var initialState = {
  7039. dynamicOptionOverrides: dynamicOptionOverrides,
  7040. currentViewType: currentViewType,
  7041. currentDate: currentDate,
  7042. dateProfile: dateProfile,
  7043. businessHours: this.parseContextBusinessHours(calendarContext),
  7044. eventSources: eventSources,
  7045. eventUiBases: {},
  7046. eventStore: createEmptyEventStore(),
  7047. renderableEventStore: createEmptyEventStore(),
  7048. dateSelection: null,
  7049. eventSelection: '',
  7050. eventDrag: null,
  7051. eventResize: null,
  7052. selectionConfig: this.buildViewUiProps(calendarContext).selectionConfig,
  7053. };
  7054. var contextAndState = __assign(__assign({}, calendarContext), initialState);
  7055. for (var _b = 0, _c = optionsData.pluginHooks.reducers; _b < _c.length; _b++) {
  7056. var reducer = _c[_b];
  7057. __assign(initialState, reducer(null, null, contextAndState));
  7058. }
  7059. if (computeIsLoading(initialState, calendarContext)) {
  7060. this.emitter.trigger('loading', true); // NOT DRY
  7061. }
  7062. this.state = initialState;
  7063. this.updateData();
  7064. this.actionRunner.resume();
  7065. }
  7066. CalendarDataManager.prototype.resetOptions = function (optionOverrides, append) {
  7067. var props = this.props;
  7068. props.optionOverrides = append
  7069. ? __assign(__assign({}, props.optionOverrides), optionOverrides) : optionOverrides;
  7070. this.actionRunner.request({
  7071. type: 'NOTHING',
  7072. });
  7073. };
  7074. CalendarDataManager.prototype._handleAction = function (action) {
  7075. var _a = this, props = _a.props, state = _a.state, emitter = _a.emitter;
  7076. var dynamicOptionOverrides = reduceDynamicOptionOverrides(state.dynamicOptionOverrides, action);
  7077. var optionsData = this.computeOptionsData(props.optionOverrides, dynamicOptionOverrides, props.calendarApi);
  7078. var currentViewType = reduceViewType(state.currentViewType, action);
  7079. var currentViewData = this.computeCurrentViewData(currentViewType, optionsData, props.optionOverrides, dynamicOptionOverrides);
  7080. // wire things up
  7081. // TODO: not DRY
  7082. props.calendarApi.currentDataManager = this;
  7083. emitter.setThisContext(props.calendarApi);
  7084. emitter.setOptions(currentViewData.options);
  7085. var calendarContext = {
  7086. dateEnv: optionsData.dateEnv,
  7087. options: optionsData.calendarOptions,
  7088. pluginHooks: optionsData.pluginHooks,
  7089. calendarApi: props.calendarApi,
  7090. dispatch: this.dispatch,
  7091. emitter: emitter,
  7092. getCurrentData: this.getCurrentData,
  7093. };
  7094. var currentDate = state.currentDate, dateProfile = state.dateProfile;
  7095. if (this.data && this.data.dateProfileGenerator !== currentViewData.dateProfileGenerator) { // hack
  7096. dateProfile = currentViewData.dateProfileGenerator.build(currentDate);
  7097. }
  7098. currentDate = reduceCurrentDate(currentDate, action);
  7099. dateProfile = reduceDateProfile(dateProfile, action, currentDate, currentViewData.dateProfileGenerator);
  7100. if (action.type === 'PREV' || // TODO: move this logic into DateProfileGenerator
  7101. action.type === 'NEXT' || // "
  7102. !rangeContainsMarker(dateProfile.currentRange, currentDate)) {
  7103. currentDate = dateProfile.currentRange.start;
  7104. }
  7105. var eventSources = reduceEventSources(state.eventSources, action, dateProfile, calendarContext);
  7106. var eventStore = reduceEventStore(state.eventStore, action, eventSources, dateProfile, calendarContext);
  7107. var isEventsLoading = computeEventSourcesLoading(eventSources); // BAD. also called in this func in computeIsLoading
  7108. var renderableEventStore = (isEventsLoading && !currentViewData.options.progressiveEventRendering) ?
  7109. (state.renderableEventStore || eventStore) : // try from previous state
  7110. eventStore;
  7111. var _b = this.buildViewUiProps(calendarContext), eventUiSingleBase = _b.eventUiSingleBase, selectionConfig = _b.selectionConfig; // will memoize obj
  7112. var eventUiBySource = this.buildEventUiBySource(eventSources);
  7113. var eventUiBases = this.buildEventUiBases(renderableEventStore.defs, eventUiSingleBase, eventUiBySource);
  7114. var newState = {
  7115. dynamicOptionOverrides: dynamicOptionOverrides,
  7116. currentViewType: currentViewType,
  7117. currentDate: currentDate,
  7118. dateProfile: dateProfile,
  7119. eventSources: eventSources,
  7120. eventStore: eventStore,
  7121. renderableEventStore: renderableEventStore,
  7122. selectionConfig: selectionConfig,
  7123. eventUiBases: eventUiBases,
  7124. businessHours: this.parseContextBusinessHours(calendarContext),
  7125. dateSelection: reduceDateSelection(state.dateSelection, action),
  7126. eventSelection: reduceSelectedEvent(state.eventSelection, action),
  7127. eventDrag: reduceEventDrag(state.eventDrag, action),
  7128. eventResize: reduceEventResize(state.eventResize, action),
  7129. };
  7130. var contextAndState = __assign(__assign({}, calendarContext), newState);
  7131. for (var _i = 0, _c = optionsData.pluginHooks.reducers; _i < _c.length; _i++) {
  7132. var reducer = _c[_i];
  7133. __assign(newState, reducer(state, action, contextAndState)); // give the OLD state, for old value
  7134. }
  7135. var wasLoading = computeIsLoading(state, calendarContext);
  7136. var isLoading = computeIsLoading(newState, calendarContext);
  7137. // TODO: use propSetHandlers in plugin system
  7138. if (!wasLoading && isLoading) {
  7139. emitter.trigger('loading', true);
  7140. }
  7141. else if (wasLoading && !isLoading) {
  7142. emitter.trigger('loading', false);
  7143. }
  7144. this.state = newState;
  7145. if (props.onAction) {
  7146. props.onAction(action);
  7147. }
  7148. };
  7149. CalendarDataManager.prototype.updateData = function () {
  7150. var _a = this, props = _a.props, state = _a.state;
  7151. var oldData = this.data;
  7152. var optionsData = this.computeOptionsData(props.optionOverrides, state.dynamicOptionOverrides, props.calendarApi);
  7153. var currentViewData = this.computeCurrentViewData(state.currentViewType, optionsData, props.optionOverrides, state.dynamicOptionOverrides);
  7154. var data = this.data = __assign(__assign(__assign({ viewTitle: this.buildTitle(state.dateProfile, currentViewData.options, optionsData.dateEnv), calendarApi: props.calendarApi, dispatch: this.dispatch, emitter: this.emitter, getCurrentData: this.getCurrentData }, optionsData), currentViewData), state);
  7155. var changeHandlers = optionsData.pluginHooks.optionChangeHandlers;
  7156. var oldCalendarOptions = oldData && oldData.calendarOptions;
  7157. var newCalendarOptions = optionsData.calendarOptions;
  7158. if (oldCalendarOptions && oldCalendarOptions !== newCalendarOptions) {
  7159. if (oldCalendarOptions.timeZone !== newCalendarOptions.timeZone) {
  7160. // hack
  7161. state.eventSources = data.eventSources = reduceEventSourcesNewTimeZone(data.eventSources, state.dateProfile, data);
  7162. state.eventStore = data.eventStore = rezoneEventStoreDates(data.eventStore, oldData.dateEnv, data.dateEnv);
  7163. }
  7164. for (var optionName in changeHandlers) {
  7165. if (oldCalendarOptions[optionName] !== newCalendarOptions[optionName]) {
  7166. changeHandlers[optionName](newCalendarOptions[optionName], data);
  7167. }
  7168. }
  7169. }
  7170. if (props.onData) {
  7171. props.onData(data);
  7172. }
  7173. };
  7174. CalendarDataManager.prototype._computeOptionsData = function (optionOverrides, dynamicOptionOverrides, calendarApi) {
  7175. // TODO: blacklist options that are handled by optionChangeHandlers
  7176. var _a = this.processRawCalendarOptions(optionOverrides, dynamicOptionOverrides), refinedOptions = _a.refinedOptions, pluginHooks = _a.pluginHooks, localeDefaults = _a.localeDefaults, availableLocaleData = _a.availableLocaleData, extra = _a.extra;
  7177. warnUnknownOptions(extra);
  7178. var dateEnv = this.buildDateEnv(refinedOptions.timeZone, refinedOptions.locale, refinedOptions.weekNumberCalculation, refinedOptions.firstDay, refinedOptions.weekText, pluginHooks, availableLocaleData, refinedOptions.defaultRangeSeparator);
  7179. var viewSpecs = this.buildViewSpecs(pluginHooks.views, optionOverrides, dynamicOptionOverrides, localeDefaults);
  7180. var theme = this.buildTheme(refinedOptions, pluginHooks);
  7181. var toolbarConfig = this.parseToolbars(refinedOptions, optionOverrides, theme, viewSpecs, calendarApi);
  7182. return {
  7183. calendarOptions: refinedOptions,
  7184. pluginHooks: pluginHooks,
  7185. dateEnv: dateEnv,
  7186. viewSpecs: viewSpecs,
  7187. theme: theme,
  7188. toolbarConfig: toolbarConfig,
  7189. localeDefaults: localeDefaults,
  7190. availableRawLocales: availableLocaleData.map,
  7191. };
  7192. };
  7193. // always called from behind a memoizer
  7194. CalendarDataManager.prototype.processRawCalendarOptions = function (optionOverrides, dynamicOptionOverrides) {
  7195. var _a = mergeRawOptions([
  7196. BASE_OPTION_DEFAULTS,
  7197. optionOverrides,
  7198. dynamicOptionOverrides,
  7199. ]), locales = _a.locales, locale = _a.locale;
  7200. var availableLocaleData = this.organizeRawLocales(locales);
  7201. var availableRawLocales = availableLocaleData.map;
  7202. var localeDefaults = this.buildLocale(locale || availableLocaleData.defaultCode, availableRawLocales).options;
  7203. var pluginHooks = this.buildPluginHooks(optionOverrides.plugins || [], globalPlugins);
  7204. var refiners = this.currentCalendarOptionsRefiners = __assign(__assign(__assign(__assign(__assign({}, BASE_OPTION_REFINERS), CALENDAR_LISTENER_REFINERS), CALENDAR_OPTION_REFINERS), pluginHooks.listenerRefiners), pluginHooks.optionRefiners);
  7205. var extra = {};
  7206. var raw = mergeRawOptions([
  7207. BASE_OPTION_DEFAULTS,
  7208. localeDefaults,
  7209. optionOverrides,
  7210. dynamicOptionOverrides,
  7211. ]);
  7212. var refined = {};
  7213. var currentRaw = this.currentCalendarOptionsInput;
  7214. var currentRefined = this.currentCalendarOptionsRefined;
  7215. var anyChanges = false;
  7216. for (var optionName in raw) {
  7217. if (optionName !== 'plugins') { // because plugins is special-cased
  7218. if (raw[optionName] === currentRaw[optionName] ||
  7219. (COMPLEX_OPTION_COMPARATORS[optionName] &&
  7220. (optionName in currentRaw) &&
  7221. COMPLEX_OPTION_COMPARATORS[optionName](currentRaw[optionName], raw[optionName]))) {
  7222. refined[optionName] = currentRefined[optionName];
  7223. }
  7224. else if (refiners[optionName]) {
  7225. refined[optionName] = refiners[optionName](raw[optionName]);
  7226. anyChanges = true;
  7227. }
  7228. else {
  7229. extra[optionName] = currentRaw[optionName];
  7230. }
  7231. }
  7232. }
  7233. if (anyChanges) {
  7234. this.currentCalendarOptionsInput = raw;
  7235. this.currentCalendarOptionsRefined = refined;
  7236. }
  7237. return {
  7238. rawOptions: this.currentCalendarOptionsInput,
  7239. refinedOptions: this.currentCalendarOptionsRefined,
  7240. pluginHooks: pluginHooks,
  7241. availableLocaleData: availableLocaleData,
  7242. localeDefaults: localeDefaults,
  7243. extra: extra,
  7244. };
  7245. };
  7246. CalendarDataManager.prototype._computeCurrentViewData = function (viewType, optionsData, optionOverrides, dynamicOptionOverrides) {
  7247. var viewSpec = optionsData.viewSpecs[viewType];
  7248. if (!viewSpec) {
  7249. throw new Error("viewType \"" + viewType + "\" is not available. Please make sure you've loaded all neccessary plugins");
  7250. }
  7251. var _a = this.processRawViewOptions(viewSpec, optionsData.pluginHooks, optionsData.localeDefaults, optionOverrides, dynamicOptionOverrides), refinedOptions = _a.refinedOptions, extra = _a.extra;
  7252. warnUnknownOptions(extra);
  7253. var dateProfileGenerator = this.buildDateProfileGenerator({
  7254. dateProfileGeneratorClass: viewSpec.optionDefaults.dateProfileGeneratorClass,
  7255. duration: viewSpec.duration,
  7256. durationUnit: viewSpec.durationUnit,
  7257. usesMinMaxTime: viewSpec.optionDefaults.usesMinMaxTime,
  7258. dateEnv: optionsData.dateEnv,
  7259. calendarApi: this.props.calendarApi,
  7260. slotMinTime: refinedOptions.slotMinTime,
  7261. slotMaxTime: refinedOptions.slotMaxTime,
  7262. showNonCurrentDates: refinedOptions.showNonCurrentDates,
  7263. dayCount: refinedOptions.dayCount,
  7264. dateAlignment: refinedOptions.dateAlignment,
  7265. dateIncrement: refinedOptions.dateIncrement,
  7266. hiddenDays: refinedOptions.hiddenDays,
  7267. weekends: refinedOptions.weekends,
  7268. nowInput: refinedOptions.now,
  7269. validRangeInput: refinedOptions.validRange,
  7270. visibleRangeInput: refinedOptions.visibleRange,
  7271. monthMode: refinedOptions.monthMode,
  7272. fixedWeekCount: refinedOptions.fixedWeekCount,
  7273. });
  7274. var viewApi = this.buildViewApi(viewType, this.getCurrentData, optionsData.dateEnv);
  7275. return { viewSpec: viewSpec, options: refinedOptions, dateProfileGenerator: dateProfileGenerator, viewApi: viewApi };
  7276. };
  7277. CalendarDataManager.prototype.processRawViewOptions = function (viewSpec, pluginHooks, localeDefaults, optionOverrides, dynamicOptionOverrides) {
  7278. var raw = mergeRawOptions([
  7279. BASE_OPTION_DEFAULTS,
  7280. viewSpec.optionDefaults,
  7281. localeDefaults,
  7282. optionOverrides,
  7283. viewSpec.optionOverrides,
  7284. dynamicOptionOverrides,
  7285. ]);
  7286. var refiners = __assign(__assign(__assign(__assign(__assign(__assign({}, BASE_OPTION_REFINERS), CALENDAR_LISTENER_REFINERS), CALENDAR_OPTION_REFINERS), VIEW_OPTION_REFINERS), pluginHooks.listenerRefiners), pluginHooks.optionRefiners);
  7287. var refined = {};
  7288. var currentRaw = this.currentViewOptionsInput;
  7289. var currentRefined = this.currentViewOptionsRefined;
  7290. var anyChanges = false;
  7291. var extra = {};
  7292. for (var optionName in raw) {
  7293. if (raw[optionName] === currentRaw[optionName]) {
  7294. refined[optionName] = currentRefined[optionName];
  7295. }
  7296. else {
  7297. if (raw[optionName] === this.currentCalendarOptionsInput[optionName]) {
  7298. if (optionName in this.currentCalendarOptionsRefined) { // might be an "extra" prop
  7299. refined[optionName] = this.currentCalendarOptionsRefined[optionName];
  7300. }
  7301. }
  7302. else if (refiners[optionName]) {
  7303. refined[optionName] = refiners[optionName](raw[optionName]);
  7304. }
  7305. else {
  7306. extra[optionName] = raw[optionName];
  7307. }
  7308. anyChanges = true;
  7309. }
  7310. }
  7311. if (anyChanges) {
  7312. this.currentViewOptionsInput = raw;
  7313. this.currentViewOptionsRefined = refined;
  7314. }
  7315. return {
  7316. rawOptions: this.currentViewOptionsInput,
  7317. refinedOptions: this.currentViewOptionsRefined,
  7318. extra: extra,
  7319. };
  7320. };
  7321. return CalendarDataManager;
  7322. }());
  7323. function buildDateEnv(timeZone, explicitLocale, weekNumberCalculation, firstDay, weekText, pluginHooks, availableLocaleData, defaultSeparator) {
  7324. var locale = buildLocale(explicitLocale || availableLocaleData.defaultCode, availableLocaleData.map);
  7325. return new DateEnv({
  7326. calendarSystem: 'gregory',
  7327. timeZone: timeZone,
  7328. namedTimeZoneImpl: pluginHooks.namedTimeZonedImpl,
  7329. locale: locale,
  7330. weekNumberCalculation: weekNumberCalculation,
  7331. firstDay: firstDay,
  7332. weekText: weekText,
  7333. cmdFormatter: pluginHooks.cmdFormatter,
  7334. defaultSeparator: defaultSeparator,
  7335. });
  7336. }
  7337. function buildTheme(options, pluginHooks) {
  7338. var ThemeClass = pluginHooks.themeClasses[options.themeSystem] || StandardTheme;
  7339. return new ThemeClass(options);
  7340. }
  7341. function buildDateProfileGenerator(props) {
  7342. var DateProfileGeneratorClass = props.dateProfileGeneratorClass || DateProfileGenerator;
  7343. return new DateProfileGeneratorClass(props);
  7344. }
  7345. function buildViewApi(type, getCurrentData, dateEnv) {
  7346. return new ViewApi(type, getCurrentData, dateEnv);
  7347. }
  7348. function buildEventUiBySource(eventSources) {
  7349. return mapHash(eventSources, function (eventSource) { return eventSource.ui; });
  7350. }
  7351. function buildEventUiBases(eventDefs, eventUiSingleBase, eventUiBySource) {
  7352. var eventUiBases = { '': eventUiSingleBase };
  7353. for (var defId in eventDefs) {
  7354. var def = eventDefs[defId];
  7355. if (def.sourceId && eventUiBySource[def.sourceId]) {
  7356. eventUiBases[defId] = eventUiBySource[def.sourceId];
  7357. }
  7358. }
  7359. return eventUiBases;
  7360. }
  7361. function buildViewUiProps(calendarContext) {
  7362. var options = calendarContext.options;
  7363. return {
  7364. eventUiSingleBase: createEventUi({
  7365. display: options.eventDisplay,
  7366. editable: options.editable,
  7367. startEditable: options.eventStartEditable,
  7368. durationEditable: options.eventDurationEditable,
  7369. constraint: options.eventConstraint,
  7370. overlap: typeof options.eventOverlap === 'boolean' ? options.eventOverlap : undefined,
  7371. allow: options.eventAllow,
  7372. backgroundColor: options.eventBackgroundColor,
  7373. borderColor: options.eventBorderColor,
  7374. textColor: options.eventTextColor,
  7375. color: options.eventColor,
  7376. // classNames: options.eventClassNames // render hook will handle this
  7377. }, calendarContext),
  7378. selectionConfig: createEventUi({
  7379. constraint: options.selectConstraint,
  7380. overlap: typeof options.selectOverlap === 'boolean' ? options.selectOverlap : undefined,
  7381. allow: options.selectAllow,
  7382. }, calendarContext),
  7383. };
  7384. }
  7385. function computeIsLoading(state, context) {
  7386. for (var _i = 0, _a = context.pluginHooks.isLoadingFuncs; _i < _a.length; _i++) {
  7387. var isLoadingFunc = _a[_i];
  7388. if (isLoadingFunc(state)) {
  7389. return true;
  7390. }
  7391. }
  7392. return false;
  7393. }
  7394. function parseContextBusinessHours(calendarContext) {
  7395. return parseBusinessHours(calendarContext.options.businessHours, calendarContext);
  7396. }
  7397. function warnUnknownOptions(options, viewName) {
  7398. for (var optionName in options) {
  7399. console.warn("Unknown option '" + optionName + "'" +
  7400. (viewName ? " for view '" + viewName + "'" : ''));
  7401. }
  7402. }
  7403. // TODO: move this to react plugin?
  7404. var CalendarDataProvider = /** @class */ (function (_super) {
  7405. __extends(CalendarDataProvider, _super);
  7406. function CalendarDataProvider(props) {
  7407. var _this = _super.call(this, props) || this;
  7408. _this.handleData = function (data) {
  7409. if (!_this.dataManager) { // still within initial run, before assignment in constructor
  7410. // eslint-disable-next-line react/no-direct-mutation-state
  7411. _this.state = data; // can't use setState yet
  7412. }
  7413. else {
  7414. _this.setState(data);
  7415. }
  7416. };
  7417. _this.dataManager = new CalendarDataManager({
  7418. optionOverrides: props.optionOverrides,
  7419. calendarApi: props.calendarApi,
  7420. onData: _this.handleData,
  7421. });
  7422. return _this;
  7423. }
  7424. CalendarDataProvider.prototype.render = function () {
  7425. return this.props.children(this.state);
  7426. };
  7427. CalendarDataProvider.prototype.componentDidUpdate = function (prevProps) {
  7428. var newOptionOverrides = this.props.optionOverrides;
  7429. if (newOptionOverrides !== prevProps.optionOverrides) { // prevent recursive handleData
  7430. this.dataManager.resetOptions(newOptionOverrides);
  7431. }
  7432. };
  7433. return CalendarDataProvider;
  7434. }(Component));
  7435. // HELPERS
  7436. /*
  7437. if nextDayThreshold is specified, slicing is done in an all-day fashion.
  7438. you can get nextDayThreshold from context.nextDayThreshold
  7439. */
  7440. function sliceEvents(props, allDay) {
  7441. return sliceEventStore(props.eventStore, props.eventUiBases, props.dateProfile.activeRange, allDay ? props.nextDayThreshold : null).fg;
  7442. }
  7443. var NamedTimeZoneImpl = /** @class */ (function () {
  7444. function NamedTimeZoneImpl(timeZoneName) {
  7445. this.timeZoneName = timeZoneName;
  7446. }
  7447. return NamedTimeZoneImpl;
  7448. }());
  7449. var SegHierarchy = /** @class */ (function () {
  7450. function SegHierarchy() {
  7451. // settings
  7452. this.strictOrder = false;
  7453. this.allowReslicing = false;
  7454. this.maxCoord = -1; // -1 means no max
  7455. this.maxStackCnt = -1; // -1 means no max
  7456. this.levelCoords = []; // ordered
  7457. this.entriesByLevel = []; // parallel with levelCoords
  7458. this.stackCnts = {}; // TODO: use better technique!?
  7459. }
  7460. SegHierarchy.prototype.addSegs = function (inputs) {
  7461. var hiddenEntries = [];
  7462. for (var _i = 0, inputs_1 = inputs; _i < inputs_1.length; _i++) {
  7463. var input = inputs_1[_i];
  7464. this.insertEntry(input, hiddenEntries);
  7465. }
  7466. return hiddenEntries;
  7467. };
  7468. SegHierarchy.prototype.insertEntry = function (entry, hiddenEntries) {
  7469. var insertion = this.findInsertion(entry);
  7470. if (this.isInsertionValid(insertion, entry)) {
  7471. this.insertEntryAt(entry, insertion);
  7472. return 1;
  7473. }
  7474. return this.handleInvalidInsertion(insertion, entry, hiddenEntries);
  7475. };
  7476. SegHierarchy.prototype.isInsertionValid = function (insertion, entry) {
  7477. return (this.maxCoord === -1 || insertion.levelCoord + entry.thickness <= this.maxCoord) &&
  7478. (this.maxStackCnt === -1 || insertion.stackCnt < this.maxStackCnt);
  7479. };
  7480. // returns number of new entries inserted
  7481. SegHierarchy.prototype.handleInvalidInsertion = function (insertion, entry, hiddenEntries) {
  7482. if (this.allowReslicing && insertion.touchingEntry) {
  7483. return this.splitEntry(entry, insertion.touchingEntry, hiddenEntries);
  7484. }
  7485. hiddenEntries.push(entry);
  7486. return 0;
  7487. };
  7488. SegHierarchy.prototype.splitEntry = function (entry, barrier, hiddenEntries) {
  7489. var partCnt = 0;
  7490. var splitHiddenEntries = [];
  7491. var entrySpan = entry.span;
  7492. var barrierSpan = barrier.span;
  7493. if (entrySpan.start < barrierSpan.start) {
  7494. partCnt += this.insertEntry({
  7495. index: entry.index,
  7496. thickness: entry.thickness,
  7497. span: { start: entrySpan.start, end: barrierSpan.start },
  7498. }, splitHiddenEntries);
  7499. }
  7500. if (entrySpan.end > barrierSpan.end) {
  7501. partCnt += this.insertEntry({
  7502. index: entry.index,
  7503. thickness: entry.thickness,
  7504. span: { start: barrierSpan.end, end: entrySpan.end },
  7505. }, splitHiddenEntries);
  7506. }
  7507. if (partCnt) {
  7508. hiddenEntries.push.apply(hiddenEntries, __spreadArray([{
  7509. index: entry.index,
  7510. thickness: entry.thickness,
  7511. span: intersectSpans(barrierSpan, entrySpan), // guaranteed to intersect
  7512. }], splitHiddenEntries));
  7513. return partCnt;
  7514. }
  7515. hiddenEntries.push(entry);
  7516. return 0;
  7517. };
  7518. SegHierarchy.prototype.insertEntryAt = function (entry, insertion) {
  7519. var _a = this, entriesByLevel = _a.entriesByLevel, levelCoords = _a.levelCoords;
  7520. if (insertion.lateral === -1) {
  7521. // create a new level
  7522. insertAt(levelCoords, insertion.level, insertion.levelCoord);
  7523. insertAt(entriesByLevel, insertion.level, [entry]);
  7524. }
  7525. else {
  7526. // insert into existing level
  7527. insertAt(entriesByLevel[insertion.level], insertion.lateral, entry);
  7528. }
  7529. this.stackCnts[buildEntryKey(entry)] = insertion.stackCnt;
  7530. };
  7531. SegHierarchy.prototype.findInsertion = function (newEntry) {
  7532. var _a = this, levelCoords = _a.levelCoords, entriesByLevel = _a.entriesByLevel, strictOrder = _a.strictOrder, stackCnts = _a.stackCnts;
  7533. var levelCnt = levelCoords.length;
  7534. var candidateCoord = 0;
  7535. var touchingLevel = -1;
  7536. var touchingLateral = -1;
  7537. var touchingEntry = null;
  7538. var stackCnt = 0;
  7539. for (var trackingLevel = 0; trackingLevel < levelCnt; trackingLevel += 1) {
  7540. var trackingCoord = levelCoords[trackingLevel];
  7541. // if the current level is past the placed entry, we have found a good empty space and can stop.
  7542. // if strictOrder, keep finding more lateral intersections.
  7543. if (!strictOrder && trackingCoord >= candidateCoord + newEntry.thickness) {
  7544. break;
  7545. }
  7546. var trackingEntries = entriesByLevel[trackingLevel];
  7547. var trackingEntry = void 0;
  7548. var searchRes = binarySearch(trackingEntries, newEntry.span.start, getEntrySpanEnd); // find first entry after newEntry's end
  7549. var lateralIndex = searchRes[0] + searchRes[1]; // if exact match (which doesn't collide), go to next one
  7550. while ( // loop through entries that horizontally intersect
  7551. (trackingEntry = trackingEntries[lateralIndex]) && // but not past the whole entry list
  7552. trackingEntry.span.start < newEntry.span.end // and not entirely past newEntry
  7553. ) {
  7554. var trackingEntryBottom = trackingCoord + trackingEntry.thickness;
  7555. // intersects into the top of the candidate?
  7556. if (trackingEntryBottom > candidateCoord) {
  7557. candidateCoord = trackingEntryBottom;
  7558. touchingEntry = trackingEntry;
  7559. touchingLevel = trackingLevel;
  7560. touchingLateral = lateralIndex;
  7561. }
  7562. // butts up against top of candidate? (will happen if just intersected as well)
  7563. if (trackingEntryBottom === candidateCoord) {
  7564. // accumulate the highest possible stackCnt of the trackingEntries that butt up
  7565. stackCnt = Math.max(stackCnt, stackCnts[buildEntryKey(trackingEntry)] + 1);
  7566. }
  7567. lateralIndex += 1;
  7568. }
  7569. }
  7570. // the destination level will be after touchingEntry's level. find it
  7571. var destLevel = 0;
  7572. if (touchingEntry) {
  7573. destLevel = touchingLevel + 1;
  7574. while (destLevel < levelCnt && levelCoords[destLevel] < candidateCoord) {
  7575. destLevel += 1;
  7576. }
  7577. }
  7578. // if adding to an existing level, find where to insert
  7579. var destLateral = -1;
  7580. if (destLevel < levelCnt && levelCoords[destLevel] === candidateCoord) {
  7581. destLateral = binarySearch(entriesByLevel[destLevel], newEntry.span.end, getEntrySpanEnd)[0];
  7582. }
  7583. return {
  7584. touchingLevel: touchingLevel,
  7585. touchingLateral: touchingLateral,
  7586. touchingEntry: touchingEntry,
  7587. stackCnt: stackCnt,
  7588. levelCoord: candidateCoord,
  7589. level: destLevel,
  7590. lateral: destLateral,
  7591. };
  7592. };
  7593. // sorted by levelCoord (lowest to highest)
  7594. SegHierarchy.prototype.toRects = function () {
  7595. var _a = this, entriesByLevel = _a.entriesByLevel, levelCoords = _a.levelCoords;
  7596. var levelCnt = entriesByLevel.length;
  7597. var rects = [];
  7598. for (var level = 0; level < levelCnt; level += 1) {
  7599. var entries = entriesByLevel[level];
  7600. var levelCoord = levelCoords[level];
  7601. for (var _i = 0, entries_1 = entries; _i < entries_1.length; _i++) {
  7602. var entry = entries_1[_i];
  7603. rects.push(__assign(__assign({}, entry), { levelCoord: levelCoord }));
  7604. }
  7605. }
  7606. return rects;
  7607. };
  7608. return SegHierarchy;
  7609. }());
  7610. function getEntrySpanEnd(entry) {
  7611. return entry.span.end;
  7612. }
  7613. function buildEntryKey(entry) {
  7614. return entry.index + ':' + entry.span.start;
  7615. }
  7616. // returns groups with entries sorted by input order
  7617. function groupIntersectingEntries(entries) {
  7618. var merges = [];
  7619. for (var _i = 0, entries_2 = entries; _i < entries_2.length; _i++) {
  7620. var entry = entries_2[_i];
  7621. var filteredMerges = [];
  7622. var hungryMerge = {
  7623. span: entry.span,
  7624. entries: [entry],
  7625. };
  7626. for (var _a = 0, merges_1 = merges; _a < merges_1.length; _a++) {
  7627. var merge = merges_1[_a];
  7628. if (intersectSpans(merge.span, hungryMerge.span)) {
  7629. hungryMerge = {
  7630. entries: merge.entries.concat(hungryMerge.entries),
  7631. span: joinSpans(merge.span, hungryMerge.span),
  7632. };
  7633. }
  7634. else {
  7635. filteredMerges.push(merge);
  7636. }
  7637. }
  7638. filteredMerges.push(hungryMerge);
  7639. merges = filteredMerges;
  7640. }
  7641. return merges;
  7642. }
  7643. function joinSpans(span0, span1) {
  7644. return {
  7645. start: Math.min(span0.start, span1.start),
  7646. end: Math.max(span0.end, span1.end),
  7647. };
  7648. }
  7649. function intersectSpans(span0, span1) {
  7650. var start = Math.max(span0.start, span1.start);
  7651. var end = Math.min(span0.end, span1.end);
  7652. if (start < end) {
  7653. return { start: start, end: end };
  7654. }
  7655. return null;
  7656. }
  7657. // general util
  7658. // ---------------------------------------------------------------------------------------------------------------------
  7659. function insertAt(arr, index, item) {
  7660. arr.splice(index, 0, item);
  7661. }
  7662. function binarySearch(a, searchVal, getItemVal) {
  7663. var startIndex = 0;
  7664. var endIndex = a.length; // exclusive
  7665. if (!endIndex || searchVal < getItemVal(a[startIndex])) { // no items OR before first item
  7666. return [0, 0];
  7667. }
  7668. if (searchVal > getItemVal(a[endIndex - 1])) { // after last item
  7669. return [endIndex, 0];
  7670. }
  7671. while (startIndex < endIndex) {
  7672. var middleIndex = Math.floor(startIndex + (endIndex - startIndex) / 2);
  7673. var middleVal = getItemVal(a[middleIndex]);
  7674. if (searchVal < middleVal) {
  7675. endIndex = middleIndex;
  7676. }
  7677. else if (searchVal > middleVal) {
  7678. startIndex = middleIndex + 1;
  7679. }
  7680. else { // equal!
  7681. return [middleIndex, 1];
  7682. }
  7683. }
  7684. return [startIndex, 0];
  7685. }
  7686. var Interaction = /** @class */ (function () {
  7687. function Interaction(settings) {
  7688. this.component = settings.component;
  7689. this.isHitComboAllowed = settings.isHitComboAllowed || null;
  7690. }
  7691. Interaction.prototype.destroy = function () {
  7692. };
  7693. return Interaction;
  7694. }());
  7695. function parseInteractionSettings(component, input) {
  7696. return {
  7697. component: component,
  7698. el: input.el,
  7699. useEventCenter: input.useEventCenter != null ? input.useEventCenter : true,
  7700. isHitComboAllowed: input.isHitComboAllowed || null,
  7701. };
  7702. }
  7703. function interactionSettingsToStore(settings) {
  7704. var _a;
  7705. return _a = {},
  7706. _a[settings.component.uid] = settings,
  7707. _a;
  7708. }
  7709. // global state
  7710. var interactionSettingsStore = {};
  7711. /*
  7712. An abstraction for a dragging interaction originating on an event.
  7713. Does higher-level things than PointerDragger, such as possibly:
  7714. - a "mirror" that moves with the pointer
  7715. - a minimum number of pixels or other criteria for a true drag to begin
  7716. subclasses must emit:
  7717. - pointerdown
  7718. - dragstart
  7719. - dragmove
  7720. - pointerup
  7721. - dragend
  7722. */
  7723. var ElementDragging = /** @class */ (function () {
  7724. function ElementDragging(el, selector) {
  7725. this.emitter = new Emitter();
  7726. }
  7727. ElementDragging.prototype.destroy = function () {
  7728. };
  7729. ElementDragging.prototype.setMirrorIsVisible = function (bool) {
  7730. // optional if subclass doesn't want to support a mirror
  7731. };
  7732. ElementDragging.prototype.setMirrorNeedsRevert = function (bool) {
  7733. // optional if subclass doesn't want to support a mirror
  7734. };
  7735. ElementDragging.prototype.setAutoScrollEnabled = function (bool) {
  7736. // optional
  7737. };
  7738. return ElementDragging;
  7739. }());
  7740. // TODO: get rid of this in favor of options system,
  7741. // tho it's really easy to access this globally rather than pass thru options.
  7742. var config = {};
  7743. /*
  7744. Information about what will happen when an external element is dragged-and-dropped
  7745. onto a calendar. Contains information for creating an event.
  7746. */
  7747. var DRAG_META_REFINERS = {
  7748. startTime: createDuration,
  7749. duration: createDuration,
  7750. create: Boolean,
  7751. sourceId: String,
  7752. };
  7753. function parseDragMeta(raw) {
  7754. var _a = refineProps(raw, DRAG_META_REFINERS), refined = _a.refined, extra = _a.extra;
  7755. return {
  7756. startTime: refined.startTime || null,
  7757. duration: refined.duration || null,
  7758. create: refined.create != null ? refined.create : true,
  7759. sourceId: refined.sourceId,
  7760. leftoverProps: extra,
  7761. };
  7762. }
  7763. var ToolbarSection = /** @class */ (function (_super) {
  7764. __extends(ToolbarSection, _super);
  7765. function ToolbarSection() {
  7766. return _super !== null && _super.apply(this, arguments) || this;
  7767. }
  7768. ToolbarSection.prototype.render = function () {
  7769. var _this = this;
  7770. var children = this.props.widgetGroups.map(function (widgetGroup) { return _this.renderWidgetGroup(widgetGroup); });
  7771. return createElement.apply(void 0, __spreadArray(['div', { className: 'fc-toolbar-chunk' }], children));
  7772. };
  7773. ToolbarSection.prototype.renderWidgetGroup = function (widgetGroup) {
  7774. var props = this.props;
  7775. var theme = this.context.theme;
  7776. var children = [];
  7777. var isOnlyButtons = true;
  7778. for (var _i = 0, widgetGroup_1 = widgetGroup; _i < widgetGroup_1.length; _i++) {
  7779. var widget = widgetGroup_1[_i];
  7780. var buttonName = widget.buttonName, buttonClick = widget.buttonClick, buttonText = widget.buttonText, buttonIcon = widget.buttonIcon, buttonHint = widget.buttonHint;
  7781. if (buttonName === 'title') {
  7782. isOnlyButtons = false;
  7783. children.push(createElement("h2", { className: "fc-toolbar-title", id: props.titleId }, props.title));
  7784. }
  7785. else {
  7786. var isPressed = buttonName === props.activeButton;
  7787. var isDisabled = (!props.isTodayEnabled && buttonName === 'today') ||
  7788. (!props.isPrevEnabled && buttonName === 'prev') ||
  7789. (!props.isNextEnabled && buttonName === 'next');
  7790. var buttonClasses = ["fc-" + buttonName + "-button", theme.getClass('button')];
  7791. if (isPressed) {
  7792. buttonClasses.push(theme.getClass('buttonActive'));
  7793. }
  7794. children.push(createElement("button", { type: "button", title: typeof buttonHint === 'function' ? buttonHint(props.navUnit) : buttonHint, disabled: isDisabled, "aria-pressed": isPressed, className: buttonClasses.join(' '), onClick: buttonClick }, buttonText || (buttonIcon ? createElement("span", { className: buttonIcon }) : '')));
  7795. }
  7796. }
  7797. if (children.length > 1) {
  7798. var groupClassName = (isOnlyButtons && theme.getClass('buttonGroup')) || '';
  7799. return createElement.apply(void 0, __spreadArray(['div', { className: groupClassName }], children));
  7800. }
  7801. return children[0];
  7802. };
  7803. return ToolbarSection;
  7804. }(BaseComponent));
  7805. var Toolbar = /** @class */ (function (_super) {
  7806. __extends(Toolbar, _super);
  7807. function Toolbar() {
  7808. return _super !== null && _super.apply(this, arguments) || this;
  7809. }
  7810. Toolbar.prototype.render = function () {
  7811. var _a = this.props, model = _a.model, extraClassName = _a.extraClassName;
  7812. var forceLtr = false;
  7813. var startContent;
  7814. var endContent;
  7815. var sectionWidgets = model.sectionWidgets;
  7816. var centerContent = sectionWidgets.center;
  7817. if (sectionWidgets.left) {
  7818. forceLtr = true;
  7819. startContent = sectionWidgets.left;
  7820. }
  7821. else {
  7822. startContent = sectionWidgets.start;
  7823. }
  7824. if (sectionWidgets.right) {
  7825. forceLtr = true;
  7826. endContent = sectionWidgets.right;
  7827. }
  7828. else {
  7829. endContent = sectionWidgets.end;
  7830. }
  7831. var classNames = [
  7832. extraClassName || '',
  7833. 'fc-toolbar',
  7834. forceLtr ? 'fc-toolbar-ltr' : '',
  7835. ];
  7836. return (createElement("div", { className: classNames.join(' ') },
  7837. this.renderSection('start', startContent || []),
  7838. this.renderSection('center', centerContent || []),
  7839. this.renderSection('end', endContent || [])));
  7840. };
  7841. Toolbar.prototype.renderSection = function (key, widgetGroups) {
  7842. var props = this.props;
  7843. return (createElement(ToolbarSection, { key: key, widgetGroups: widgetGroups, title: props.title, navUnit: props.navUnit, activeButton: props.activeButton, isTodayEnabled: props.isTodayEnabled, isPrevEnabled: props.isPrevEnabled, isNextEnabled: props.isNextEnabled, titleId: props.titleId }));
  7844. };
  7845. return Toolbar;
  7846. }(BaseComponent));
  7847. // TODO: do function component?
  7848. var ViewContainer = /** @class */ (function (_super) {
  7849. __extends(ViewContainer, _super);
  7850. function ViewContainer() {
  7851. var _this = _super !== null && _super.apply(this, arguments) || this;
  7852. _this.state = {
  7853. availableWidth: null,
  7854. };
  7855. _this.handleEl = function (el) {
  7856. _this.el = el;
  7857. setRef(_this.props.elRef, el);
  7858. _this.updateAvailableWidth();
  7859. };
  7860. _this.handleResize = function () {
  7861. _this.updateAvailableWidth();
  7862. };
  7863. return _this;
  7864. }
  7865. ViewContainer.prototype.render = function () {
  7866. var _a = this, props = _a.props, state = _a.state;
  7867. var aspectRatio = props.aspectRatio;
  7868. var classNames = [
  7869. 'fc-view-harness',
  7870. (aspectRatio || props.liquid || props.height)
  7871. ? 'fc-view-harness-active' // harness controls the height
  7872. : 'fc-view-harness-passive', // let the view do the height
  7873. ];
  7874. var height = '';
  7875. var paddingBottom = '';
  7876. if (aspectRatio) {
  7877. if (state.availableWidth !== null) {
  7878. height = state.availableWidth / aspectRatio;
  7879. }
  7880. else {
  7881. // while waiting to know availableWidth, we can't set height to *zero*
  7882. // because will cause lots of unnecessary scrollbars within scrollgrid.
  7883. // BETTER: don't start rendering ANYTHING yet until we know container width
  7884. // NOTE: why not always use paddingBottom? Causes height oscillation (issue 5606)
  7885. paddingBottom = (1 / aspectRatio) * 100 + "%";
  7886. }
  7887. }
  7888. else {
  7889. height = props.height || '';
  7890. }
  7891. return (createElement("div", { "aria-labelledby": props.labeledById, ref: this.handleEl, className: classNames.join(' '), style: { height: height, paddingBottom: paddingBottom } }, props.children));
  7892. };
  7893. ViewContainer.prototype.componentDidMount = function () {
  7894. this.context.addResizeHandler(this.handleResize);
  7895. };
  7896. ViewContainer.prototype.componentWillUnmount = function () {
  7897. this.context.removeResizeHandler(this.handleResize);
  7898. };
  7899. ViewContainer.prototype.updateAvailableWidth = function () {
  7900. if (this.el && // needed. but why?
  7901. this.props.aspectRatio // aspectRatio is the only height setting that needs availableWidth
  7902. ) {
  7903. this.setState({ availableWidth: this.el.offsetWidth });
  7904. }
  7905. };
  7906. return ViewContainer;
  7907. }(BaseComponent));
  7908. /*
  7909. Detects when the user clicks on an event within a DateComponent
  7910. */
  7911. var EventClicking = /** @class */ (function (_super) {
  7912. __extends(EventClicking, _super);
  7913. function EventClicking(settings) {
  7914. var _this = _super.call(this, settings) || this;
  7915. _this.handleSegClick = function (ev, segEl) {
  7916. var component = _this.component;
  7917. var context = component.context;
  7918. var seg = getElSeg(segEl);
  7919. if (seg && // might be the <div> surrounding the more link
  7920. component.isValidSegDownEl(ev.target)) {
  7921. // our way to simulate a link click for elements that can't be <a> tags
  7922. // grab before trigger fired in case trigger trashes DOM thru rerendering
  7923. var hasUrlContainer = elementClosest(ev.target, '.fc-event-forced-url');
  7924. var url = hasUrlContainer ? hasUrlContainer.querySelector('a[href]').href : '';
  7925. context.emitter.trigger('eventClick', {
  7926. el: segEl,
  7927. event: new EventApi(component.context, seg.eventRange.def, seg.eventRange.instance),
  7928. jsEvent: ev,
  7929. view: context.viewApi,
  7930. });
  7931. if (url && !ev.defaultPrevented) {
  7932. window.location.href = url;
  7933. }
  7934. }
  7935. };
  7936. _this.destroy = listenBySelector(settings.el, 'click', '.fc-event', // on both fg and bg events
  7937. _this.handleSegClick);
  7938. return _this;
  7939. }
  7940. return EventClicking;
  7941. }(Interaction));
  7942. /*
  7943. Triggers events and adds/removes core classNames when the user's pointer
  7944. enters/leaves event-elements of a component.
  7945. */
  7946. var EventHovering = /** @class */ (function (_super) {
  7947. __extends(EventHovering, _super);
  7948. function EventHovering(settings) {
  7949. var _this = _super.call(this, settings) || this;
  7950. // for simulating an eventMouseLeave when the event el is destroyed while mouse is over it
  7951. _this.handleEventElRemove = function (el) {
  7952. if (el === _this.currentSegEl) {
  7953. _this.handleSegLeave(null, _this.currentSegEl);
  7954. }
  7955. };
  7956. _this.handleSegEnter = function (ev, segEl) {
  7957. if (getElSeg(segEl)) { // TODO: better way to make sure not hovering over more+ link or its wrapper
  7958. _this.currentSegEl = segEl;
  7959. _this.triggerEvent('eventMouseEnter', ev, segEl);
  7960. }
  7961. };
  7962. _this.handleSegLeave = function (ev, segEl) {
  7963. if (_this.currentSegEl) {
  7964. _this.currentSegEl = null;
  7965. _this.triggerEvent('eventMouseLeave', ev, segEl);
  7966. }
  7967. };
  7968. _this.removeHoverListeners = listenToHoverBySelector(settings.el, '.fc-event', // on both fg and bg events
  7969. _this.handleSegEnter, _this.handleSegLeave);
  7970. return _this;
  7971. }
  7972. EventHovering.prototype.destroy = function () {
  7973. this.removeHoverListeners();
  7974. };
  7975. EventHovering.prototype.triggerEvent = function (publicEvName, ev, segEl) {
  7976. var component = this.component;
  7977. var context = component.context;
  7978. var seg = getElSeg(segEl);
  7979. if (!ev || component.isValidSegDownEl(ev.target)) {
  7980. context.emitter.trigger(publicEvName, {
  7981. el: segEl,
  7982. event: new EventApi(context, seg.eventRange.def, seg.eventRange.instance),
  7983. jsEvent: ev,
  7984. view: context.viewApi,
  7985. });
  7986. }
  7987. };
  7988. return EventHovering;
  7989. }(Interaction));
  7990. var CalendarContent = /** @class */ (function (_super) {
  7991. __extends(CalendarContent, _super);
  7992. function CalendarContent() {
  7993. var _this = _super !== null && _super.apply(this, arguments) || this;
  7994. _this.buildViewContext = memoize(buildViewContext);
  7995. _this.buildViewPropTransformers = memoize(buildViewPropTransformers);
  7996. _this.buildToolbarProps = memoize(buildToolbarProps);
  7997. _this.headerRef = createRef();
  7998. _this.footerRef = createRef();
  7999. _this.interactionsStore = {};
  8000. // eslint-disable-next-line
  8001. _this.state = {
  8002. viewLabelId: getUniqueDomId(),
  8003. };
  8004. // Component Registration
  8005. // -----------------------------------------------------------------------------------------------------------------
  8006. _this.registerInteractiveComponent = function (component, settingsInput) {
  8007. var settings = parseInteractionSettings(component, settingsInput);
  8008. var DEFAULT_INTERACTIONS = [
  8009. EventClicking,
  8010. EventHovering,
  8011. ];
  8012. var interactionClasses = DEFAULT_INTERACTIONS.concat(_this.props.pluginHooks.componentInteractions);
  8013. var interactions = interactionClasses.map(function (TheInteractionClass) { return new TheInteractionClass(settings); });
  8014. _this.interactionsStore[component.uid] = interactions;
  8015. interactionSettingsStore[component.uid] = settings;
  8016. };
  8017. _this.unregisterInteractiveComponent = function (component) {
  8018. for (var _i = 0, _a = _this.interactionsStore[component.uid]; _i < _a.length; _i++) {
  8019. var listener = _a[_i];
  8020. listener.destroy();
  8021. }
  8022. delete _this.interactionsStore[component.uid];
  8023. delete interactionSettingsStore[component.uid];
  8024. };
  8025. // Resizing
  8026. // -----------------------------------------------------------------------------------------------------------------
  8027. _this.resizeRunner = new DelayedRunner(function () {
  8028. _this.props.emitter.trigger('_resize', true); // should window resizes be considered "forced" ?
  8029. _this.props.emitter.trigger('windowResize', { view: _this.props.viewApi });
  8030. });
  8031. _this.handleWindowResize = function (ev) {
  8032. var options = _this.props.options;
  8033. if (options.handleWindowResize &&
  8034. ev.target === window // avoid jqui events
  8035. ) {
  8036. _this.resizeRunner.request(options.windowResizeDelay);
  8037. }
  8038. };
  8039. return _this;
  8040. }
  8041. /*
  8042. renders INSIDE of an outer div
  8043. */
  8044. CalendarContent.prototype.render = function () {
  8045. var props = this.props;
  8046. var toolbarConfig = props.toolbarConfig, options = props.options;
  8047. var toolbarProps = this.buildToolbarProps(props.viewSpec, props.dateProfile, props.dateProfileGenerator, props.currentDate, getNow(props.options.now, props.dateEnv), // TODO: use NowTimer????
  8048. props.viewTitle);
  8049. var viewVGrow = false;
  8050. var viewHeight = '';
  8051. var viewAspectRatio;
  8052. if (props.isHeightAuto || props.forPrint) {
  8053. viewHeight = '';
  8054. }
  8055. else if (options.height != null) {
  8056. viewVGrow = true;
  8057. }
  8058. else if (options.contentHeight != null) {
  8059. viewHeight = options.contentHeight;
  8060. }
  8061. else {
  8062. viewAspectRatio = Math.max(options.aspectRatio, 0.5); // prevent from getting too tall
  8063. }
  8064. var viewContext = this.buildViewContext(props.viewSpec, props.viewApi, props.options, props.dateProfileGenerator, props.dateEnv, props.theme, props.pluginHooks, props.dispatch, props.getCurrentData, props.emitter, props.calendarApi, this.registerInteractiveComponent, this.unregisterInteractiveComponent);
  8065. var viewLabelId = (toolbarConfig.header && toolbarConfig.header.hasTitle)
  8066. ? this.state.viewLabelId
  8067. : '';
  8068. return (createElement(ViewContextType.Provider, { value: viewContext },
  8069. toolbarConfig.header && (createElement(Toolbar, __assign({ ref: this.headerRef, extraClassName: "fc-header-toolbar", model: toolbarConfig.header, titleId: viewLabelId }, toolbarProps))),
  8070. createElement(ViewContainer, { liquid: viewVGrow, height: viewHeight, aspectRatio: viewAspectRatio, labeledById: viewLabelId },
  8071. this.renderView(props),
  8072. this.buildAppendContent()),
  8073. toolbarConfig.footer && (createElement(Toolbar, __assign({ ref: this.footerRef, extraClassName: "fc-footer-toolbar", model: toolbarConfig.footer, titleId: "" }, toolbarProps)))));
  8074. };
  8075. CalendarContent.prototype.componentDidMount = function () {
  8076. var props = this.props;
  8077. this.calendarInteractions = props.pluginHooks.calendarInteractions
  8078. .map(function (CalendarInteractionClass) { return new CalendarInteractionClass(props); });
  8079. window.addEventListener('resize', this.handleWindowResize);
  8080. var propSetHandlers = props.pluginHooks.propSetHandlers;
  8081. for (var propName in propSetHandlers) {
  8082. propSetHandlers[propName](props[propName], props);
  8083. }
  8084. };
  8085. CalendarContent.prototype.componentDidUpdate = function (prevProps) {
  8086. var props = this.props;
  8087. var propSetHandlers = props.pluginHooks.propSetHandlers;
  8088. for (var propName in propSetHandlers) {
  8089. if (props[propName] !== prevProps[propName]) {
  8090. propSetHandlers[propName](props[propName], props);
  8091. }
  8092. }
  8093. };
  8094. CalendarContent.prototype.componentWillUnmount = function () {
  8095. window.removeEventListener('resize', this.handleWindowResize);
  8096. this.resizeRunner.clear();
  8097. for (var _i = 0, _a = this.calendarInteractions; _i < _a.length; _i++) {
  8098. var interaction = _a[_i];
  8099. interaction.destroy();
  8100. }
  8101. this.props.emitter.trigger('_unmount');
  8102. };
  8103. CalendarContent.prototype.buildAppendContent = function () {
  8104. var props = this.props;
  8105. var children = props.pluginHooks.viewContainerAppends.map(function (buildAppendContent) { return buildAppendContent(props); });
  8106. return createElement.apply(void 0, __spreadArray([Fragment, {}], children));
  8107. };
  8108. CalendarContent.prototype.renderView = function (props) {
  8109. var pluginHooks = props.pluginHooks;
  8110. var viewSpec = props.viewSpec;
  8111. var viewProps = {
  8112. dateProfile: props.dateProfile,
  8113. businessHours: props.businessHours,
  8114. eventStore: props.renderableEventStore,
  8115. eventUiBases: props.eventUiBases,
  8116. dateSelection: props.dateSelection,
  8117. eventSelection: props.eventSelection,
  8118. eventDrag: props.eventDrag,
  8119. eventResize: props.eventResize,
  8120. isHeightAuto: props.isHeightAuto,
  8121. forPrint: props.forPrint,
  8122. };
  8123. var transformers = this.buildViewPropTransformers(pluginHooks.viewPropsTransformers);
  8124. for (var _i = 0, transformers_1 = transformers; _i < transformers_1.length; _i++) {
  8125. var transformer = transformers_1[_i];
  8126. __assign(viewProps, transformer.transform(viewProps, props));
  8127. }
  8128. var ViewComponent = viewSpec.component;
  8129. return (createElement(ViewComponent, __assign({}, viewProps)));
  8130. };
  8131. return CalendarContent;
  8132. }(PureComponent));
  8133. function buildToolbarProps(viewSpec, dateProfile, dateProfileGenerator, currentDate, now, title) {
  8134. // don't force any date-profiles to valid date profiles (the `false`) so that we can tell if it's invalid
  8135. var todayInfo = dateProfileGenerator.build(now, undefined, false); // TODO: need `undefined` or else INFINITE LOOP for some reason
  8136. var prevInfo = dateProfileGenerator.buildPrev(dateProfile, currentDate, false);
  8137. var nextInfo = dateProfileGenerator.buildNext(dateProfile, currentDate, false);
  8138. return {
  8139. title: title,
  8140. activeButton: viewSpec.type,
  8141. navUnit: viewSpec.singleUnit,
  8142. isTodayEnabled: todayInfo.isValid && !rangeContainsMarker(dateProfile.currentRange, now),
  8143. isPrevEnabled: prevInfo.isValid,
  8144. isNextEnabled: nextInfo.isValid,
  8145. };
  8146. }
  8147. // Plugin
  8148. // -----------------------------------------------------------------------------------------------------------------
  8149. function buildViewPropTransformers(theClasses) {
  8150. return theClasses.map(function (TheClass) { return new TheClass(); });
  8151. }
  8152. var CalendarRoot = /** @class */ (function (_super) {
  8153. __extends(CalendarRoot, _super);
  8154. function CalendarRoot() {
  8155. var _this = _super !== null && _super.apply(this, arguments) || this;
  8156. _this.state = {
  8157. forPrint: false,
  8158. };
  8159. _this.handleBeforePrint = function () {
  8160. _this.setState({ forPrint: true });
  8161. };
  8162. _this.handleAfterPrint = function () {
  8163. _this.setState({ forPrint: false });
  8164. };
  8165. return _this;
  8166. }
  8167. CalendarRoot.prototype.render = function () {
  8168. var props = this.props;
  8169. var options = props.options;
  8170. var forPrint = this.state.forPrint;
  8171. var isHeightAuto = forPrint || options.height === 'auto' || options.contentHeight === 'auto';
  8172. var height = (!isHeightAuto && options.height != null) ? options.height : '';
  8173. var classNames = [
  8174. 'fc',
  8175. forPrint ? 'fc-media-print' : 'fc-media-screen',
  8176. "fc-direction-" + options.direction,
  8177. props.theme.getClass('root'),
  8178. ];
  8179. if (!getCanVGrowWithinCell()) {
  8180. classNames.push('fc-liquid-hack');
  8181. }
  8182. return props.children(classNames, height, isHeightAuto, forPrint);
  8183. };
  8184. CalendarRoot.prototype.componentDidMount = function () {
  8185. var emitter = this.props.emitter;
  8186. emitter.on('_beforeprint', this.handleBeforePrint);
  8187. emitter.on('_afterprint', this.handleAfterPrint);
  8188. };
  8189. CalendarRoot.prototype.componentWillUnmount = function () {
  8190. var emitter = this.props.emitter;
  8191. emitter.off('_beforeprint', this.handleBeforePrint);
  8192. emitter.off('_afterprint', this.handleAfterPrint);
  8193. };
  8194. return CalendarRoot;
  8195. }(BaseComponent));
  8196. // Computes a default column header formatting string if `colFormat` is not explicitly defined
  8197. function computeFallbackHeaderFormat(datesRepDistinctDays, dayCnt) {
  8198. // if more than one week row, or if there are a lot of columns with not much space,
  8199. // put just the day numbers will be in each cell
  8200. if (!datesRepDistinctDays || dayCnt > 10) {
  8201. return createFormatter({ weekday: 'short' }); // "Sat"
  8202. }
  8203. if (dayCnt > 1) {
  8204. return createFormatter({ weekday: 'short', month: 'numeric', day: 'numeric', omitCommas: true }); // "Sat 11/12"
  8205. }
  8206. return createFormatter({ weekday: 'long' }); // "Saturday"
  8207. }
  8208. var CLASS_NAME = 'fc-col-header-cell'; // do the cushion too? no
  8209. function renderInner$1(hookProps) {
  8210. return hookProps.text;
  8211. }
  8212. var TableDateCell = /** @class */ (function (_super) {
  8213. __extends(TableDateCell, _super);
  8214. function TableDateCell() {
  8215. return _super !== null && _super.apply(this, arguments) || this;
  8216. }
  8217. TableDateCell.prototype.render = function () {
  8218. var _a = this.context, dateEnv = _a.dateEnv, options = _a.options, theme = _a.theme, viewApi = _a.viewApi;
  8219. var props = this.props;
  8220. var date = props.date, dateProfile = props.dateProfile;
  8221. var dayMeta = getDateMeta(date, props.todayRange, null, dateProfile);
  8222. var classNames = [CLASS_NAME].concat(getDayClassNames(dayMeta, theme));
  8223. var text = dateEnv.format(date, props.dayHeaderFormat);
  8224. // if colCnt is 1, we are already in a day-view and don't need a navlink
  8225. var navLinkAttrs = (!dayMeta.isDisabled && props.colCnt > 1)
  8226. ? buildNavLinkAttrs(this.context, date)
  8227. : {};
  8228. var hookProps = __assign(__assign(__assign({ date: dateEnv.toDate(date), view: viewApi }, props.extraHookProps), { text: text }), dayMeta);
  8229. return (createElement(RenderHook, { hookProps: hookProps, classNames: options.dayHeaderClassNames, content: options.dayHeaderContent, defaultContent: renderInner$1, didMount: options.dayHeaderDidMount, willUnmount: options.dayHeaderWillUnmount }, function (rootElRef, customClassNames, innerElRef, innerContent) { return (createElement("th", __assign({ ref: rootElRef, role: "columnheader", className: classNames.concat(customClassNames).join(' '), "data-date": !dayMeta.isDisabled ? formatDayString(date) : undefined, colSpan: props.colSpan }, props.extraDataAttrs),
  8230. createElement("div", { className: "fc-scrollgrid-sync-inner" }, !dayMeta.isDisabled && (createElement("a", __assign({ ref: innerElRef, className: [
  8231. 'fc-col-header-cell-cushion',
  8232. props.isSticky ? 'fc-sticky' : '',
  8233. ].join(' ') }, navLinkAttrs), innerContent))))); }));
  8234. };
  8235. return TableDateCell;
  8236. }(BaseComponent));
  8237. var WEEKDAY_FORMAT = createFormatter({ weekday: 'long' });
  8238. var TableDowCell = /** @class */ (function (_super) {
  8239. __extends(TableDowCell, _super);
  8240. function TableDowCell() {
  8241. return _super !== null && _super.apply(this, arguments) || this;
  8242. }
  8243. TableDowCell.prototype.render = function () {
  8244. var props = this.props;
  8245. var _a = this.context, dateEnv = _a.dateEnv, theme = _a.theme, viewApi = _a.viewApi, options = _a.options;
  8246. var date = addDays(new Date(259200000), props.dow); // start with Sun, 04 Jan 1970 00:00:00 GMT
  8247. var dateMeta = {
  8248. dow: props.dow,
  8249. isDisabled: false,
  8250. isFuture: false,
  8251. isPast: false,
  8252. isToday: false,
  8253. isOther: false,
  8254. };
  8255. var classNames = [CLASS_NAME].concat(getDayClassNames(dateMeta, theme), props.extraClassNames || []);
  8256. var text = dateEnv.format(date, props.dayHeaderFormat);
  8257. var hookProps = __assign(__assign(__assign(__assign({ // TODO: make this public?
  8258. date: date }, dateMeta), { view: viewApi }), props.extraHookProps), { text: text });
  8259. return (createElement(RenderHook, { hookProps: hookProps, classNames: options.dayHeaderClassNames, content: options.dayHeaderContent, defaultContent: renderInner$1, didMount: options.dayHeaderDidMount, willUnmount: options.dayHeaderWillUnmount }, function (rootElRef, customClassNames, innerElRef, innerContent) { return (createElement("th", __assign({ ref: rootElRef, role: "columnheader", className: classNames.concat(customClassNames).join(' '), colSpan: props.colSpan }, props.extraDataAttrs),
  8260. createElement("div", { className: "fc-scrollgrid-sync-inner" },
  8261. createElement("a", { "aria-label": dateEnv.format(date, WEEKDAY_FORMAT), className: [
  8262. 'fc-col-header-cell-cushion',
  8263. props.isSticky ? 'fc-sticky' : '',
  8264. ].join(' '), ref: innerElRef }, innerContent)))); }));
  8265. };
  8266. return TableDowCell;
  8267. }(BaseComponent));
  8268. var NowTimer = /** @class */ (function (_super) {
  8269. __extends(NowTimer, _super);
  8270. function NowTimer(props, context) {
  8271. var _this = _super.call(this, props, context) || this;
  8272. _this.initialNowDate = getNow(context.options.now, context.dateEnv);
  8273. _this.initialNowQueriedMs = new Date().valueOf();
  8274. _this.state = _this.computeTiming().currentState;
  8275. return _this;
  8276. }
  8277. NowTimer.prototype.render = function () {
  8278. var _a = this, props = _a.props, state = _a.state;
  8279. return props.children(state.nowDate, state.todayRange);
  8280. };
  8281. NowTimer.prototype.componentDidMount = function () {
  8282. this.setTimeout();
  8283. };
  8284. NowTimer.prototype.componentDidUpdate = function (prevProps) {
  8285. if (prevProps.unit !== this.props.unit) {
  8286. this.clearTimeout();
  8287. this.setTimeout();
  8288. }
  8289. };
  8290. NowTimer.prototype.componentWillUnmount = function () {
  8291. this.clearTimeout();
  8292. };
  8293. NowTimer.prototype.computeTiming = function () {
  8294. var _a = this, props = _a.props, context = _a.context;
  8295. var unroundedNow = addMs(this.initialNowDate, new Date().valueOf() - this.initialNowQueriedMs);
  8296. var currentUnitStart = context.dateEnv.startOf(unroundedNow, props.unit);
  8297. var nextUnitStart = context.dateEnv.add(currentUnitStart, createDuration(1, props.unit));
  8298. var waitMs = nextUnitStart.valueOf() - unroundedNow.valueOf();
  8299. // there is a max setTimeout ms value (https://stackoverflow.com/a/3468650/96342)
  8300. // ensure no longer than a day
  8301. waitMs = Math.min(1000 * 60 * 60 * 24, waitMs);
  8302. return {
  8303. currentState: { nowDate: currentUnitStart, todayRange: buildDayRange(currentUnitStart) },
  8304. nextState: { nowDate: nextUnitStart, todayRange: buildDayRange(nextUnitStart) },
  8305. waitMs: waitMs,
  8306. };
  8307. };
  8308. NowTimer.prototype.setTimeout = function () {
  8309. var _this = this;
  8310. var _a = this.computeTiming(), nextState = _a.nextState, waitMs = _a.waitMs;
  8311. this.timeoutId = setTimeout(function () {
  8312. _this.setState(nextState, function () {
  8313. _this.setTimeout();
  8314. });
  8315. }, waitMs);
  8316. };
  8317. NowTimer.prototype.clearTimeout = function () {
  8318. if (this.timeoutId) {
  8319. clearTimeout(this.timeoutId);
  8320. }
  8321. };
  8322. NowTimer.contextType = ViewContextType;
  8323. return NowTimer;
  8324. }(Component));
  8325. function buildDayRange(date) {
  8326. var start = startOfDay(date);
  8327. var end = addDays(start, 1);
  8328. return { start: start, end: end };
  8329. }
  8330. var DayHeader = /** @class */ (function (_super) {
  8331. __extends(DayHeader, _super);
  8332. function DayHeader() {
  8333. var _this = _super !== null && _super.apply(this, arguments) || this;
  8334. _this.createDayHeaderFormatter = memoize(createDayHeaderFormatter);
  8335. return _this;
  8336. }
  8337. DayHeader.prototype.render = function () {
  8338. var context = this.context;
  8339. var _a = this.props, dates = _a.dates, dateProfile = _a.dateProfile, datesRepDistinctDays = _a.datesRepDistinctDays, renderIntro = _a.renderIntro;
  8340. var dayHeaderFormat = this.createDayHeaderFormatter(context.options.dayHeaderFormat, datesRepDistinctDays, dates.length);
  8341. return (createElement(NowTimer, { unit: "day" }, function (nowDate, todayRange) { return (createElement("tr", { role: "row" },
  8342. renderIntro && renderIntro('day'),
  8343. dates.map(function (date) { return (datesRepDistinctDays ? (createElement(TableDateCell, { key: date.toISOString(), date: date, dateProfile: dateProfile, todayRange: todayRange, colCnt: dates.length, dayHeaderFormat: dayHeaderFormat })) : (createElement(TableDowCell, { key: date.getUTCDay(), dow: date.getUTCDay(), dayHeaderFormat: dayHeaderFormat }))); }))); }));
  8344. };
  8345. return DayHeader;
  8346. }(BaseComponent));
  8347. function createDayHeaderFormatter(explicitFormat, datesRepDistinctDays, dateCnt) {
  8348. return explicitFormat || computeFallbackHeaderFormat(datesRepDistinctDays, dateCnt);
  8349. }
  8350. var DaySeriesModel = /** @class */ (function () {
  8351. function DaySeriesModel(range, dateProfileGenerator) {
  8352. var date = range.start;
  8353. var end = range.end;
  8354. var indices = [];
  8355. var dates = [];
  8356. var dayIndex = -1;
  8357. while (date < end) { // loop each day from start to end
  8358. if (dateProfileGenerator.isHiddenDay(date)) {
  8359. indices.push(dayIndex + 0.5); // mark that it's between indices
  8360. }
  8361. else {
  8362. dayIndex += 1;
  8363. indices.push(dayIndex);
  8364. dates.push(date);
  8365. }
  8366. date = addDays(date, 1);
  8367. }
  8368. this.dates = dates;
  8369. this.indices = indices;
  8370. this.cnt = dates.length;
  8371. }
  8372. DaySeriesModel.prototype.sliceRange = function (range) {
  8373. var firstIndex = this.getDateDayIndex(range.start); // inclusive first index
  8374. var lastIndex = this.getDateDayIndex(addDays(range.end, -1)); // inclusive last index
  8375. var clippedFirstIndex = Math.max(0, firstIndex);
  8376. var clippedLastIndex = Math.min(this.cnt - 1, lastIndex);
  8377. // deal with in-between indices
  8378. clippedFirstIndex = Math.ceil(clippedFirstIndex); // in-between starts round to next cell
  8379. clippedLastIndex = Math.floor(clippedLastIndex); // in-between ends round to prev cell
  8380. if (clippedFirstIndex <= clippedLastIndex) {
  8381. return {
  8382. firstIndex: clippedFirstIndex,
  8383. lastIndex: clippedLastIndex,
  8384. isStart: firstIndex === clippedFirstIndex,
  8385. isEnd: lastIndex === clippedLastIndex,
  8386. };
  8387. }
  8388. return null;
  8389. };
  8390. // Given a date, returns its chronolocial cell-index from the first cell of the grid.
  8391. // If the date lies between cells (because of hiddenDays), returns a floating-point value between offsets.
  8392. // If before the first offset, returns a negative number.
  8393. // If after the last offset, returns an offset past the last cell offset.
  8394. // Only works for *start* dates of cells. Will not work for exclusive end dates for cells.
  8395. DaySeriesModel.prototype.getDateDayIndex = function (date) {
  8396. var indices = this.indices;
  8397. var dayOffset = Math.floor(diffDays(this.dates[0], date));
  8398. if (dayOffset < 0) {
  8399. return indices[0] - 1;
  8400. }
  8401. if (dayOffset >= indices.length) {
  8402. return indices[indices.length - 1] + 1;
  8403. }
  8404. return indices[dayOffset];
  8405. };
  8406. return DaySeriesModel;
  8407. }());
  8408. var DayTableModel = /** @class */ (function () {
  8409. function DayTableModel(daySeries, breakOnWeeks) {
  8410. var dates = daySeries.dates;
  8411. var daysPerRow;
  8412. var firstDay;
  8413. var rowCnt;
  8414. if (breakOnWeeks) {
  8415. // count columns until the day-of-week repeats
  8416. firstDay = dates[0].getUTCDay();
  8417. for (daysPerRow = 1; daysPerRow < dates.length; daysPerRow += 1) {
  8418. if (dates[daysPerRow].getUTCDay() === firstDay) {
  8419. break;
  8420. }
  8421. }
  8422. rowCnt = Math.ceil(dates.length / daysPerRow);
  8423. }
  8424. else {
  8425. rowCnt = 1;
  8426. daysPerRow = dates.length;
  8427. }
  8428. this.rowCnt = rowCnt;
  8429. this.colCnt = daysPerRow;
  8430. this.daySeries = daySeries;
  8431. this.cells = this.buildCells();
  8432. this.headerDates = this.buildHeaderDates();
  8433. }
  8434. DayTableModel.prototype.buildCells = function () {
  8435. var rows = [];
  8436. for (var row = 0; row < this.rowCnt; row += 1) {
  8437. var cells = [];
  8438. for (var col = 0; col < this.colCnt; col += 1) {
  8439. cells.push(this.buildCell(row, col));
  8440. }
  8441. rows.push(cells);
  8442. }
  8443. return rows;
  8444. };
  8445. DayTableModel.prototype.buildCell = function (row, col) {
  8446. var date = this.daySeries.dates[row * this.colCnt + col];
  8447. return {
  8448. key: date.toISOString(),
  8449. date: date,
  8450. };
  8451. };
  8452. DayTableModel.prototype.buildHeaderDates = function () {
  8453. var dates = [];
  8454. for (var col = 0; col < this.colCnt; col += 1) {
  8455. dates.push(this.cells[0][col].date);
  8456. }
  8457. return dates;
  8458. };
  8459. DayTableModel.prototype.sliceRange = function (range) {
  8460. var colCnt = this.colCnt;
  8461. var seriesSeg = this.daySeries.sliceRange(range);
  8462. var segs = [];
  8463. if (seriesSeg) {
  8464. var firstIndex = seriesSeg.firstIndex, lastIndex = seriesSeg.lastIndex;
  8465. var index = firstIndex;
  8466. while (index <= lastIndex) {
  8467. var row = Math.floor(index / colCnt);
  8468. var nextIndex = Math.min((row + 1) * colCnt, lastIndex + 1);
  8469. segs.push({
  8470. row: row,
  8471. firstCol: index % colCnt,
  8472. lastCol: (nextIndex - 1) % colCnt,
  8473. isStart: seriesSeg.isStart && index === firstIndex,
  8474. isEnd: seriesSeg.isEnd && (nextIndex - 1) === lastIndex,
  8475. });
  8476. index = nextIndex;
  8477. }
  8478. }
  8479. return segs;
  8480. };
  8481. return DayTableModel;
  8482. }());
  8483. var Slicer = /** @class */ (function () {
  8484. function Slicer() {
  8485. this.sliceBusinessHours = memoize(this._sliceBusinessHours);
  8486. this.sliceDateSelection = memoize(this._sliceDateSpan);
  8487. this.sliceEventStore = memoize(this._sliceEventStore);
  8488. this.sliceEventDrag = memoize(this._sliceInteraction);
  8489. this.sliceEventResize = memoize(this._sliceInteraction);
  8490. this.forceDayIfListItem = false; // hack
  8491. }
  8492. Slicer.prototype.sliceProps = function (props, dateProfile, nextDayThreshold, context) {
  8493. var extraArgs = [];
  8494. for (var _i = 4; _i < arguments.length; _i++) {
  8495. extraArgs[_i - 4] = arguments[_i];
  8496. }
  8497. var eventUiBases = props.eventUiBases;
  8498. var eventSegs = this.sliceEventStore.apply(this, __spreadArray([props.eventStore, eventUiBases, dateProfile, nextDayThreshold], extraArgs));
  8499. return {
  8500. dateSelectionSegs: this.sliceDateSelection.apply(this, __spreadArray([props.dateSelection, eventUiBases, context], extraArgs)),
  8501. businessHourSegs: this.sliceBusinessHours.apply(this, __spreadArray([props.businessHours, dateProfile, nextDayThreshold, context], extraArgs)),
  8502. fgEventSegs: eventSegs.fg,
  8503. bgEventSegs: eventSegs.bg,
  8504. eventDrag: this.sliceEventDrag.apply(this, __spreadArray([props.eventDrag, eventUiBases, dateProfile, nextDayThreshold], extraArgs)),
  8505. eventResize: this.sliceEventResize.apply(this, __spreadArray([props.eventResize, eventUiBases, dateProfile, nextDayThreshold], extraArgs)),
  8506. eventSelection: props.eventSelection,
  8507. }; // TODO: give interactionSegs?
  8508. };
  8509. Slicer.prototype.sliceNowDate = function (// does not memoize
  8510. date, context) {
  8511. var extraArgs = [];
  8512. for (var _i = 2; _i < arguments.length; _i++) {
  8513. extraArgs[_i - 2] = arguments[_i];
  8514. }
  8515. return this._sliceDateSpan.apply(this, __spreadArray([{ range: { start: date, end: addMs(date, 1) }, allDay: false },
  8516. {},
  8517. context], extraArgs));
  8518. };
  8519. Slicer.prototype._sliceBusinessHours = function (businessHours, dateProfile, nextDayThreshold, context) {
  8520. var extraArgs = [];
  8521. for (var _i = 4; _i < arguments.length; _i++) {
  8522. extraArgs[_i - 4] = arguments[_i];
  8523. }
  8524. if (!businessHours) {
  8525. return [];
  8526. }
  8527. return this._sliceEventStore.apply(this, __spreadArray([expandRecurring(businessHours, computeActiveRange(dateProfile, Boolean(nextDayThreshold)), context),
  8528. {},
  8529. dateProfile,
  8530. nextDayThreshold], extraArgs)).bg;
  8531. };
  8532. Slicer.prototype._sliceEventStore = function (eventStore, eventUiBases, dateProfile, nextDayThreshold) {
  8533. var extraArgs = [];
  8534. for (var _i = 4; _i < arguments.length; _i++) {
  8535. extraArgs[_i - 4] = arguments[_i];
  8536. }
  8537. if (eventStore) {
  8538. var rangeRes = sliceEventStore(eventStore, eventUiBases, computeActiveRange(dateProfile, Boolean(nextDayThreshold)), nextDayThreshold);
  8539. return {
  8540. bg: this.sliceEventRanges(rangeRes.bg, extraArgs),
  8541. fg: this.sliceEventRanges(rangeRes.fg, extraArgs),
  8542. };
  8543. }
  8544. return { bg: [], fg: [] };
  8545. };
  8546. Slicer.prototype._sliceInteraction = function (interaction, eventUiBases, dateProfile, nextDayThreshold) {
  8547. var extraArgs = [];
  8548. for (var _i = 4; _i < arguments.length; _i++) {
  8549. extraArgs[_i - 4] = arguments[_i];
  8550. }
  8551. if (!interaction) {
  8552. return null;
  8553. }
  8554. var rangeRes = sliceEventStore(interaction.mutatedEvents, eventUiBases, computeActiveRange(dateProfile, Boolean(nextDayThreshold)), nextDayThreshold);
  8555. return {
  8556. segs: this.sliceEventRanges(rangeRes.fg, extraArgs),
  8557. affectedInstances: interaction.affectedEvents.instances,
  8558. isEvent: interaction.isEvent,
  8559. };
  8560. };
  8561. Slicer.prototype._sliceDateSpan = function (dateSpan, eventUiBases, context) {
  8562. var extraArgs = [];
  8563. for (var _i = 3; _i < arguments.length; _i++) {
  8564. extraArgs[_i - 3] = arguments[_i];
  8565. }
  8566. if (!dateSpan) {
  8567. return [];
  8568. }
  8569. var eventRange = fabricateEventRange(dateSpan, eventUiBases, context);
  8570. var segs = this.sliceRange.apply(this, __spreadArray([dateSpan.range], extraArgs));
  8571. for (var _a = 0, segs_1 = segs; _a < segs_1.length; _a++) {
  8572. var seg = segs_1[_a];
  8573. seg.eventRange = eventRange;
  8574. }
  8575. return segs;
  8576. };
  8577. /*
  8578. "complete" seg means it has component and eventRange
  8579. */
  8580. Slicer.prototype.sliceEventRanges = function (eventRanges, extraArgs) {
  8581. var segs = [];
  8582. for (var _i = 0, eventRanges_1 = eventRanges; _i < eventRanges_1.length; _i++) {
  8583. var eventRange = eventRanges_1[_i];
  8584. segs.push.apply(segs, this.sliceEventRange(eventRange, extraArgs));
  8585. }
  8586. return segs;
  8587. };
  8588. /*
  8589. "complete" seg means it has component and eventRange
  8590. */
  8591. Slicer.prototype.sliceEventRange = function (eventRange, extraArgs) {
  8592. var dateRange = eventRange.range;
  8593. // hack to make multi-day events that are being force-displayed as list-items to take up only one day
  8594. if (this.forceDayIfListItem && eventRange.ui.display === 'list-item') {
  8595. dateRange = {
  8596. start: dateRange.start,
  8597. end: addDays(dateRange.start, 1),
  8598. };
  8599. }
  8600. var segs = this.sliceRange.apply(this, __spreadArray([dateRange], extraArgs));
  8601. for (var _i = 0, segs_2 = segs; _i < segs_2.length; _i++) {
  8602. var seg = segs_2[_i];
  8603. seg.eventRange = eventRange;
  8604. seg.isStart = eventRange.isStart && seg.isStart;
  8605. seg.isEnd = eventRange.isEnd && seg.isEnd;
  8606. }
  8607. return segs;
  8608. };
  8609. return Slicer;
  8610. }());
  8611. /*
  8612. for incorporating slotMinTime/slotMaxTime if appropriate
  8613. TODO: should be part of DateProfile!
  8614. TimelineDateProfile already does this btw
  8615. */
  8616. function computeActiveRange(dateProfile, isComponentAllDay) {
  8617. var range = dateProfile.activeRange;
  8618. if (isComponentAllDay) {
  8619. return range;
  8620. }
  8621. return {
  8622. start: addMs(range.start, dateProfile.slotMinTime.milliseconds),
  8623. end: addMs(range.end, dateProfile.slotMaxTime.milliseconds - 864e5), // 864e5 = ms in a day
  8624. };
  8625. }
  8626. // high-level segmenting-aware tester functions
  8627. // ------------------------------------------------------------------------------------------------------------------------
  8628. function isInteractionValid(interaction, dateProfile, context) {
  8629. var instances = interaction.mutatedEvents.instances;
  8630. for (var instanceId in instances) {
  8631. if (!rangeContainsRange(dateProfile.validRange, instances[instanceId].range)) {
  8632. return false;
  8633. }
  8634. }
  8635. return isNewPropsValid({ eventDrag: interaction }, context); // HACK: the eventDrag props is used for ALL interactions
  8636. }
  8637. function isDateSelectionValid(dateSelection, dateProfile, context) {
  8638. if (!rangeContainsRange(dateProfile.validRange, dateSelection.range)) {
  8639. return false;
  8640. }
  8641. return isNewPropsValid({ dateSelection: dateSelection }, context);
  8642. }
  8643. function isNewPropsValid(newProps, context) {
  8644. var calendarState = context.getCurrentData();
  8645. var props = __assign({ businessHours: calendarState.businessHours, dateSelection: '', eventStore: calendarState.eventStore, eventUiBases: calendarState.eventUiBases, eventSelection: '', eventDrag: null, eventResize: null }, newProps);
  8646. return (context.pluginHooks.isPropsValid || isPropsValid)(props, context);
  8647. }
  8648. function isPropsValid(state, context, dateSpanMeta, filterConfig) {
  8649. if (dateSpanMeta === void 0) { dateSpanMeta = {}; }
  8650. if (state.eventDrag && !isInteractionPropsValid(state, context, dateSpanMeta, filterConfig)) {
  8651. return false;
  8652. }
  8653. if (state.dateSelection && !isDateSelectionPropsValid(state, context, dateSpanMeta, filterConfig)) {
  8654. return false;
  8655. }
  8656. return true;
  8657. }
  8658. // Moving Event Validation
  8659. // ------------------------------------------------------------------------------------------------------------------------
  8660. function isInteractionPropsValid(state, context, dateSpanMeta, filterConfig) {
  8661. var currentState = context.getCurrentData();
  8662. var interaction = state.eventDrag; // HACK: the eventDrag props is used for ALL interactions
  8663. var subjectEventStore = interaction.mutatedEvents;
  8664. var subjectDefs = subjectEventStore.defs;
  8665. var subjectInstances = subjectEventStore.instances;
  8666. var subjectConfigs = compileEventUis(subjectDefs, interaction.isEvent ?
  8667. state.eventUiBases :
  8668. { '': currentState.selectionConfig });
  8669. if (filterConfig) {
  8670. subjectConfigs = mapHash(subjectConfigs, filterConfig);
  8671. }
  8672. // exclude the subject events. TODO: exclude defs too?
  8673. var otherEventStore = excludeInstances(state.eventStore, interaction.affectedEvents.instances);
  8674. var otherDefs = otherEventStore.defs;
  8675. var otherInstances = otherEventStore.instances;
  8676. var otherConfigs = compileEventUis(otherDefs, state.eventUiBases);
  8677. for (var subjectInstanceId in subjectInstances) {
  8678. var subjectInstance = subjectInstances[subjectInstanceId];
  8679. var subjectRange = subjectInstance.range;
  8680. var subjectConfig = subjectConfigs[subjectInstance.defId];
  8681. var subjectDef = subjectDefs[subjectInstance.defId];
  8682. // constraint
  8683. if (!allConstraintsPass(subjectConfig.constraints, subjectRange, otherEventStore, state.businessHours, context)) {
  8684. return false;
  8685. }
  8686. // overlap
  8687. var eventOverlap = context.options.eventOverlap;
  8688. var eventOverlapFunc = typeof eventOverlap === 'function' ? eventOverlap : null;
  8689. for (var otherInstanceId in otherInstances) {
  8690. var otherInstance = otherInstances[otherInstanceId];
  8691. // intersect! evaluate
  8692. if (rangesIntersect(subjectRange, otherInstance.range)) {
  8693. var otherOverlap = otherConfigs[otherInstance.defId].overlap;
  8694. // consider the other event's overlap. only do this if the subject event is a "real" event
  8695. if (otherOverlap === false && interaction.isEvent) {
  8696. return false;
  8697. }
  8698. if (subjectConfig.overlap === false) {
  8699. return false;
  8700. }
  8701. if (eventOverlapFunc && !eventOverlapFunc(new EventApi(context, otherDefs[otherInstance.defId], otherInstance), // still event
  8702. new EventApi(context, subjectDef, subjectInstance))) {
  8703. return false;
  8704. }
  8705. }
  8706. }
  8707. // allow (a function)
  8708. var calendarEventStore = currentState.eventStore; // need global-to-calendar, not local to component (splittable)state
  8709. for (var _i = 0, _a = subjectConfig.allows; _i < _a.length; _i++) {
  8710. var subjectAllow = _a[_i];
  8711. var subjectDateSpan = __assign(__assign({}, dateSpanMeta), { range: subjectInstance.range, allDay: subjectDef.allDay });
  8712. var origDef = calendarEventStore.defs[subjectDef.defId];
  8713. var origInstance = calendarEventStore.instances[subjectInstanceId];
  8714. var eventApi = void 0;
  8715. if (origDef) { // was previously in the calendar
  8716. eventApi = new EventApi(context, origDef, origInstance);
  8717. }
  8718. else { // was an external event
  8719. eventApi = new EventApi(context, subjectDef); // no instance, because had no dates
  8720. }
  8721. if (!subjectAllow(buildDateSpanApiWithContext(subjectDateSpan, context), eventApi)) {
  8722. return false;
  8723. }
  8724. }
  8725. }
  8726. return true;
  8727. }
  8728. // Date Selection Validation
  8729. // ------------------------------------------------------------------------------------------------------------------------
  8730. function isDateSelectionPropsValid(state, context, dateSpanMeta, filterConfig) {
  8731. var relevantEventStore = state.eventStore;
  8732. var relevantDefs = relevantEventStore.defs;
  8733. var relevantInstances = relevantEventStore.instances;
  8734. var selection = state.dateSelection;
  8735. var selectionRange = selection.range;
  8736. var selectionConfig = context.getCurrentData().selectionConfig;
  8737. if (filterConfig) {
  8738. selectionConfig = filterConfig(selectionConfig);
  8739. }
  8740. // constraint
  8741. if (!allConstraintsPass(selectionConfig.constraints, selectionRange, relevantEventStore, state.businessHours, context)) {
  8742. return false;
  8743. }
  8744. // overlap
  8745. var selectOverlap = context.options.selectOverlap;
  8746. var selectOverlapFunc = typeof selectOverlap === 'function' ? selectOverlap : null;
  8747. for (var relevantInstanceId in relevantInstances) {
  8748. var relevantInstance = relevantInstances[relevantInstanceId];
  8749. // intersect! evaluate
  8750. if (rangesIntersect(selectionRange, relevantInstance.range)) {
  8751. if (selectionConfig.overlap === false) {
  8752. return false;
  8753. }
  8754. if (selectOverlapFunc && !selectOverlapFunc(new EventApi(context, relevantDefs[relevantInstance.defId], relevantInstance), null)) {
  8755. return false;
  8756. }
  8757. }
  8758. }
  8759. // allow (a function)
  8760. for (var _i = 0, _a = selectionConfig.allows; _i < _a.length; _i++) {
  8761. var selectionAllow = _a[_i];
  8762. var fullDateSpan = __assign(__assign({}, dateSpanMeta), selection);
  8763. if (!selectionAllow(buildDateSpanApiWithContext(fullDateSpan, context), null)) {
  8764. return false;
  8765. }
  8766. }
  8767. return true;
  8768. }
  8769. // Constraint Utils
  8770. // ------------------------------------------------------------------------------------------------------------------------
  8771. function allConstraintsPass(constraints, subjectRange, otherEventStore, businessHoursUnexpanded, context) {
  8772. for (var _i = 0, constraints_1 = constraints; _i < constraints_1.length; _i++) {
  8773. var constraint = constraints_1[_i];
  8774. if (!anyRangesContainRange(constraintToRanges(constraint, subjectRange, otherEventStore, businessHoursUnexpanded, context), subjectRange)) {
  8775. return false;
  8776. }
  8777. }
  8778. return true;
  8779. }
  8780. function constraintToRanges(constraint, subjectRange, // for expanding a recurring constraint, or expanding business hours
  8781. otherEventStore, // for if constraint is an even group ID
  8782. businessHoursUnexpanded, // for if constraint is 'businessHours'
  8783. context) {
  8784. if (constraint === 'businessHours') {
  8785. return eventStoreToRanges(expandRecurring(businessHoursUnexpanded, subjectRange, context));
  8786. }
  8787. if (typeof constraint === 'string') { // an group ID
  8788. return eventStoreToRanges(filterEventStoreDefs(otherEventStore, function (eventDef) { return eventDef.groupId === constraint; }));
  8789. }
  8790. if (typeof constraint === 'object' && constraint) { // non-null object
  8791. return eventStoreToRanges(expandRecurring(constraint, subjectRange, context));
  8792. }
  8793. return []; // if it's false
  8794. }
  8795. // TODO: move to event-store file?
  8796. function eventStoreToRanges(eventStore) {
  8797. var instances = eventStore.instances;
  8798. var ranges = [];
  8799. for (var instanceId in instances) {
  8800. ranges.push(instances[instanceId].range);
  8801. }
  8802. return ranges;
  8803. }
  8804. // TODO: move to geom file?
  8805. function anyRangesContainRange(outerRanges, innerRange) {
  8806. for (var _i = 0, outerRanges_1 = outerRanges; _i < outerRanges_1.length; _i++) {
  8807. var outerRange = outerRanges_1[_i];
  8808. if (rangeContainsRange(outerRange, innerRange)) {
  8809. return true;
  8810. }
  8811. }
  8812. return false;
  8813. }
  8814. var VISIBLE_HIDDEN_RE = /^(visible|hidden)$/;
  8815. var Scroller = /** @class */ (function (_super) {
  8816. __extends(Scroller, _super);
  8817. function Scroller() {
  8818. var _this = _super !== null && _super.apply(this, arguments) || this;
  8819. _this.handleEl = function (el) {
  8820. _this.el = el;
  8821. setRef(_this.props.elRef, el);
  8822. };
  8823. return _this;
  8824. }
  8825. Scroller.prototype.render = function () {
  8826. var props = this.props;
  8827. var liquid = props.liquid, liquidIsAbsolute = props.liquidIsAbsolute;
  8828. var isAbsolute = liquid && liquidIsAbsolute;
  8829. var className = ['fc-scroller'];
  8830. if (liquid) {
  8831. if (liquidIsAbsolute) {
  8832. className.push('fc-scroller-liquid-absolute');
  8833. }
  8834. else {
  8835. className.push('fc-scroller-liquid');
  8836. }
  8837. }
  8838. return (createElement("div", { ref: this.handleEl, className: className.join(' '), style: {
  8839. overflowX: props.overflowX,
  8840. overflowY: props.overflowY,
  8841. left: (isAbsolute && -(props.overcomeLeft || 0)) || '',
  8842. right: (isAbsolute && -(props.overcomeRight || 0)) || '',
  8843. bottom: (isAbsolute && -(props.overcomeBottom || 0)) || '',
  8844. marginLeft: (!isAbsolute && -(props.overcomeLeft || 0)) || '',
  8845. marginRight: (!isAbsolute && -(props.overcomeRight || 0)) || '',
  8846. marginBottom: (!isAbsolute && -(props.overcomeBottom || 0)) || '',
  8847. maxHeight: props.maxHeight || '',
  8848. } }, props.children));
  8849. };
  8850. Scroller.prototype.needsXScrolling = function () {
  8851. if (VISIBLE_HIDDEN_RE.test(this.props.overflowX)) {
  8852. return false;
  8853. }
  8854. // testing scrollWidth>clientWidth is unreliable cross-browser when pixel heights aren't integers.
  8855. // much more reliable to see if children are taller than the scroller, even tho doesn't account for
  8856. // inner-child margins and absolute positioning
  8857. var el = this.el;
  8858. var realClientWidth = this.el.getBoundingClientRect().width - this.getYScrollbarWidth();
  8859. var children = el.children;
  8860. for (var i = 0; i < children.length; i += 1) {
  8861. var childEl = children[i];
  8862. if (childEl.getBoundingClientRect().width > realClientWidth) {
  8863. return true;
  8864. }
  8865. }
  8866. return false;
  8867. };
  8868. Scroller.prototype.needsYScrolling = function () {
  8869. if (VISIBLE_HIDDEN_RE.test(this.props.overflowY)) {
  8870. return false;
  8871. }
  8872. // testing scrollHeight>clientHeight is unreliable cross-browser when pixel heights aren't integers.
  8873. // much more reliable to see if children are taller than the scroller, even tho doesn't account for
  8874. // inner-child margins and absolute positioning
  8875. var el = this.el;
  8876. var realClientHeight = this.el.getBoundingClientRect().height - this.getXScrollbarWidth();
  8877. var children = el.children;
  8878. for (var i = 0; i < children.length; i += 1) {
  8879. var childEl = children[i];
  8880. if (childEl.getBoundingClientRect().height > realClientHeight) {
  8881. return true;
  8882. }
  8883. }
  8884. return false;
  8885. };
  8886. Scroller.prototype.getXScrollbarWidth = function () {
  8887. if (VISIBLE_HIDDEN_RE.test(this.props.overflowX)) {
  8888. return 0;
  8889. }
  8890. return this.el.offsetHeight - this.el.clientHeight; // only works because we guarantee no borders. TODO: add to CSS with important?
  8891. };
  8892. Scroller.prototype.getYScrollbarWidth = function () {
  8893. if (VISIBLE_HIDDEN_RE.test(this.props.overflowY)) {
  8894. return 0;
  8895. }
  8896. return this.el.offsetWidth - this.el.clientWidth; // only works because we guarantee no borders. TODO: add to CSS with important?
  8897. };
  8898. return Scroller;
  8899. }(BaseComponent));
  8900. /*
  8901. TODO: somehow infer OtherArgs from masterCallback?
  8902. TODO: infer RefType from masterCallback if provided
  8903. */
  8904. var RefMap = /** @class */ (function () {
  8905. function RefMap(masterCallback) {
  8906. var _this = this;
  8907. this.masterCallback = masterCallback;
  8908. this.currentMap = {};
  8909. this.depths = {};
  8910. this.callbackMap = {};
  8911. this.handleValue = function (val, key) {
  8912. var _a = _this, depths = _a.depths, currentMap = _a.currentMap;
  8913. var removed = false;
  8914. var added = false;
  8915. if (val !== null) {
  8916. // for bug... ACTUALLY: can probably do away with this now that callers don't share numeric indices anymore
  8917. removed = (key in currentMap);
  8918. currentMap[key] = val;
  8919. depths[key] = (depths[key] || 0) + 1;
  8920. added = true;
  8921. }
  8922. else {
  8923. depths[key] -= 1;
  8924. if (!depths[key]) {
  8925. delete currentMap[key];
  8926. delete _this.callbackMap[key];
  8927. removed = true;
  8928. }
  8929. }
  8930. if (_this.masterCallback) {
  8931. if (removed) {
  8932. _this.masterCallback(null, String(key));
  8933. }
  8934. if (added) {
  8935. _this.masterCallback(val, String(key));
  8936. }
  8937. }
  8938. };
  8939. }
  8940. RefMap.prototype.createRef = function (key) {
  8941. var _this = this;
  8942. var refCallback = this.callbackMap[key];
  8943. if (!refCallback) {
  8944. refCallback = this.callbackMap[key] = function (val) {
  8945. _this.handleValue(val, String(key));
  8946. };
  8947. }
  8948. return refCallback;
  8949. };
  8950. // TODO: check callers that don't care about order. should use getAll instead
  8951. // NOTE: this method has become less valuable now that we are encouraged to map order by some other index
  8952. // TODO: provide ONE array-export function, buildArray, which fails on non-numeric indexes. caller can manipulate and "collect"
  8953. RefMap.prototype.collect = function (startIndex, endIndex, step) {
  8954. return collectFromHash(this.currentMap, startIndex, endIndex, step);
  8955. };
  8956. RefMap.prototype.getAll = function () {
  8957. return hashValuesToArray(this.currentMap);
  8958. };
  8959. return RefMap;
  8960. }());
  8961. function computeShrinkWidth(chunkEls) {
  8962. var shrinkCells = findElements(chunkEls, '.fc-scrollgrid-shrink');
  8963. var largestWidth = 0;
  8964. for (var _i = 0, shrinkCells_1 = shrinkCells; _i < shrinkCells_1.length; _i++) {
  8965. var shrinkCell = shrinkCells_1[_i];
  8966. largestWidth = Math.max(largestWidth, computeSmallestCellWidth(shrinkCell));
  8967. }
  8968. return Math.ceil(largestWidth); // <table> elements work best with integers. round up to ensure contents fits
  8969. }
  8970. function getSectionHasLiquidHeight(props, sectionConfig) {
  8971. return props.liquid && sectionConfig.liquid; // does the section do liquid-height? (need to have whole scrollgrid liquid-height as well)
  8972. }
  8973. function getAllowYScrolling(props, sectionConfig) {
  8974. return sectionConfig.maxHeight != null || // if its possible for the height to max out, we might need scrollbars
  8975. getSectionHasLiquidHeight(props, sectionConfig); // if the section is liquid height, it might condense enough to require scrollbars
  8976. }
  8977. // TODO: ONLY use `arg`. force out internal function to use same API
  8978. function renderChunkContent(sectionConfig, chunkConfig, arg, isHeader) {
  8979. var expandRows = arg.expandRows;
  8980. var content = typeof chunkConfig.content === 'function' ?
  8981. chunkConfig.content(arg) :
  8982. createElement('table', {
  8983. role: 'presentation',
  8984. className: [
  8985. chunkConfig.tableClassName,
  8986. sectionConfig.syncRowHeights ? 'fc-scrollgrid-sync-table' : '',
  8987. ].join(' '),
  8988. style: {
  8989. minWidth: arg.tableMinWidth,
  8990. width: arg.clientWidth,
  8991. height: expandRows ? arg.clientHeight : '', // css `height` on a <table> serves as a min-height
  8992. },
  8993. }, arg.tableColGroupNode, createElement(isHeader ? 'thead' : 'tbody', {
  8994. role: 'presentation',
  8995. }, typeof chunkConfig.rowContent === 'function'
  8996. ? chunkConfig.rowContent(arg)
  8997. : chunkConfig.rowContent));
  8998. return content;
  8999. }
  9000. function isColPropsEqual(cols0, cols1) {
  9001. return isArraysEqual(cols0, cols1, isPropsEqual);
  9002. }
  9003. function renderMicroColGroup(cols, shrinkWidth) {
  9004. var colNodes = [];
  9005. /*
  9006. for ColProps with spans, it would have been great to make a single <col span="">
  9007. HOWEVER, Chrome was getting messing up distributing the width to <td>/<th> elements with colspans.
  9008. SOLUTION: making individual <col> elements makes Chrome behave.
  9009. */
  9010. for (var _i = 0, cols_1 = cols; _i < cols_1.length; _i++) {
  9011. var colProps = cols_1[_i];
  9012. var span = colProps.span || 1;
  9013. for (var i = 0; i < span; i += 1) {
  9014. colNodes.push(createElement("col", { style: {
  9015. width: colProps.width === 'shrink' ? sanitizeShrinkWidth(shrinkWidth) : (colProps.width || ''),
  9016. minWidth: colProps.minWidth || '',
  9017. } }));
  9018. }
  9019. }
  9020. return createElement.apply(void 0, __spreadArray(['colgroup', {}], colNodes));
  9021. }
  9022. function sanitizeShrinkWidth(shrinkWidth) {
  9023. /* why 4? if we do 0, it will kill any border, which are needed for computeSmallestCellWidth
  9024. 4 accounts for 2 2-pixel borders. TODO: better solution? */
  9025. return shrinkWidth == null ? 4 : shrinkWidth;
  9026. }
  9027. function hasShrinkWidth(cols) {
  9028. for (var _i = 0, cols_2 = cols; _i < cols_2.length; _i++) {
  9029. var col = cols_2[_i];
  9030. if (col.width === 'shrink') {
  9031. return true;
  9032. }
  9033. }
  9034. return false;
  9035. }
  9036. function getScrollGridClassNames(liquid, context) {
  9037. var classNames = [
  9038. 'fc-scrollgrid',
  9039. context.theme.getClass('table'),
  9040. ];
  9041. if (liquid) {
  9042. classNames.push('fc-scrollgrid-liquid');
  9043. }
  9044. return classNames;
  9045. }
  9046. function getSectionClassNames(sectionConfig, wholeTableVGrow) {
  9047. var classNames = [
  9048. 'fc-scrollgrid-section',
  9049. "fc-scrollgrid-section-" + sectionConfig.type,
  9050. sectionConfig.className, // used?
  9051. ];
  9052. if (wholeTableVGrow && sectionConfig.liquid && sectionConfig.maxHeight == null) {
  9053. classNames.push('fc-scrollgrid-section-liquid');
  9054. }
  9055. if (sectionConfig.isSticky) {
  9056. classNames.push('fc-scrollgrid-section-sticky');
  9057. }
  9058. return classNames;
  9059. }
  9060. function renderScrollShim(arg) {
  9061. return (createElement("div", { className: "fc-scrollgrid-sticky-shim", style: {
  9062. width: arg.clientWidth,
  9063. minWidth: arg.tableMinWidth,
  9064. } }));
  9065. }
  9066. function getStickyHeaderDates(options) {
  9067. var stickyHeaderDates = options.stickyHeaderDates;
  9068. if (stickyHeaderDates == null || stickyHeaderDates === 'auto') {
  9069. stickyHeaderDates = options.height === 'auto' || options.viewHeight === 'auto';
  9070. }
  9071. return stickyHeaderDates;
  9072. }
  9073. function getStickyFooterScrollbar(options) {
  9074. var stickyFooterScrollbar = options.stickyFooterScrollbar;
  9075. if (stickyFooterScrollbar == null || stickyFooterScrollbar === 'auto') {
  9076. stickyFooterScrollbar = options.height === 'auto' || options.viewHeight === 'auto';
  9077. }
  9078. return stickyFooterScrollbar;
  9079. }
  9080. var SimpleScrollGrid = /** @class */ (function (_super) {
  9081. __extends(SimpleScrollGrid, _super);
  9082. function SimpleScrollGrid() {
  9083. var _this = _super !== null && _super.apply(this, arguments) || this;
  9084. _this.processCols = memoize(function (a) { return a; }, isColPropsEqual); // so we get same `cols` props every time
  9085. // yucky to memoize VNodes, but much more efficient for consumers
  9086. _this.renderMicroColGroup = memoize(renderMicroColGroup);
  9087. _this.scrollerRefs = new RefMap();
  9088. _this.scrollerElRefs = new RefMap(_this._handleScrollerEl.bind(_this));
  9089. _this.state = {
  9090. shrinkWidth: null,
  9091. forceYScrollbars: false,
  9092. scrollerClientWidths: {},
  9093. scrollerClientHeights: {},
  9094. };
  9095. // TODO: can do a really simple print-view. dont need to join rows
  9096. _this.handleSizing = function () {
  9097. _this.setState(__assign({ shrinkWidth: _this.computeShrinkWidth() }, _this.computeScrollerDims()));
  9098. };
  9099. return _this;
  9100. }
  9101. SimpleScrollGrid.prototype.render = function () {
  9102. var _a = this, props = _a.props, state = _a.state, context = _a.context;
  9103. var sectionConfigs = props.sections || [];
  9104. var cols = this.processCols(props.cols);
  9105. var microColGroupNode = this.renderMicroColGroup(cols, state.shrinkWidth);
  9106. var classNames = getScrollGridClassNames(props.liquid, context);
  9107. if (props.collapsibleWidth) {
  9108. classNames.push('fc-scrollgrid-collapsible');
  9109. }
  9110. // TODO: make DRY
  9111. var configCnt = sectionConfigs.length;
  9112. var configI = 0;
  9113. var currentConfig;
  9114. var headSectionNodes = [];
  9115. var bodySectionNodes = [];
  9116. var footSectionNodes = [];
  9117. while (configI < configCnt && (currentConfig = sectionConfigs[configI]).type === 'header') {
  9118. headSectionNodes.push(this.renderSection(currentConfig, microColGroupNode, true));
  9119. configI += 1;
  9120. }
  9121. while (configI < configCnt && (currentConfig = sectionConfigs[configI]).type === 'body') {
  9122. bodySectionNodes.push(this.renderSection(currentConfig, microColGroupNode, false));
  9123. configI += 1;
  9124. }
  9125. while (configI < configCnt && (currentConfig = sectionConfigs[configI]).type === 'footer') {
  9126. footSectionNodes.push(this.renderSection(currentConfig, microColGroupNode, true));
  9127. configI += 1;
  9128. }
  9129. // firefox bug: when setting height on table and there is a thead or tfoot,
  9130. // the necessary height:100% on the liquid-height body section forces the *whole* table to be taller. (bug #5524)
  9131. // use getCanVGrowWithinCell as a way to detect table-stupid firefox.
  9132. // if so, use a simpler dom structure, jam everything into a lone tbody.
  9133. var isBuggy = !getCanVGrowWithinCell();
  9134. var roleAttrs = { role: 'rowgroup' };
  9135. return createElement('table', {
  9136. role: 'grid',
  9137. className: classNames.join(' '),
  9138. style: { height: props.height },
  9139. }, Boolean(!isBuggy && headSectionNodes.length) && createElement.apply(void 0, __spreadArray(['thead', roleAttrs], headSectionNodes)), Boolean(!isBuggy && bodySectionNodes.length) && createElement.apply(void 0, __spreadArray(['tbody', roleAttrs], bodySectionNodes)), Boolean(!isBuggy && footSectionNodes.length) && createElement.apply(void 0, __spreadArray(['tfoot', roleAttrs], footSectionNodes)), isBuggy && createElement.apply(void 0, __spreadArray(__spreadArray(__spreadArray(['tbody', roleAttrs], headSectionNodes), bodySectionNodes), footSectionNodes)));
  9140. };
  9141. SimpleScrollGrid.prototype.renderSection = function (sectionConfig, microColGroupNode, isHeader) {
  9142. if ('outerContent' in sectionConfig) {
  9143. return (createElement(Fragment, { key: sectionConfig.key }, sectionConfig.outerContent));
  9144. }
  9145. return (createElement("tr", { key: sectionConfig.key, role: "presentation", className: getSectionClassNames(sectionConfig, this.props.liquid).join(' ') }, this.renderChunkTd(sectionConfig, microColGroupNode, sectionConfig.chunk, isHeader)));
  9146. };
  9147. SimpleScrollGrid.prototype.renderChunkTd = function (sectionConfig, microColGroupNode, chunkConfig, isHeader) {
  9148. if ('outerContent' in chunkConfig) {
  9149. return chunkConfig.outerContent;
  9150. }
  9151. var props = this.props;
  9152. var _a = this.state, forceYScrollbars = _a.forceYScrollbars, scrollerClientWidths = _a.scrollerClientWidths, scrollerClientHeights = _a.scrollerClientHeights;
  9153. var needsYScrolling = getAllowYScrolling(props, sectionConfig); // TODO: do lazily. do in section config?
  9154. var isLiquid = getSectionHasLiquidHeight(props, sectionConfig);
  9155. // for `!props.liquid` - is WHOLE scrollgrid natural height?
  9156. // TODO: do same thing in advanced scrollgrid? prolly not b/c always has horizontal scrollbars
  9157. var overflowY = !props.liquid ? 'visible' :
  9158. forceYScrollbars ? 'scroll' :
  9159. !needsYScrolling ? 'hidden' :
  9160. 'auto';
  9161. var sectionKey = sectionConfig.key;
  9162. var content = renderChunkContent(sectionConfig, chunkConfig, {
  9163. tableColGroupNode: microColGroupNode,
  9164. tableMinWidth: '',
  9165. clientWidth: (!props.collapsibleWidth && scrollerClientWidths[sectionKey] !== undefined) ? scrollerClientWidths[sectionKey] : null,
  9166. clientHeight: scrollerClientHeights[sectionKey] !== undefined ? scrollerClientHeights[sectionKey] : null,
  9167. expandRows: sectionConfig.expandRows,
  9168. syncRowHeights: false,
  9169. rowSyncHeights: [],
  9170. reportRowHeightChange: function () { },
  9171. }, isHeader);
  9172. return createElement(isHeader ? 'th' : 'td', {
  9173. ref: chunkConfig.elRef,
  9174. role: 'presentation',
  9175. }, createElement("div", { className: "fc-scroller-harness" + (isLiquid ? ' fc-scroller-harness-liquid' : '') },
  9176. createElement(Scroller, { ref: this.scrollerRefs.createRef(sectionKey), elRef: this.scrollerElRefs.createRef(sectionKey), overflowY: overflowY, overflowX: !props.liquid ? 'visible' : 'hidden' /* natural height? */, maxHeight: sectionConfig.maxHeight, liquid: isLiquid, liquidIsAbsolute // because its within a harness
  9177. : true }, content)));
  9178. };
  9179. SimpleScrollGrid.prototype._handleScrollerEl = function (scrollerEl, key) {
  9180. var section = getSectionByKey(this.props.sections, key);
  9181. if (section) {
  9182. setRef(section.chunk.scrollerElRef, scrollerEl);
  9183. }
  9184. };
  9185. SimpleScrollGrid.prototype.componentDidMount = function () {
  9186. this.handleSizing();
  9187. this.context.addResizeHandler(this.handleSizing);
  9188. };
  9189. SimpleScrollGrid.prototype.componentDidUpdate = function () {
  9190. // TODO: need better solution when state contains non-sizing things
  9191. this.handleSizing();
  9192. };
  9193. SimpleScrollGrid.prototype.componentWillUnmount = function () {
  9194. this.context.removeResizeHandler(this.handleSizing);
  9195. };
  9196. SimpleScrollGrid.prototype.computeShrinkWidth = function () {
  9197. return hasShrinkWidth(this.props.cols)
  9198. ? computeShrinkWidth(this.scrollerElRefs.getAll())
  9199. : 0;
  9200. };
  9201. SimpleScrollGrid.prototype.computeScrollerDims = function () {
  9202. var scrollbarWidth = getScrollbarWidths();
  9203. var _a = this, scrollerRefs = _a.scrollerRefs, scrollerElRefs = _a.scrollerElRefs;
  9204. var forceYScrollbars = false;
  9205. var scrollerClientWidths = {};
  9206. var scrollerClientHeights = {};
  9207. for (var sectionKey in scrollerRefs.currentMap) {
  9208. var scroller = scrollerRefs.currentMap[sectionKey];
  9209. if (scroller && scroller.needsYScrolling()) {
  9210. forceYScrollbars = true;
  9211. break;
  9212. }
  9213. }
  9214. for (var _i = 0, _b = this.props.sections; _i < _b.length; _i++) {
  9215. var section = _b[_i];
  9216. var sectionKey = section.key;
  9217. var scrollerEl = scrollerElRefs.currentMap[sectionKey];
  9218. if (scrollerEl) {
  9219. var harnessEl = scrollerEl.parentNode; // TODO: weird way to get this. need harness b/c doesn't include table borders
  9220. scrollerClientWidths[sectionKey] = Math.floor(harnessEl.getBoundingClientRect().width - (forceYScrollbars
  9221. ? scrollbarWidth.y // use global because scroller might not have scrollbars yet but will need them in future
  9222. : 0));
  9223. scrollerClientHeights[sectionKey] = Math.floor(harnessEl.getBoundingClientRect().height);
  9224. }
  9225. }
  9226. return { forceYScrollbars: forceYScrollbars, scrollerClientWidths: scrollerClientWidths, scrollerClientHeights: scrollerClientHeights };
  9227. };
  9228. return SimpleScrollGrid;
  9229. }(BaseComponent));
  9230. SimpleScrollGrid.addStateEquality({
  9231. scrollerClientWidths: isPropsEqual,
  9232. scrollerClientHeights: isPropsEqual,
  9233. });
  9234. function getSectionByKey(sections, key) {
  9235. for (var _i = 0, sections_1 = sections; _i < sections_1.length; _i++) {
  9236. var section = sections_1[_i];
  9237. if (section.key === key) {
  9238. return section;
  9239. }
  9240. }
  9241. return null;
  9242. }
  9243. var EventRoot = /** @class */ (function (_super) {
  9244. __extends(EventRoot, _super);
  9245. function EventRoot() {
  9246. var _this = _super !== null && _super.apply(this, arguments) || this;
  9247. _this.elRef = createRef();
  9248. return _this;
  9249. }
  9250. EventRoot.prototype.render = function () {
  9251. var _a = this, props = _a.props, context = _a.context;
  9252. var options = context.options;
  9253. var seg = props.seg;
  9254. var eventRange = seg.eventRange;
  9255. var ui = eventRange.ui;
  9256. var hookProps = {
  9257. event: new EventApi(context, eventRange.def, eventRange.instance),
  9258. view: context.viewApi,
  9259. timeText: props.timeText,
  9260. textColor: ui.textColor,
  9261. backgroundColor: ui.backgroundColor,
  9262. borderColor: ui.borderColor,
  9263. isDraggable: !props.disableDragging && computeSegDraggable(seg, context),
  9264. isStartResizable: !props.disableResizing && computeSegStartResizable(seg, context),
  9265. isEndResizable: !props.disableResizing && computeSegEndResizable(seg),
  9266. isMirror: Boolean(props.isDragging || props.isResizing || props.isDateSelecting),
  9267. isStart: Boolean(seg.isStart),
  9268. isEnd: Boolean(seg.isEnd),
  9269. isPast: Boolean(props.isPast),
  9270. isFuture: Boolean(props.isFuture),
  9271. isToday: Boolean(props.isToday),
  9272. isSelected: Boolean(props.isSelected),
  9273. isDragging: Boolean(props.isDragging),
  9274. isResizing: Boolean(props.isResizing),
  9275. };
  9276. var standardClassNames = getEventClassNames(hookProps).concat(ui.classNames);
  9277. return (createElement(RenderHook, { hookProps: hookProps, classNames: options.eventClassNames, content: options.eventContent, defaultContent: props.defaultContent, didMount: options.eventDidMount, willUnmount: options.eventWillUnmount, elRef: this.elRef }, function (rootElRef, customClassNames, innerElRef, innerContent) { return props.children(rootElRef, standardClassNames.concat(customClassNames), innerElRef, innerContent, hookProps); }));
  9278. };
  9279. EventRoot.prototype.componentDidMount = function () {
  9280. setElSeg(this.elRef.current, this.props.seg);
  9281. };
  9282. /*
  9283. need to re-assign seg to the element if seg changes, even if the element is the same
  9284. */
  9285. EventRoot.prototype.componentDidUpdate = function (prevProps) {
  9286. var seg = this.props.seg;
  9287. if (seg !== prevProps.seg) {
  9288. setElSeg(this.elRef.current, seg);
  9289. }
  9290. };
  9291. return EventRoot;
  9292. }(BaseComponent));
  9293. // should not be a purecomponent
  9294. var StandardEvent = /** @class */ (function (_super) {
  9295. __extends(StandardEvent, _super);
  9296. function StandardEvent() {
  9297. return _super !== null && _super.apply(this, arguments) || this;
  9298. }
  9299. StandardEvent.prototype.render = function () {
  9300. var _a = this, props = _a.props, context = _a.context;
  9301. var seg = props.seg;
  9302. var timeFormat = context.options.eventTimeFormat || props.defaultTimeFormat;
  9303. var timeText = buildSegTimeText(seg, timeFormat, context, props.defaultDisplayEventTime, props.defaultDisplayEventEnd);
  9304. return (createElement(EventRoot, { seg: seg, timeText: timeText, disableDragging: props.disableDragging, disableResizing: props.disableResizing, defaultContent: props.defaultContent || renderInnerContent$4, isDragging: props.isDragging, isResizing: props.isResizing, isDateSelecting: props.isDateSelecting, isSelected: props.isSelected, isPast: props.isPast, isFuture: props.isFuture, isToday: props.isToday }, function (rootElRef, classNames, innerElRef, innerContent, hookProps) { return (createElement("a", __assign({ className: props.extraClassNames.concat(classNames).join(' '), style: {
  9305. borderColor: hookProps.borderColor,
  9306. backgroundColor: hookProps.backgroundColor,
  9307. }, ref: rootElRef }, getSegAnchorAttrs(seg, context)),
  9308. createElement("div", { className: "fc-event-main", ref: innerElRef, style: { color: hookProps.textColor } }, innerContent),
  9309. hookProps.isStartResizable &&
  9310. createElement("div", { className: "fc-event-resizer fc-event-resizer-start" }),
  9311. hookProps.isEndResizable &&
  9312. createElement("div", { className: "fc-event-resizer fc-event-resizer-end" }))); }));
  9313. };
  9314. return StandardEvent;
  9315. }(BaseComponent));
  9316. function renderInnerContent$4(innerProps) {
  9317. return (createElement("div", { className: "fc-event-main-frame" },
  9318. innerProps.timeText && (createElement("div", { className: "fc-event-time" }, innerProps.timeText)),
  9319. createElement("div", { className: "fc-event-title-container" },
  9320. createElement("div", { className: "fc-event-title fc-sticky" }, innerProps.event.title || createElement(Fragment, null, "\u00A0")))));
  9321. }
  9322. var NowIndicatorRoot = function (props) { return (createElement(ViewContextType.Consumer, null, function (context) {
  9323. var options = context.options;
  9324. var hookProps = {
  9325. isAxis: props.isAxis,
  9326. date: context.dateEnv.toDate(props.date),
  9327. view: context.viewApi,
  9328. };
  9329. return (createElement(RenderHook, { hookProps: hookProps, classNames: options.nowIndicatorClassNames, content: options.nowIndicatorContent, didMount: options.nowIndicatorDidMount, willUnmount: options.nowIndicatorWillUnmount }, props.children));
  9330. })); };
  9331. var DAY_NUM_FORMAT = createFormatter({ day: 'numeric' });
  9332. var DayCellContent = /** @class */ (function (_super) {
  9333. __extends(DayCellContent, _super);
  9334. function DayCellContent() {
  9335. return _super !== null && _super.apply(this, arguments) || this;
  9336. }
  9337. DayCellContent.prototype.render = function () {
  9338. var _a = this, props = _a.props, context = _a.context;
  9339. var options = context.options;
  9340. var hookProps = refineDayCellHookProps({
  9341. date: props.date,
  9342. dateProfile: props.dateProfile,
  9343. todayRange: props.todayRange,
  9344. showDayNumber: props.showDayNumber,
  9345. extraProps: props.extraHookProps,
  9346. viewApi: context.viewApi,
  9347. dateEnv: context.dateEnv,
  9348. });
  9349. return (createElement(ContentHook, { hookProps: hookProps, content: options.dayCellContent, defaultContent: props.defaultContent }, props.children));
  9350. };
  9351. return DayCellContent;
  9352. }(BaseComponent));
  9353. function refineDayCellHookProps(raw) {
  9354. var date = raw.date, dateEnv = raw.dateEnv;
  9355. var dayMeta = getDateMeta(date, raw.todayRange, null, raw.dateProfile);
  9356. return __assign(__assign(__assign({ date: dateEnv.toDate(date), view: raw.viewApi }, dayMeta), { dayNumberText: raw.showDayNumber ? dateEnv.format(date, DAY_NUM_FORMAT) : '' }), raw.extraProps);
  9357. }
  9358. var DayCellRoot = /** @class */ (function (_super) {
  9359. __extends(DayCellRoot, _super);
  9360. function DayCellRoot() {
  9361. var _this = _super !== null && _super.apply(this, arguments) || this;
  9362. _this.refineHookProps = memoizeObjArg(refineDayCellHookProps);
  9363. _this.normalizeClassNames = buildClassNameNormalizer();
  9364. return _this;
  9365. }
  9366. DayCellRoot.prototype.render = function () {
  9367. var _a = this, props = _a.props, context = _a.context;
  9368. var options = context.options;
  9369. var hookProps = this.refineHookProps({
  9370. date: props.date,
  9371. dateProfile: props.dateProfile,
  9372. todayRange: props.todayRange,
  9373. showDayNumber: props.showDayNumber,
  9374. extraProps: props.extraHookProps,
  9375. viewApi: context.viewApi,
  9376. dateEnv: context.dateEnv,
  9377. });
  9378. var classNames = getDayClassNames(hookProps, context.theme).concat(hookProps.isDisabled
  9379. ? [] // don't use custom classNames if disabled
  9380. : this.normalizeClassNames(options.dayCellClassNames, hookProps));
  9381. var dataAttrs = hookProps.isDisabled ? {} : {
  9382. 'data-date': formatDayString(props.date),
  9383. };
  9384. return (createElement(MountHook, { hookProps: hookProps, didMount: options.dayCellDidMount, willUnmount: options.dayCellWillUnmount, elRef: props.elRef }, function (rootElRef) { return props.children(rootElRef, classNames, dataAttrs, hookProps.isDisabled); }));
  9385. };
  9386. return DayCellRoot;
  9387. }(BaseComponent));
  9388. function renderFill(fillType) {
  9389. return (createElement("div", { className: "fc-" + fillType }));
  9390. }
  9391. var BgEvent = function (props) { return (createElement(EventRoot, { defaultContent: renderInnerContent$3, seg: props.seg /* uselesss i think */, timeText: "", disableDragging: true, disableResizing: true, isDragging: false, isResizing: false, isDateSelecting: false, isSelected: false, isPast: props.isPast, isFuture: props.isFuture, isToday: props.isToday }, function (rootElRef, classNames, innerElRef, innerContent, hookProps) { return (createElement("div", { ref: rootElRef, className: ['fc-bg-event'].concat(classNames).join(' '), style: {
  9392. backgroundColor: hookProps.backgroundColor,
  9393. } }, innerContent)); })); };
  9394. function renderInnerContent$3(props) {
  9395. var title = props.event.title;
  9396. return title && (createElement("div", { className: "fc-event-title" }, props.event.title));
  9397. }
  9398. var WeekNumberRoot = function (props) { return (createElement(ViewContextType.Consumer, null, function (context) {
  9399. var dateEnv = context.dateEnv, options = context.options;
  9400. var date = props.date;
  9401. var format = options.weekNumberFormat || props.defaultFormat;
  9402. var num = dateEnv.computeWeekNumber(date); // TODO: somehow use for formatting as well?
  9403. var text = dateEnv.format(date, format);
  9404. var hookProps = { num: num, text: text, date: date };
  9405. return (createElement(RenderHook, { hookProps: hookProps, classNames: options.weekNumberClassNames, content: options.weekNumberContent, defaultContent: renderInner, didMount: options.weekNumberDidMount, willUnmount: options.weekNumberWillUnmount }, props.children));
  9406. })); };
  9407. function renderInner(innerProps) {
  9408. return innerProps.text;
  9409. }
  9410. var PADDING_FROM_VIEWPORT = 10;
  9411. var Popover = /** @class */ (function (_super) {
  9412. __extends(Popover, _super);
  9413. function Popover() {
  9414. var _this = _super !== null && _super.apply(this, arguments) || this;
  9415. _this.state = {
  9416. titleId: getUniqueDomId(),
  9417. };
  9418. _this.handleRootEl = function (el) {
  9419. _this.rootEl = el;
  9420. if (_this.props.elRef) {
  9421. setRef(_this.props.elRef, el);
  9422. }
  9423. };
  9424. // Triggered when the user clicks *anywhere* in the document, for the autoHide feature
  9425. _this.handleDocumentMouseDown = function (ev) {
  9426. // only hide the popover if the click happened outside the popover
  9427. var target = getEventTargetViaRoot(ev);
  9428. if (!_this.rootEl.contains(target)) {
  9429. _this.handleCloseClick();
  9430. }
  9431. };
  9432. _this.handleDocumentKeyDown = function (ev) {
  9433. if (ev.key === 'Escape') {
  9434. _this.handleCloseClick();
  9435. }
  9436. };
  9437. _this.handleCloseClick = function () {
  9438. var onClose = _this.props.onClose;
  9439. if (onClose) {
  9440. onClose();
  9441. }
  9442. };
  9443. return _this;
  9444. }
  9445. Popover.prototype.render = function () {
  9446. var _a = this.context, theme = _a.theme, options = _a.options;
  9447. var _b = this, props = _b.props, state = _b.state;
  9448. var classNames = [
  9449. 'fc-popover',
  9450. theme.getClass('popover'),
  9451. ].concat(props.extraClassNames || []);
  9452. return createPortal(createElement("div", __assign({ id: props.id, className: classNames.join(' '), "aria-labelledby": state.titleId }, props.extraAttrs, { ref: this.handleRootEl }),
  9453. createElement("div", { className: 'fc-popover-header ' + theme.getClass('popoverHeader') },
  9454. createElement("span", { className: "fc-popover-title", id: state.titleId }, props.title),
  9455. createElement("span", { className: 'fc-popover-close ' + theme.getIconClass('close'), title: options.closeHint, onClick: this.handleCloseClick })),
  9456. createElement("div", { className: 'fc-popover-body ' + theme.getClass('popoverContent') }, props.children)), props.parentEl);
  9457. };
  9458. Popover.prototype.componentDidMount = function () {
  9459. document.addEventListener('mousedown', this.handleDocumentMouseDown);
  9460. document.addEventListener('keydown', this.handleDocumentKeyDown);
  9461. this.updateSize();
  9462. };
  9463. Popover.prototype.componentWillUnmount = function () {
  9464. document.removeEventListener('mousedown', this.handleDocumentMouseDown);
  9465. document.removeEventListener('keydown', this.handleDocumentKeyDown);
  9466. };
  9467. Popover.prototype.updateSize = function () {
  9468. var isRtl = this.context.isRtl;
  9469. var _a = this.props, alignmentEl = _a.alignmentEl, alignGridTop = _a.alignGridTop;
  9470. var rootEl = this.rootEl;
  9471. var alignmentRect = computeClippedClientRect(alignmentEl);
  9472. if (alignmentRect) {
  9473. var popoverDims = rootEl.getBoundingClientRect();
  9474. // position relative to viewport
  9475. var popoverTop = alignGridTop
  9476. ? elementClosest(alignmentEl, '.fc-scrollgrid').getBoundingClientRect().top
  9477. : alignmentRect.top;
  9478. var popoverLeft = isRtl ? alignmentRect.right - popoverDims.width : alignmentRect.left;
  9479. // constrain
  9480. popoverTop = Math.max(popoverTop, PADDING_FROM_VIEWPORT);
  9481. popoverLeft = Math.min(popoverLeft, document.documentElement.clientWidth - PADDING_FROM_VIEWPORT - popoverDims.width);
  9482. popoverLeft = Math.max(popoverLeft, PADDING_FROM_VIEWPORT);
  9483. var origin_1 = rootEl.offsetParent.getBoundingClientRect();
  9484. applyStyle(rootEl, {
  9485. top: popoverTop - origin_1.top,
  9486. left: popoverLeft - origin_1.left,
  9487. });
  9488. }
  9489. };
  9490. return Popover;
  9491. }(BaseComponent));
  9492. var MorePopover = /** @class */ (function (_super) {
  9493. __extends(MorePopover, _super);
  9494. function MorePopover() {
  9495. var _this = _super !== null && _super.apply(this, arguments) || this;
  9496. _this.handleRootEl = function (rootEl) {
  9497. _this.rootEl = rootEl;
  9498. if (rootEl) {
  9499. _this.context.registerInteractiveComponent(_this, {
  9500. el: rootEl,
  9501. useEventCenter: false,
  9502. });
  9503. }
  9504. else {
  9505. _this.context.unregisterInteractiveComponent(_this);
  9506. }
  9507. };
  9508. return _this;
  9509. }
  9510. MorePopover.prototype.render = function () {
  9511. var _a = this.context, options = _a.options, dateEnv = _a.dateEnv;
  9512. var props = this.props;
  9513. var startDate = props.startDate, todayRange = props.todayRange, dateProfile = props.dateProfile;
  9514. var title = dateEnv.format(startDate, options.dayPopoverFormat);
  9515. return (createElement(DayCellRoot, { date: startDate, dateProfile: dateProfile, todayRange: todayRange, elRef: this.handleRootEl }, function (rootElRef, dayClassNames, dataAttrs) { return (createElement(Popover, { elRef: rootElRef, id: props.id, title: title, extraClassNames: ['fc-more-popover'].concat(dayClassNames), extraAttrs: dataAttrs /* TODO: make these time-based when not whole-day? */, parentEl: props.parentEl, alignmentEl: props.alignmentEl, alignGridTop: props.alignGridTop, onClose: props.onClose },
  9516. createElement(DayCellContent, { date: startDate, dateProfile: dateProfile, todayRange: todayRange }, function (innerElRef, innerContent) { return (innerContent &&
  9517. createElement("div", { className: "fc-more-popover-misc", ref: innerElRef }, innerContent)); }),
  9518. props.children)); }));
  9519. };
  9520. MorePopover.prototype.queryHit = function (positionLeft, positionTop, elWidth, elHeight) {
  9521. var _a = this, rootEl = _a.rootEl, props = _a.props;
  9522. if (positionLeft >= 0 && positionLeft < elWidth &&
  9523. positionTop >= 0 && positionTop < elHeight) {
  9524. return {
  9525. dateProfile: props.dateProfile,
  9526. dateSpan: __assign({ allDay: true, range: {
  9527. start: props.startDate,
  9528. end: props.endDate,
  9529. } }, props.extraDateSpan),
  9530. dayEl: rootEl,
  9531. rect: {
  9532. left: 0,
  9533. top: 0,
  9534. right: elWidth,
  9535. bottom: elHeight,
  9536. },
  9537. layer: 1, // important when comparing with hits from other components
  9538. };
  9539. }
  9540. return null;
  9541. };
  9542. return MorePopover;
  9543. }(DateComponent));
  9544. var MoreLinkRoot = /** @class */ (function (_super) {
  9545. __extends(MoreLinkRoot, _super);
  9546. function MoreLinkRoot() {
  9547. var _this = _super !== null && _super.apply(this, arguments) || this;
  9548. _this.linkElRef = createRef();
  9549. _this.state = {
  9550. isPopoverOpen: false,
  9551. popoverId: getUniqueDomId(),
  9552. };
  9553. _this.handleClick = function (ev) {
  9554. var _a = _this, props = _a.props, context = _a.context;
  9555. var moreLinkClick = context.options.moreLinkClick;
  9556. var date = computeRange(props).start;
  9557. function buildPublicSeg(seg) {
  9558. var _a = seg.eventRange, def = _a.def, instance = _a.instance, range = _a.range;
  9559. return {
  9560. event: new EventApi(context, def, instance),
  9561. start: context.dateEnv.toDate(range.start),
  9562. end: context.dateEnv.toDate(range.end),
  9563. isStart: seg.isStart,
  9564. isEnd: seg.isEnd,
  9565. };
  9566. }
  9567. if (typeof moreLinkClick === 'function') {
  9568. moreLinkClick = moreLinkClick({
  9569. date: date,
  9570. allDay: Boolean(props.allDayDate),
  9571. allSegs: props.allSegs.map(buildPublicSeg),
  9572. hiddenSegs: props.hiddenSegs.map(buildPublicSeg),
  9573. jsEvent: ev,
  9574. view: context.viewApi,
  9575. });
  9576. }
  9577. if (!moreLinkClick || moreLinkClick === 'popover') {
  9578. _this.setState({ isPopoverOpen: true });
  9579. }
  9580. else if (typeof moreLinkClick === 'string') { // a view name
  9581. context.calendarApi.zoomTo(date, moreLinkClick);
  9582. }
  9583. };
  9584. _this.handlePopoverClose = function () {
  9585. _this.setState({ isPopoverOpen: false });
  9586. };
  9587. return _this;
  9588. }
  9589. MoreLinkRoot.prototype.render = function () {
  9590. var _this = this;
  9591. var _a = this, props = _a.props, state = _a.state;
  9592. return (createElement(ViewContextType.Consumer, null, function (context) {
  9593. var viewApi = context.viewApi, options = context.options, calendarApi = context.calendarApi;
  9594. var moreLinkText = options.moreLinkText;
  9595. var moreCnt = props.moreCnt;
  9596. var range = computeRange(props);
  9597. var text = typeof moreLinkText === 'function' // TODO: eventually use formatWithOrdinals
  9598. ? moreLinkText.call(calendarApi, moreCnt)
  9599. : "+" + moreCnt + " " + moreLinkText;
  9600. var title = formatWithOrdinals(options.moreLinkHint, [moreCnt], text);
  9601. var hookProps = {
  9602. num: moreCnt,
  9603. shortText: "+" + moreCnt,
  9604. text: text,
  9605. view: viewApi,
  9606. };
  9607. return (createElement(Fragment, null,
  9608. Boolean(props.moreCnt) && (createElement(RenderHook, { elRef: _this.linkElRef, hookProps: hookProps, classNames: options.moreLinkClassNames, content: options.moreLinkContent, defaultContent: props.defaultContent || renderMoreLinkInner$1, didMount: options.moreLinkDidMount, willUnmount: options.moreLinkWillUnmount }, function (rootElRef, customClassNames, innerElRef, innerContent) { return props.children(rootElRef, ['fc-more-link'].concat(customClassNames), innerElRef, innerContent, _this.handleClick, title, state.isPopoverOpen, state.isPopoverOpen ? state.popoverId : ''); })),
  9609. state.isPopoverOpen && (createElement(MorePopover, { id: state.popoverId, startDate: range.start, endDate: range.end, dateProfile: props.dateProfile, todayRange: props.todayRange, extraDateSpan: props.extraDateSpan, parentEl: _this.parentEl, alignmentEl: props.alignmentElRef.current, alignGridTop: props.alignGridTop, onClose: _this.handlePopoverClose }, props.popoverContent()))));
  9610. }));
  9611. };
  9612. MoreLinkRoot.prototype.componentDidMount = function () {
  9613. this.updateParentEl();
  9614. };
  9615. MoreLinkRoot.prototype.componentDidUpdate = function () {
  9616. this.updateParentEl();
  9617. };
  9618. MoreLinkRoot.prototype.updateParentEl = function () {
  9619. if (this.linkElRef.current) {
  9620. this.parentEl = elementClosest(this.linkElRef.current, '.fc-view-harness');
  9621. }
  9622. };
  9623. return MoreLinkRoot;
  9624. }(BaseComponent));
  9625. function renderMoreLinkInner$1(props) {
  9626. return props.text;
  9627. }
  9628. function computeRange(props) {
  9629. if (props.allDayDate) {
  9630. return {
  9631. start: props.allDayDate,
  9632. end: addDays(props.allDayDate, 1),
  9633. };
  9634. }
  9635. var hiddenSegs = props.hiddenSegs;
  9636. return {
  9637. start: computeEarliestSegStart(hiddenSegs),
  9638. end: computeLatestSegEnd(hiddenSegs),
  9639. };
  9640. }
  9641. function computeEarliestSegStart(segs) {
  9642. return segs.reduce(pickEarliestStart).eventRange.range.start;
  9643. }
  9644. function pickEarliestStart(seg0, seg1) {
  9645. return seg0.eventRange.range.start < seg1.eventRange.range.start ? seg0 : seg1;
  9646. }
  9647. function computeLatestSegEnd(segs) {
  9648. return segs.reduce(pickLatestEnd).eventRange.range.end;
  9649. }
  9650. function pickLatestEnd(seg0, seg1) {
  9651. return seg0.eventRange.range.end > seg1.eventRange.range.end ? seg0 : seg1;
  9652. }
  9653. // exports
  9654. // --------------------------------------------------------------------------------------------------
  9655. var version = '5.10.1'; // important to type it, so .d.ts has generic string
  9656. var Calendar = /** @class */ (function (_super) {
  9657. __extends(Calendar, _super);
  9658. function Calendar(el, optionOverrides) {
  9659. if (optionOverrides === void 0) { optionOverrides = {}; }
  9660. var _this = _super.call(this) || this;
  9661. _this.isRendering = false;
  9662. _this.isRendered = false;
  9663. _this.currentClassNames = [];
  9664. _this.customContentRenderId = 0; // will affect custom generated classNames?
  9665. _this.handleAction = function (action) {
  9666. // actions we know we want to render immediately
  9667. switch (action.type) {
  9668. case 'SET_EVENT_DRAG':
  9669. case 'SET_EVENT_RESIZE':
  9670. _this.renderRunner.tryDrain();
  9671. }
  9672. };
  9673. _this.handleData = function (data) {
  9674. _this.currentData = data;
  9675. _this.renderRunner.request(data.calendarOptions.rerenderDelay);
  9676. };
  9677. _this.handleRenderRequest = function () {
  9678. if (_this.isRendering) {
  9679. _this.isRendered = true;
  9680. var currentData_1 = _this.currentData;
  9681. render(createElement(CalendarRoot, { options: currentData_1.calendarOptions, theme: currentData_1.theme, emitter: currentData_1.emitter }, function (classNames, height, isHeightAuto, forPrint) {
  9682. _this.setClassNames(classNames);
  9683. _this.setHeight(height);
  9684. return (createElement(CustomContentRenderContext.Provider, { value: _this.customContentRenderId },
  9685. createElement(CalendarContent, __assign({ isHeightAuto: isHeightAuto, forPrint: forPrint }, currentData_1))));
  9686. }), _this.el);
  9687. }
  9688. else if (_this.isRendered) {
  9689. _this.isRendered = false;
  9690. unmountComponentAtNode(_this.el);
  9691. _this.setClassNames([]);
  9692. _this.setHeight('');
  9693. }
  9694. flushToDom();
  9695. };
  9696. _this.el = el;
  9697. _this.renderRunner = new DelayedRunner(_this.handleRenderRequest);
  9698. new CalendarDataManager({
  9699. optionOverrides: optionOverrides,
  9700. calendarApi: _this,
  9701. onAction: _this.handleAction,
  9702. onData: _this.handleData,
  9703. });
  9704. return _this;
  9705. }
  9706. Object.defineProperty(Calendar.prototype, "view", {
  9707. get: function () { return this.currentData.viewApi; } // for public API
  9708. ,
  9709. enumerable: false,
  9710. configurable: true
  9711. });
  9712. Calendar.prototype.render = function () {
  9713. var wasRendering = this.isRendering;
  9714. if (!wasRendering) {
  9715. this.isRendering = true;
  9716. }
  9717. else {
  9718. this.customContentRenderId += 1;
  9719. }
  9720. this.renderRunner.request();
  9721. if (wasRendering) {
  9722. this.updateSize();
  9723. }
  9724. };
  9725. Calendar.prototype.destroy = function () {
  9726. if (this.isRendering) {
  9727. this.isRendering = false;
  9728. this.renderRunner.request();
  9729. }
  9730. };
  9731. Calendar.prototype.updateSize = function () {
  9732. _super.prototype.updateSize.call(this);
  9733. flushToDom();
  9734. };
  9735. Calendar.prototype.batchRendering = function (func) {
  9736. this.renderRunner.pause('batchRendering');
  9737. func();
  9738. this.renderRunner.resume('batchRendering');
  9739. };
  9740. Calendar.prototype.pauseRendering = function () {
  9741. this.renderRunner.pause('pauseRendering');
  9742. };
  9743. Calendar.prototype.resumeRendering = function () {
  9744. this.renderRunner.resume('pauseRendering', true);
  9745. };
  9746. Calendar.prototype.resetOptions = function (optionOverrides, append) {
  9747. this.currentDataManager.resetOptions(optionOverrides, append);
  9748. };
  9749. Calendar.prototype.setClassNames = function (classNames) {
  9750. if (!isArraysEqual(classNames, this.currentClassNames)) {
  9751. var classList = this.el.classList;
  9752. for (var _i = 0, _a = this.currentClassNames; _i < _a.length; _i++) {
  9753. var className = _a[_i];
  9754. classList.remove(className);
  9755. }
  9756. for (var _b = 0, classNames_1 = classNames; _b < classNames_1.length; _b++) {
  9757. var className = classNames_1[_b];
  9758. classList.add(className);
  9759. }
  9760. this.currentClassNames = classNames;
  9761. }
  9762. };
  9763. Calendar.prototype.setHeight = function (height) {
  9764. applyStyleProp(this.el, 'height', height);
  9765. };
  9766. return Calendar;
  9767. }(CalendarApi));
  9768. config.touchMouseIgnoreWait = 500;
  9769. var ignoreMouseDepth = 0;
  9770. var listenerCnt = 0;
  9771. var isWindowTouchMoveCancelled = false;
  9772. /*
  9773. Uses a "pointer" abstraction, which monitors UI events for both mouse and touch.
  9774. Tracks when the pointer "drags" on a certain element, meaning down+move+up.
  9775. Also, tracks if there was touch-scrolling.
  9776. Also, can prevent touch-scrolling from happening.
  9777. Also, can fire pointermove events when scrolling happens underneath, even when no real pointer movement.
  9778. emits:
  9779. - pointerdown
  9780. - pointermove
  9781. - pointerup
  9782. */
  9783. var PointerDragging = /** @class */ (function () {
  9784. function PointerDragging(containerEl) {
  9785. var _this = this;
  9786. this.subjectEl = null;
  9787. // options that can be directly assigned by caller
  9788. this.selector = ''; // will cause subjectEl in all emitted events to be this element
  9789. this.handleSelector = '';
  9790. this.shouldIgnoreMove = false;
  9791. this.shouldWatchScroll = true; // for simulating pointermove on scroll
  9792. // internal states
  9793. this.isDragging = false;
  9794. this.isTouchDragging = false;
  9795. this.wasTouchScroll = false;
  9796. // Mouse
  9797. // ----------------------------------------------------------------------------------------------------
  9798. this.handleMouseDown = function (ev) {
  9799. if (!_this.shouldIgnoreMouse() &&
  9800. isPrimaryMouseButton(ev) &&
  9801. _this.tryStart(ev)) {
  9802. var pev = _this.createEventFromMouse(ev, true);
  9803. _this.emitter.trigger('pointerdown', pev);
  9804. _this.initScrollWatch(pev);
  9805. if (!_this.shouldIgnoreMove) {
  9806. document.addEventListener('mousemove', _this.handleMouseMove);
  9807. }
  9808. document.addEventListener('mouseup', _this.handleMouseUp);
  9809. }
  9810. };
  9811. this.handleMouseMove = function (ev) {
  9812. var pev = _this.createEventFromMouse(ev);
  9813. _this.recordCoords(pev);
  9814. _this.emitter.trigger('pointermove', pev);
  9815. };
  9816. this.handleMouseUp = function (ev) {
  9817. document.removeEventListener('mousemove', _this.handleMouseMove);
  9818. document.removeEventListener('mouseup', _this.handleMouseUp);
  9819. _this.emitter.trigger('pointerup', _this.createEventFromMouse(ev));
  9820. _this.cleanup(); // call last so that pointerup has access to props
  9821. };
  9822. // Touch
  9823. // ----------------------------------------------------------------------------------------------------
  9824. this.handleTouchStart = function (ev) {
  9825. if (_this.tryStart(ev)) {
  9826. _this.isTouchDragging = true;
  9827. var pev = _this.createEventFromTouch(ev, true);
  9828. _this.emitter.trigger('pointerdown', pev);
  9829. _this.initScrollWatch(pev);
  9830. // unlike mouse, need to attach to target, not document
  9831. // https://stackoverflow.com/a/45760014
  9832. var targetEl = ev.target;
  9833. if (!_this.shouldIgnoreMove) {
  9834. targetEl.addEventListener('touchmove', _this.handleTouchMove);
  9835. }
  9836. targetEl.addEventListener('touchend', _this.handleTouchEnd);
  9837. targetEl.addEventListener('touchcancel', _this.handleTouchEnd); // treat it as a touch end
  9838. // attach a handler to get called when ANY scroll action happens on the page.
  9839. // this was impossible to do with normal on/off because 'scroll' doesn't bubble.
  9840. // http://stackoverflow.com/a/32954565/96342
  9841. window.addEventListener('scroll', _this.handleTouchScroll, true);
  9842. }
  9843. };
  9844. this.handleTouchMove = function (ev) {
  9845. var pev = _this.createEventFromTouch(ev);
  9846. _this.recordCoords(pev);
  9847. _this.emitter.trigger('pointermove', pev);
  9848. };
  9849. this.handleTouchEnd = function (ev) {
  9850. if (_this.isDragging) { // done to guard against touchend followed by touchcancel
  9851. var targetEl = ev.target;
  9852. targetEl.removeEventListener('touchmove', _this.handleTouchMove);
  9853. targetEl.removeEventListener('touchend', _this.handleTouchEnd);
  9854. targetEl.removeEventListener('touchcancel', _this.handleTouchEnd);
  9855. window.removeEventListener('scroll', _this.handleTouchScroll, true); // useCaptured=true
  9856. _this.emitter.trigger('pointerup', _this.createEventFromTouch(ev));
  9857. _this.cleanup(); // call last so that pointerup has access to props
  9858. _this.isTouchDragging = false;
  9859. startIgnoringMouse();
  9860. }
  9861. };
  9862. this.handleTouchScroll = function () {
  9863. _this.wasTouchScroll = true;
  9864. };
  9865. this.handleScroll = function (ev) {
  9866. if (!_this.shouldIgnoreMove) {
  9867. var pageX = (window.pageXOffset - _this.prevScrollX) + _this.prevPageX;
  9868. var pageY = (window.pageYOffset - _this.prevScrollY) + _this.prevPageY;
  9869. _this.emitter.trigger('pointermove', {
  9870. origEvent: ev,
  9871. isTouch: _this.isTouchDragging,
  9872. subjectEl: _this.subjectEl,
  9873. pageX: pageX,
  9874. pageY: pageY,
  9875. deltaX: pageX - _this.origPageX,
  9876. deltaY: pageY - _this.origPageY,
  9877. });
  9878. }
  9879. };
  9880. this.containerEl = containerEl;
  9881. this.emitter = new Emitter();
  9882. containerEl.addEventListener('mousedown', this.handleMouseDown);
  9883. containerEl.addEventListener('touchstart', this.handleTouchStart, { passive: true });
  9884. listenerCreated();
  9885. }
  9886. PointerDragging.prototype.destroy = function () {
  9887. this.containerEl.removeEventListener('mousedown', this.handleMouseDown);
  9888. this.containerEl.removeEventListener('touchstart', this.handleTouchStart, { passive: true });
  9889. listenerDestroyed();
  9890. };
  9891. PointerDragging.prototype.tryStart = function (ev) {
  9892. var subjectEl = this.querySubjectEl(ev);
  9893. var downEl = ev.target;
  9894. if (subjectEl &&
  9895. (!this.handleSelector || elementClosest(downEl, this.handleSelector))) {
  9896. this.subjectEl = subjectEl;
  9897. this.isDragging = true; // do this first so cancelTouchScroll will work
  9898. this.wasTouchScroll = false;
  9899. return true;
  9900. }
  9901. return false;
  9902. };
  9903. PointerDragging.prototype.cleanup = function () {
  9904. isWindowTouchMoveCancelled = false;
  9905. this.isDragging = false;
  9906. this.subjectEl = null;
  9907. // keep wasTouchScroll around for later access
  9908. this.destroyScrollWatch();
  9909. };
  9910. PointerDragging.prototype.querySubjectEl = function (ev) {
  9911. if (this.selector) {
  9912. return elementClosest(ev.target, this.selector);
  9913. }
  9914. return this.containerEl;
  9915. };
  9916. PointerDragging.prototype.shouldIgnoreMouse = function () {
  9917. return ignoreMouseDepth || this.isTouchDragging;
  9918. };
  9919. // can be called by user of this class, to cancel touch-based scrolling for the current drag
  9920. PointerDragging.prototype.cancelTouchScroll = function () {
  9921. if (this.isDragging) {
  9922. isWindowTouchMoveCancelled = true;
  9923. }
  9924. };
  9925. // Scrolling that simulates pointermoves
  9926. // ----------------------------------------------------------------------------------------------------
  9927. PointerDragging.prototype.initScrollWatch = function (ev) {
  9928. if (this.shouldWatchScroll) {
  9929. this.recordCoords(ev);
  9930. window.addEventListener('scroll', this.handleScroll, true); // useCapture=true
  9931. }
  9932. };
  9933. PointerDragging.prototype.recordCoords = function (ev) {
  9934. if (this.shouldWatchScroll) {
  9935. this.prevPageX = ev.pageX;
  9936. this.prevPageY = ev.pageY;
  9937. this.prevScrollX = window.pageXOffset;
  9938. this.prevScrollY = window.pageYOffset;
  9939. }
  9940. };
  9941. PointerDragging.prototype.destroyScrollWatch = function () {
  9942. if (this.shouldWatchScroll) {
  9943. window.removeEventListener('scroll', this.handleScroll, true); // useCaptured=true
  9944. }
  9945. };
  9946. // Event Normalization
  9947. // ----------------------------------------------------------------------------------------------------
  9948. PointerDragging.prototype.createEventFromMouse = function (ev, isFirst) {
  9949. var deltaX = 0;
  9950. var deltaY = 0;
  9951. // TODO: repeat code
  9952. if (isFirst) {
  9953. this.origPageX = ev.pageX;
  9954. this.origPageY = ev.pageY;
  9955. }
  9956. else {
  9957. deltaX = ev.pageX - this.origPageX;
  9958. deltaY = ev.pageY - this.origPageY;
  9959. }
  9960. return {
  9961. origEvent: ev,
  9962. isTouch: false,
  9963. subjectEl: this.subjectEl,
  9964. pageX: ev.pageX,
  9965. pageY: ev.pageY,
  9966. deltaX: deltaX,
  9967. deltaY: deltaY,
  9968. };
  9969. };
  9970. PointerDragging.prototype.createEventFromTouch = function (ev, isFirst) {
  9971. var touches = ev.touches;
  9972. var pageX;
  9973. var pageY;
  9974. var deltaX = 0;
  9975. var deltaY = 0;
  9976. // if touch coords available, prefer,
  9977. // because FF would give bad ev.pageX ev.pageY
  9978. if (touches && touches.length) {
  9979. pageX = touches[0].pageX;
  9980. pageY = touches[0].pageY;
  9981. }
  9982. else {
  9983. pageX = ev.pageX;
  9984. pageY = ev.pageY;
  9985. }
  9986. // TODO: repeat code
  9987. if (isFirst) {
  9988. this.origPageX = pageX;
  9989. this.origPageY = pageY;
  9990. }
  9991. else {
  9992. deltaX = pageX - this.origPageX;
  9993. deltaY = pageY - this.origPageY;
  9994. }
  9995. return {
  9996. origEvent: ev,
  9997. isTouch: true,
  9998. subjectEl: this.subjectEl,
  9999. pageX: pageX,
  10000. pageY: pageY,
  10001. deltaX: deltaX,
  10002. deltaY: deltaY,
  10003. };
  10004. };
  10005. return PointerDragging;
  10006. }());
  10007. // Returns a boolean whether this was a left mouse click and no ctrl key (which means right click on Mac)
  10008. function isPrimaryMouseButton(ev) {
  10009. return ev.button === 0 && !ev.ctrlKey;
  10010. }
  10011. // Ignoring fake mouse events generated by touch
  10012. // ----------------------------------------------------------------------------------------------------
  10013. function startIgnoringMouse() {
  10014. ignoreMouseDepth += 1;
  10015. setTimeout(function () {
  10016. ignoreMouseDepth -= 1;
  10017. }, config.touchMouseIgnoreWait);
  10018. }
  10019. // We want to attach touchmove as early as possible for Safari
  10020. // ----------------------------------------------------------------------------------------------------
  10021. function listenerCreated() {
  10022. listenerCnt += 1;
  10023. if (listenerCnt === 1) {
  10024. window.addEventListener('touchmove', onWindowTouchMove, { passive: false });
  10025. }
  10026. }
  10027. function listenerDestroyed() {
  10028. listenerCnt -= 1;
  10029. if (!listenerCnt) {
  10030. window.removeEventListener('touchmove', onWindowTouchMove, { passive: false });
  10031. }
  10032. }
  10033. function onWindowTouchMove(ev) {
  10034. if (isWindowTouchMoveCancelled) {
  10035. ev.preventDefault();
  10036. }
  10037. }
  10038. /*
  10039. An effect in which an element follows the movement of a pointer across the screen.
  10040. The moving element is a clone of some other element.
  10041. Must call start + handleMove + stop.
  10042. */
  10043. var ElementMirror = /** @class */ (function () {
  10044. function ElementMirror() {
  10045. this.isVisible = false; // must be explicitly enabled
  10046. this.sourceEl = null;
  10047. this.mirrorEl = null;
  10048. this.sourceElRect = null; // screen coords relative to viewport
  10049. // options that can be set directly by caller
  10050. this.parentNode = document.body; // HIGHLY SUGGESTED to set this to sidestep ShadowDOM issues
  10051. this.zIndex = 9999;
  10052. this.revertDuration = 0;
  10053. }
  10054. ElementMirror.prototype.start = function (sourceEl, pageX, pageY) {
  10055. this.sourceEl = sourceEl;
  10056. this.sourceElRect = this.sourceEl.getBoundingClientRect();
  10057. this.origScreenX = pageX - window.pageXOffset;
  10058. this.origScreenY = pageY - window.pageYOffset;
  10059. this.deltaX = 0;
  10060. this.deltaY = 0;
  10061. this.updateElPosition();
  10062. };
  10063. ElementMirror.prototype.handleMove = function (pageX, pageY) {
  10064. this.deltaX = (pageX - window.pageXOffset) - this.origScreenX;
  10065. this.deltaY = (pageY - window.pageYOffset) - this.origScreenY;
  10066. this.updateElPosition();
  10067. };
  10068. // can be called before start
  10069. ElementMirror.prototype.setIsVisible = function (bool) {
  10070. if (bool) {
  10071. if (!this.isVisible) {
  10072. if (this.mirrorEl) {
  10073. this.mirrorEl.style.display = '';
  10074. }
  10075. this.isVisible = bool; // needs to happen before updateElPosition
  10076. this.updateElPosition(); // because was not updating the position while invisible
  10077. }
  10078. }
  10079. else if (this.isVisible) {
  10080. if (this.mirrorEl) {
  10081. this.mirrorEl.style.display = 'none';
  10082. }
  10083. this.isVisible = bool;
  10084. }
  10085. };
  10086. // always async
  10087. ElementMirror.prototype.stop = function (needsRevertAnimation, callback) {
  10088. var _this = this;
  10089. var done = function () {
  10090. _this.cleanup();
  10091. callback();
  10092. };
  10093. if (needsRevertAnimation &&
  10094. this.mirrorEl &&
  10095. this.isVisible &&
  10096. this.revertDuration && // if 0, transition won't work
  10097. (this.deltaX || this.deltaY) // if same coords, transition won't work
  10098. ) {
  10099. this.doRevertAnimation(done, this.revertDuration);
  10100. }
  10101. else {
  10102. setTimeout(done, 0);
  10103. }
  10104. };
  10105. ElementMirror.prototype.doRevertAnimation = function (callback, revertDuration) {
  10106. var mirrorEl = this.mirrorEl;
  10107. var finalSourceElRect = this.sourceEl.getBoundingClientRect(); // because autoscrolling might have happened
  10108. mirrorEl.style.transition =
  10109. 'top ' + revertDuration + 'ms,' +
  10110. 'left ' + revertDuration + 'ms';
  10111. applyStyle(mirrorEl, {
  10112. left: finalSourceElRect.left,
  10113. top: finalSourceElRect.top,
  10114. });
  10115. whenTransitionDone(mirrorEl, function () {
  10116. mirrorEl.style.transition = '';
  10117. callback();
  10118. });
  10119. };
  10120. ElementMirror.prototype.cleanup = function () {
  10121. if (this.mirrorEl) {
  10122. removeElement(this.mirrorEl);
  10123. this.mirrorEl = null;
  10124. }
  10125. this.sourceEl = null;
  10126. };
  10127. ElementMirror.prototype.updateElPosition = function () {
  10128. if (this.sourceEl && this.isVisible) {
  10129. applyStyle(this.getMirrorEl(), {
  10130. left: this.sourceElRect.left + this.deltaX,
  10131. top: this.sourceElRect.top + this.deltaY,
  10132. });
  10133. }
  10134. };
  10135. ElementMirror.prototype.getMirrorEl = function () {
  10136. var sourceElRect = this.sourceElRect;
  10137. var mirrorEl = this.mirrorEl;
  10138. if (!mirrorEl) {
  10139. mirrorEl = this.mirrorEl = this.sourceEl.cloneNode(true); // cloneChildren=true
  10140. // we don't want long taps or any mouse interaction causing selection/menus.
  10141. // would use preventSelection(), but that prevents selectstart, causing problems.
  10142. mirrorEl.classList.add('fc-unselectable');
  10143. mirrorEl.classList.add('fc-event-dragging');
  10144. applyStyle(mirrorEl, {
  10145. position: 'fixed',
  10146. zIndex: this.zIndex,
  10147. visibility: '',
  10148. boxSizing: 'border-box',
  10149. width: sourceElRect.right - sourceElRect.left,
  10150. height: sourceElRect.bottom - sourceElRect.top,
  10151. right: 'auto',
  10152. bottom: 'auto',
  10153. margin: 0,
  10154. });
  10155. this.parentNode.appendChild(mirrorEl);
  10156. }
  10157. return mirrorEl;
  10158. };
  10159. return ElementMirror;
  10160. }());
  10161. /*
  10162. Is a cache for a given element's scroll information (all the info that ScrollController stores)
  10163. in addition the "client rectangle" of the element.. the area within the scrollbars.
  10164. The cache can be in one of two modes:
  10165. - doesListening:false - ignores when the container is scrolled by someone else
  10166. - doesListening:true - watch for scrolling and update the cache
  10167. */
  10168. var ScrollGeomCache = /** @class */ (function (_super) {
  10169. __extends(ScrollGeomCache, _super);
  10170. function ScrollGeomCache(scrollController, doesListening) {
  10171. var _this = _super.call(this) || this;
  10172. _this.handleScroll = function () {
  10173. _this.scrollTop = _this.scrollController.getScrollTop();
  10174. _this.scrollLeft = _this.scrollController.getScrollLeft();
  10175. _this.handleScrollChange();
  10176. };
  10177. _this.scrollController = scrollController;
  10178. _this.doesListening = doesListening;
  10179. _this.scrollTop = _this.origScrollTop = scrollController.getScrollTop();
  10180. _this.scrollLeft = _this.origScrollLeft = scrollController.getScrollLeft();
  10181. _this.scrollWidth = scrollController.getScrollWidth();
  10182. _this.scrollHeight = scrollController.getScrollHeight();
  10183. _this.clientWidth = scrollController.getClientWidth();
  10184. _this.clientHeight = scrollController.getClientHeight();
  10185. _this.clientRect = _this.computeClientRect(); // do last in case it needs cached values
  10186. if (_this.doesListening) {
  10187. _this.getEventTarget().addEventListener('scroll', _this.handleScroll);
  10188. }
  10189. return _this;
  10190. }
  10191. ScrollGeomCache.prototype.destroy = function () {
  10192. if (this.doesListening) {
  10193. this.getEventTarget().removeEventListener('scroll', this.handleScroll);
  10194. }
  10195. };
  10196. ScrollGeomCache.prototype.getScrollTop = function () {
  10197. return this.scrollTop;
  10198. };
  10199. ScrollGeomCache.prototype.getScrollLeft = function () {
  10200. return this.scrollLeft;
  10201. };
  10202. ScrollGeomCache.prototype.setScrollTop = function (top) {
  10203. this.scrollController.setScrollTop(top);
  10204. if (!this.doesListening) {
  10205. // we are not relying on the element to normalize out-of-bounds scroll values
  10206. // so we need to sanitize ourselves
  10207. this.scrollTop = Math.max(Math.min(top, this.getMaxScrollTop()), 0);
  10208. this.handleScrollChange();
  10209. }
  10210. };
  10211. ScrollGeomCache.prototype.setScrollLeft = function (top) {
  10212. this.scrollController.setScrollLeft(top);
  10213. if (!this.doesListening) {
  10214. // we are not relying on the element to normalize out-of-bounds scroll values
  10215. // so we need to sanitize ourselves
  10216. this.scrollLeft = Math.max(Math.min(top, this.getMaxScrollLeft()), 0);
  10217. this.handleScrollChange();
  10218. }
  10219. };
  10220. ScrollGeomCache.prototype.getClientWidth = function () {
  10221. return this.clientWidth;
  10222. };
  10223. ScrollGeomCache.prototype.getClientHeight = function () {
  10224. return this.clientHeight;
  10225. };
  10226. ScrollGeomCache.prototype.getScrollWidth = function () {
  10227. return this.scrollWidth;
  10228. };
  10229. ScrollGeomCache.prototype.getScrollHeight = function () {
  10230. return this.scrollHeight;
  10231. };
  10232. ScrollGeomCache.prototype.handleScrollChange = function () {
  10233. };
  10234. return ScrollGeomCache;
  10235. }(ScrollController));
  10236. var ElementScrollGeomCache = /** @class */ (function (_super) {
  10237. __extends(ElementScrollGeomCache, _super);
  10238. function ElementScrollGeomCache(el, doesListening) {
  10239. return _super.call(this, new ElementScrollController(el), doesListening) || this;
  10240. }
  10241. ElementScrollGeomCache.prototype.getEventTarget = function () {
  10242. return this.scrollController.el;
  10243. };
  10244. ElementScrollGeomCache.prototype.computeClientRect = function () {
  10245. return computeInnerRect(this.scrollController.el);
  10246. };
  10247. return ElementScrollGeomCache;
  10248. }(ScrollGeomCache));
  10249. var WindowScrollGeomCache = /** @class */ (function (_super) {
  10250. __extends(WindowScrollGeomCache, _super);
  10251. function WindowScrollGeomCache(doesListening) {
  10252. return _super.call(this, new WindowScrollController(), doesListening) || this;
  10253. }
  10254. WindowScrollGeomCache.prototype.getEventTarget = function () {
  10255. return window;
  10256. };
  10257. WindowScrollGeomCache.prototype.computeClientRect = function () {
  10258. return {
  10259. left: this.scrollLeft,
  10260. right: this.scrollLeft + this.clientWidth,
  10261. top: this.scrollTop,
  10262. bottom: this.scrollTop + this.clientHeight,
  10263. };
  10264. };
  10265. // the window is the only scroll object that changes it's rectangle relative
  10266. // to the document's topleft as it scrolls
  10267. WindowScrollGeomCache.prototype.handleScrollChange = function () {
  10268. this.clientRect = this.computeClientRect();
  10269. };
  10270. return WindowScrollGeomCache;
  10271. }(ScrollGeomCache));
  10272. // If available we are using native "performance" API instead of "Date"
  10273. // Read more about it on MDN:
  10274. // https://developer.mozilla.org/en-US/docs/Web/API/Performance
  10275. var getTime = typeof performance === 'function' ? performance.now : Date.now;
  10276. /*
  10277. For a pointer interaction, automatically scrolls certain scroll containers when the pointer
  10278. approaches the edge.
  10279. The caller must call start + handleMove + stop.
  10280. */
  10281. var AutoScroller = /** @class */ (function () {
  10282. function AutoScroller() {
  10283. var _this = this;
  10284. // options that can be set by caller
  10285. this.isEnabled = true;
  10286. this.scrollQuery = [window, '.fc-scroller'];
  10287. this.edgeThreshold = 50; // pixels
  10288. this.maxVelocity = 300; // pixels per second
  10289. // internal state
  10290. this.pointerScreenX = null;
  10291. this.pointerScreenY = null;
  10292. this.isAnimating = false;
  10293. this.scrollCaches = null;
  10294. // protect against the initial pointerdown being too close to an edge and starting the scroll
  10295. this.everMovedUp = false;
  10296. this.everMovedDown = false;
  10297. this.everMovedLeft = false;
  10298. this.everMovedRight = false;
  10299. this.animate = function () {
  10300. if (_this.isAnimating) { // wasn't cancelled between animation calls
  10301. var edge = _this.computeBestEdge(_this.pointerScreenX + window.pageXOffset, _this.pointerScreenY + window.pageYOffset);
  10302. if (edge) {
  10303. var now = getTime();
  10304. _this.handleSide(edge, (now - _this.msSinceRequest) / 1000);
  10305. _this.requestAnimation(now);
  10306. }
  10307. else {
  10308. _this.isAnimating = false; // will stop animation
  10309. }
  10310. }
  10311. };
  10312. }
  10313. AutoScroller.prototype.start = function (pageX, pageY, scrollStartEl) {
  10314. if (this.isEnabled) {
  10315. this.scrollCaches = this.buildCaches(scrollStartEl);
  10316. this.pointerScreenX = null;
  10317. this.pointerScreenY = null;
  10318. this.everMovedUp = false;
  10319. this.everMovedDown = false;
  10320. this.everMovedLeft = false;
  10321. this.everMovedRight = false;
  10322. this.handleMove(pageX, pageY);
  10323. }
  10324. };
  10325. AutoScroller.prototype.handleMove = function (pageX, pageY) {
  10326. if (this.isEnabled) {
  10327. var pointerScreenX = pageX - window.pageXOffset;
  10328. var pointerScreenY = pageY - window.pageYOffset;
  10329. var yDelta = this.pointerScreenY === null ? 0 : pointerScreenY - this.pointerScreenY;
  10330. var xDelta = this.pointerScreenX === null ? 0 : pointerScreenX - this.pointerScreenX;
  10331. if (yDelta < 0) {
  10332. this.everMovedUp = true;
  10333. }
  10334. else if (yDelta > 0) {
  10335. this.everMovedDown = true;
  10336. }
  10337. if (xDelta < 0) {
  10338. this.everMovedLeft = true;
  10339. }
  10340. else if (xDelta > 0) {
  10341. this.everMovedRight = true;
  10342. }
  10343. this.pointerScreenX = pointerScreenX;
  10344. this.pointerScreenY = pointerScreenY;
  10345. if (!this.isAnimating) {
  10346. this.isAnimating = true;
  10347. this.requestAnimation(getTime());
  10348. }
  10349. }
  10350. };
  10351. AutoScroller.prototype.stop = function () {
  10352. if (this.isEnabled) {
  10353. this.isAnimating = false; // will stop animation
  10354. for (var _i = 0, _a = this.scrollCaches; _i < _a.length; _i++) {
  10355. var scrollCache = _a[_i];
  10356. scrollCache.destroy();
  10357. }
  10358. this.scrollCaches = null;
  10359. }
  10360. };
  10361. AutoScroller.prototype.requestAnimation = function (now) {
  10362. this.msSinceRequest = now;
  10363. requestAnimationFrame(this.animate);
  10364. };
  10365. AutoScroller.prototype.handleSide = function (edge, seconds) {
  10366. var scrollCache = edge.scrollCache;
  10367. var edgeThreshold = this.edgeThreshold;
  10368. var invDistance = edgeThreshold - edge.distance;
  10369. var velocity = // the closer to the edge, the faster we scroll
  10370. ((invDistance * invDistance) / (edgeThreshold * edgeThreshold)) * // quadratic
  10371. this.maxVelocity * seconds;
  10372. var sign = 1;
  10373. switch (edge.name) {
  10374. case 'left':
  10375. sign = -1;
  10376. // falls through
  10377. case 'right':
  10378. scrollCache.setScrollLeft(scrollCache.getScrollLeft() + velocity * sign);
  10379. break;
  10380. case 'top':
  10381. sign = -1;
  10382. // falls through
  10383. case 'bottom':
  10384. scrollCache.setScrollTop(scrollCache.getScrollTop() + velocity * sign);
  10385. break;
  10386. }
  10387. };
  10388. // left/top are relative to document topleft
  10389. AutoScroller.prototype.computeBestEdge = function (left, top) {
  10390. var edgeThreshold = this.edgeThreshold;
  10391. var bestSide = null;
  10392. for (var _i = 0, _a = this.scrollCaches; _i < _a.length; _i++) {
  10393. var scrollCache = _a[_i];
  10394. var rect = scrollCache.clientRect;
  10395. var leftDist = left - rect.left;
  10396. var rightDist = rect.right - left;
  10397. var topDist = top - rect.top;
  10398. var bottomDist = rect.bottom - top;
  10399. // completely within the rect?
  10400. if (leftDist >= 0 && rightDist >= 0 && topDist >= 0 && bottomDist >= 0) {
  10401. if (topDist <= edgeThreshold && this.everMovedUp && scrollCache.canScrollUp() &&
  10402. (!bestSide || bestSide.distance > topDist)) {
  10403. bestSide = { scrollCache: scrollCache, name: 'top', distance: topDist };
  10404. }
  10405. if (bottomDist <= edgeThreshold && this.everMovedDown && scrollCache.canScrollDown() &&
  10406. (!bestSide || bestSide.distance > bottomDist)) {
  10407. bestSide = { scrollCache: scrollCache, name: 'bottom', distance: bottomDist };
  10408. }
  10409. if (leftDist <= edgeThreshold && this.everMovedLeft && scrollCache.canScrollLeft() &&
  10410. (!bestSide || bestSide.distance > leftDist)) {
  10411. bestSide = { scrollCache: scrollCache, name: 'left', distance: leftDist };
  10412. }
  10413. if (rightDist <= edgeThreshold && this.everMovedRight && scrollCache.canScrollRight() &&
  10414. (!bestSide || bestSide.distance > rightDist)) {
  10415. bestSide = { scrollCache: scrollCache, name: 'right', distance: rightDist };
  10416. }
  10417. }
  10418. }
  10419. return bestSide;
  10420. };
  10421. AutoScroller.prototype.buildCaches = function (scrollStartEl) {
  10422. return this.queryScrollEls(scrollStartEl).map(function (el) {
  10423. if (el === window) {
  10424. return new WindowScrollGeomCache(false); // false = don't listen to user-generated scrolls
  10425. }
  10426. return new ElementScrollGeomCache(el, false); // false = don't listen to user-generated scrolls
  10427. });
  10428. };
  10429. AutoScroller.prototype.queryScrollEls = function (scrollStartEl) {
  10430. var els = [];
  10431. for (var _i = 0, _a = this.scrollQuery; _i < _a.length; _i++) {
  10432. var query = _a[_i];
  10433. if (typeof query === 'object') {
  10434. els.push(query);
  10435. }
  10436. else {
  10437. els.push.apply(els, Array.prototype.slice.call(getElRoot(scrollStartEl).querySelectorAll(query)));
  10438. }
  10439. }
  10440. return els;
  10441. };
  10442. return AutoScroller;
  10443. }());
  10444. /*
  10445. Monitors dragging on an element. Has a number of high-level features:
  10446. - minimum distance required before dragging
  10447. - minimum wait time ("delay") before dragging
  10448. - a mirror element that follows the pointer
  10449. */
  10450. var FeaturefulElementDragging = /** @class */ (function (_super) {
  10451. __extends(FeaturefulElementDragging, _super);
  10452. function FeaturefulElementDragging(containerEl, selector) {
  10453. var _this = _super.call(this, containerEl) || this;
  10454. _this.containerEl = containerEl;
  10455. // options that can be directly set by caller
  10456. // the caller can also set the PointerDragging's options as well
  10457. _this.delay = null;
  10458. _this.minDistance = 0;
  10459. _this.touchScrollAllowed = true; // prevents drag from starting and blocks scrolling during drag
  10460. _this.mirrorNeedsRevert = false;
  10461. _this.isInteracting = false; // is the user validly moving the pointer? lasts until pointerup
  10462. _this.isDragging = false; // is it INTENTFULLY dragging? lasts until after revert animation
  10463. _this.isDelayEnded = false;
  10464. _this.isDistanceSurpassed = false;
  10465. _this.delayTimeoutId = null;
  10466. _this.onPointerDown = function (ev) {
  10467. if (!_this.isDragging) { // so new drag doesn't happen while revert animation is going
  10468. _this.isInteracting = true;
  10469. _this.isDelayEnded = false;
  10470. _this.isDistanceSurpassed = false;
  10471. preventSelection(document.body);
  10472. preventContextMenu(document.body);
  10473. // prevent links from being visited if there's an eventual drag.
  10474. // also prevents selection in older browsers (maybe?).
  10475. // not necessary for touch, besides, browser would complain about passiveness.
  10476. if (!ev.isTouch) {
  10477. ev.origEvent.preventDefault();
  10478. }
  10479. _this.emitter.trigger('pointerdown', ev);
  10480. if (_this.isInteracting && // not destroyed via pointerdown handler
  10481. !_this.pointer.shouldIgnoreMove) {
  10482. // actions related to initiating dragstart+dragmove+dragend...
  10483. _this.mirror.setIsVisible(false); // reset. caller must set-visible
  10484. _this.mirror.start(ev.subjectEl, ev.pageX, ev.pageY); // must happen on first pointer down
  10485. _this.startDelay(ev);
  10486. if (!_this.minDistance) {
  10487. _this.handleDistanceSurpassed(ev);
  10488. }
  10489. }
  10490. }
  10491. };
  10492. _this.onPointerMove = function (ev) {
  10493. if (_this.isInteracting) {
  10494. _this.emitter.trigger('pointermove', ev);
  10495. if (!_this.isDistanceSurpassed) {
  10496. var minDistance = _this.minDistance;
  10497. var distanceSq = void 0; // current distance from the origin, squared
  10498. var deltaX = ev.deltaX, deltaY = ev.deltaY;
  10499. distanceSq = deltaX * deltaX + deltaY * deltaY;
  10500. if (distanceSq >= minDistance * minDistance) { // use pythagorean theorem
  10501. _this.handleDistanceSurpassed(ev);
  10502. }
  10503. }
  10504. if (_this.isDragging) {
  10505. // a real pointer move? (not one simulated by scrolling)
  10506. if (ev.origEvent.type !== 'scroll') {
  10507. _this.mirror.handleMove(ev.pageX, ev.pageY);
  10508. _this.autoScroller.handleMove(ev.pageX, ev.pageY);
  10509. }
  10510. _this.emitter.trigger('dragmove', ev);
  10511. }
  10512. }
  10513. };
  10514. _this.onPointerUp = function (ev) {
  10515. if (_this.isInteracting) {
  10516. _this.isInteracting = false;
  10517. allowSelection(document.body);
  10518. allowContextMenu(document.body);
  10519. _this.emitter.trigger('pointerup', ev); // can potentially set mirrorNeedsRevert
  10520. if (_this.isDragging) {
  10521. _this.autoScroller.stop();
  10522. _this.tryStopDrag(ev); // which will stop the mirror
  10523. }
  10524. if (_this.delayTimeoutId) {
  10525. clearTimeout(_this.delayTimeoutId);
  10526. _this.delayTimeoutId = null;
  10527. }
  10528. }
  10529. };
  10530. var pointer = _this.pointer = new PointerDragging(containerEl);
  10531. pointer.emitter.on('pointerdown', _this.onPointerDown);
  10532. pointer.emitter.on('pointermove', _this.onPointerMove);
  10533. pointer.emitter.on('pointerup', _this.onPointerUp);
  10534. if (selector) {
  10535. pointer.selector = selector;
  10536. }
  10537. _this.mirror = new ElementMirror();
  10538. _this.autoScroller = new AutoScroller();
  10539. return _this;
  10540. }
  10541. FeaturefulElementDragging.prototype.destroy = function () {
  10542. this.pointer.destroy();
  10543. // HACK: simulate a pointer-up to end the current drag
  10544. // TODO: fire 'dragend' directly and stop interaction. discourage use of pointerup event (b/c might not fire)
  10545. this.onPointerUp({});
  10546. };
  10547. FeaturefulElementDragging.prototype.startDelay = function (ev) {
  10548. var _this = this;
  10549. if (typeof this.delay === 'number') {
  10550. this.delayTimeoutId = setTimeout(function () {
  10551. _this.delayTimeoutId = null;
  10552. _this.handleDelayEnd(ev);
  10553. }, this.delay); // not assignable to number!
  10554. }
  10555. else {
  10556. this.handleDelayEnd(ev);
  10557. }
  10558. };
  10559. FeaturefulElementDragging.prototype.handleDelayEnd = function (ev) {
  10560. this.isDelayEnded = true;
  10561. this.tryStartDrag(ev);
  10562. };
  10563. FeaturefulElementDragging.prototype.handleDistanceSurpassed = function (ev) {
  10564. this.isDistanceSurpassed = true;
  10565. this.tryStartDrag(ev);
  10566. };
  10567. FeaturefulElementDragging.prototype.tryStartDrag = function (ev) {
  10568. if (this.isDelayEnded && this.isDistanceSurpassed) {
  10569. if (!this.pointer.wasTouchScroll || this.touchScrollAllowed) {
  10570. this.isDragging = true;
  10571. this.mirrorNeedsRevert = false;
  10572. this.autoScroller.start(ev.pageX, ev.pageY, this.containerEl);
  10573. this.emitter.trigger('dragstart', ev);
  10574. if (this.touchScrollAllowed === false) {
  10575. this.pointer.cancelTouchScroll();
  10576. }
  10577. }
  10578. }
  10579. };
  10580. FeaturefulElementDragging.prototype.tryStopDrag = function (ev) {
  10581. // .stop() is ALWAYS asynchronous, which we NEED because we want all pointerup events
  10582. // that come from the document to fire beforehand. much more convenient this way.
  10583. this.mirror.stop(this.mirrorNeedsRevert, this.stopDrag.bind(this, ev));
  10584. };
  10585. FeaturefulElementDragging.prototype.stopDrag = function (ev) {
  10586. this.isDragging = false;
  10587. this.emitter.trigger('dragend', ev);
  10588. };
  10589. // fill in the implementations...
  10590. FeaturefulElementDragging.prototype.setIgnoreMove = function (bool) {
  10591. this.pointer.shouldIgnoreMove = bool;
  10592. };
  10593. FeaturefulElementDragging.prototype.setMirrorIsVisible = function (bool) {
  10594. this.mirror.setIsVisible(bool);
  10595. };
  10596. FeaturefulElementDragging.prototype.setMirrorNeedsRevert = function (bool) {
  10597. this.mirrorNeedsRevert = bool;
  10598. };
  10599. FeaturefulElementDragging.prototype.setAutoScrollEnabled = function (bool) {
  10600. this.autoScroller.isEnabled = bool;
  10601. };
  10602. return FeaturefulElementDragging;
  10603. }(ElementDragging));
  10604. /*
  10605. When this class is instantiated, it records the offset of an element (relative to the document topleft),
  10606. and continues to monitor scrolling, updating the cached coordinates if it needs to.
  10607. Does not access the DOM after instantiation, so highly performant.
  10608. Also keeps track of all scrolling/overflow:hidden containers that are parents of the given element
  10609. and an determine if a given point is inside the combined clipping rectangle.
  10610. */
  10611. var OffsetTracker = /** @class */ (function () {
  10612. function OffsetTracker(el) {
  10613. this.origRect = computeRect(el);
  10614. // will work fine for divs that have overflow:hidden
  10615. this.scrollCaches = getClippingParents(el).map(function (scrollEl) { return new ElementScrollGeomCache(scrollEl, true); });
  10616. }
  10617. OffsetTracker.prototype.destroy = function () {
  10618. for (var _i = 0, _a = this.scrollCaches; _i < _a.length; _i++) {
  10619. var scrollCache = _a[_i];
  10620. scrollCache.destroy();
  10621. }
  10622. };
  10623. OffsetTracker.prototype.computeLeft = function () {
  10624. var left = this.origRect.left;
  10625. for (var _i = 0, _a = this.scrollCaches; _i < _a.length; _i++) {
  10626. var scrollCache = _a[_i];
  10627. left += scrollCache.origScrollLeft - scrollCache.getScrollLeft();
  10628. }
  10629. return left;
  10630. };
  10631. OffsetTracker.prototype.computeTop = function () {
  10632. var top = this.origRect.top;
  10633. for (var _i = 0, _a = this.scrollCaches; _i < _a.length; _i++) {
  10634. var scrollCache = _a[_i];
  10635. top += scrollCache.origScrollTop - scrollCache.getScrollTop();
  10636. }
  10637. return top;
  10638. };
  10639. OffsetTracker.prototype.isWithinClipping = function (pageX, pageY) {
  10640. var point = { left: pageX, top: pageY };
  10641. for (var _i = 0, _a = this.scrollCaches; _i < _a.length; _i++) {
  10642. var scrollCache = _a[_i];
  10643. if (!isIgnoredClipping(scrollCache.getEventTarget()) &&
  10644. !pointInsideRect(point, scrollCache.clientRect)) {
  10645. return false;
  10646. }
  10647. }
  10648. return true;
  10649. };
  10650. return OffsetTracker;
  10651. }());
  10652. // certain clipping containers should never constrain interactions, like <html> and <body>
  10653. // https://github.com/fullcalendar/fullcalendar/issues/3615
  10654. function isIgnoredClipping(node) {
  10655. var tagName = node.tagName;
  10656. return tagName === 'HTML' || tagName === 'BODY';
  10657. }
  10658. /*
  10659. Tracks movement over multiple droppable areas (aka "hits")
  10660. that exist in one or more DateComponents.
  10661. Relies on an existing draggable.
  10662. emits:
  10663. - pointerdown
  10664. - dragstart
  10665. - hitchange - fires initially, even if not over a hit
  10666. - pointerup
  10667. - (hitchange - again, to null, if ended over a hit)
  10668. - dragend
  10669. */
  10670. var HitDragging = /** @class */ (function () {
  10671. function HitDragging(dragging, droppableStore) {
  10672. var _this = this;
  10673. // options that can be set by caller
  10674. this.useSubjectCenter = false;
  10675. this.requireInitial = true; // if doesn't start out on a hit, won't emit any events
  10676. this.initialHit = null;
  10677. this.movingHit = null;
  10678. this.finalHit = null; // won't ever be populated if shouldIgnoreMove
  10679. this.handlePointerDown = function (ev) {
  10680. var dragging = _this.dragging;
  10681. _this.initialHit = null;
  10682. _this.movingHit = null;
  10683. _this.finalHit = null;
  10684. _this.prepareHits();
  10685. _this.processFirstCoord(ev);
  10686. if (_this.initialHit || !_this.requireInitial) {
  10687. dragging.setIgnoreMove(false);
  10688. // TODO: fire this before computing processFirstCoord, so listeners can cancel. this gets fired by almost every handler :(
  10689. _this.emitter.trigger('pointerdown', ev);
  10690. }
  10691. else {
  10692. dragging.setIgnoreMove(true);
  10693. }
  10694. };
  10695. this.handleDragStart = function (ev) {
  10696. _this.emitter.trigger('dragstart', ev);
  10697. _this.handleMove(ev, true); // force = fire even if initially null
  10698. };
  10699. this.handleDragMove = function (ev) {
  10700. _this.emitter.trigger('dragmove', ev);
  10701. _this.handleMove(ev);
  10702. };
  10703. this.handlePointerUp = function (ev) {
  10704. _this.releaseHits();
  10705. _this.emitter.trigger('pointerup', ev);
  10706. };
  10707. this.handleDragEnd = function (ev) {
  10708. if (_this.movingHit) {
  10709. _this.emitter.trigger('hitupdate', null, true, ev);
  10710. }
  10711. _this.finalHit = _this.movingHit;
  10712. _this.movingHit = null;
  10713. _this.emitter.trigger('dragend', ev);
  10714. };
  10715. this.droppableStore = droppableStore;
  10716. dragging.emitter.on('pointerdown', this.handlePointerDown);
  10717. dragging.emitter.on('dragstart', this.handleDragStart);
  10718. dragging.emitter.on('dragmove', this.handleDragMove);
  10719. dragging.emitter.on('pointerup', this.handlePointerUp);
  10720. dragging.emitter.on('dragend', this.handleDragEnd);
  10721. this.dragging = dragging;
  10722. this.emitter = new Emitter();
  10723. }
  10724. // sets initialHit
  10725. // sets coordAdjust
  10726. HitDragging.prototype.processFirstCoord = function (ev) {
  10727. var origPoint = { left: ev.pageX, top: ev.pageY };
  10728. var adjustedPoint = origPoint;
  10729. var subjectEl = ev.subjectEl;
  10730. var subjectRect;
  10731. if (subjectEl instanceof HTMLElement) { // i.e. not a Document/ShadowRoot
  10732. subjectRect = computeRect(subjectEl);
  10733. adjustedPoint = constrainPoint(adjustedPoint, subjectRect);
  10734. }
  10735. var initialHit = this.initialHit = this.queryHitForOffset(adjustedPoint.left, adjustedPoint.top);
  10736. if (initialHit) {
  10737. if (this.useSubjectCenter && subjectRect) {
  10738. var slicedSubjectRect = intersectRects(subjectRect, initialHit.rect);
  10739. if (slicedSubjectRect) {
  10740. adjustedPoint = getRectCenter(slicedSubjectRect);
  10741. }
  10742. }
  10743. this.coordAdjust = diffPoints(adjustedPoint, origPoint);
  10744. }
  10745. else {
  10746. this.coordAdjust = { left: 0, top: 0 };
  10747. }
  10748. };
  10749. HitDragging.prototype.handleMove = function (ev, forceHandle) {
  10750. var hit = this.queryHitForOffset(ev.pageX + this.coordAdjust.left, ev.pageY + this.coordAdjust.top);
  10751. if (forceHandle || !isHitsEqual(this.movingHit, hit)) {
  10752. this.movingHit = hit;
  10753. this.emitter.trigger('hitupdate', hit, false, ev);
  10754. }
  10755. };
  10756. HitDragging.prototype.prepareHits = function () {
  10757. this.offsetTrackers = mapHash(this.droppableStore, function (interactionSettings) {
  10758. interactionSettings.component.prepareHits();
  10759. return new OffsetTracker(interactionSettings.el);
  10760. });
  10761. };
  10762. HitDragging.prototype.releaseHits = function () {
  10763. var offsetTrackers = this.offsetTrackers;
  10764. for (var id in offsetTrackers) {
  10765. offsetTrackers[id].destroy();
  10766. }
  10767. this.offsetTrackers = {};
  10768. };
  10769. HitDragging.prototype.queryHitForOffset = function (offsetLeft, offsetTop) {
  10770. var _a = this, droppableStore = _a.droppableStore, offsetTrackers = _a.offsetTrackers;
  10771. var bestHit = null;
  10772. for (var id in droppableStore) {
  10773. var component = droppableStore[id].component;
  10774. var offsetTracker = offsetTrackers[id];
  10775. if (offsetTracker && // wasn't destroyed mid-drag
  10776. offsetTracker.isWithinClipping(offsetLeft, offsetTop)) {
  10777. var originLeft = offsetTracker.computeLeft();
  10778. var originTop = offsetTracker.computeTop();
  10779. var positionLeft = offsetLeft - originLeft;
  10780. var positionTop = offsetTop - originTop;
  10781. var origRect = offsetTracker.origRect;
  10782. var width = origRect.right - origRect.left;
  10783. var height = origRect.bottom - origRect.top;
  10784. if (
  10785. // must be within the element's bounds
  10786. positionLeft >= 0 && positionLeft < width &&
  10787. positionTop >= 0 && positionTop < height) {
  10788. var hit = component.queryHit(positionLeft, positionTop, width, height);
  10789. if (hit && (
  10790. // make sure the hit is within activeRange, meaning it's not a dead cell
  10791. rangeContainsRange(hit.dateProfile.activeRange, hit.dateSpan.range)) &&
  10792. (!bestHit || hit.layer > bestHit.layer)) {
  10793. hit.componentId = id;
  10794. hit.context = component.context;
  10795. // TODO: better way to re-orient rectangle
  10796. hit.rect.left += originLeft;
  10797. hit.rect.right += originLeft;
  10798. hit.rect.top += originTop;
  10799. hit.rect.bottom += originTop;
  10800. bestHit = hit;
  10801. }
  10802. }
  10803. }
  10804. }
  10805. return bestHit;
  10806. };
  10807. return HitDragging;
  10808. }());
  10809. function isHitsEqual(hit0, hit1) {
  10810. if (!hit0 && !hit1) {
  10811. return true;
  10812. }
  10813. if (Boolean(hit0) !== Boolean(hit1)) {
  10814. return false;
  10815. }
  10816. return isDateSpansEqual(hit0.dateSpan, hit1.dateSpan);
  10817. }
  10818. function buildDatePointApiWithContext(dateSpan, context) {
  10819. var props = {};
  10820. for (var _i = 0, _a = context.pluginHooks.datePointTransforms; _i < _a.length; _i++) {
  10821. var transform = _a[_i];
  10822. __assign(props, transform(dateSpan, context));
  10823. }
  10824. __assign(props, buildDatePointApi(dateSpan, context.dateEnv));
  10825. return props;
  10826. }
  10827. function buildDatePointApi(span, dateEnv) {
  10828. return {
  10829. date: dateEnv.toDate(span.range.start),
  10830. dateStr: dateEnv.formatIso(span.range.start, { omitTime: span.allDay }),
  10831. allDay: span.allDay,
  10832. };
  10833. }
  10834. /*
  10835. Monitors when the user clicks on a specific date/time of a component.
  10836. A pointerdown+pointerup on the same "hit" constitutes a click.
  10837. */
  10838. var DateClicking = /** @class */ (function (_super) {
  10839. __extends(DateClicking, _super);
  10840. function DateClicking(settings) {
  10841. var _this = _super.call(this, settings) || this;
  10842. _this.handlePointerDown = function (pev) {
  10843. var dragging = _this.dragging;
  10844. var downEl = pev.origEvent.target;
  10845. // do this in pointerdown (not dragend) because DOM might be mutated by the time dragend is fired
  10846. dragging.setIgnoreMove(!_this.component.isValidDateDownEl(downEl));
  10847. };
  10848. // won't even fire if moving was ignored
  10849. _this.handleDragEnd = function (ev) {
  10850. var component = _this.component;
  10851. var pointer = _this.dragging.pointer;
  10852. if (!pointer.wasTouchScroll) {
  10853. var _a = _this.hitDragging, initialHit = _a.initialHit, finalHit = _a.finalHit;
  10854. if (initialHit && finalHit && isHitsEqual(initialHit, finalHit)) {
  10855. var context = component.context;
  10856. var arg = __assign(__assign({}, buildDatePointApiWithContext(initialHit.dateSpan, context)), { dayEl: initialHit.dayEl, jsEvent: ev.origEvent, view: context.viewApi || context.calendarApi.view });
  10857. context.emitter.trigger('dateClick', arg);
  10858. }
  10859. }
  10860. };
  10861. // we DO want to watch pointer moves because otherwise finalHit won't get populated
  10862. _this.dragging = new FeaturefulElementDragging(settings.el);
  10863. _this.dragging.autoScroller.isEnabled = false;
  10864. var hitDragging = _this.hitDragging = new HitDragging(_this.dragging, interactionSettingsToStore(settings));
  10865. hitDragging.emitter.on('pointerdown', _this.handlePointerDown);
  10866. hitDragging.emitter.on('dragend', _this.handleDragEnd);
  10867. return _this;
  10868. }
  10869. DateClicking.prototype.destroy = function () {
  10870. this.dragging.destroy();
  10871. };
  10872. return DateClicking;
  10873. }(Interaction));
  10874. /*
  10875. Tracks when the user selects a portion of time of a component,
  10876. constituted by a drag over date cells, with a possible delay at the beginning of the drag.
  10877. */
  10878. var DateSelecting = /** @class */ (function (_super) {
  10879. __extends(DateSelecting, _super);
  10880. function DateSelecting(settings) {
  10881. var _this = _super.call(this, settings) || this;
  10882. _this.dragSelection = null;
  10883. _this.handlePointerDown = function (ev) {
  10884. var _a = _this, component = _a.component, dragging = _a.dragging;
  10885. var options = component.context.options;
  10886. var canSelect = options.selectable &&
  10887. component.isValidDateDownEl(ev.origEvent.target);
  10888. // don't bother to watch expensive moves if component won't do selection
  10889. dragging.setIgnoreMove(!canSelect);
  10890. // if touch, require user to hold down
  10891. dragging.delay = ev.isTouch ? getComponentTouchDelay$1(component) : null;
  10892. };
  10893. _this.handleDragStart = function (ev) {
  10894. _this.component.context.calendarApi.unselect(ev); // unselect previous selections
  10895. };
  10896. _this.handleHitUpdate = function (hit, isFinal) {
  10897. var context = _this.component.context;
  10898. var dragSelection = null;
  10899. var isInvalid = false;
  10900. if (hit) {
  10901. var initialHit = _this.hitDragging.initialHit;
  10902. var disallowed = hit.componentId === initialHit.componentId
  10903. && _this.isHitComboAllowed
  10904. && !_this.isHitComboAllowed(initialHit, hit);
  10905. if (!disallowed) {
  10906. dragSelection = joinHitsIntoSelection(initialHit, hit, context.pluginHooks.dateSelectionTransformers);
  10907. }
  10908. if (!dragSelection || !isDateSelectionValid(dragSelection, hit.dateProfile, context)) {
  10909. isInvalid = true;
  10910. dragSelection = null;
  10911. }
  10912. }
  10913. if (dragSelection) {
  10914. context.dispatch({ type: 'SELECT_DATES', selection: dragSelection });
  10915. }
  10916. else if (!isFinal) { // only unselect if moved away while dragging
  10917. context.dispatch({ type: 'UNSELECT_DATES' });
  10918. }
  10919. if (!isInvalid) {
  10920. enableCursor();
  10921. }
  10922. else {
  10923. disableCursor();
  10924. }
  10925. if (!isFinal) {
  10926. _this.dragSelection = dragSelection; // only clear if moved away from all hits while dragging
  10927. }
  10928. };
  10929. _this.handlePointerUp = function (pev) {
  10930. if (_this.dragSelection) {
  10931. // selection is already rendered, so just need to report selection
  10932. triggerDateSelect(_this.dragSelection, pev, _this.component.context);
  10933. _this.dragSelection = null;
  10934. }
  10935. };
  10936. var component = settings.component;
  10937. var options = component.context.options;
  10938. var dragging = _this.dragging = new FeaturefulElementDragging(settings.el);
  10939. dragging.touchScrollAllowed = false;
  10940. dragging.minDistance = options.selectMinDistance || 0;
  10941. dragging.autoScroller.isEnabled = options.dragScroll;
  10942. var hitDragging = _this.hitDragging = new HitDragging(_this.dragging, interactionSettingsToStore(settings));
  10943. hitDragging.emitter.on('pointerdown', _this.handlePointerDown);
  10944. hitDragging.emitter.on('dragstart', _this.handleDragStart);
  10945. hitDragging.emitter.on('hitupdate', _this.handleHitUpdate);
  10946. hitDragging.emitter.on('pointerup', _this.handlePointerUp);
  10947. return _this;
  10948. }
  10949. DateSelecting.prototype.destroy = function () {
  10950. this.dragging.destroy();
  10951. };
  10952. return DateSelecting;
  10953. }(Interaction));
  10954. function getComponentTouchDelay$1(component) {
  10955. var options = component.context.options;
  10956. var delay = options.selectLongPressDelay;
  10957. if (delay == null) {
  10958. delay = options.longPressDelay;
  10959. }
  10960. return delay;
  10961. }
  10962. function joinHitsIntoSelection(hit0, hit1, dateSelectionTransformers) {
  10963. var dateSpan0 = hit0.dateSpan;
  10964. var dateSpan1 = hit1.dateSpan;
  10965. var ms = [
  10966. dateSpan0.range.start,
  10967. dateSpan0.range.end,
  10968. dateSpan1.range.start,
  10969. dateSpan1.range.end,
  10970. ];
  10971. ms.sort(compareNumbers);
  10972. var props = {};
  10973. for (var _i = 0, dateSelectionTransformers_1 = dateSelectionTransformers; _i < dateSelectionTransformers_1.length; _i++) {
  10974. var transformer = dateSelectionTransformers_1[_i];
  10975. var res = transformer(hit0, hit1);
  10976. if (res === false) {
  10977. return null;
  10978. }
  10979. if (res) {
  10980. __assign(props, res);
  10981. }
  10982. }
  10983. props.range = { start: ms[0], end: ms[3] };
  10984. props.allDay = dateSpan0.allDay;
  10985. return props;
  10986. }
  10987. var EventDragging = /** @class */ (function (_super) {
  10988. __extends(EventDragging, _super);
  10989. function EventDragging(settings) {
  10990. var _this = _super.call(this, settings) || this;
  10991. // internal state
  10992. _this.subjectEl = null;
  10993. _this.subjectSeg = null; // the seg being selected/dragged
  10994. _this.isDragging = false;
  10995. _this.eventRange = null;
  10996. _this.relevantEvents = null; // the events being dragged
  10997. _this.receivingContext = null;
  10998. _this.validMutation = null;
  10999. _this.mutatedRelevantEvents = null;
  11000. _this.handlePointerDown = function (ev) {
  11001. var origTarget = ev.origEvent.target;
  11002. var _a = _this, component = _a.component, dragging = _a.dragging;
  11003. var mirror = dragging.mirror;
  11004. var options = component.context.options;
  11005. var initialContext = component.context;
  11006. _this.subjectEl = ev.subjectEl;
  11007. var subjectSeg = _this.subjectSeg = getElSeg(ev.subjectEl);
  11008. var eventRange = _this.eventRange = subjectSeg.eventRange;
  11009. var eventInstanceId = eventRange.instance.instanceId;
  11010. _this.relevantEvents = getRelevantEvents(initialContext.getCurrentData().eventStore, eventInstanceId);
  11011. dragging.minDistance = ev.isTouch ? 0 : options.eventDragMinDistance;
  11012. dragging.delay =
  11013. // only do a touch delay if touch and this event hasn't been selected yet
  11014. (ev.isTouch && eventInstanceId !== component.props.eventSelection) ?
  11015. getComponentTouchDelay(component) :
  11016. null;
  11017. if (options.fixedMirrorParent) {
  11018. mirror.parentNode = options.fixedMirrorParent;
  11019. }
  11020. else {
  11021. mirror.parentNode = elementClosest(origTarget, '.fc');
  11022. }
  11023. mirror.revertDuration = options.dragRevertDuration;
  11024. var isValid = component.isValidSegDownEl(origTarget) &&
  11025. !elementClosest(origTarget, '.fc-event-resizer'); // NOT on a resizer
  11026. dragging.setIgnoreMove(!isValid);
  11027. // disable dragging for elements that are resizable (ie, selectable)
  11028. // but are not draggable
  11029. _this.isDragging = isValid &&
  11030. ev.subjectEl.classList.contains('fc-event-draggable');
  11031. };
  11032. _this.handleDragStart = function (ev) {
  11033. var initialContext = _this.component.context;
  11034. var eventRange = _this.eventRange;
  11035. var eventInstanceId = eventRange.instance.instanceId;
  11036. if (ev.isTouch) {
  11037. // need to select a different event?
  11038. if (eventInstanceId !== _this.component.props.eventSelection) {
  11039. initialContext.dispatch({ type: 'SELECT_EVENT', eventInstanceId: eventInstanceId });
  11040. }
  11041. }
  11042. else {
  11043. // if now using mouse, but was previous touch interaction, clear selected event
  11044. initialContext.dispatch({ type: 'UNSELECT_EVENT' });
  11045. }
  11046. if (_this.isDragging) {
  11047. initialContext.calendarApi.unselect(ev); // unselect *date* selection
  11048. initialContext.emitter.trigger('eventDragStart', {
  11049. el: _this.subjectEl,
  11050. event: new EventApi(initialContext, eventRange.def, eventRange.instance),
  11051. jsEvent: ev.origEvent,
  11052. view: initialContext.viewApi,
  11053. });
  11054. }
  11055. };
  11056. _this.handleHitUpdate = function (hit, isFinal) {
  11057. if (!_this.isDragging) {
  11058. return;
  11059. }
  11060. var relevantEvents = _this.relevantEvents;
  11061. var initialHit = _this.hitDragging.initialHit;
  11062. var initialContext = _this.component.context;
  11063. // states based on new hit
  11064. var receivingContext = null;
  11065. var mutation = null;
  11066. var mutatedRelevantEvents = null;
  11067. var isInvalid = false;
  11068. var interaction = {
  11069. affectedEvents: relevantEvents,
  11070. mutatedEvents: createEmptyEventStore(),
  11071. isEvent: true,
  11072. };
  11073. if (hit) {
  11074. receivingContext = hit.context;
  11075. var receivingOptions = receivingContext.options;
  11076. if (initialContext === receivingContext ||
  11077. (receivingOptions.editable && receivingOptions.droppable)) {
  11078. mutation = computeEventMutation(initialHit, hit, receivingContext.getCurrentData().pluginHooks.eventDragMutationMassagers);
  11079. if (mutation) {
  11080. mutatedRelevantEvents = applyMutationToEventStore(relevantEvents, receivingContext.getCurrentData().eventUiBases, mutation, receivingContext);
  11081. interaction.mutatedEvents = mutatedRelevantEvents;
  11082. if (!isInteractionValid(interaction, hit.dateProfile, receivingContext)) {
  11083. isInvalid = true;
  11084. mutation = null;
  11085. mutatedRelevantEvents = null;
  11086. interaction.mutatedEvents = createEmptyEventStore();
  11087. }
  11088. }
  11089. }
  11090. else {
  11091. receivingContext = null;
  11092. }
  11093. }
  11094. _this.displayDrag(receivingContext, interaction);
  11095. if (!isInvalid) {
  11096. enableCursor();
  11097. }
  11098. else {
  11099. disableCursor();
  11100. }
  11101. if (!isFinal) {
  11102. if (initialContext === receivingContext && // TODO: write test for this
  11103. isHitsEqual(initialHit, hit)) {
  11104. mutation = null;
  11105. }
  11106. _this.dragging.setMirrorNeedsRevert(!mutation);
  11107. // render the mirror if no already-rendered mirror
  11108. // TODO: wish we could somehow wait for dispatch to guarantee render
  11109. _this.dragging.setMirrorIsVisible(!hit || !getElRoot(_this.subjectEl).querySelector('.fc-event-mirror'));
  11110. // assign states based on new hit
  11111. _this.receivingContext = receivingContext;
  11112. _this.validMutation = mutation;
  11113. _this.mutatedRelevantEvents = mutatedRelevantEvents;
  11114. }
  11115. };
  11116. _this.handlePointerUp = function () {
  11117. if (!_this.isDragging) {
  11118. _this.cleanup(); // because handleDragEnd won't fire
  11119. }
  11120. };
  11121. _this.handleDragEnd = function (ev) {
  11122. if (_this.isDragging) {
  11123. var initialContext_1 = _this.component.context;
  11124. var initialView = initialContext_1.viewApi;
  11125. var _a = _this, receivingContext_1 = _a.receivingContext, validMutation = _a.validMutation;
  11126. var eventDef = _this.eventRange.def;
  11127. var eventInstance = _this.eventRange.instance;
  11128. var eventApi = new EventApi(initialContext_1, eventDef, eventInstance);
  11129. var relevantEvents_1 = _this.relevantEvents;
  11130. var mutatedRelevantEvents_1 = _this.mutatedRelevantEvents;
  11131. var finalHit = _this.hitDragging.finalHit;
  11132. _this.clearDrag(); // must happen after revert animation
  11133. initialContext_1.emitter.trigger('eventDragStop', {
  11134. el: _this.subjectEl,
  11135. event: eventApi,
  11136. jsEvent: ev.origEvent,
  11137. view: initialView,
  11138. });
  11139. if (validMutation) {
  11140. // dropped within same calendar
  11141. if (receivingContext_1 === initialContext_1) {
  11142. var updatedEventApi = new EventApi(initialContext_1, mutatedRelevantEvents_1.defs[eventDef.defId], eventInstance ? mutatedRelevantEvents_1.instances[eventInstance.instanceId] : null);
  11143. initialContext_1.dispatch({
  11144. type: 'MERGE_EVENTS',
  11145. eventStore: mutatedRelevantEvents_1,
  11146. });
  11147. var eventChangeArg = {
  11148. oldEvent: eventApi,
  11149. event: updatedEventApi,
  11150. relatedEvents: buildEventApis(mutatedRelevantEvents_1, initialContext_1, eventInstance),
  11151. revert: function () {
  11152. initialContext_1.dispatch({
  11153. type: 'MERGE_EVENTS',
  11154. eventStore: relevantEvents_1, // the pre-change data
  11155. });
  11156. },
  11157. };
  11158. var transformed = {};
  11159. for (var _i = 0, _b = initialContext_1.getCurrentData().pluginHooks.eventDropTransformers; _i < _b.length; _i++) {
  11160. var transformer = _b[_i];
  11161. __assign(transformed, transformer(validMutation, initialContext_1));
  11162. }
  11163. initialContext_1.emitter.trigger('eventDrop', __assign(__assign(__assign({}, eventChangeArg), transformed), { el: ev.subjectEl, delta: validMutation.datesDelta, jsEvent: ev.origEvent, view: initialView }));
  11164. initialContext_1.emitter.trigger('eventChange', eventChangeArg);
  11165. // dropped in different calendar
  11166. }
  11167. else if (receivingContext_1) {
  11168. var eventRemoveArg = {
  11169. event: eventApi,
  11170. relatedEvents: buildEventApis(relevantEvents_1, initialContext_1, eventInstance),
  11171. revert: function () {
  11172. initialContext_1.dispatch({
  11173. type: 'MERGE_EVENTS',
  11174. eventStore: relevantEvents_1,
  11175. });
  11176. },
  11177. };
  11178. initialContext_1.emitter.trigger('eventLeave', __assign(__assign({}, eventRemoveArg), { draggedEl: ev.subjectEl, view: initialView }));
  11179. initialContext_1.dispatch({
  11180. type: 'REMOVE_EVENTS',
  11181. eventStore: relevantEvents_1,
  11182. });
  11183. initialContext_1.emitter.trigger('eventRemove', eventRemoveArg);
  11184. var addedEventDef = mutatedRelevantEvents_1.defs[eventDef.defId];
  11185. var addedEventInstance = mutatedRelevantEvents_1.instances[eventInstance.instanceId];
  11186. var addedEventApi = new EventApi(receivingContext_1, addedEventDef, addedEventInstance);
  11187. receivingContext_1.dispatch({
  11188. type: 'MERGE_EVENTS',
  11189. eventStore: mutatedRelevantEvents_1,
  11190. });
  11191. var eventAddArg = {
  11192. event: addedEventApi,
  11193. relatedEvents: buildEventApis(mutatedRelevantEvents_1, receivingContext_1, addedEventInstance),
  11194. revert: function () {
  11195. receivingContext_1.dispatch({
  11196. type: 'REMOVE_EVENTS',
  11197. eventStore: mutatedRelevantEvents_1,
  11198. });
  11199. },
  11200. };
  11201. receivingContext_1.emitter.trigger('eventAdd', eventAddArg);
  11202. if (ev.isTouch) {
  11203. receivingContext_1.dispatch({
  11204. type: 'SELECT_EVENT',
  11205. eventInstanceId: eventInstance.instanceId,
  11206. });
  11207. }
  11208. receivingContext_1.emitter.trigger('drop', __assign(__assign({}, buildDatePointApiWithContext(finalHit.dateSpan, receivingContext_1)), { draggedEl: ev.subjectEl, jsEvent: ev.origEvent, view: finalHit.context.viewApi }));
  11209. receivingContext_1.emitter.trigger('eventReceive', __assign(__assign({}, eventAddArg), { draggedEl: ev.subjectEl, view: finalHit.context.viewApi }));
  11210. }
  11211. }
  11212. else {
  11213. initialContext_1.emitter.trigger('_noEventDrop');
  11214. }
  11215. }
  11216. _this.cleanup();
  11217. };
  11218. var component = _this.component;
  11219. var options = component.context.options;
  11220. var dragging = _this.dragging = new FeaturefulElementDragging(settings.el);
  11221. dragging.pointer.selector = EventDragging.SELECTOR;
  11222. dragging.touchScrollAllowed = false;
  11223. dragging.autoScroller.isEnabled = options.dragScroll;
  11224. var hitDragging = _this.hitDragging = new HitDragging(_this.dragging, interactionSettingsStore);
  11225. hitDragging.useSubjectCenter = settings.useEventCenter;
  11226. hitDragging.emitter.on('pointerdown', _this.handlePointerDown);
  11227. hitDragging.emitter.on('dragstart', _this.handleDragStart);
  11228. hitDragging.emitter.on('hitupdate', _this.handleHitUpdate);
  11229. hitDragging.emitter.on('pointerup', _this.handlePointerUp);
  11230. hitDragging.emitter.on('dragend', _this.handleDragEnd);
  11231. return _this;
  11232. }
  11233. EventDragging.prototype.destroy = function () {
  11234. this.dragging.destroy();
  11235. };
  11236. // render a drag state on the next receivingCalendar
  11237. EventDragging.prototype.displayDrag = function (nextContext, state) {
  11238. var initialContext = this.component.context;
  11239. var prevContext = this.receivingContext;
  11240. // does the previous calendar need to be cleared?
  11241. if (prevContext && prevContext !== nextContext) {
  11242. // does the initial calendar need to be cleared?
  11243. // if so, don't clear all the way. we still need to to hide the affectedEvents
  11244. if (prevContext === initialContext) {
  11245. prevContext.dispatch({
  11246. type: 'SET_EVENT_DRAG',
  11247. state: {
  11248. affectedEvents: state.affectedEvents,
  11249. mutatedEvents: createEmptyEventStore(),
  11250. isEvent: true,
  11251. },
  11252. });
  11253. // completely clear the old calendar if it wasn't the initial
  11254. }
  11255. else {
  11256. prevContext.dispatch({ type: 'UNSET_EVENT_DRAG' });
  11257. }
  11258. }
  11259. if (nextContext) {
  11260. nextContext.dispatch({ type: 'SET_EVENT_DRAG', state: state });
  11261. }
  11262. };
  11263. EventDragging.prototype.clearDrag = function () {
  11264. var initialCalendar = this.component.context;
  11265. var receivingContext = this.receivingContext;
  11266. if (receivingContext) {
  11267. receivingContext.dispatch({ type: 'UNSET_EVENT_DRAG' });
  11268. }
  11269. // the initial calendar might have an dummy drag state from displayDrag
  11270. if (initialCalendar !== receivingContext) {
  11271. initialCalendar.dispatch({ type: 'UNSET_EVENT_DRAG' });
  11272. }
  11273. };
  11274. EventDragging.prototype.cleanup = function () {
  11275. this.subjectSeg = null;
  11276. this.isDragging = false;
  11277. this.eventRange = null;
  11278. this.relevantEvents = null;
  11279. this.receivingContext = null;
  11280. this.validMutation = null;
  11281. this.mutatedRelevantEvents = null;
  11282. };
  11283. // TODO: test this in IE11
  11284. // QUESTION: why do we need it on the resizable???
  11285. EventDragging.SELECTOR = '.fc-event-draggable, .fc-event-resizable';
  11286. return EventDragging;
  11287. }(Interaction));
  11288. function computeEventMutation(hit0, hit1, massagers) {
  11289. var dateSpan0 = hit0.dateSpan;
  11290. var dateSpan1 = hit1.dateSpan;
  11291. var date0 = dateSpan0.range.start;
  11292. var date1 = dateSpan1.range.start;
  11293. var standardProps = {};
  11294. if (dateSpan0.allDay !== dateSpan1.allDay) {
  11295. standardProps.allDay = dateSpan1.allDay;
  11296. standardProps.hasEnd = hit1.context.options.allDayMaintainDuration;
  11297. if (dateSpan1.allDay) {
  11298. // means date1 is already start-of-day,
  11299. // but date0 needs to be converted
  11300. date0 = startOfDay(date0);
  11301. }
  11302. }
  11303. var delta = diffDates(date0, date1, hit0.context.dateEnv, hit0.componentId === hit1.componentId ?
  11304. hit0.largeUnit :
  11305. null);
  11306. if (delta.milliseconds) { // has hours/minutes/seconds
  11307. standardProps.allDay = false;
  11308. }
  11309. var mutation = {
  11310. datesDelta: delta,
  11311. standardProps: standardProps,
  11312. };
  11313. for (var _i = 0, massagers_1 = massagers; _i < massagers_1.length; _i++) {
  11314. var massager = massagers_1[_i];
  11315. massager(mutation, hit0, hit1);
  11316. }
  11317. return mutation;
  11318. }
  11319. function getComponentTouchDelay(component) {
  11320. var options = component.context.options;
  11321. var delay = options.eventLongPressDelay;
  11322. if (delay == null) {
  11323. delay = options.longPressDelay;
  11324. }
  11325. return delay;
  11326. }
  11327. var EventResizing = /** @class */ (function (_super) {
  11328. __extends(EventResizing, _super);
  11329. function EventResizing(settings) {
  11330. var _this = _super.call(this, settings) || this;
  11331. // internal state
  11332. _this.draggingSegEl = null;
  11333. _this.draggingSeg = null; // TODO: rename to resizingSeg? subjectSeg?
  11334. _this.eventRange = null;
  11335. _this.relevantEvents = null;
  11336. _this.validMutation = null;
  11337. _this.mutatedRelevantEvents = null;
  11338. _this.handlePointerDown = function (ev) {
  11339. var component = _this.component;
  11340. var segEl = _this.querySegEl(ev);
  11341. var seg = getElSeg(segEl);
  11342. var eventRange = _this.eventRange = seg.eventRange;
  11343. _this.dragging.minDistance = component.context.options.eventDragMinDistance;
  11344. // if touch, need to be working with a selected event
  11345. _this.dragging.setIgnoreMove(!_this.component.isValidSegDownEl(ev.origEvent.target) ||
  11346. (ev.isTouch && _this.component.props.eventSelection !== eventRange.instance.instanceId));
  11347. };
  11348. _this.handleDragStart = function (ev) {
  11349. var context = _this.component.context;
  11350. var eventRange = _this.eventRange;
  11351. _this.relevantEvents = getRelevantEvents(context.getCurrentData().eventStore, _this.eventRange.instance.instanceId);
  11352. var segEl = _this.querySegEl(ev);
  11353. _this.draggingSegEl = segEl;
  11354. _this.draggingSeg = getElSeg(segEl);
  11355. context.calendarApi.unselect();
  11356. context.emitter.trigger('eventResizeStart', {
  11357. el: segEl,
  11358. event: new EventApi(context, eventRange.def, eventRange.instance),
  11359. jsEvent: ev.origEvent,
  11360. view: context.viewApi,
  11361. });
  11362. };
  11363. _this.handleHitUpdate = function (hit, isFinal, ev) {
  11364. var context = _this.component.context;
  11365. var relevantEvents = _this.relevantEvents;
  11366. var initialHit = _this.hitDragging.initialHit;
  11367. var eventInstance = _this.eventRange.instance;
  11368. var mutation = null;
  11369. var mutatedRelevantEvents = null;
  11370. var isInvalid = false;
  11371. var interaction = {
  11372. affectedEvents: relevantEvents,
  11373. mutatedEvents: createEmptyEventStore(),
  11374. isEvent: true,
  11375. };
  11376. if (hit) {
  11377. var disallowed = hit.componentId === initialHit.componentId
  11378. && _this.isHitComboAllowed
  11379. && !_this.isHitComboAllowed(initialHit, hit);
  11380. if (!disallowed) {
  11381. mutation = computeMutation(initialHit, hit, ev.subjectEl.classList.contains('fc-event-resizer-start'), eventInstance.range);
  11382. }
  11383. }
  11384. if (mutation) {
  11385. mutatedRelevantEvents = applyMutationToEventStore(relevantEvents, context.getCurrentData().eventUiBases, mutation, context);
  11386. interaction.mutatedEvents = mutatedRelevantEvents;
  11387. if (!isInteractionValid(interaction, hit.dateProfile, context)) {
  11388. isInvalid = true;
  11389. mutation = null;
  11390. mutatedRelevantEvents = null;
  11391. interaction.mutatedEvents = null;
  11392. }
  11393. }
  11394. if (mutatedRelevantEvents) {
  11395. context.dispatch({
  11396. type: 'SET_EVENT_RESIZE',
  11397. state: interaction,
  11398. });
  11399. }
  11400. else {
  11401. context.dispatch({ type: 'UNSET_EVENT_RESIZE' });
  11402. }
  11403. if (!isInvalid) {
  11404. enableCursor();
  11405. }
  11406. else {
  11407. disableCursor();
  11408. }
  11409. if (!isFinal) {
  11410. if (mutation && isHitsEqual(initialHit, hit)) {
  11411. mutation = null;
  11412. }
  11413. _this.validMutation = mutation;
  11414. _this.mutatedRelevantEvents = mutatedRelevantEvents;
  11415. }
  11416. };
  11417. _this.handleDragEnd = function (ev) {
  11418. var context = _this.component.context;
  11419. var eventDef = _this.eventRange.def;
  11420. var eventInstance = _this.eventRange.instance;
  11421. var eventApi = new EventApi(context, eventDef, eventInstance);
  11422. var relevantEvents = _this.relevantEvents;
  11423. var mutatedRelevantEvents = _this.mutatedRelevantEvents;
  11424. context.emitter.trigger('eventResizeStop', {
  11425. el: _this.draggingSegEl,
  11426. event: eventApi,
  11427. jsEvent: ev.origEvent,
  11428. view: context.viewApi,
  11429. });
  11430. if (_this.validMutation) {
  11431. var updatedEventApi = new EventApi(context, mutatedRelevantEvents.defs[eventDef.defId], eventInstance ? mutatedRelevantEvents.instances[eventInstance.instanceId] : null);
  11432. context.dispatch({
  11433. type: 'MERGE_EVENTS',
  11434. eventStore: mutatedRelevantEvents,
  11435. });
  11436. var eventChangeArg = {
  11437. oldEvent: eventApi,
  11438. event: updatedEventApi,
  11439. relatedEvents: buildEventApis(mutatedRelevantEvents, context, eventInstance),
  11440. revert: function () {
  11441. context.dispatch({
  11442. type: 'MERGE_EVENTS',
  11443. eventStore: relevantEvents, // the pre-change events
  11444. });
  11445. },
  11446. };
  11447. context.emitter.trigger('eventResize', __assign(__assign({}, eventChangeArg), { el: _this.draggingSegEl, startDelta: _this.validMutation.startDelta || createDuration(0), endDelta: _this.validMutation.endDelta || createDuration(0), jsEvent: ev.origEvent, view: context.viewApi }));
  11448. context.emitter.trigger('eventChange', eventChangeArg);
  11449. }
  11450. else {
  11451. context.emitter.trigger('_noEventResize');
  11452. }
  11453. // reset all internal state
  11454. _this.draggingSeg = null;
  11455. _this.relevantEvents = null;
  11456. _this.validMutation = null;
  11457. // okay to keep eventInstance around. useful to set it in handlePointerDown
  11458. };
  11459. var component = settings.component;
  11460. var dragging = _this.dragging = new FeaturefulElementDragging(settings.el);
  11461. dragging.pointer.selector = '.fc-event-resizer';
  11462. dragging.touchScrollAllowed = false;
  11463. dragging.autoScroller.isEnabled = component.context.options.dragScroll;
  11464. var hitDragging = _this.hitDragging = new HitDragging(_this.dragging, interactionSettingsToStore(settings));
  11465. hitDragging.emitter.on('pointerdown', _this.handlePointerDown);
  11466. hitDragging.emitter.on('dragstart', _this.handleDragStart);
  11467. hitDragging.emitter.on('hitupdate', _this.handleHitUpdate);
  11468. hitDragging.emitter.on('dragend', _this.handleDragEnd);
  11469. return _this;
  11470. }
  11471. EventResizing.prototype.destroy = function () {
  11472. this.dragging.destroy();
  11473. };
  11474. EventResizing.prototype.querySegEl = function (ev) {
  11475. return elementClosest(ev.subjectEl, '.fc-event');
  11476. };
  11477. return EventResizing;
  11478. }(Interaction));
  11479. function computeMutation(hit0, hit1, isFromStart, instanceRange) {
  11480. var dateEnv = hit0.context.dateEnv;
  11481. var date0 = hit0.dateSpan.range.start;
  11482. var date1 = hit1.dateSpan.range.start;
  11483. var delta = diffDates(date0, date1, dateEnv, hit0.largeUnit);
  11484. if (isFromStart) {
  11485. if (dateEnv.add(instanceRange.start, delta) < instanceRange.end) {
  11486. return { startDelta: delta };
  11487. }
  11488. }
  11489. else if (dateEnv.add(instanceRange.end, delta) > instanceRange.start) {
  11490. return { endDelta: delta };
  11491. }
  11492. return null;
  11493. }
  11494. var UnselectAuto = /** @class */ (function () {
  11495. function UnselectAuto(context) {
  11496. var _this = this;
  11497. this.context = context;
  11498. this.isRecentPointerDateSelect = false; // wish we could use a selector to detect date selection, but uses hit system
  11499. this.matchesCancel = false;
  11500. this.matchesEvent = false;
  11501. this.onSelect = function (selectInfo) {
  11502. if (selectInfo.jsEvent) {
  11503. _this.isRecentPointerDateSelect = true;
  11504. }
  11505. };
  11506. this.onDocumentPointerDown = function (pev) {
  11507. var unselectCancel = _this.context.options.unselectCancel;
  11508. var downEl = getEventTargetViaRoot(pev.origEvent);
  11509. _this.matchesCancel = !!elementClosest(downEl, unselectCancel);
  11510. _this.matchesEvent = !!elementClosest(downEl, EventDragging.SELECTOR); // interaction started on an event?
  11511. };
  11512. this.onDocumentPointerUp = function (pev) {
  11513. var context = _this.context;
  11514. var documentPointer = _this.documentPointer;
  11515. var calendarState = context.getCurrentData();
  11516. // touch-scrolling should never unfocus any type of selection
  11517. if (!documentPointer.wasTouchScroll) {
  11518. if (calendarState.dateSelection && // an existing date selection?
  11519. !_this.isRecentPointerDateSelect // a new pointer-initiated date selection since last onDocumentPointerUp?
  11520. ) {
  11521. var unselectAuto = context.options.unselectAuto;
  11522. if (unselectAuto && (!unselectAuto || !_this.matchesCancel)) {
  11523. context.calendarApi.unselect(pev);
  11524. }
  11525. }
  11526. if (calendarState.eventSelection && // an existing event selected?
  11527. !_this.matchesEvent // interaction DIDN'T start on an event
  11528. ) {
  11529. context.dispatch({ type: 'UNSELECT_EVENT' });
  11530. }
  11531. }
  11532. _this.isRecentPointerDateSelect = false;
  11533. };
  11534. var documentPointer = this.documentPointer = new PointerDragging(document);
  11535. documentPointer.shouldIgnoreMove = true;
  11536. documentPointer.shouldWatchScroll = false;
  11537. documentPointer.emitter.on('pointerdown', this.onDocumentPointerDown);
  11538. documentPointer.emitter.on('pointerup', this.onDocumentPointerUp);
  11539. /*
  11540. TODO: better way to know about whether there was a selection with the pointer
  11541. */
  11542. context.emitter.on('select', this.onSelect);
  11543. }
  11544. UnselectAuto.prototype.destroy = function () {
  11545. this.context.emitter.off('select', this.onSelect);
  11546. this.documentPointer.destroy();
  11547. };
  11548. return UnselectAuto;
  11549. }());
  11550. var OPTION_REFINERS$3 = {
  11551. fixedMirrorParent: identity,
  11552. };
  11553. var LISTENER_REFINERS = {
  11554. dateClick: identity,
  11555. eventDragStart: identity,
  11556. eventDragStop: identity,
  11557. eventDrop: identity,
  11558. eventResizeStart: identity,
  11559. eventResizeStop: identity,
  11560. eventResize: identity,
  11561. drop: identity,
  11562. eventReceive: identity,
  11563. eventLeave: identity,
  11564. };
  11565. /*
  11566. Given an already instantiated draggable object for one-or-more elements,
  11567. Interprets any dragging as an attempt to drag an events that lives outside
  11568. of a calendar onto a calendar.
  11569. */
  11570. var ExternalElementDragging = /** @class */ (function () {
  11571. function ExternalElementDragging(dragging, suppliedDragMeta) {
  11572. var _this = this;
  11573. this.receivingContext = null;
  11574. this.droppableEvent = null; // will exist for all drags, even if create:false
  11575. this.suppliedDragMeta = null;
  11576. this.dragMeta = null;
  11577. this.handleDragStart = function (ev) {
  11578. _this.dragMeta = _this.buildDragMeta(ev.subjectEl);
  11579. };
  11580. this.handleHitUpdate = function (hit, isFinal, ev) {
  11581. var dragging = _this.hitDragging.dragging;
  11582. var receivingContext = null;
  11583. var droppableEvent = null;
  11584. var isInvalid = false;
  11585. var interaction = {
  11586. affectedEvents: createEmptyEventStore(),
  11587. mutatedEvents: createEmptyEventStore(),
  11588. isEvent: _this.dragMeta.create,
  11589. };
  11590. if (hit) {
  11591. receivingContext = hit.context;
  11592. if (_this.canDropElOnCalendar(ev.subjectEl, receivingContext)) {
  11593. droppableEvent = computeEventForDateSpan(hit.dateSpan, _this.dragMeta, receivingContext);
  11594. interaction.mutatedEvents = eventTupleToStore(droppableEvent);
  11595. isInvalid = !isInteractionValid(interaction, hit.dateProfile, receivingContext);
  11596. if (isInvalid) {
  11597. interaction.mutatedEvents = createEmptyEventStore();
  11598. droppableEvent = null;
  11599. }
  11600. }
  11601. }
  11602. _this.displayDrag(receivingContext, interaction);
  11603. // show mirror if no already-rendered mirror element OR if we are shutting down the mirror (?)
  11604. // TODO: wish we could somehow wait for dispatch to guarantee render
  11605. dragging.setMirrorIsVisible(isFinal || !droppableEvent || !document.querySelector('.fc-event-mirror'));
  11606. if (!isInvalid) {
  11607. enableCursor();
  11608. }
  11609. else {
  11610. disableCursor();
  11611. }
  11612. if (!isFinal) {
  11613. dragging.setMirrorNeedsRevert(!droppableEvent);
  11614. _this.receivingContext = receivingContext;
  11615. _this.droppableEvent = droppableEvent;
  11616. }
  11617. };
  11618. this.handleDragEnd = function (pev) {
  11619. var _a = _this, receivingContext = _a.receivingContext, droppableEvent = _a.droppableEvent;
  11620. _this.clearDrag();
  11621. if (receivingContext && droppableEvent) {
  11622. var finalHit = _this.hitDragging.finalHit;
  11623. var finalView = finalHit.context.viewApi;
  11624. var dragMeta = _this.dragMeta;
  11625. receivingContext.emitter.trigger('drop', __assign(__assign({}, buildDatePointApiWithContext(finalHit.dateSpan, receivingContext)), { draggedEl: pev.subjectEl, jsEvent: pev.origEvent, view: finalView }));
  11626. if (dragMeta.create) {
  11627. var addingEvents_1 = eventTupleToStore(droppableEvent);
  11628. receivingContext.dispatch({
  11629. type: 'MERGE_EVENTS',
  11630. eventStore: addingEvents_1,
  11631. });
  11632. if (pev.isTouch) {
  11633. receivingContext.dispatch({
  11634. type: 'SELECT_EVENT',
  11635. eventInstanceId: droppableEvent.instance.instanceId,
  11636. });
  11637. }
  11638. // signal that an external event landed
  11639. receivingContext.emitter.trigger('eventReceive', {
  11640. event: new EventApi(receivingContext, droppableEvent.def, droppableEvent.instance),
  11641. relatedEvents: [],
  11642. revert: function () {
  11643. receivingContext.dispatch({
  11644. type: 'REMOVE_EVENTS',
  11645. eventStore: addingEvents_1,
  11646. });
  11647. },
  11648. draggedEl: pev.subjectEl,
  11649. view: finalView,
  11650. });
  11651. }
  11652. }
  11653. _this.receivingContext = null;
  11654. _this.droppableEvent = null;
  11655. };
  11656. var hitDragging = this.hitDragging = new HitDragging(dragging, interactionSettingsStore);
  11657. hitDragging.requireInitial = false; // will start outside of a component
  11658. hitDragging.emitter.on('dragstart', this.handleDragStart);
  11659. hitDragging.emitter.on('hitupdate', this.handleHitUpdate);
  11660. hitDragging.emitter.on('dragend', this.handleDragEnd);
  11661. this.suppliedDragMeta = suppliedDragMeta;
  11662. }
  11663. ExternalElementDragging.prototype.buildDragMeta = function (subjectEl) {
  11664. if (typeof this.suppliedDragMeta === 'object') {
  11665. return parseDragMeta(this.suppliedDragMeta);
  11666. }
  11667. if (typeof this.suppliedDragMeta === 'function') {
  11668. return parseDragMeta(this.suppliedDragMeta(subjectEl));
  11669. }
  11670. return getDragMetaFromEl(subjectEl);
  11671. };
  11672. ExternalElementDragging.prototype.displayDrag = function (nextContext, state) {
  11673. var prevContext = this.receivingContext;
  11674. if (prevContext && prevContext !== nextContext) {
  11675. prevContext.dispatch({ type: 'UNSET_EVENT_DRAG' });
  11676. }
  11677. if (nextContext) {
  11678. nextContext.dispatch({ type: 'SET_EVENT_DRAG', state: state });
  11679. }
  11680. };
  11681. ExternalElementDragging.prototype.clearDrag = function () {
  11682. if (this.receivingContext) {
  11683. this.receivingContext.dispatch({ type: 'UNSET_EVENT_DRAG' });
  11684. }
  11685. };
  11686. ExternalElementDragging.prototype.canDropElOnCalendar = function (el, receivingContext) {
  11687. var dropAccept = receivingContext.options.dropAccept;
  11688. if (typeof dropAccept === 'function') {
  11689. return dropAccept.call(receivingContext.calendarApi, el);
  11690. }
  11691. if (typeof dropAccept === 'string' && dropAccept) {
  11692. return Boolean(elementMatches(el, dropAccept));
  11693. }
  11694. return true;
  11695. };
  11696. return ExternalElementDragging;
  11697. }());
  11698. // Utils for computing event store from the DragMeta
  11699. // ----------------------------------------------------------------------------------------------------
  11700. function computeEventForDateSpan(dateSpan, dragMeta, context) {
  11701. var defProps = __assign({}, dragMeta.leftoverProps);
  11702. for (var _i = 0, _a = context.pluginHooks.externalDefTransforms; _i < _a.length; _i++) {
  11703. var transform = _a[_i];
  11704. __assign(defProps, transform(dateSpan, dragMeta));
  11705. }
  11706. var _b = refineEventDef(defProps, context), refined = _b.refined, extra = _b.extra;
  11707. var def = parseEventDef(refined, extra, dragMeta.sourceId, dateSpan.allDay, context.options.forceEventDuration || Boolean(dragMeta.duration), // hasEnd
  11708. context);
  11709. var start = dateSpan.range.start;
  11710. // only rely on time info if drop zone is all-day,
  11711. // otherwise, we already know the time
  11712. if (dateSpan.allDay && dragMeta.startTime) {
  11713. start = context.dateEnv.add(start, dragMeta.startTime);
  11714. }
  11715. var end = dragMeta.duration ?
  11716. context.dateEnv.add(start, dragMeta.duration) :
  11717. getDefaultEventEnd(dateSpan.allDay, start, context);
  11718. var instance = createEventInstance(def.defId, { start: start, end: end });
  11719. return { def: def, instance: instance };
  11720. }
  11721. // Utils for extracting data from element
  11722. // ----------------------------------------------------------------------------------------------------
  11723. function getDragMetaFromEl(el) {
  11724. var str = getEmbeddedElData(el, 'event');
  11725. var obj = str ?
  11726. JSON.parse(str) :
  11727. { create: false }; // if no embedded data, assume no event creation
  11728. return parseDragMeta(obj);
  11729. }
  11730. config.dataAttrPrefix = '';
  11731. function getEmbeddedElData(el, name) {
  11732. var prefix = config.dataAttrPrefix;
  11733. var prefixedName = (prefix ? prefix + '-' : '') + name;
  11734. return el.getAttribute('data-' + prefixedName) || '';
  11735. }
  11736. /*
  11737. Makes an element (that is *external* to any calendar) draggable.
  11738. Can pass in data that determines how an event will be created when dropped onto a calendar.
  11739. Leverages FullCalendar's internal drag-n-drop functionality WITHOUT a third-party drag system.
  11740. */
  11741. var ExternalDraggable = /** @class */ (function () {
  11742. function ExternalDraggable(el, settings) {
  11743. var _this = this;
  11744. if (settings === void 0) { settings = {}; }
  11745. this.handlePointerDown = function (ev) {
  11746. var dragging = _this.dragging;
  11747. var _a = _this.settings, minDistance = _a.minDistance, longPressDelay = _a.longPressDelay;
  11748. dragging.minDistance =
  11749. minDistance != null ?
  11750. minDistance :
  11751. (ev.isTouch ? 0 : BASE_OPTION_DEFAULTS.eventDragMinDistance);
  11752. dragging.delay =
  11753. ev.isTouch ? // TODO: eventually read eventLongPressDelay instead vvv
  11754. (longPressDelay != null ? longPressDelay : BASE_OPTION_DEFAULTS.longPressDelay) :
  11755. 0;
  11756. };
  11757. this.handleDragStart = function (ev) {
  11758. if (ev.isTouch &&
  11759. _this.dragging.delay &&
  11760. ev.subjectEl.classList.contains('fc-event')) {
  11761. _this.dragging.mirror.getMirrorEl().classList.add('fc-event-selected');
  11762. }
  11763. };
  11764. this.settings = settings;
  11765. var dragging = this.dragging = new FeaturefulElementDragging(el);
  11766. dragging.touchScrollAllowed = false;
  11767. if (settings.itemSelector != null) {
  11768. dragging.pointer.selector = settings.itemSelector;
  11769. }
  11770. if (settings.appendTo != null) {
  11771. dragging.mirror.parentNode = settings.appendTo; // TODO: write tests
  11772. }
  11773. dragging.emitter.on('pointerdown', this.handlePointerDown);
  11774. dragging.emitter.on('dragstart', this.handleDragStart);
  11775. new ExternalElementDragging(dragging, settings.eventData); // eslint-disable-line no-new
  11776. }
  11777. ExternalDraggable.prototype.destroy = function () {
  11778. this.dragging.destroy();
  11779. };
  11780. return ExternalDraggable;
  11781. }());
  11782. /*
  11783. Detects when a *THIRD-PARTY* drag-n-drop system interacts with elements.
  11784. The third-party system is responsible for drawing the visuals effects of the drag.
  11785. This class simply monitors for pointer movements and fires events.
  11786. It also has the ability to hide the moving element (the "mirror") during the drag.
  11787. */
  11788. var InferredElementDragging = /** @class */ (function (_super) {
  11789. __extends(InferredElementDragging, _super);
  11790. function InferredElementDragging(containerEl) {
  11791. var _this = _super.call(this, containerEl) || this;
  11792. _this.shouldIgnoreMove = false;
  11793. _this.mirrorSelector = '';
  11794. _this.currentMirrorEl = null;
  11795. _this.handlePointerDown = function (ev) {
  11796. _this.emitter.trigger('pointerdown', ev);
  11797. if (!_this.shouldIgnoreMove) {
  11798. // fire dragstart right away. does not support delay or min-distance
  11799. _this.emitter.trigger('dragstart', ev);
  11800. }
  11801. };
  11802. _this.handlePointerMove = function (ev) {
  11803. if (!_this.shouldIgnoreMove) {
  11804. _this.emitter.trigger('dragmove', ev);
  11805. }
  11806. };
  11807. _this.handlePointerUp = function (ev) {
  11808. _this.emitter.trigger('pointerup', ev);
  11809. if (!_this.shouldIgnoreMove) {
  11810. // fire dragend right away. does not support a revert animation
  11811. _this.emitter.trigger('dragend', ev);
  11812. }
  11813. };
  11814. var pointer = _this.pointer = new PointerDragging(containerEl);
  11815. pointer.emitter.on('pointerdown', _this.handlePointerDown);
  11816. pointer.emitter.on('pointermove', _this.handlePointerMove);
  11817. pointer.emitter.on('pointerup', _this.handlePointerUp);
  11818. return _this;
  11819. }
  11820. InferredElementDragging.prototype.destroy = function () {
  11821. this.pointer.destroy();
  11822. };
  11823. InferredElementDragging.prototype.setIgnoreMove = function (bool) {
  11824. this.shouldIgnoreMove = bool;
  11825. };
  11826. InferredElementDragging.prototype.setMirrorIsVisible = function (bool) {
  11827. if (bool) {
  11828. // restore a previously hidden element.
  11829. // use the reference in case the selector class has already been removed.
  11830. if (this.currentMirrorEl) {
  11831. this.currentMirrorEl.style.visibility = '';
  11832. this.currentMirrorEl = null;
  11833. }
  11834. }
  11835. else {
  11836. var mirrorEl = this.mirrorSelector
  11837. // TODO: somehow query FullCalendars WITHIN shadow-roots
  11838. ? document.querySelector(this.mirrorSelector)
  11839. : null;
  11840. if (mirrorEl) {
  11841. this.currentMirrorEl = mirrorEl;
  11842. mirrorEl.style.visibility = 'hidden';
  11843. }
  11844. }
  11845. };
  11846. return InferredElementDragging;
  11847. }(ElementDragging));
  11848. /*
  11849. Bridges third-party drag-n-drop systems with FullCalendar.
  11850. Must be instantiated and destroyed by caller.
  11851. */
  11852. var ThirdPartyDraggable = /** @class */ (function () {
  11853. function ThirdPartyDraggable(containerOrSettings, settings) {
  11854. var containerEl = document;
  11855. if (
  11856. // wish we could just test instanceof EventTarget, but doesn't work in IE11
  11857. containerOrSettings === document ||
  11858. containerOrSettings instanceof Element) {
  11859. containerEl = containerOrSettings;
  11860. settings = settings || {};
  11861. }
  11862. else {
  11863. settings = (containerOrSettings || {});
  11864. }
  11865. var dragging = this.dragging = new InferredElementDragging(containerEl);
  11866. if (typeof settings.itemSelector === 'string') {
  11867. dragging.pointer.selector = settings.itemSelector;
  11868. }
  11869. else if (containerEl === document) {
  11870. dragging.pointer.selector = '[data-event]';
  11871. }
  11872. if (typeof settings.mirrorSelector === 'string') {
  11873. dragging.mirrorSelector = settings.mirrorSelector;
  11874. }
  11875. new ExternalElementDragging(dragging, settings.eventData); // eslint-disable-line no-new
  11876. }
  11877. ThirdPartyDraggable.prototype.destroy = function () {
  11878. this.dragging.destroy();
  11879. };
  11880. return ThirdPartyDraggable;
  11881. }());
  11882. var interactionPlugin = createPlugin({
  11883. componentInteractions: [DateClicking, DateSelecting, EventDragging, EventResizing],
  11884. calendarInteractions: [UnselectAuto],
  11885. elementDraggingImpl: FeaturefulElementDragging,
  11886. optionRefiners: OPTION_REFINERS$3,
  11887. listenerRefiners: LISTENER_REFINERS,
  11888. });
  11889. /* An abstract class for the daygrid views, as well as month view. Renders one or more rows of day cells.
  11890. ----------------------------------------------------------------------------------------------------------------------*/
  11891. // It is a manager for a Table subcomponent, which does most of the heavy lifting.
  11892. // It is responsible for managing width/height.
  11893. var TableView = /** @class */ (function (_super) {
  11894. __extends(TableView, _super);
  11895. function TableView() {
  11896. var _this = _super !== null && _super.apply(this, arguments) || this;
  11897. _this.headerElRef = createRef();
  11898. return _this;
  11899. }
  11900. TableView.prototype.renderSimpleLayout = function (headerRowContent, bodyContent) {
  11901. var _a = this, props = _a.props, context = _a.context;
  11902. var sections = [];
  11903. var stickyHeaderDates = getStickyHeaderDates(context.options);
  11904. if (headerRowContent) {
  11905. sections.push({
  11906. type: 'header',
  11907. key: 'header',
  11908. isSticky: stickyHeaderDates,
  11909. chunk: {
  11910. elRef: this.headerElRef,
  11911. tableClassName: 'fc-col-header',
  11912. rowContent: headerRowContent,
  11913. },
  11914. });
  11915. }
  11916. sections.push({
  11917. type: 'body',
  11918. key: 'body',
  11919. liquid: true,
  11920. chunk: { content: bodyContent },
  11921. });
  11922. return (createElement(ViewRoot, { viewSpec: context.viewSpec }, function (rootElRef, classNames) { return (createElement("div", { ref: rootElRef, className: ['fc-daygrid'].concat(classNames).join(' ') },
  11923. createElement(SimpleScrollGrid, { liquid: !props.isHeightAuto && !props.forPrint, collapsibleWidth: props.forPrint, cols: [] /* TODO: make optional? */, sections: sections }))); }));
  11924. };
  11925. TableView.prototype.renderHScrollLayout = function (headerRowContent, bodyContent, colCnt, dayMinWidth) {
  11926. var ScrollGrid = this.context.pluginHooks.scrollGridImpl;
  11927. if (!ScrollGrid) {
  11928. throw new Error('No ScrollGrid implementation');
  11929. }
  11930. var _a = this, props = _a.props, context = _a.context;
  11931. var stickyHeaderDates = !props.forPrint && getStickyHeaderDates(context.options);
  11932. var stickyFooterScrollbar = !props.forPrint && getStickyFooterScrollbar(context.options);
  11933. var sections = [];
  11934. if (headerRowContent) {
  11935. sections.push({
  11936. type: 'header',
  11937. key: 'header',
  11938. isSticky: stickyHeaderDates,
  11939. chunks: [{
  11940. key: 'main',
  11941. elRef: this.headerElRef,
  11942. tableClassName: 'fc-col-header',
  11943. rowContent: headerRowContent,
  11944. }],
  11945. });
  11946. }
  11947. sections.push({
  11948. type: 'body',
  11949. key: 'body',
  11950. liquid: true,
  11951. chunks: [{
  11952. key: 'main',
  11953. content: bodyContent,
  11954. }],
  11955. });
  11956. if (stickyFooterScrollbar) {
  11957. sections.push({
  11958. type: 'footer',
  11959. key: 'footer',
  11960. isSticky: true,
  11961. chunks: [{
  11962. key: 'main',
  11963. content: renderScrollShim,
  11964. }],
  11965. });
  11966. }
  11967. return (createElement(ViewRoot, { viewSpec: context.viewSpec }, function (rootElRef, classNames) { return (createElement("div", { ref: rootElRef, className: ['fc-daygrid'].concat(classNames).join(' ') },
  11968. createElement(ScrollGrid, { liquid: !props.isHeightAuto && !props.forPrint, collapsibleWidth: props.forPrint, colGroups: [{ cols: [{ span: colCnt, minWidth: dayMinWidth }] }], sections: sections }))); }));
  11969. };
  11970. return TableView;
  11971. }(DateComponent));
  11972. function splitSegsByRow(segs, rowCnt) {
  11973. var byRow = [];
  11974. for (var i = 0; i < rowCnt; i += 1) {
  11975. byRow[i] = [];
  11976. }
  11977. for (var _i = 0, segs_1 = segs; _i < segs_1.length; _i++) {
  11978. var seg = segs_1[_i];
  11979. byRow[seg.row].push(seg);
  11980. }
  11981. return byRow;
  11982. }
  11983. function splitSegsByFirstCol(segs, colCnt) {
  11984. var byCol = [];
  11985. for (var i = 0; i < colCnt; i += 1) {
  11986. byCol[i] = [];
  11987. }
  11988. for (var _i = 0, segs_2 = segs; _i < segs_2.length; _i++) {
  11989. var seg = segs_2[_i];
  11990. byCol[seg.firstCol].push(seg);
  11991. }
  11992. return byCol;
  11993. }
  11994. function splitInteractionByRow(ui, rowCnt) {
  11995. var byRow = [];
  11996. if (!ui) {
  11997. for (var i = 0; i < rowCnt; i += 1) {
  11998. byRow[i] = null;
  11999. }
  12000. }
  12001. else {
  12002. for (var i = 0; i < rowCnt; i += 1) {
  12003. byRow[i] = {
  12004. affectedInstances: ui.affectedInstances,
  12005. isEvent: ui.isEvent,
  12006. segs: [],
  12007. };
  12008. }
  12009. for (var _i = 0, _a = ui.segs; _i < _a.length; _i++) {
  12010. var seg = _a[_i];
  12011. byRow[seg.row].segs.push(seg);
  12012. }
  12013. }
  12014. return byRow;
  12015. }
  12016. var TableCellTop = /** @class */ (function (_super) {
  12017. __extends(TableCellTop, _super);
  12018. function TableCellTop() {
  12019. return _super !== null && _super.apply(this, arguments) || this;
  12020. }
  12021. TableCellTop.prototype.render = function () {
  12022. var props = this.props;
  12023. var navLinkAttrs = buildNavLinkAttrs(this.context, props.date);
  12024. return (createElement(DayCellContent, { date: props.date, dateProfile: props.dateProfile, todayRange: props.todayRange, showDayNumber: props.showDayNumber, extraHookProps: props.extraHookProps, defaultContent: renderTopInner }, function (innerElRef, innerContent) { return ((innerContent || props.forceDayTop) && (createElement("div", { className: "fc-daygrid-day-top", ref: innerElRef },
  12025. createElement("a", __assign({ id: props.dayNumberId, className: "fc-daygrid-day-number" }, navLinkAttrs), innerContent || createElement(Fragment, null, "\u00A0"))))); }));
  12026. };
  12027. return TableCellTop;
  12028. }(BaseComponent));
  12029. function renderTopInner(props) {
  12030. return props.dayNumberText;
  12031. }
  12032. var DEFAULT_TABLE_EVENT_TIME_FORMAT = createFormatter({
  12033. hour: 'numeric',
  12034. minute: '2-digit',
  12035. omitZeroMinute: true,
  12036. meridiem: 'narrow',
  12037. });
  12038. function hasListItemDisplay(seg) {
  12039. var display = seg.eventRange.ui.display;
  12040. return display === 'list-item' || (display === 'auto' &&
  12041. !seg.eventRange.def.allDay &&
  12042. seg.firstCol === seg.lastCol && // can't be multi-day
  12043. seg.isStart && // "
  12044. seg.isEnd // "
  12045. );
  12046. }
  12047. var TableBlockEvent = /** @class */ (function (_super) {
  12048. __extends(TableBlockEvent, _super);
  12049. function TableBlockEvent() {
  12050. return _super !== null && _super.apply(this, arguments) || this;
  12051. }
  12052. TableBlockEvent.prototype.render = function () {
  12053. var props = this.props;
  12054. return (createElement(StandardEvent, __assign({}, props, { extraClassNames: ['fc-daygrid-event', 'fc-daygrid-block-event', 'fc-h-event'], defaultTimeFormat: DEFAULT_TABLE_EVENT_TIME_FORMAT, defaultDisplayEventEnd: props.defaultDisplayEventEnd, disableResizing: !props.seg.eventRange.def.allDay })));
  12055. };
  12056. return TableBlockEvent;
  12057. }(BaseComponent));
  12058. var TableListItemEvent = /** @class */ (function (_super) {
  12059. __extends(TableListItemEvent, _super);
  12060. function TableListItemEvent() {
  12061. return _super !== null && _super.apply(this, arguments) || this;
  12062. }
  12063. TableListItemEvent.prototype.render = function () {
  12064. var _a = this, props = _a.props, context = _a.context;
  12065. var timeFormat = context.options.eventTimeFormat || DEFAULT_TABLE_EVENT_TIME_FORMAT;
  12066. var timeText = buildSegTimeText(props.seg, timeFormat, context, true, props.defaultDisplayEventEnd);
  12067. return (createElement(EventRoot, { seg: props.seg, timeText: timeText, defaultContent: renderInnerContent$2, isDragging: props.isDragging, isResizing: false, isDateSelecting: false, isSelected: props.isSelected, isPast: props.isPast, isFuture: props.isFuture, isToday: props.isToday }, function (rootElRef, classNames, innerElRef, innerContent) { return ( // we don't use styles!
  12068. createElement("a", __assign({ className: ['fc-daygrid-event', 'fc-daygrid-dot-event'].concat(classNames).join(' '), ref: rootElRef }, getSegAnchorAttrs(props.seg, context)), innerContent)); }));
  12069. };
  12070. return TableListItemEvent;
  12071. }(BaseComponent));
  12072. function renderInnerContent$2(innerProps) {
  12073. return (createElement(Fragment, null,
  12074. createElement("div", { className: "fc-daygrid-event-dot", style: { borderColor: innerProps.borderColor || innerProps.backgroundColor } }),
  12075. innerProps.timeText && (createElement("div", { className: "fc-event-time" }, innerProps.timeText)),
  12076. createElement("div", { className: "fc-event-title" }, innerProps.event.title || createElement(Fragment, null, "\u00A0"))));
  12077. }
  12078. var TableCellMoreLink = /** @class */ (function (_super) {
  12079. __extends(TableCellMoreLink, _super);
  12080. function TableCellMoreLink() {
  12081. var _this = _super !== null && _super.apply(this, arguments) || this;
  12082. _this.compileSegs = memoize(compileSegs);
  12083. return _this;
  12084. }
  12085. TableCellMoreLink.prototype.render = function () {
  12086. var props = this.props;
  12087. var _a = this.compileSegs(props.singlePlacements), allSegs = _a.allSegs, invisibleSegs = _a.invisibleSegs;
  12088. return (createElement(MoreLinkRoot, { dateProfile: props.dateProfile, todayRange: props.todayRange, allDayDate: props.allDayDate, moreCnt: props.moreCnt, allSegs: allSegs, hiddenSegs: invisibleSegs, alignmentElRef: props.alignmentElRef, alignGridTop: props.alignGridTop, extraDateSpan: props.extraDateSpan, popoverContent: function () {
  12089. var isForcedInvisible = (props.eventDrag ? props.eventDrag.affectedInstances : null) ||
  12090. (props.eventResize ? props.eventResize.affectedInstances : null) ||
  12091. {};
  12092. return (createElement(Fragment, null, allSegs.map(function (seg) {
  12093. var instanceId = seg.eventRange.instance.instanceId;
  12094. return (createElement("div", { className: "fc-daygrid-event-harness", key: instanceId, style: {
  12095. visibility: isForcedInvisible[instanceId] ? 'hidden' : '',
  12096. } }, hasListItemDisplay(seg) ? (createElement(TableListItemEvent, __assign({ seg: seg, isDragging: false, isSelected: instanceId === props.eventSelection, defaultDisplayEventEnd: false }, getSegMeta(seg, props.todayRange)))) : (createElement(TableBlockEvent, __assign({ seg: seg, isDragging: false, isResizing: false, isDateSelecting: false, isSelected: instanceId === props.eventSelection, defaultDisplayEventEnd: false }, getSegMeta(seg, props.todayRange))))));
  12097. })));
  12098. } }, function (rootElRef, classNames, innerElRef, innerContent, handleClick, title, isExpanded, popoverId) { return (createElement("a", __assign({ ref: rootElRef, className: ['fc-daygrid-more-link'].concat(classNames).join(' '), title: title, "aria-expanded": isExpanded, "aria-controls": popoverId }, createAriaClickAttrs(handleClick)), innerContent)); }));
  12099. };
  12100. return TableCellMoreLink;
  12101. }(BaseComponent));
  12102. function compileSegs(singlePlacements) {
  12103. var allSegs = [];
  12104. var invisibleSegs = [];
  12105. for (var _i = 0, singlePlacements_1 = singlePlacements; _i < singlePlacements_1.length; _i++) {
  12106. var placement = singlePlacements_1[_i];
  12107. allSegs.push(placement.seg);
  12108. if (!placement.isVisible) {
  12109. invisibleSegs.push(placement.seg);
  12110. }
  12111. }
  12112. return { allSegs: allSegs, invisibleSegs: invisibleSegs };
  12113. }
  12114. var DEFAULT_WEEK_NUM_FORMAT$1 = createFormatter({ week: 'narrow' });
  12115. var TableCell = /** @class */ (function (_super) {
  12116. __extends(TableCell, _super);
  12117. function TableCell() {
  12118. var _this = _super !== null && _super.apply(this, arguments) || this;
  12119. _this.rootElRef = createRef();
  12120. _this.state = {
  12121. dayNumberId: getUniqueDomId(),
  12122. };
  12123. _this.handleRootEl = function (el) {
  12124. setRef(_this.rootElRef, el);
  12125. setRef(_this.props.elRef, el);
  12126. };
  12127. return _this;
  12128. }
  12129. TableCell.prototype.render = function () {
  12130. var _a = this, context = _a.context, props = _a.props, state = _a.state, rootElRef = _a.rootElRef;
  12131. var date = props.date, dateProfile = props.dateProfile;
  12132. var navLinkAttrs = buildNavLinkAttrs(context, date, 'week');
  12133. return (createElement(DayCellRoot, { date: date, dateProfile: dateProfile, todayRange: props.todayRange, showDayNumber: props.showDayNumber, extraHookProps: props.extraHookProps, elRef: this.handleRootEl }, function (dayElRef, dayClassNames, rootDataAttrs, isDisabled) { return (createElement("td", __assign({ ref: dayElRef, role: "gridcell", className: ['fc-daygrid-day'].concat(dayClassNames, props.extraClassNames || []).join(' ') }, rootDataAttrs, props.extraDataAttrs, (props.showDayNumber ? { 'aria-labelledby': state.dayNumberId } : {})),
  12134. createElement("div", { className: "fc-daygrid-day-frame fc-scrollgrid-sync-inner", ref: props.innerElRef /* different from hook system! RENAME */ },
  12135. props.showWeekNumber && (createElement(WeekNumberRoot, { date: date, defaultFormat: DEFAULT_WEEK_NUM_FORMAT$1 }, function (weekElRef, weekClassNames, innerElRef, innerContent) { return (createElement("a", __assign({ ref: weekElRef, className: ['fc-daygrid-week-number'].concat(weekClassNames).join(' ') }, navLinkAttrs), innerContent)); })),
  12136. !isDisabled && (createElement(TableCellTop, { date: date, dateProfile: dateProfile, showDayNumber: props.showDayNumber, dayNumberId: state.dayNumberId, forceDayTop: props.forceDayTop, todayRange: props.todayRange, extraHookProps: props.extraHookProps })),
  12137. createElement("div", { className: "fc-daygrid-day-events", ref: props.fgContentElRef },
  12138. props.fgContent,
  12139. createElement("div", { className: "fc-daygrid-day-bottom", style: { marginTop: props.moreMarginTop } },
  12140. createElement(TableCellMoreLink, { allDayDate: date, singlePlacements: props.singlePlacements, moreCnt: props.moreCnt, alignmentElRef: rootElRef, alignGridTop: !props.showDayNumber, extraDateSpan: props.extraDateSpan, dateProfile: props.dateProfile, eventSelection: props.eventSelection, eventDrag: props.eventDrag, eventResize: props.eventResize, todayRange: props.todayRange }))),
  12141. createElement("div", { className: "fc-daygrid-day-bg" }, props.bgContent)))); }));
  12142. };
  12143. return TableCell;
  12144. }(DateComponent));
  12145. function computeFgSegPlacement(segs, // assumed already sorted
  12146. dayMaxEvents, dayMaxEventRows, strictOrder, eventInstanceHeights, maxContentHeight, cells) {
  12147. var hierarchy = new DayGridSegHierarchy();
  12148. hierarchy.allowReslicing = true;
  12149. hierarchy.strictOrder = strictOrder;
  12150. if (dayMaxEvents === true || dayMaxEventRows === true) {
  12151. hierarchy.maxCoord = maxContentHeight;
  12152. hierarchy.hiddenConsumes = true;
  12153. }
  12154. else if (typeof dayMaxEvents === 'number') {
  12155. hierarchy.maxStackCnt = dayMaxEvents;
  12156. }
  12157. else if (typeof dayMaxEventRows === 'number') {
  12158. hierarchy.maxStackCnt = dayMaxEventRows;
  12159. hierarchy.hiddenConsumes = true;
  12160. }
  12161. // create segInputs only for segs with known heights
  12162. var segInputs = [];
  12163. var unknownHeightSegs = [];
  12164. for (var i = 0; i < segs.length; i += 1) {
  12165. var seg = segs[i];
  12166. var instanceId = seg.eventRange.instance.instanceId;
  12167. var eventHeight = eventInstanceHeights[instanceId];
  12168. if (eventHeight != null) {
  12169. segInputs.push({
  12170. index: i,
  12171. thickness: eventHeight,
  12172. span: {
  12173. start: seg.firstCol,
  12174. end: seg.lastCol + 1,
  12175. },
  12176. });
  12177. }
  12178. else {
  12179. unknownHeightSegs.push(seg);
  12180. }
  12181. }
  12182. var hiddenEntries = hierarchy.addSegs(segInputs);
  12183. var segRects = hierarchy.toRects();
  12184. var _a = placeRects(segRects, segs, cells), singleColPlacements = _a.singleColPlacements, multiColPlacements = _a.multiColPlacements, leftoverMargins = _a.leftoverMargins;
  12185. var moreCnts = [];
  12186. var moreMarginTops = [];
  12187. // add segs with unknown heights
  12188. for (var _i = 0, unknownHeightSegs_1 = unknownHeightSegs; _i < unknownHeightSegs_1.length; _i++) {
  12189. var seg = unknownHeightSegs_1[_i];
  12190. multiColPlacements[seg.firstCol].push({
  12191. seg: seg,
  12192. isVisible: false,
  12193. isAbsolute: true,
  12194. absoluteTop: 0,
  12195. marginTop: 0,
  12196. });
  12197. for (var col = seg.firstCol; col <= seg.lastCol; col += 1) {
  12198. singleColPlacements[col].push({
  12199. seg: resliceSeg(seg, col, col + 1, cells),
  12200. isVisible: false,
  12201. isAbsolute: false,
  12202. absoluteTop: 0,
  12203. marginTop: 0,
  12204. });
  12205. }
  12206. }
  12207. // add the hidden entries
  12208. for (var col = 0; col < cells.length; col += 1) {
  12209. moreCnts.push(0);
  12210. }
  12211. for (var _b = 0, hiddenEntries_1 = hiddenEntries; _b < hiddenEntries_1.length; _b++) {
  12212. var hiddenEntry = hiddenEntries_1[_b];
  12213. var seg = segs[hiddenEntry.index];
  12214. var hiddenSpan = hiddenEntry.span;
  12215. multiColPlacements[hiddenSpan.start].push({
  12216. seg: resliceSeg(seg, hiddenSpan.start, hiddenSpan.end, cells),
  12217. isVisible: false,
  12218. isAbsolute: true,
  12219. absoluteTop: 0,
  12220. marginTop: 0,
  12221. });
  12222. for (var col = hiddenSpan.start; col < hiddenSpan.end; col += 1) {
  12223. moreCnts[col] += 1;
  12224. singleColPlacements[col].push({
  12225. seg: resliceSeg(seg, col, col + 1, cells),
  12226. isVisible: false,
  12227. isAbsolute: false,
  12228. absoluteTop: 0,
  12229. marginTop: 0,
  12230. });
  12231. }
  12232. }
  12233. // deal with leftover margins
  12234. for (var col = 0; col < cells.length; col += 1) {
  12235. moreMarginTops.push(leftoverMargins[col]);
  12236. }
  12237. return { singleColPlacements: singleColPlacements, multiColPlacements: multiColPlacements, moreCnts: moreCnts, moreMarginTops: moreMarginTops };
  12238. }
  12239. // rects ordered by top coord, then left
  12240. function placeRects(allRects, segs, cells) {
  12241. var rectsByEachCol = groupRectsByEachCol(allRects, cells.length);
  12242. var singleColPlacements = [];
  12243. var multiColPlacements = [];
  12244. var leftoverMargins = [];
  12245. for (var col = 0; col < cells.length; col += 1) {
  12246. var rects = rectsByEachCol[col];
  12247. // compute all static segs in singlePlacements
  12248. var singlePlacements = [];
  12249. var currentHeight = 0;
  12250. var currentMarginTop = 0;
  12251. for (var _i = 0, rects_1 = rects; _i < rects_1.length; _i++) {
  12252. var rect = rects_1[_i];
  12253. var seg = segs[rect.index];
  12254. singlePlacements.push({
  12255. seg: resliceSeg(seg, col, col + 1, cells),
  12256. isVisible: true,
  12257. isAbsolute: false,
  12258. absoluteTop: rect.levelCoord,
  12259. marginTop: rect.levelCoord - currentHeight,
  12260. });
  12261. currentHeight = rect.levelCoord + rect.thickness;
  12262. }
  12263. // compute mixed static/absolute segs in multiPlacements
  12264. var multiPlacements = [];
  12265. currentHeight = 0;
  12266. currentMarginTop = 0;
  12267. for (var _a = 0, rects_2 = rects; _a < rects_2.length; _a++) {
  12268. var rect = rects_2[_a];
  12269. var seg = segs[rect.index];
  12270. var isAbsolute = rect.span.end - rect.span.start > 1; // multi-column?
  12271. var isFirstCol = rect.span.start === col;
  12272. currentMarginTop += rect.levelCoord - currentHeight; // amount of space since bottom of previous seg
  12273. currentHeight = rect.levelCoord + rect.thickness; // height will now be bottom of current seg
  12274. if (isAbsolute) {
  12275. currentMarginTop += rect.thickness;
  12276. if (isFirstCol) {
  12277. multiPlacements.push({
  12278. seg: resliceSeg(seg, rect.span.start, rect.span.end, cells),
  12279. isVisible: true,
  12280. isAbsolute: true,
  12281. absoluteTop: rect.levelCoord,
  12282. marginTop: 0,
  12283. });
  12284. }
  12285. }
  12286. else if (isFirstCol) {
  12287. multiPlacements.push({
  12288. seg: resliceSeg(seg, rect.span.start, rect.span.end, cells),
  12289. isVisible: true,
  12290. isAbsolute: false,
  12291. absoluteTop: rect.levelCoord,
  12292. marginTop: currentMarginTop, // claim the margin
  12293. });
  12294. currentMarginTop = 0;
  12295. }
  12296. }
  12297. singleColPlacements.push(singlePlacements);
  12298. multiColPlacements.push(multiPlacements);
  12299. leftoverMargins.push(currentMarginTop);
  12300. }
  12301. return { singleColPlacements: singleColPlacements, multiColPlacements: multiColPlacements, leftoverMargins: leftoverMargins };
  12302. }
  12303. function groupRectsByEachCol(rects, colCnt) {
  12304. var rectsByEachCol = [];
  12305. for (var col = 0; col < colCnt; col += 1) {
  12306. rectsByEachCol.push([]);
  12307. }
  12308. for (var _i = 0, rects_3 = rects; _i < rects_3.length; _i++) {
  12309. var rect = rects_3[_i];
  12310. for (var col = rect.span.start; col < rect.span.end; col += 1) {
  12311. rectsByEachCol[col].push(rect);
  12312. }
  12313. }
  12314. return rectsByEachCol;
  12315. }
  12316. function resliceSeg(seg, spanStart, spanEnd, cells) {
  12317. if (seg.firstCol === spanStart && seg.lastCol === spanEnd - 1) {
  12318. return seg;
  12319. }
  12320. var eventRange = seg.eventRange;
  12321. var origRange = eventRange.range;
  12322. var slicedRange = intersectRanges(origRange, {
  12323. start: cells[spanStart].date,
  12324. end: addDays(cells[spanEnd - 1].date, 1),
  12325. });
  12326. return __assign(__assign({}, seg), { firstCol: spanStart, lastCol: spanEnd - 1, eventRange: {
  12327. def: eventRange.def,
  12328. ui: __assign(__assign({}, eventRange.ui), { durationEditable: false }),
  12329. instance: eventRange.instance,
  12330. range: slicedRange,
  12331. }, isStart: seg.isStart && slicedRange.start.valueOf() === origRange.start.valueOf(), isEnd: seg.isEnd && slicedRange.end.valueOf() === origRange.end.valueOf() });
  12332. }
  12333. var DayGridSegHierarchy = /** @class */ (function (_super) {
  12334. __extends(DayGridSegHierarchy, _super);
  12335. function DayGridSegHierarchy() {
  12336. var _this = _super !== null && _super.apply(this, arguments) || this;
  12337. // config
  12338. _this.hiddenConsumes = false;
  12339. // allows us to keep hidden entries in the hierarchy so they take up space
  12340. _this.forceHidden = {};
  12341. return _this;
  12342. }
  12343. DayGridSegHierarchy.prototype.addSegs = function (segInputs) {
  12344. var _this = this;
  12345. var hiddenSegs = _super.prototype.addSegs.call(this, segInputs);
  12346. var entriesByLevel = this.entriesByLevel;
  12347. var excludeHidden = function (entry) { return !_this.forceHidden[buildEntryKey(entry)]; };
  12348. // remove the forced-hidden segs
  12349. for (var level = 0; level < entriesByLevel.length; level += 1) {
  12350. entriesByLevel[level] = entriesByLevel[level].filter(excludeHidden);
  12351. }
  12352. return hiddenSegs;
  12353. };
  12354. DayGridSegHierarchy.prototype.handleInvalidInsertion = function (insertion, entry, hiddenEntries) {
  12355. var _a = this, entriesByLevel = _a.entriesByLevel, forceHidden = _a.forceHidden;
  12356. var touchingEntry = insertion.touchingEntry, touchingLevel = insertion.touchingLevel, touchingLateral = insertion.touchingLateral;
  12357. if (this.hiddenConsumes && touchingEntry) {
  12358. var touchingEntryId = buildEntryKey(touchingEntry);
  12359. // if not already hidden
  12360. if (!forceHidden[touchingEntryId]) {
  12361. if (this.allowReslicing) {
  12362. var placeholderEntry = __assign(__assign({}, touchingEntry), { span: intersectSpans(touchingEntry.span, entry.span) });
  12363. var placeholderEntryId = buildEntryKey(placeholderEntry);
  12364. forceHidden[placeholderEntryId] = true;
  12365. entriesByLevel[touchingLevel][touchingLateral] = placeholderEntry; // replace touchingEntry with our placeholder
  12366. this.splitEntry(touchingEntry, entry, hiddenEntries); // split up the touchingEntry, reinsert it
  12367. }
  12368. else {
  12369. forceHidden[touchingEntryId] = true;
  12370. hiddenEntries.push(touchingEntry);
  12371. }
  12372. }
  12373. }
  12374. return _super.prototype.handleInvalidInsertion.call(this, insertion, entry, hiddenEntries);
  12375. };
  12376. return DayGridSegHierarchy;
  12377. }(SegHierarchy));
  12378. var TableRow = /** @class */ (function (_super) {
  12379. __extends(TableRow, _super);
  12380. function TableRow() {
  12381. var _this = _super !== null && _super.apply(this, arguments) || this;
  12382. _this.cellElRefs = new RefMap(); // the <td>
  12383. _this.frameElRefs = new RefMap(); // the fc-daygrid-day-frame
  12384. _this.fgElRefs = new RefMap(); // the fc-daygrid-day-events
  12385. _this.segHarnessRefs = new RefMap(); // indexed by "instanceId:firstCol"
  12386. _this.rootElRef = createRef();
  12387. _this.state = {
  12388. framePositions: null,
  12389. maxContentHeight: null,
  12390. eventInstanceHeights: {},
  12391. };
  12392. return _this;
  12393. }
  12394. TableRow.prototype.render = function () {
  12395. var _this = this;
  12396. var _a = this, props = _a.props, state = _a.state, context = _a.context;
  12397. var options = context.options;
  12398. var colCnt = props.cells.length;
  12399. var businessHoursByCol = splitSegsByFirstCol(props.businessHourSegs, colCnt);
  12400. var bgEventSegsByCol = splitSegsByFirstCol(props.bgEventSegs, colCnt);
  12401. var highlightSegsByCol = splitSegsByFirstCol(this.getHighlightSegs(), colCnt);
  12402. var mirrorSegsByCol = splitSegsByFirstCol(this.getMirrorSegs(), colCnt);
  12403. var _b = computeFgSegPlacement(sortEventSegs(props.fgEventSegs, options.eventOrder), props.dayMaxEvents, props.dayMaxEventRows, options.eventOrderStrict, state.eventInstanceHeights, state.maxContentHeight, props.cells), singleColPlacements = _b.singleColPlacements, multiColPlacements = _b.multiColPlacements, moreCnts = _b.moreCnts, moreMarginTops = _b.moreMarginTops;
  12404. var isForcedInvisible = // TODO: messy way to compute this
  12405. (props.eventDrag && props.eventDrag.affectedInstances) ||
  12406. (props.eventResize && props.eventResize.affectedInstances) ||
  12407. {};
  12408. return (createElement("tr", { ref: this.rootElRef, role: "row" },
  12409. props.renderIntro && props.renderIntro(),
  12410. props.cells.map(function (cell, col) {
  12411. var normalFgNodes = _this.renderFgSegs(col, props.forPrint ? singleColPlacements[col] : multiColPlacements[col], props.todayRange, isForcedInvisible);
  12412. var mirrorFgNodes = _this.renderFgSegs(col, buildMirrorPlacements(mirrorSegsByCol[col], multiColPlacements), props.todayRange, {}, Boolean(props.eventDrag), Boolean(props.eventResize), false);
  12413. return (createElement(TableCell, { key: cell.key, elRef: _this.cellElRefs.createRef(cell.key), innerElRef: _this.frameElRefs.createRef(cell.key) /* FF <td> problem, but okay to use for left/right. TODO: rename prop */, dateProfile: props.dateProfile, date: cell.date, showDayNumber: props.showDayNumbers, showWeekNumber: props.showWeekNumbers && col === 0, forceDayTop: props.showWeekNumbers /* even displaying weeknum for row, not necessarily day */, todayRange: props.todayRange, eventSelection: props.eventSelection, eventDrag: props.eventDrag, eventResize: props.eventResize, extraHookProps: cell.extraHookProps, extraDataAttrs: cell.extraDataAttrs, extraClassNames: cell.extraClassNames, extraDateSpan: cell.extraDateSpan, moreCnt: moreCnts[col], moreMarginTop: moreMarginTops[col], singlePlacements: singleColPlacements[col], fgContentElRef: _this.fgElRefs.createRef(cell.key), fgContent: ( // Fragment scopes the keys
  12414. createElement(Fragment, null,
  12415. createElement(Fragment, null, normalFgNodes),
  12416. createElement(Fragment, null, mirrorFgNodes))), bgContent: ( // Fragment scopes the keys
  12417. createElement(Fragment, null,
  12418. _this.renderFillSegs(highlightSegsByCol[col], 'highlight'),
  12419. _this.renderFillSegs(businessHoursByCol[col], 'non-business'),
  12420. _this.renderFillSegs(bgEventSegsByCol[col], 'bg-event'))) }));
  12421. })));
  12422. };
  12423. TableRow.prototype.componentDidMount = function () {
  12424. this.updateSizing(true);
  12425. };
  12426. TableRow.prototype.componentDidUpdate = function (prevProps, prevState) {
  12427. var currentProps = this.props;
  12428. this.updateSizing(!isPropsEqual(prevProps, currentProps));
  12429. };
  12430. TableRow.prototype.getHighlightSegs = function () {
  12431. var props = this.props;
  12432. if (props.eventDrag && props.eventDrag.segs.length) { // messy check
  12433. return props.eventDrag.segs;
  12434. }
  12435. if (props.eventResize && props.eventResize.segs.length) { // messy check
  12436. return props.eventResize.segs;
  12437. }
  12438. return props.dateSelectionSegs;
  12439. };
  12440. TableRow.prototype.getMirrorSegs = function () {
  12441. var props = this.props;
  12442. if (props.eventResize && props.eventResize.segs.length) { // messy check
  12443. return props.eventResize.segs;
  12444. }
  12445. return [];
  12446. };
  12447. TableRow.prototype.renderFgSegs = function (col, segPlacements, todayRange, isForcedInvisible, isDragging, isResizing, isDateSelecting) {
  12448. var context = this.context;
  12449. var eventSelection = this.props.eventSelection;
  12450. var framePositions = this.state.framePositions;
  12451. var defaultDisplayEventEnd = this.props.cells.length === 1; // colCnt === 1
  12452. var isMirror = isDragging || isResizing || isDateSelecting;
  12453. var nodes = [];
  12454. if (framePositions) {
  12455. for (var _i = 0, segPlacements_1 = segPlacements; _i < segPlacements_1.length; _i++) {
  12456. var placement = segPlacements_1[_i];
  12457. var seg = placement.seg;
  12458. var instanceId = seg.eventRange.instance.instanceId;
  12459. var key = instanceId + ':' + col;
  12460. var isVisible = placement.isVisible && !isForcedInvisible[instanceId];
  12461. var isAbsolute = placement.isAbsolute;
  12462. var left = '';
  12463. var right = '';
  12464. if (isAbsolute) {
  12465. if (context.isRtl) {
  12466. right = 0;
  12467. left = framePositions.lefts[seg.lastCol] - framePositions.lefts[seg.firstCol];
  12468. }
  12469. else {
  12470. left = 0;
  12471. right = framePositions.rights[seg.firstCol] - framePositions.rights[seg.lastCol];
  12472. }
  12473. }
  12474. /*
  12475. known bug: events that are force to be list-item but span multiple days still take up space in later columns
  12476. todo: in print view, for multi-day events, don't display title within non-start/end segs
  12477. */
  12478. nodes.push(createElement("div", { className: 'fc-daygrid-event-harness' + (isAbsolute ? ' fc-daygrid-event-harness-abs' : ''), key: key, ref: isMirror ? null : this.segHarnessRefs.createRef(key), style: {
  12479. visibility: isVisible ? '' : 'hidden',
  12480. marginTop: isAbsolute ? '' : placement.marginTop,
  12481. top: isAbsolute ? placement.absoluteTop : '',
  12482. left: left,
  12483. right: right,
  12484. } }, hasListItemDisplay(seg) ? (createElement(TableListItemEvent, __assign({ seg: seg, isDragging: isDragging, isSelected: instanceId === eventSelection, defaultDisplayEventEnd: defaultDisplayEventEnd }, getSegMeta(seg, todayRange)))) : (createElement(TableBlockEvent, __assign({ seg: seg, isDragging: isDragging, isResizing: isResizing, isDateSelecting: isDateSelecting, isSelected: instanceId === eventSelection, defaultDisplayEventEnd: defaultDisplayEventEnd }, getSegMeta(seg, todayRange))))));
  12485. }
  12486. }
  12487. return nodes;
  12488. };
  12489. TableRow.prototype.renderFillSegs = function (segs, fillType) {
  12490. var isRtl = this.context.isRtl;
  12491. var todayRange = this.props.todayRange;
  12492. var framePositions = this.state.framePositions;
  12493. var nodes = [];
  12494. if (framePositions) {
  12495. for (var _i = 0, segs_1 = segs; _i < segs_1.length; _i++) {
  12496. var seg = segs_1[_i];
  12497. var leftRightCss = isRtl ? {
  12498. right: 0,
  12499. left: framePositions.lefts[seg.lastCol] - framePositions.lefts[seg.firstCol],
  12500. } : {
  12501. left: 0,
  12502. right: framePositions.rights[seg.firstCol] - framePositions.rights[seg.lastCol],
  12503. };
  12504. nodes.push(createElement("div", { key: buildEventRangeKey(seg.eventRange), className: "fc-daygrid-bg-harness", style: leftRightCss }, fillType === 'bg-event' ?
  12505. createElement(BgEvent, __assign({ seg: seg }, getSegMeta(seg, todayRange))) :
  12506. renderFill(fillType)));
  12507. }
  12508. }
  12509. return createElement.apply(void 0, __spreadArray([Fragment, {}], nodes));
  12510. };
  12511. TableRow.prototype.updateSizing = function (isExternalSizingChange) {
  12512. var _a = this, props = _a.props, frameElRefs = _a.frameElRefs;
  12513. if (!props.forPrint &&
  12514. props.clientWidth !== null // positioning ready?
  12515. ) {
  12516. if (isExternalSizingChange) {
  12517. var frameEls = props.cells.map(function (cell) { return frameElRefs.currentMap[cell.key]; });
  12518. if (frameEls.length) {
  12519. var originEl = this.rootElRef.current;
  12520. this.setState({
  12521. framePositions: new PositionCache(originEl, frameEls, true, // isHorizontal
  12522. false),
  12523. });
  12524. }
  12525. }
  12526. var oldInstanceHeights = this.state.eventInstanceHeights;
  12527. var newInstanceHeights = this.queryEventInstanceHeights();
  12528. var limitByContentHeight = props.dayMaxEvents === true || props.dayMaxEventRows === true;
  12529. this.setState({
  12530. // HACK to prevent oscillations of events being shown/hidden from max-event-rows
  12531. // Essentially, once you compute an element's height, never null-out.
  12532. // TODO: always display all events, as visibility:hidden?
  12533. eventInstanceHeights: __assign(__assign({}, oldInstanceHeights), newInstanceHeights),
  12534. maxContentHeight: limitByContentHeight ? this.computeMaxContentHeight() : null,
  12535. });
  12536. }
  12537. };
  12538. TableRow.prototype.queryEventInstanceHeights = function () {
  12539. var segElMap = this.segHarnessRefs.currentMap;
  12540. var eventInstanceHeights = {};
  12541. // get the max height amongst instance segs
  12542. for (var key in segElMap) {
  12543. var height = Math.round(segElMap[key].getBoundingClientRect().height);
  12544. var instanceId = key.split(':')[0]; // deconstruct how renderFgSegs makes the key
  12545. eventInstanceHeights[instanceId] = Math.max(eventInstanceHeights[instanceId] || 0, height);
  12546. }
  12547. return eventInstanceHeights;
  12548. };
  12549. TableRow.prototype.computeMaxContentHeight = function () {
  12550. var firstKey = this.props.cells[0].key;
  12551. var cellEl = this.cellElRefs.currentMap[firstKey];
  12552. var fcContainerEl = this.fgElRefs.currentMap[firstKey];
  12553. return cellEl.getBoundingClientRect().bottom - fcContainerEl.getBoundingClientRect().top;
  12554. };
  12555. TableRow.prototype.getCellEls = function () {
  12556. var elMap = this.cellElRefs.currentMap;
  12557. return this.props.cells.map(function (cell) { return elMap[cell.key]; });
  12558. };
  12559. return TableRow;
  12560. }(DateComponent));
  12561. TableRow.addStateEquality({
  12562. eventInstanceHeights: isPropsEqual,
  12563. });
  12564. function buildMirrorPlacements(mirrorSegs, colPlacements) {
  12565. if (!mirrorSegs.length) {
  12566. return [];
  12567. }
  12568. var topsByInstanceId = buildAbsoluteTopHash(colPlacements); // TODO: cache this at first render?
  12569. return mirrorSegs.map(function (seg) { return ({
  12570. seg: seg,
  12571. isVisible: true,
  12572. isAbsolute: true,
  12573. absoluteTop: topsByInstanceId[seg.eventRange.instance.instanceId],
  12574. marginTop: 0,
  12575. }); });
  12576. }
  12577. function buildAbsoluteTopHash(colPlacements) {
  12578. var topsByInstanceId = {};
  12579. for (var _i = 0, colPlacements_1 = colPlacements; _i < colPlacements_1.length; _i++) {
  12580. var placements = colPlacements_1[_i];
  12581. for (var _a = 0, placements_1 = placements; _a < placements_1.length; _a++) {
  12582. var placement = placements_1[_a];
  12583. topsByInstanceId[placement.seg.eventRange.instance.instanceId] = placement.absoluteTop;
  12584. }
  12585. }
  12586. return topsByInstanceId;
  12587. }
  12588. var Table = /** @class */ (function (_super) {
  12589. __extends(Table, _super);
  12590. function Table() {
  12591. var _this = _super !== null && _super.apply(this, arguments) || this;
  12592. _this.splitBusinessHourSegs = memoize(splitSegsByRow);
  12593. _this.splitBgEventSegs = memoize(splitSegsByRow);
  12594. _this.splitFgEventSegs = memoize(splitSegsByRow);
  12595. _this.splitDateSelectionSegs = memoize(splitSegsByRow);
  12596. _this.splitEventDrag = memoize(splitInteractionByRow);
  12597. _this.splitEventResize = memoize(splitInteractionByRow);
  12598. _this.rowRefs = new RefMap();
  12599. _this.handleRootEl = function (rootEl) {
  12600. _this.rootEl = rootEl;
  12601. if (rootEl) {
  12602. _this.context.registerInteractiveComponent(_this, {
  12603. el: rootEl,
  12604. isHitComboAllowed: _this.props.isHitComboAllowed,
  12605. });
  12606. }
  12607. else {
  12608. _this.context.unregisterInteractiveComponent(_this);
  12609. }
  12610. };
  12611. return _this;
  12612. }
  12613. Table.prototype.render = function () {
  12614. var _this = this;
  12615. var props = this.props;
  12616. var dateProfile = props.dateProfile, dayMaxEventRows = props.dayMaxEventRows, dayMaxEvents = props.dayMaxEvents, expandRows = props.expandRows;
  12617. var rowCnt = props.cells.length;
  12618. var businessHourSegsByRow = this.splitBusinessHourSegs(props.businessHourSegs, rowCnt);
  12619. var bgEventSegsByRow = this.splitBgEventSegs(props.bgEventSegs, rowCnt);
  12620. var fgEventSegsByRow = this.splitFgEventSegs(props.fgEventSegs, rowCnt);
  12621. var dateSelectionSegsByRow = this.splitDateSelectionSegs(props.dateSelectionSegs, rowCnt);
  12622. var eventDragByRow = this.splitEventDrag(props.eventDrag, rowCnt);
  12623. var eventResizeByRow = this.splitEventResize(props.eventResize, rowCnt);
  12624. var limitViaBalanced = dayMaxEvents === true || dayMaxEventRows === true;
  12625. // if rows can't expand to fill fixed height, can't do balanced-height event limit
  12626. // TODO: best place to normalize these options?
  12627. if (limitViaBalanced && !expandRows) {
  12628. limitViaBalanced = false;
  12629. dayMaxEventRows = null;
  12630. dayMaxEvents = null;
  12631. }
  12632. var classNames = [
  12633. 'fc-daygrid-body',
  12634. limitViaBalanced ? 'fc-daygrid-body-balanced' : 'fc-daygrid-body-unbalanced',
  12635. expandRows ? '' : 'fc-daygrid-body-natural', // will height of one row depend on the others?
  12636. ];
  12637. return (createElement("div", { className: classNames.join(' '), ref: this.handleRootEl, style: {
  12638. // these props are important to give this wrapper correct dimensions for interactions
  12639. // TODO: if we set it here, can we avoid giving to inner tables?
  12640. width: props.clientWidth,
  12641. minWidth: props.tableMinWidth,
  12642. } },
  12643. createElement(NowTimer, { unit: "day" }, function (nowDate, todayRange) { return (createElement(Fragment, null,
  12644. createElement("table", { role: "presentation", className: "fc-scrollgrid-sync-table", style: {
  12645. width: props.clientWidth,
  12646. minWidth: props.tableMinWidth,
  12647. height: expandRows ? props.clientHeight : '',
  12648. } },
  12649. props.colGroupNode,
  12650. createElement("tbody", { role: "presentation" }, props.cells.map(function (cells, row) { return (createElement(TableRow, { ref: _this.rowRefs.createRef(row), key: cells.length
  12651. ? cells[0].date.toISOString() /* best? or put key on cell? or use diff formatter? */
  12652. : row // in case there are no cells (like when resource view is loading)
  12653. , showDayNumbers: rowCnt > 1, showWeekNumbers: props.showWeekNumbers, todayRange: todayRange, dateProfile: dateProfile, cells: cells, renderIntro: props.renderRowIntro, businessHourSegs: businessHourSegsByRow[row], eventSelection: props.eventSelection, bgEventSegs: bgEventSegsByRow[row].filter(isSegAllDay) /* hack */, fgEventSegs: fgEventSegsByRow[row], dateSelectionSegs: dateSelectionSegsByRow[row], eventDrag: eventDragByRow[row], eventResize: eventResizeByRow[row], dayMaxEvents: dayMaxEvents, dayMaxEventRows: dayMaxEventRows, clientWidth: props.clientWidth, clientHeight: props.clientHeight, forPrint: props.forPrint })); }))))); })));
  12654. };
  12655. // Hit System
  12656. // ----------------------------------------------------------------------------------------------------
  12657. Table.prototype.prepareHits = function () {
  12658. this.rowPositions = new PositionCache(this.rootEl, this.rowRefs.collect().map(function (rowObj) { return rowObj.getCellEls()[0]; }), // first cell el in each row. TODO: not optimal
  12659. false, true);
  12660. this.colPositions = new PositionCache(this.rootEl, this.rowRefs.currentMap[0].getCellEls(), // cell els in first row
  12661. true, // horizontal
  12662. false);
  12663. };
  12664. Table.prototype.queryHit = function (positionLeft, positionTop) {
  12665. var _a = this, colPositions = _a.colPositions, rowPositions = _a.rowPositions;
  12666. var col = colPositions.leftToIndex(positionLeft);
  12667. var row = rowPositions.topToIndex(positionTop);
  12668. if (row != null && col != null) {
  12669. var cell = this.props.cells[row][col];
  12670. return {
  12671. dateProfile: this.props.dateProfile,
  12672. dateSpan: __assign({ range: this.getCellRange(row, col), allDay: true }, cell.extraDateSpan),
  12673. dayEl: this.getCellEl(row, col),
  12674. rect: {
  12675. left: colPositions.lefts[col],
  12676. right: colPositions.rights[col],
  12677. top: rowPositions.tops[row],
  12678. bottom: rowPositions.bottoms[row],
  12679. },
  12680. layer: 0,
  12681. };
  12682. }
  12683. return null;
  12684. };
  12685. Table.prototype.getCellEl = function (row, col) {
  12686. return this.rowRefs.currentMap[row].getCellEls()[col]; // TODO: not optimal
  12687. };
  12688. Table.prototype.getCellRange = function (row, col) {
  12689. var start = this.props.cells[row][col].date;
  12690. var end = addDays(start, 1);
  12691. return { start: start, end: end };
  12692. };
  12693. return Table;
  12694. }(DateComponent));
  12695. function isSegAllDay(seg) {
  12696. return seg.eventRange.def.allDay;
  12697. }
  12698. var DayTableSlicer = /** @class */ (function (_super) {
  12699. __extends(DayTableSlicer, _super);
  12700. function DayTableSlicer() {
  12701. var _this = _super !== null && _super.apply(this, arguments) || this;
  12702. _this.forceDayIfListItem = true;
  12703. return _this;
  12704. }
  12705. DayTableSlicer.prototype.sliceRange = function (dateRange, dayTableModel) {
  12706. return dayTableModel.sliceRange(dateRange);
  12707. };
  12708. return DayTableSlicer;
  12709. }(Slicer));
  12710. var DayTable = /** @class */ (function (_super) {
  12711. __extends(DayTable, _super);
  12712. function DayTable() {
  12713. var _this = _super !== null && _super.apply(this, arguments) || this;
  12714. _this.slicer = new DayTableSlicer();
  12715. _this.tableRef = createRef();
  12716. return _this;
  12717. }
  12718. DayTable.prototype.render = function () {
  12719. var _a = this, props = _a.props, context = _a.context;
  12720. return (createElement(Table, __assign({ ref: this.tableRef }, this.slicer.sliceProps(props, props.dateProfile, props.nextDayThreshold, context, props.dayTableModel), { dateProfile: props.dateProfile, cells: props.dayTableModel.cells, colGroupNode: props.colGroupNode, tableMinWidth: props.tableMinWidth, renderRowIntro: props.renderRowIntro, dayMaxEvents: props.dayMaxEvents, dayMaxEventRows: props.dayMaxEventRows, showWeekNumbers: props.showWeekNumbers, expandRows: props.expandRows, headerAlignElRef: props.headerAlignElRef, clientWidth: props.clientWidth, clientHeight: props.clientHeight, forPrint: props.forPrint })));
  12721. };
  12722. return DayTable;
  12723. }(DateComponent));
  12724. var DayTableView = /** @class */ (function (_super) {
  12725. __extends(DayTableView, _super);
  12726. function DayTableView() {
  12727. var _this = _super !== null && _super.apply(this, arguments) || this;
  12728. _this.buildDayTableModel = memoize(buildDayTableModel);
  12729. _this.headerRef = createRef();
  12730. _this.tableRef = createRef();
  12731. return _this;
  12732. }
  12733. DayTableView.prototype.render = function () {
  12734. var _this = this;
  12735. var _a = this.context, options = _a.options, dateProfileGenerator = _a.dateProfileGenerator;
  12736. var props = this.props;
  12737. var dayTableModel = this.buildDayTableModel(props.dateProfile, dateProfileGenerator);
  12738. var headerContent = options.dayHeaders && (createElement(DayHeader, { ref: this.headerRef, dateProfile: props.dateProfile, dates: dayTableModel.headerDates, datesRepDistinctDays: dayTableModel.rowCnt === 1 }));
  12739. var bodyContent = function (contentArg) { return (createElement(DayTable, { ref: _this.tableRef, dateProfile: props.dateProfile, dayTableModel: dayTableModel, businessHours: props.businessHours, dateSelection: props.dateSelection, eventStore: props.eventStore, eventUiBases: props.eventUiBases, eventSelection: props.eventSelection, eventDrag: props.eventDrag, eventResize: props.eventResize, nextDayThreshold: options.nextDayThreshold, colGroupNode: contentArg.tableColGroupNode, tableMinWidth: contentArg.tableMinWidth, dayMaxEvents: options.dayMaxEvents, dayMaxEventRows: options.dayMaxEventRows, showWeekNumbers: options.weekNumbers, expandRows: !props.isHeightAuto, headerAlignElRef: _this.headerElRef, clientWidth: contentArg.clientWidth, clientHeight: contentArg.clientHeight, forPrint: props.forPrint })); };
  12740. return options.dayMinWidth
  12741. ? this.renderHScrollLayout(headerContent, bodyContent, dayTableModel.colCnt, options.dayMinWidth)
  12742. : this.renderSimpleLayout(headerContent, bodyContent);
  12743. };
  12744. return DayTableView;
  12745. }(TableView));
  12746. function buildDayTableModel(dateProfile, dateProfileGenerator) {
  12747. var daySeries = new DaySeriesModel(dateProfile.renderRange, dateProfileGenerator);
  12748. return new DayTableModel(daySeries, /year|month|week/.test(dateProfile.currentRangeUnit));
  12749. }
  12750. var TableDateProfileGenerator = /** @class */ (function (_super) {
  12751. __extends(TableDateProfileGenerator, _super);
  12752. function TableDateProfileGenerator() {
  12753. return _super !== null && _super.apply(this, arguments) || this;
  12754. }
  12755. // Computes the date range that will be rendered.
  12756. TableDateProfileGenerator.prototype.buildRenderRange = function (currentRange, currentRangeUnit, isRangeAllDay) {
  12757. var dateEnv = this.props.dateEnv;
  12758. var renderRange = _super.prototype.buildRenderRange.call(this, currentRange, currentRangeUnit, isRangeAllDay);
  12759. var start = renderRange.start;
  12760. var end = renderRange.end;
  12761. var endOfWeek;
  12762. // year and month views should be aligned with weeks. this is already done for week
  12763. if (/^(year|month)$/.test(currentRangeUnit)) {
  12764. start = dateEnv.startOfWeek(start);
  12765. // make end-of-week if not already
  12766. endOfWeek = dateEnv.startOfWeek(end);
  12767. if (endOfWeek.valueOf() !== end.valueOf()) {
  12768. end = addWeeks(endOfWeek, 1);
  12769. }
  12770. }
  12771. // ensure 6 weeks
  12772. if (this.props.monthMode &&
  12773. this.props.fixedWeekCount) {
  12774. var rowCnt = Math.ceil(// could be partial weeks due to hiddenDays
  12775. diffWeeks(start, end));
  12776. end = addWeeks(end, 6 - rowCnt);
  12777. }
  12778. return { start: start, end: end };
  12779. };
  12780. return TableDateProfileGenerator;
  12781. }(DateProfileGenerator));
  12782. var dayGridPlugin = createPlugin({
  12783. initialView: 'dayGridMonth',
  12784. views: {
  12785. dayGrid: {
  12786. component: DayTableView,
  12787. dateProfileGeneratorClass: TableDateProfileGenerator,
  12788. },
  12789. dayGridDay: {
  12790. type: 'dayGrid',
  12791. duration: { days: 1 },
  12792. },
  12793. dayGridWeek: {
  12794. type: 'dayGrid',
  12795. duration: { weeks: 1 },
  12796. },
  12797. dayGridMonth: {
  12798. type: 'dayGrid',
  12799. duration: { months: 1 },
  12800. monthMode: true,
  12801. fixedWeekCount: true,
  12802. },
  12803. },
  12804. });
  12805. var AllDaySplitter = /** @class */ (function (_super) {
  12806. __extends(AllDaySplitter, _super);
  12807. function AllDaySplitter() {
  12808. return _super !== null && _super.apply(this, arguments) || this;
  12809. }
  12810. AllDaySplitter.prototype.getKeyInfo = function () {
  12811. return {
  12812. allDay: {},
  12813. timed: {},
  12814. };
  12815. };
  12816. AllDaySplitter.prototype.getKeysForDateSpan = function (dateSpan) {
  12817. if (dateSpan.allDay) {
  12818. return ['allDay'];
  12819. }
  12820. return ['timed'];
  12821. };
  12822. AllDaySplitter.prototype.getKeysForEventDef = function (eventDef) {
  12823. if (!eventDef.allDay) {
  12824. return ['timed'];
  12825. }
  12826. if (hasBgRendering(eventDef)) {
  12827. return ['timed', 'allDay'];
  12828. }
  12829. return ['allDay'];
  12830. };
  12831. return AllDaySplitter;
  12832. }(Splitter));
  12833. var DEFAULT_SLAT_LABEL_FORMAT = createFormatter({
  12834. hour: 'numeric',
  12835. minute: '2-digit',
  12836. omitZeroMinute: true,
  12837. meridiem: 'short',
  12838. });
  12839. function TimeColsAxisCell(props) {
  12840. var classNames = [
  12841. 'fc-timegrid-slot',
  12842. 'fc-timegrid-slot-label',
  12843. props.isLabeled ? 'fc-scrollgrid-shrink' : 'fc-timegrid-slot-minor',
  12844. ];
  12845. return (createElement(ViewContextType.Consumer, null, function (context) {
  12846. if (!props.isLabeled) {
  12847. return (createElement("td", { className: classNames.join(' '), "data-time": props.isoTimeStr }));
  12848. }
  12849. var dateEnv = context.dateEnv, options = context.options, viewApi = context.viewApi;
  12850. var labelFormat = // TODO: fully pre-parse
  12851. options.slotLabelFormat == null ? DEFAULT_SLAT_LABEL_FORMAT :
  12852. Array.isArray(options.slotLabelFormat) ? createFormatter(options.slotLabelFormat[0]) :
  12853. createFormatter(options.slotLabelFormat);
  12854. var hookProps = {
  12855. level: 0,
  12856. time: props.time,
  12857. date: dateEnv.toDate(props.date),
  12858. view: viewApi,
  12859. text: dateEnv.format(props.date, labelFormat),
  12860. };
  12861. return (createElement(RenderHook, { hookProps: hookProps, classNames: options.slotLabelClassNames, content: options.slotLabelContent, defaultContent: renderInnerContent$1, didMount: options.slotLabelDidMount, willUnmount: options.slotLabelWillUnmount }, function (rootElRef, customClassNames, innerElRef, innerContent) { return (createElement("td", { ref: rootElRef, className: classNames.concat(customClassNames).join(' '), "data-time": props.isoTimeStr },
  12862. createElement("div", { className: "fc-timegrid-slot-label-frame fc-scrollgrid-shrink-frame" },
  12863. createElement("div", { className: "fc-timegrid-slot-label-cushion fc-scrollgrid-shrink-cushion", ref: innerElRef }, innerContent)))); }));
  12864. }));
  12865. }
  12866. function renderInnerContent$1(props) {
  12867. return props.text;
  12868. }
  12869. var TimeBodyAxis = /** @class */ (function (_super) {
  12870. __extends(TimeBodyAxis, _super);
  12871. function TimeBodyAxis() {
  12872. return _super !== null && _super.apply(this, arguments) || this;
  12873. }
  12874. TimeBodyAxis.prototype.render = function () {
  12875. return this.props.slatMetas.map(function (slatMeta) { return (createElement("tr", { key: slatMeta.key },
  12876. createElement(TimeColsAxisCell, __assign({}, slatMeta)))); });
  12877. };
  12878. return TimeBodyAxis;
  12879. }(BaseComponent));
  12880. var DEFAULT_WEEK_NUM_FORMAT = createFormatter({ week: 'short' });
  12881. var AUTO_ALL_DAY_MAX_EVENT_ROWS = 5;
  12882. var TimeColsView = /** @class */ (function (_super) {
  12883. __extends(TimeColsView, _super);
  12884. function TimeColsView() {
  12885. var _this = _super !== null && _super.apply(this, arguments) || this;
  12886. _this.allDaySplitter = new AllDaySplitter(); // for use by subclasses
  12887. _this.headerElRef = createRef();
  12888. _this.rootElRef = createRef();
  12889. _this.scrollerElRef = createRef();
  12890. _this.state = {
  12891. slatCoords: null,
  12892. };
  12893. _this.handleScrollTopRequest = function (scrollTop) {
  12894. var scrollerEl = _this.scrollerElRef.current;
  12895. if (scrollerEl) { // TODO: not sure how this could ever be null. weirdness with the reducer
  12896. scrollerEl.scrollTop = scrollTop;
  12897. }
  12898. };
  12899. /* Header Render Methods
  12900. ------------------------------------------------------------------------------------------------------------------*/
  12901. _this.renderHeadAxis = function (rowKey, frameHeight) {
  12902. if (frameHeight === void 0) { frameHeight = ''; }
  12903. var options = _this.context.options;
  12904. var dateProfile = _this.props.dateProfile;
  12905. var range = dateProfile.renderRange;
  12906. var dayCnt = diffDays(range.start, range.end);
  12907. var navLinkAttrs = (dayCnt === 1) // only do in day views (to avoid doing in week views that dont need it)
  12908. ? buildNavLinkAttrs(_this.context, range.start, 'week')
  12909. : {};
  12910. if (options.weekNumbers && rowKey === 'day') {
  12911. return (createElement(WeekNumberRoot, { date: range.start, defaultFormat: DEFAULT_WEEK_NUM_FORMAT }, function (rootElRef, classNames, innerElRef, innerContent) { return (createElement("th", { ref: rootElRef, "aria-hidden": true, className: [
  12912. 'fc-timegrid-axis',
  12913. 'fc-scrollgrid-shrink',
  12914. ].concat(classNames).join(' ') },
  12915. createElement("div", { className: "fc-timegrid-axis-frame fc-scrollgrid-shrink-frame fc-timegrid-axis-frame-liquid", style: { height: frameHeight } },
  12916. createElement("a", __assign({ ref: innerElRef, className: "fc-timegrid-axis-cushion fc-scrollgrid-shrink-cushion fc-scrollgrid-sync-inner" }, navLinkAttrs), innerContent)))); }));
  12917. }
  12918. return (createElement("th", { "aria-hidden": true, className: "fc-timegrid-axis" },
  12919. createElement("div", { className: "fc-timegrid-axis-frame", style: { height: frameHeight } })));
  12920. };
  12921. /* Table Component Render Methods
  12922. ------------------------------------------------------------------------------------------------------------------*/
  12923. // only a one-way height sync. we don't send the axis inner-content height to the DayGrid,
  12924. // but DayGrid still needs to have classNames on inner elements in order to measure.
  12925. _this.renderTableRowAxis = function (rowHeight) {
  12926. var _a = _this.context, options = _a.options, viewApi = _a.viewApi;
  12927. var hookProps = {
  12928. text: options.allDayText,
  12929. view: viewApi,
  12930. };
  12931. return (
  12932. // TODO: make reusable hook. used in list view too
  12933. createElement(RenderHook, { hookProps: hookProps, classNames: options.allDayClassNames, content: options.allDayContent, defaultContent: renderAllDayInner$1, didMount: options.allDayDidMount, willUnmount: options.allDayWillUnmount }, function (rootElRef, classNames, innerElRef, innerContent) { return (createElement("td", { ref: rootElRef, "aria-hidden": true, className: [
  12934. 'fc-timegrid-axis',
  12935. 'fc-scrollgrid-shrink',
  12936. ].concat(classNames).join(' ') },
  12937. createElement("div", { className: 'fc-timegrid-axis-frame fc-scrollgrid-shrink-frame' + (rowHeight == null ? ' fc-timegrid-axis-frame-liquid' : ''), style: { height: rowHeight } },
  12938. createElement("span", { className: "fc-timegrid-axis-cushion fc-scrollgrid-shrink-cushion fc-scrollgrid-sync-inner", ref: innerElRef }, innerContent)))); }));
  12939. };
  12940. _this.handleSlatCoords = function (slatCoords) {
  12941. _this.setState({ slatCoords: slatCoords });
  12942. };
  12943. return _this;
  12944. }
  12945. // rendering
  12946. // ----------------------------------------------------------------------------------------------------
  12947. TimeColsView.prototype.renderSimpleLayout = function (headerRowContent, allDayContent, timeContent) {
  12948. var _a = this, context = _a.context, props = _a.props;
  12949. var sections = [];
  12950. var stickyHeaderDates = getStickyHeaderDates(context.options);
  12951. if (headerRowContent) {
  12952. sections.push({
  12953. type: 'header',
  12954. key: 'header',
  12955. isSticky: stickyHeaderDates,
  12956. chunk: {
  12957. elRef: this.headerElRef,
  12958. tableClassName: 'fc-col-header',
  12959. rowContent: headerRowContent,
  12960. },
  12961. });
  12962. }
  12963. if (allDayContent) {
  12964. sections.push({
  12965. type: 'body',
  12966. key: 'all-day',
  12967. chunk: { content: allDayContent },
  12968. });
  12969. sections.push({
  12970. type: 'body',
  12971. key: 'all-day-divider',
  12972. outerContent: ( // TODO: rename to cellContent so don't need to define <tr>?
  12973. createElement("tr", { role: "presentation", className: "fc-scrollgrid-section" },
  12974. createElement("td", { className: 'fc-timegrid-divider ' + context.theme.getClass('tableCellShaded') }))),
  12975. });
  12976. }
  12977. sections.push({
  12978. type: 'body',
  12979. key: 'body',
  12980. liquid: true,
  12981. expandRows: Boolean(context.options.expandRows),
  12982. chunk: {
  12983. scrollerElRef: this.scrollerElRef,
  12984. content: timeContent,
  12985. },
  12986. });
  12987. return (createElement(ViewRoot, { viewSpec: context.viewSpec, elRef: this.rootElRef }, function (rootElRef, classNames) { return (createElement("div", { className: ['fc-timegrid'].concat(classNames).join(' '), ref: rootElRef },
  12988. createElement(SimpleScrollGrid, { liquid: !props.isHeightAuto && !props.forPrint, collapsibleWidth: props.forPrint, cols: [{ width: 'shrink' }], sections: sections }))); }));
  12989. };
  12990. TimeColsView.prototype.renderHScrollLayout = function (headerRowContent, allDayContent, timeContent, colCnt, dayMinWidth, slatMetas, slatCoords) {
  12991. var _this = this;
  12992. var ScrollGrid = this.context.pluginHooks.scrollGridImpl;
  12993. if (!ScrollGrid) {
  12994. throw new Error('No ScrollGrid implementation');
  12995. }
  12996. var _a = this, context = _a.context, props = _a.props;
  12997. var stickyHeaderDates = !props.forPrint && getStickyHeaderDates(context.options);
  12998. var stickyFooterScrollbar = !props.forPrint && getStickyFooterScrollbar(context.options);
  12999. var sections = [];
  13000. if (headerRowContent) {
  13001. sections.push({
  13002. type: 'header',
  13003. key: 'header',
  13004. isSticky: stickyHeaderDates,
  13005. syncRowHeights: true,
  13006. chunks: [
  13007. {
  13008. key: 'axis',
  13009. rowContent: function (arg) { return (createElement("tr", { role: "presentation" }, _this.renderHeadAxis('day', arg.rowSyncHeights[0]))); },
  13010. },
  13011. {
  13012. key: 'cols',
  13013. elRef: this.headerElRef,
  13014. tableClassName: 'fc-col-header',
  13015. rowContent: headerRowContent,
  13016. },
  13017. ],
  13018. });
  13019. }
  13020. if (allDayContent) {
  13021. sections.push({
  13022. type: 'body',
  13023. key: 'all-day',
  13024. syncRowHeights: true,
  13025. chunks: [
  13026. {
  13027. key: 'axis',
  13028. rowContent: function (contentArg) { return (createElement("tr", { role: "presentation" }, _this.renderTableRowAxis(contentArg.rowSyncHeights[0]))); },
  13029. },
  13030. {
  13031. key: 'cols',
  13032. content: allDayContent,
  13033. },
  13034. ],
  13035. });
  13036. sections.push({
  13037. key: 'all-day-divider',
  13038. type: 'body',
  13039. outerContent: ( // TODO: rename to cellContent so don't need to define <tr>?
  13040. createElement("tr", { role: "presentation", className: "fc-scrollgrid-section" },
  13041. createElement("td", { colSpan: 2, className: 'fc-timegrid-divider ' + context.theme.getClass('tableCellShaded') }))),
  13042. });
  13043. }
  13044. var isNowIndicator = context.options.nowIndicator;
  13045. sections.push({
  13046. type: 'body',
  13047. key: 'body',
  13048. liquid: true,
  13049. expandRows: Boolean(context.options.expandRows),
  13050. chunks: [
  13051. {
  13052. key: 'axis',
  13053. content: function (arg) { return (
  13054. // TODO: make this now-indicator arrow more DRY with TimeColsContent
  13055. createElement("div", { className: "fc-timegrid-axis-chunk" },
  13056. createElement("table", { "aria-hidden": true, style: { height: arg.expandRows ? arg.clientHeight : '' } },
  13057. arg.tableColGroupNode,
  13058. createElement("tbody", null,
  13059. createElement(TimeBodyAxis, { slatMetas: slatMetas }))),
  13060. createElement("div", { className: "fc-timegrid-now-indicator-container" },
  13061. createElement(NowTimer, { unit: isNowIndicator ? 'minute' : 'day' /* hacky */ }, function (nowDate) {
  13062. var nowIndicatorTop = isNowIndicator &&
  13063. slatCoords &&
  13064. slatCoords.safeComputeTop(nowDate); // might return void
  13065. if (typeof nowIndicatorTop === 'number') {
  13066. return (createElement(NowIndicatorRoot, { isAxis: true, date: nowDate }, function (rootElRef, classNames, innerElRef, innerContent) { return (createElement("div", { ref: rootElRef, className: ['fc-timegrid-now-indicator-arrow'].concat(classNames).join(' '), style: { top: nowIndicatorTop } }, innerContent)); }));
  13067. }
  13068. return null;
  13069. })))); },
  13070. },
  13071. {
  13072. key: 'cols',
  13073. scrollerElRef: this.scrollerElRef,
  13074. content: timeContent,
  13075. },
  13076. ],
  13077. });
  13078. if (stickyFooterScrollbar) {
  13079. sections.push({
  13080. key: 'footer',
  13081. type: 'footer',
  13082. isSticky: true,
  13083. chunks: [
  13084. {
  13085. key: 'axis',
  13086. content: renderScrollShim,
  13087. },
  13088. {
  13089. key: 'cols',
  13090. content: renderScrollShim,
  13091. },
  13092. ],
  13093. });
  13094. }
  13095. return (createElement(ViewRoot, { viewSpec: context.viewSpec, elRef: this.rootElRef }, function (rootElRef, classNames) { return (createElement("div", { className: ['fc-timegrid'].concat(classNames).join(' '), ref: rootElRef },
  13096. createElement(ScrollGrid, { liquid: !props.isHeightAuto && !props.forPrint, collapsibleWidth: false, colGroups: [
  13097. { width: 'shrink', cols: [{ width: 'shrink' }] },
  13098. { cols: [{ span: colCnt, minWidth: dayMinWidth }] },
  13099. ], sections: sections }))); }));
  13100. };
  13101. /* Dimensions
  13102. ------------------------------------------------------------------------------------------------------------------*/
  13103. TimeColsView.prototype.getAllDayMaxEventProps = function () {
  13104. var _a = this.context.options, dayMaxEvents = _a.dayMaxEvents, dayMaxEventRows = _a.dayMaxEventRows;
  13105. if (dayMaxEvents === true || dayMaxEventRows === true) { // is auto?
  13106. dayMaxEvents = undefined;
  13107. dayMaxEventRows = AUTO_ALL_DAY_MAX_EVENT_ROWS; // make sure "auto" goes to a real number
  13108. }
  13109. return { dayMaxEvents: dayMaxEvents, dayMaxEventRows: dayMaxEventRows };
  13110. };
  13111. return TimeColsView;
  13112. }(DateComponent));
  13113. function renderAllDayInner$1(hookProps) {
  13114. return hookProps.text;
  13115. }
  13116. var TimeColsSlatsCoords = /** @class */ (function () {
  13117. function TimeColsSlatsCoords(positions, dateProfile, slotDuration) {
  13118. this.positions = positions;
  13119. this.dateProfile = dateProfile;
  13120. this.slotDuration = slotDuration;
  13121. }
  13122. TimeColsSlatsCoords.prototype.safeComputeTop = function (date) {
  13123. var dateProfile = this.dateProfile;
  13124. if (rangeContainsMarker(dateProfile.currentRange, date)) {
  13125. var startOfDayDate = startOfDay(date);
  13126. var timeMs = date.valueOf() - startOfDayDate.valueOf();
  13127. if (timeMs >= asRoughMs(dateProfile.slotMinTime) &&
  13128. timeMs < asRoughMs(dateProfile.slotMaxTime)) {
  13129. return this.computeTimeTop(createDuration(timeMs));
  13130. }
  13131. }
  13132. return null;
  13133. };
  13134. // Computes the top coordinate, relative to the bounds of the grid, of the given date.
  13135. // A `startOfDayDate` must be given for avoiding ambiguity over how to treat midnight.
  13136. TimeColsSlatsCoords.prototype.computeDateTop = function (when, startOfDayDate) {
  13137. if (!startOfDayDate) {
  13138. startOfDayDate = startOfDay(when);
  13139. }
  13140. return this.computeTimeTop(createDuration(when.valueOf() - startOfDayDate.valueOf()));
  13141. };
  13142. // Computes the top coordinate, relative to the bounds of the grid, of the given time (a Duration).
  13143. // This is a makeshify way to compute the time-top. Assumes all slatMetas dates are uniform.
  13144. // Eventually allow computation with arbirary slat dates.
  13145. TimeColsSlatsCoords.prototype.computeTimeTop = function (duration) {
  13146. var _a = this, positions = _a.positions, dateProfile = _a.dateProfile;
  13147. var len = positions.els.length;
  13148. // floating-point value of # of slots covered
  13149. var slatCoverage = (duration.milliseconds - asRoughMs(dateProfile.slotMinTime)) / asRoughMs(this.slotDuration);
  13150. var slatIndex;
  13151. var slatRemainder;
  13152. // compute a floating-point number for how many slats should be progressed through.
  13153. // from 0 to number of slats (inclusive)
  13154. // constrained because slotMinTime/slotMaxTime might be customized.
  13155. slatCoverage = Math.max(0, slatCoverage);
  13156. slatCoverage = Math.min(len, slatCoverage);
  13157. // an integer index of the furthest whole slat
  13158. // from 0 to number slats (*exclusive*, so len-1)
  13159. slatIndex = Math.floor(slatCoverage);
  13160. slatIndex = Math.min(slatIndex, len - 1);
  13161. // how much further through the slatIndex slat (from 0.0-1.0) must be covered in addition.
  13162. // could be 1.0 if slatCoverage is covering *all* the slots
  13163. slatRemainder = slatCoverage - slatIndex;
  13164. return positions.tops[slatIndex] +
  13165. positions.getHeight(slatIndex) * slatRemainder;
  13166. };
  13167. return TimeColsSlatsCoords;
  13168. }());
  13169. var TimeColsSlatsBody = /** @class */ (function (_super) {
  13170. __extends(TimeColsSlatsBody, _super);
  13171. function TimeColsSlatsBody() {
  13172. return _super !== null && _super.apply(this, arguments) || this;
  13173. }
  13174. TimeColsSlatsBody.prototype.render = function () {
  13175. var _a = this, props = _a.props, context = _a.context;
  13176. var options = context.options;
  13177. var slatElRefs = props.slatElRefs;
  13178. return (createElement("tbody", null, props.slatMetas.map(function (slatMeta, i) {
  13179. var hookProps = {
  13180. time: slatMeta.time,
  13181. date: context.dateEnv.toDate(slatMeta.date),
  13182. view: context.viewApi,
  13183. };
  13184. var classNames = [
  13185. 'fc-timegrid-slot',
  13186. 'fc-timegrid-slot-lane',
  13187. slatMeta.isLabeled ? '' : 'fc-timegrid-slot-minor',
  13188. ];
  13189. return (createElement("tr", { key: slatMeta.key, ref: slatElRefs.createRef(slatMeta.key) },
  13190. props.axis && (createElement(TimeColsAxisCell, __assign({}, slatMeta))),
  13191. createElement(RenderHook, { hookProps: hookProps, classNames: options.slotLaneClassNames, content: options.slotLaneContent, didMount: options.slotLaneDidMount, willUnmount: options.slotLaneWillUnmount }, function (rootElRef, customClassNames, innerElRef, innerContent) { return (createElement("td", { ref: rootElRef, className: classNames.concat(customClassNames).join(' '), "data-time": slatMeta.isoTimeStr }, innerContent)); })));
  13192. })));
  13193. };
  13194. return TimeColsSlatsBody;
  13195. }(BaseComponent));
  13196. /*
  13197. for the horizontal "slats" that run width-wise. Has a time axis on a side. Depends on RTL.
  13198. */
  13199. var TimeColsSlats = /** @class */ (function (_super) {
  13200. __extends(TimeColsSlats, _super);
  13201. function TimeColsSlats() {
  13202. var _this = _super !== null && _super.apply(this, arguments) || this;
  13203. _this.rootElRef = createRef();
  13204. _this.slatElRefs = new RefMap();
  13205. return _this;
  13206. }
  13207. TimeColsSlats.prototype.render = function () {
  13208. var _a = this, props = _a.props, context = _a.context;
  13209. return (createElement("div", { ref: this.rootElRef, className: "fc-timegrid-slots" },
  13210. createElement("table", { "aria-hidden": true, className: context.theme.getClass('table'), style: {
  13211. minWidth: props.tableMinWidth,
  13212. width: props.clientWidth,
  13213. height: props.minHeight,
  13214. } },
  13215. props.tableColGroupNode /* relies on there only being a single <col> for the axis */,
  13216. createElement(TimeColsSlatsBody, { slatElRefs: this.slatElRefs, axis: props.axis, slatMetas: props.slatMetas }))));
  13217. };
  13218. TimeColsSlats.prototype.componentDidMount = function () {
  13219. this.updateSizing();
  13220. };
  13221. TimeColsSlats.prototype.componentDidUpdate = function () {
  13222. this.updateSizing();
  13223. };
  13224. TimeColsSlats.prototype.componentWillUnmount = function () {
  13225. if (this.props.onCoords) {
  13226. this.props.onCoords(null);
  13227. }
  13228. };
  13229. TimeColsSlats.prototype.updateSizing = function () {
  13230. var _a = this, context = _a.context, props = _a.props;
  13231. if (props.onCoords &&
  13232. props.clientWidth !== null // means sizing has stabilized
  13233. ) {
  13234. var rootEl = this.rootElRef.current;
  13235. if (rootEl.offsetHeight) { // not hidden by css
  13236. props.onCoords(new TimeColsSlatsCoords(new PositionCache(this.rootElRef.current, collectSlatEls(this.slatElRefs.currentMap, props.slatMetas), false, true), this.props.dateProfile, context.options.slotDuration));
  13237. }
  13238. }
  13239. };
  13240. return TimeColsSlats;
  13241. }(BaseComponent));
  13242. function collectSlatEls(elMap, slatMetas) {
  13243. return slatMetas.map(function (slatMeta) { return elMap[slatMeta.key]; });
  13244. }
  13245. function splitSegsByCol(segs, colCnt) {
  13246. var segsByCol = [];
  13247. var i;
  13248. for (i = 0; i < colCnt; i += 1) {
  13249. segsByCol.push([]);
  13250. }
  13251. if (segs) {
  13252. for (i = 0; i < segs.length; i += 1) {
  13253. segsByCol[segs[i].col].push(segs[i]);
  13254. }
  13255. }
  13256. return segsByCol;
  13257. }
  13258. function splitInteractionByCol(ui, colCnt) {
  13259. var byRow = [];
  13260. if (!ui) {
  13261. for (var i = 0; i < colCnt; i += 1) {
  13262. byRow[i] = null;
  13263. }
  13264. }
  13265. else {
  13266. for (var i = 0; i < colCnt; i += 1) {
  13267. byRow[i] = {
  13268. affectedInstances: ui.affectedInstances,
  13269. isEvent: ui.isEvent,
  13270. segs: [],
  13271. };
  13272. }
  13273. for (var _i = 0, _a = ui.segs; _i < _a.length; _i++) {
  13274. var seg = _a[_i];
  13275. byRow[seg.col].segs.push(seg);
  13276. }
  13277. }
  13278. return byRow;
  13279. }
  13280. var TimeColMoreLink = /** @class */ (function (_super) {
  13281. __extends(TimeColMoreLink, _super);
  13282. function TimeColMoreLink() {
  13283. var _this = _super !== null && _super.apply(this, arguments) || this;
  13284. _this.rootElRef = createRef();
  13285. return _this;
  13286. }
  13287. TimeColMoreLink.prototype.render = function () {
  13288. var _this = this;
  13289. var props = this.props;
  13290. return (createElement(MoreLinkRoot, { allDayDate: null, moreCnt: props.hiddenSegs.length, allSegs: props.hiddenSegs, hiddenSegs: props.hiddenSegs, alignmentElRef: this.rootElRef, defaultContent: renderMoreLinkInner, extraDateSpan: props.extraDateSpan, dateProfile: props.dateProfile, todayRange: props.todayRange, popoverContent: function () { return renderPlainFgSegs(props.hiddenSegs, props); } }, function (rootElRef, classNames, innerElRef, innerContent, handleClick, title, isExpanded, popoverId) { return (createElement("a", { ref: function (el) {
  13291. setRef(rootElRef, el);
  13292. setRef(_this.rootElRef, el);
  13293. }, className: ['fc-timegrid-more-link'].concat(classNames).join(' '), style: { top: props.top, bottom: props.bottom }, onClick: handleClick, title: title, "aria-expanded": isExpanded, "aria-controls": popoverId },
  13294. createElement("div", { ref: innerElRef, className: "fc-timegrid-more-link-inner fc-sticky" }, innerContent))); }));
  13295. };
  13296. return TimeColMoreLink;
  13297. }(BaseComponent));
  13298. function renderMoreLinkInner(props) {
  13299. return props.shortText;
  13300. }
  13301. // segInputs assumed sorted
  13302. function buildPositioning(segInputs, strictOrder, maxStackCnt) {
  13303. var hierarchy = new SegHierarchy();
  13304. if (strictOrder != null) {
  13305. hierarchy.strictOrder = strictOrder;
  13306. }
  13307. if (maxStackCnt != null) {
  13308. hierarchy.maxStackCnt = maxStackCnt;
  13309. }
  13310. var hiddenEntries = hierarchy.addSegs(segInputs);
  13311. var hiddenGroups = groupIntersectingEntries(hiddenEntries);
  13312. var web = buildWeb(hierarchy);
  13313. web = stretchWeb(web, 1); // all levelCoords/thickness will have 0.0-1.0
  13314. var segRects = webToRects(web);
  13315. return { segRects: segRects, hiddenGroups: hiddenGroups };
  13316. }
  13317. function buildWeb(hierarchy) {
  13318. var entriesByLevel = hierarchy.entriesByLevel;
  13319. var buildNode = cacheable(function (level, lateral) { return level + ':' + lateral; }, function (level, lateral) {
  13320. var siblingRange = findNextLevelSegs(hierarchy, level, lateral);
  13321. var nextLevelRes = buildNodes(siblingRange, buildNode);
  13322. var entry = entriesByLevel[level][lateral];
  13323. return [
  13324. __assign(__assign({}, entry), { nextLevelNodes: nextLevelRes[0] }),
  13325. entry.thickness + nextLevelRes[1], // the pressure builds
  13326. ];
  13327. });
  13328. return buildNodes(entriesByLevel.length
  13329. ? { level: 0, lateralStart: 0, lateralEnd: entriesByLevel[0].length }
  13330. : null, buildNode)[0];
  13331. }
  13332. function buildNodes(siblingRange, buildNode) {
  13333. if (!siblingRange) {
  13334. return [[], 0];
  13335. }
  13336. var level = siblingRange.level, lateralStart = siblingRange.lateralStart, lateralEnd = siblingRange.lateralEnd;
  13337. var lateral = lateralStart;
  13338. var pairs = [];
  13339. while (lateral < lateralEnd) {
  13340. pairs.push(buildNode(level, lateral));
  13341. lateral += 1;
  13342. }
  13343. pairs.sort(cmpDescPressures);
  13344. return [
  13345. pairs.map(extractNode),
  13346. pairs[0][1], // first item's pressure
  13347. ];
  13348. }
  13349. function cmpDescPressures(a, b) {
  13350. return b[1] - a[1];
  13351. }
  13352. function extractNode(a) {
  13353. return a[0];
  13354. }
  13355. function findNextLevelSegs(hierarchy, subjectLevel, subjectLateral) {
  13356. var levelCoords = hierarchy.levelCoords, entriesByLevel = hierarchy.entriesByLevel;
  13357. var subjectEntry = entriesByLevel[subjectLevel][subjectLateral];
  13358. var afterSubject = levelCoords[subjectLevel] + subjectEntry.thickness;
  13359. var levelCnt = levelCoords.length;
  13360. var level = subjectLevel;
  13361. // skip past levels that are too high up
  13362. for (; level < levelCnt && levelCoords[level] < afterSubject; level += 1)
  13363. ; // do nothing
  13364. for (; level < levelCnt; level += 1) {
  13365. var entries = entriesByLevel[level];
  13366. var entry = void 0;
  13367. var searchIndex = binarySearch(entries, subjectEntry.span.start, getEntrySpanEnd);
  13368. var lateralStart = searchIndex[0] + searchIndex[1]; // if exact match (which doesn't collide), go to next one
  13369. var lateralEnd = lateralStart;
  13370. while ( // loop through entries that horizontally intersect
  13371. (entry = entries[lateralEnd]) && // but not past the whole seg list
  13372. entry.span.start < subjectEntry.span.end) {
  13373. lateralEnd += 1;
  13374. }
  13375. if (lateralStart < lateralEnd) {
  13376. return { level: level, lateralStart: lateralStart, lateralEnd: lateralEnd };
  13377. }
  13378. }
  13379. return null;
  13380. }
  13381. function stretchWeb(topLevelNodes, totalThickness) {
  13382. var stretchNode = cacheable(function (node, startCoord, prevThickness) { return buildEntryKey(node); }, function (node, startCoord, prevThickness) {
  13383. var nextLevelNodes = node.nextLevelNodes, thickness = node.thickness;
  13384. var allThickness = thickness + prevThickness;
  13385. var thicknessFraction = thickness / allThickness;
  13386. var endCoord;
  13387. var newChildren = [];
  13388. if (!nextLevelNodes.length) {
  13389. endCoord = totalThickness;
  13390. }
  13391. else {
  13392. for (var _i = 0, nextLevelNodes_1 = nextLevelNodes; _i < nextLevelNodes_1.length; _i++) {
  13393. var childNode = nextLevelNodes_1[_i];
  13394. if (endCoord === undefined) {
  13395. var res = stretchNode(childNode, startCoord, allThickness);
  13396. endCoord = res[0];
  13397. newChildren.push(res[1]);
  13398. }
  13399. else {
  13400. var res = stretchNode(childNode, endCoord, 0);
  13401. newChildren.push(res[1]);
  13402. }
  13403. }
  13404. }
  13405. var newThickness = (endCoord - startCoord) * thicknessFraction;
  13406. return [endCoord - newThickness, __assign(__assign({}, node), { thickness: newThickness, nextLevelNodes: newChildren })];
  13407. });
  13408. return topLevelNodes.map(function (node) { return stretchNode(node, 0, 0)[1]; });
  13409. }
  13410. // not sorted in any particular order
  13411. function webToRects(topLevelNodes) {
  13412. var rects = [];
  13413. var processNode = cacheable(function (node, levelCoord, stackDepth) { return buildEntryKey(node); }, function (node, levelCoord, stackDepth) {
  13414. var rect = __assign(__assign({}, node), { levelCoord: levelCoord,
  13415. stackDepth: stackDepth, stackForward: 0 });
  13416. rects.push(rect);
  13417. return (rect.stackForward = processNodes(node.nextLevelNodes, levelCoord + node.thickness, stackDepth + 1) + 1);
  13418. });
  13419. function processNodes(nodes, levelCoord, stackDepth) {
  13420. var stackForward = 0;
  13421. for (var _i = 0, nodes_1 = nodes; _i < nodes_1.length; _i++) {
  13422. var node = nodes_1[_i];
  13423. stackForward = Math.max(processNode(node, levelCoord, stackDepth), stackForward);
  13424. }
  13425. return stackForward;
  13426. }
  13427. processNodes(topLevelNodes, 0, 0);
  13428. return rects; // TODO: sort rects by levelCoord to be consistent with toRects?
  13429. }
  13430. // TODO: move to general util
  13431. function cacheable(keyFunc, workFunc) {
  13432. var cache = {};
  13433. return function () {
  13434. var args = [];
  13435. for (var _i = 0; _i < arguments.length; _i++) {
  13436. args[_i] = arguments[_i];
  13437. }
  13438. var key = keyFunc.apply(void 0, args);
  13439. return (key in cache)
  13440. ? cache[key]
  13441. : (cache[key] = workFunc.apply(void 0, args));
  13442. };
  13443. }
  13444. function computeSegVCoords(segs, colDate, slatCoords, eventMinHeight) {
  13445. if (slatCoords === void 0) { slatCoords = null; }
  13446. if (eventMinHeight === void 0) { eventMinHeight = 0; }
  13447. var vcoords = [];
  13448. if (slatCoords) {
  13449. for (var i = 0; i < segs.length; i += 1) {
  13450. var seg = segs[i];
  13451. var spanStart = slatCoords.computeDateTop(seg.start, colDate);
  13452. var spanEnd = Math.max(spanStart + (eventMinHeight || 0), // :(
  13453. slatCoords.computeDateTop(seg.end, colDate));
  13454. vcoords.push({
  13455. start: Math.round(spanStart),
  13456. end: Math.round(spanEnd), //
  13457. });
  13458. }
  13459. }
  13460. return vcoords;
  13461. }
  13462. function computeFgSegPlacements(segs, segVCoords, // might not have for every seg
  13463. eventOrderStrict, eventMaxStack) {
  13464. var segInputs = [];
  13465. var dumbSegs = []; // segs without coords
  13466. for (var i = 0; i < segs.length; i += 1) {
  13467. var vcoords = segVCoords[i];
  13468. if (vcoords) {
  13469. segInputs.push({
  13470. index: i,
  13471. thickness: 1,
  13472. span: vcoords,
  13473. });
  13474. }
  13475. else {
  13476. dumbSegs.push(segs[i]);
  13477. }
  13478. }
  13479. var _a = buildPositioning(segInputs, eventOrderStrict, eventMaxStack), segRects = _a.segRects, hiddenGroups = _a.hiddenGroups;
  13480. var segPlacements = [];
  13481. for (var _i = 0, segRects_1 = segRects; _i < segRects_1.length; _i++) {
  13482. var segRect = segRects_1[_i];
  13483. segPlacements.push({
  13484. seg: segs[segRect.index],
  13485. rect: segRect,
  13486. });
  13487. }
  13488. for (var _b = 0, dumbSegs_1 = dumbSegs; _b < dumbSegs_1.length; _b++) {
  13489. var dumbSeg = dumbSegs_1[_b];
  13490. segPlacements.push({ seg: dumbSeg, rect: null });
  13491. }
  13492. return { segPlacements: segPlacements, hiddenGroups: hiddenGroups };
  13493. }
  13494. var DEFAULT_TIME_FORMAT$1 = createFormatter({
  13495. hour: 'numeric',
  13496. minute: '2-digit',
  13497. meridiem: false,
  13498. });
  13499. var TimeColEvent = /** @class */ (function (_super) {
  13500. __extends(TimeColEvent, _super);
  13501. function TimeColEvent() {
  13502. return _super !== null && _super.apply(this, arguments) || this;
  13503. }
  13504. TimeColEvent.prototype.render = function () {
  13505. var classNames = [
  13506. 'fc-timegrid-event',
  13507. 'fc-v-event',
  13508. ];
  13509. if (this.props.isShort) {
  13510. classNames.push('fc-timegrid-event-short');
  13511. }
  13512. return (createElement(StandardEvent, __assign({}, this.props, { defaultTimeFormat: DEFAULT_TIME_FORMAT$1, extraClassNames: classNames })));
  13513. };
  13514. return TimeColEvent;
  13515. }(BaseComponent));
  13516. var TimeColMisc = /** @class */ (function (_super) {
  13517. __extends(TimeColMisc, _super);
  13518. function TimeColMisc() {
  13519. return _super !== null && _super.apply(this, arguments) || this;
  13520. }
  13521. TimeColMisc.prototype.render = function () {
  13522. var props = this.props;
  13523. return (createElement(DayCellContent, { date: props.date, dateProfile: props.dateProfile, todayRange: props.todayRange, extraHookProps: props.extraHookProps }, function (innerElRef, innerContent) { return (innerContent &&
  13524. createElement("div", { className: "fc-timegrid-col-misc", ref: innerElRef }, innerContent)); }));
  13525. };
  13526. return TimeColMisc;
  13527. }(BaseComponent));
  13528. var TimeCol = /** @class */ (function (_super) {
  13529. __extends(TimeCol, _super);
  13530. function TimeCol() {
  13531. var _this = _super !== null && _super.apply(this, arguments) || this;
  13532. _this.sortEventSegs = memoize(sortEventSegs);
  13533. return _this;
  13534. }
  13535. // TODO: memoize event-placement?
  13536. TimeCol.prototype.render = function () {
  13537. var _this = this;
  13538. var _a = this, props = _a.props, context = _a.context;
  13539. var isSelectMirror = context.options.selectMirror;
  13540. var mirrorSegs = (props.eventDrag && props.eventDrag.segs) ||
  13541. (props.eventResize && props.eventResize.segs) ||
  13542. (isSelectMirror && props.dateSelectionSegs) ||
  13543. [];
  13544. var interactionAffectedInstances = // TODO: messy way to compute this
  13545. (props.eventDrag && props.eventDrag.affectedInstances) ||
  13546. (props.eventResize && props.eventResize.affectedInstances) ||
  13547. {};
  13548. var sortedFgSegs = this.sortEventSegs(props.fgEventSegs, context.options.eventOrder);
  13549. return (createElement(DayCellRoot, { elRef: props.elRef, date: props.date, dateProfile: props.dateProfile, todayRange: props.todayRange, extraHookProps: props.extraHookProps }, function (rootElRef, classNames, dataAttrs) { return (createElement("td", __assign({ ref: rootElRef, role: "gridcell", className: ['fc-timegrid-col'].concat(classNames, props.extraClassNames || []).join(' ') }, dataAttrs, props.extraDataAttrs),
  13550. createElement("div", { className: "fc-timegrid-col-frame" },
  13551. createElement("div", { className: "fc-timegrid-col-bg" },
  13552. _this.renderFillSegs(props.businessHourSegs, 'non-business'),
  13553. _this.renderFillSegs(props.bgEventSegs, 'bg-event'),
  13554. _this.renderFillSegs(props.dateSelectionSegs, 'highlight')),
  13555. createElement("div", { className: "fc-timegrid-col-events" }, _this.renderFgSegs(sortedFgSegs, interactionAffectedInstances, false, false, false)),
  13556. createElement("div", { className: "fc-timegrid-col-events" }, _this.renderFgSegs(mirrorSegs, {}, Boolean(props.eventDrag), Boolean(props.eventResize), Boolean(isSelectMirror))),
  13557. createElement("div", { className: "fc-timegrid-now-indicator-container" }, _this.renderNowIndicator(props.nowIndicatorSegs)),
  13558. createElement(TimeColMisc, { date: props.date, dateProfile: props.dateProfile, todayRange: props.todayRange, extraHookProps: props.extraHookProps })))); }));
  13559. };
  13560. TimeCol.prototype.renderFgSegs = function (sortedFgSegs, segIsInvisible, isDragging, isResizing, isDateSelecting) {
  13561. var props = this.props;
  13562. if (props.forPrint) {
  13563. return renderPlainFgSegs(sortedFgSegs, props);
  13564. }
  13565. return this.renderPositionedFgSegs(sortedFgSegs, segIsInvisible, isDragging, isResizing, isDateSelecting);
  13566. };
  13567. TimeCol.prototype.renderPositionedFgSegs = function (segs, // if not mirror, needs to be sorted
  13568. segIsInvisible, isDragging, isResizing, isDateSelecting) {
  13569. var _this = this;
  13570. var _a = this.context.options, eventMaxStack = _a.eventMaxStack, eventShortHeight = _a.eventShortHeight, eventOrderStrict = _a.eventOrderStrict, eventMinHeight = _a.eventMinHeight;
  13571. var _b = this.props, date = _b.date, slatCoords = _b.slatCoords, eventSelection = _b.eventSelection, todayRange = _b.todayRange, nowDate = _b.nowDate;
  13572. var isMirror = isDragging || isResizing || isDateSelecting;
  13573. var segVCoords = computeSegVCoords(segs, date, slatCoords, eventMinHeight);
  13574. var _c = computeFgSegPlacements(segs, segVCoords, eventOrderStrict, eventMaxStack), segPlacements = _c.segPlacements, hiddenGroups = _c.hiddenGroups;
  13575. return (createElement(Fragment, null,
  13576. this.renderHiddenGroups(hiddenGroups, segs),
  13577. segPlacements.map(function (segPlacement) {
  13578. var seg = segPlacement.seg, rect = segPlacement.rect;
  13579. var instanceId = seg.eventRange.instance.instanceId;
  13580. var isVisible = isMirror || Boolean(!segIsInvisible[instanceId] && rect);
  13581. var vStyle = computeSegVStyle(rect && rect.span);
  13582. var hStyle = (!isMirror && rect) ? _this.computeSegHStyle(rect) : { left: 0, right: 0 };
  13583. var isInset = Boolean(rect) && rect.stackForward > 0;
  13584. var isShort = Boolean(rect) && (rect.span.end - rect.span.start) < eventShortHeight; // look at other places for this problem
  13585. return (createElement("div", { className: 'fc-timegrid-event-harness' +
  13586. (isInset ? ' fc-timegrid-event-harness-inset' : ''), key: instanceId, style: __assign(__assign({ visibility: isVisible ? '' : 'hidden' }, vStyle), hStyle) },
  13587. createElement(TimeColEvent, __assign({ seg: seg, isDragging: isDragging, isResizing: isResizing, isDateSelecting: isDateSelecting, isSelected: instanceId === eventSelection, isShort: isShort }, getSegMeta(seg, todayRange, nowDate)))));
  13588. })));
  13589. };
  13590. // will already have eventMinHeight applied because segInputs already had it
  13591. TimeCol.prototype.renderHiddenGroups = function (hiddenGroups, segs) {
  13592. var _a = this.props, extraDateSpan = _a.extraDateSpan, dateProfile = _a.dateProfile, todayRange = _a.todayRange, nowDate = _a.nowDate, eventSelection = _a.eventSelection, eventDrag = _a.eventDrag, eventResize = _a.eventResize;
  13593. return (createElement(Fragment, null, hiddenGroups.map(function (hiddenGroup) {
  13594. var positionCss = computeSegVStyle(hiddenGroup.span);
  13595. var hiddenSegs = compileSegsFromEntries(hiddenGroup.entries, segs);
  13596. return (createElement(TimeColMoreLink, { key: buildIsoString(computeEarliestSegStart(hiddenSegs)), hiddenSegs: hiddenSegs, top: positionCss.top, bottom: positionCss.bottom, extraDateSpan: extraDateSpan, dateProfile: dateProfile, todayRange: todayRange, nowDate: nowDate, eventSelection: eventSelection, eventDrag: eventDrag, eventResize: eventResize }));
  13597. })));
  13598. };
  13599. TimeCol.prototype.renderFillSegs = function (segs, fillType) {
  13600. var _a = this, props = _a.props, context = _a.context;
  13601. var segVCoords = computeSegVCoords(segs, props.date, props.slatCoords, context.options.eventMinHeight); // don't assume all populated
  13602. var children = segVCoords.map(function (vcoords, i) {
  13603. var seg = segs[i];
  13604. return (createElement("div", { key: buildEventRangeKey(seg.eventRange), className: "fc-timegrid-bg-harness", style: computeSegVStyle(vcoords) }, fillType === 'bg-event' ?
  13605. createElement(BgEvent, __assign({ seg: seg }, getSegMeta(seg, props.todayRange, props.nowDate))) :
  13606. renderFill(fillType)));
  13607. });
  13608. return createElement(Fragment, null, children);
  13609. };
  13610. TimeCol.prototype.renderNowIndicator = function (segs) {
  13611. var _a = this.props, slatCoords = _a.slatCoords, date = _a.date;
  13612. if (!slatCoords) {
  13613. return null;
  13614. }
  13615. return segs.map(function (seg, i) { return (createElement(NowIndicatorRoot, { isAxis: false, date: date,
  13616. // key doesn't matter. will only ever be one
  13617. key: i }, function (rootElRef, classNames, innerElRef, innerContent) { return (createElement("div", { ref: rootElRef, className: ['fc-timegrid-now-indicator-line'].concat(classNames).join(' '), style: { top: slatCoords.computeDateTop(seg.start, date) } }, innerContent)); })); });
  13618. };
  13619. TimeCol.prototype.computeSegHStyle = function (segHCoords) {
  13620. var _a = this.context, isRtl = _a.isRtl, options = _a.options;
  13621. var shouldOverlap = options.slotEventOverlap;
  13622. var nearCoord = segHCoords.levelCoord; // the left side if LTR. the right side if RTL. floating-point
  13623. var farCoord = segHCoords.levelCoord + segHCoords.thickness; // the right side if LTR. the left side if RTL. floating-point
  13624. var left; // amount of space from left edge, a fraction of the total width
  13625. var right; // amount of space from right edge, a fraction of the total width
  13626. if (shouldOverlap) {
  13627. // double the width, but don't go beyond the maximum forward coordinate (1.0)
  13628. farCoord = Math.min(1, nearCoord + (farCoord - nearCoord) * 2);
  13629. }
  13630. if (isRtl) {
  13631. left = 1 - farCoord;
  13632. right = nearCoord;
  13633. }
  13634. else {
  13635. left = nearCoord;
  13636. right = 1 - farCoord;
  13637. }
  13638. var props = {
  13639. zIndex: segHCoords.stackDepth + 1,
  13640. left: left * 100 + '%',
  13641. right: right * 100 + '%',
  13642. };
  13643. if (shouldOverlap && !segHCoords.stackForward) {
  13644. // add padding to the edge so that forward stacked events don't cover the resizer's icon
  13645. props[isRtl ? 'marginLeft' : 'marginRight'] = 10 * 2; // 10 is a guesstimate of the icon's width
  13646. }
  13647. return props;
  13648. };
  13649. return TimeCol;
  13650. }(BaseComponent));
  13651. function renderPlainFgSegs(sortedFgSegs, _a) {
  13652. var todayRange = _a.todayRange, nowDate = _a.nowDate, eventSelection = _a.eventSelection, eventDrag = _a.eventDrag, eventResize = _a.eventResize;
  13653. var hiddenInstances = (eventDrag ? eventDrag.affectedInstances : null) ||
  13654. (eventResize ? eventResize.affectedInstances : null) ||
  13655. {};
  13656. return (createElement(Fragment, null, sortedFgSegs.map(function (seg) {
  13657. var instanceId = seg.eventRange.instance.instanceId;
  13658. return (createElement("div", { key: instanceId, style: { visibility: hiddenInstances[instanceId] ? 'hidden' : '' } },
  13659. createElement(TimeColEvent, __assign({ seg: seg, isDragging: false, isResizing: false, isDateSelecting: false, isSelected: instanceId === eventSelection, isShort: false }, getSegMeta(seg, todayRange, nowDate)))));
  13660. })));
  13661. }
  13662. function computeSegVStyle(segVCoords) {
  13663. if (!segVCoords) {
  13664. return { top: '', bottom: '' };
  13665. }
  13666. return {
  13667. top: segVCoords.start,
  13668. bottom: -segVCoords.end,
  13669. };
  13670. }
  13671. function compileSegsFromEntries(segEntries, allSegs) {
  13672. return segEntries.map(function (segEntry) { return allSegs[segEntry.index]; });
  13673. }
  13674. var TimeColsContent = /** @class */ (function (_super) {
  13675. __extends(TimeColsContent, _super);
  13676. function TimeColsContent() {
  13677. var _this = _super !== null && _super.apply(this, arguments) || this;
  13678. _this.splitFgEventSegs = memoize(splitSegsByCol);
  13679. _this.splitBgEventSegs = memoize(splitSegsByCol);
  13680. _this.splitBusinessHourSegs = memoize(splitSegsByCol);
  13681. _this.splitNowIndicatorSegs = memoize(splitSegsByCol);
  13682. _this.splitDateSelectionSegs = memoize(splitSegsByCol);
  13683. _this.splitEventDrag = memoize(splitInteractionByCol);
  13684. _this.splitEventResize = memoize(splitInteractionByCol);
  13685. _this.rootElRef = createRef();
  13686. _this.cellElRefs = new RefMap();
  13687. return _this;
  13688. }
  13689. TimeColsContent.prototype.render = function () {
  13690. var _this = this;
  13691. var _a = this, props = _a.props, context = _a.context;
  13692. var nowIndicatorTop = context.options.nowIndicator &&
  13693. props.slatCoords &&
  13694. props.slatCoords.safeComputeTop(props.nowDate); // might return void
  13695. var colCnt = props.cells.length;
  13696. var fgEventSegsByRow = this.splitFgEventSegs(props.fgEventSegs, colCnt);
  13697. var bgEventSegsByRow = this.splitBgEventSegs(props.bgEventSegs, colCnt);
  13698. var businessHourSegsByRow = this.splitBusinessHourSegs(props.businessHourSegs, colCnt);
  13699. var nowIndicatorSegsByRow = this.splitNowIndicatorSegs(props.nowIndicatorSegs, colCnt);
  13700. var dateSelectionSegsByRow = this.splitDateSelectionSegs(props.dateSelectionSegs, colCnt);
  13701. var eventDragByRow = this.splitEventDrag(props.eventDrag, colCnt);
  13702. var eventResizeByRow = this.splitEventResize(props.eventResize, colCnt);
  13703. return (createElement("div", { className: "fc-timegrid-cols", ref: this.rootElRef },
  13704. createElement("table", { role: "presentation", style: {
  13705. minWidth: props.tableMinWidth,
  13706. width: props.clientWidth,
  13707. } },
  13708. props.tableColGroupNode,
  13709. createElement("tbody", { role: "presentation" },
  13710. createElement("tr", { role: "row" },
  13711. props.axis && (createElement("td", { "aria-hidden": true, className: "fc-timegrid-col fc-timegrid-axis" },
  13712. createElement("div", { className: "fc-timegrid-col-frame" },
  13713. createElement("div", { className: "fc-timegrid-now-indicator-container" }, typeof nowIndicatorTop === 'number' && (createElement(NowIndicatorRoot, { isAxis: true, date: props.nowDate }, function (rootElRef, classNames, innerElRef, innerContent) { return (createElement("div", { ref: rootElRef, className: ['fc-timegrid-now-indicator-arrow'].concat(classNames).join(' '), style: { top: nowIndicatorTop } }, innerContent)); })))))),
  13714. props.cells.map(function (cell, i) { return (createElement(TimeCol, { key: cell.key, elRef: _this.cellElRefs.createRef(cell.key), dateProfile: props.dateProfile, date: cell.date, nowDate: props.nowDate, todayRange: props.todayRange, extraHookProps: cell.extraHookProps, extraDataAttrs: cell.extraDataAttrs, extraClassNames: cell.extraClassNames, extraDateSpan: cell.extraDateSpan, fgEventSegs: fgEventSegsByRow[i], bgEventSegs: bgEventSegsByRow[i], businessHourSegs: businessHourSegsByRow[i], nowIndicatorSegs: nowIndicatorSegsByRow[i], dateSelectionSegs: dateSelectionSegsByRow[i], eventDrag: eventDragByRow[i], eventResize: eventResizeByRow[i], slatCoords: props.slatCoords, eventSelection: props.eventSelection, forPrint: props.forPrint })); }))))));
  13715. };
  13716. TimeColsContent.prototype.componentDidMount = function () {
  13717. this.updateCoords();
  13718. };
  13719. TimeColsContent.prototype.componentDidUpdate = function () {
  13720. this.updateCoords();
  13721. };
  13722. TimeColsContent.prototype.updateCoords = function () {
  13723. var props = this.props;
  13724. if (props.onColCoords &&
  13725. props.clientWidth !== null // means sizing has stabilized
  13726. ) {
  13727. props.onColCoords(new PositionCache(this.rootElRef.current, collectCellEls(this.cellElRefs.currentMap, props.cells), true, // horizontal
  13728. false));
  13729. }
  13730. };
  13731. return TimeColsContent;
  13732. }(BaseComponent));
  13733. function collectCellEls(elMap, cells) {
  13734. return cells.map(function (cell) { return elMap[cell.key]; });
  13735. }
  13736. /* A component that renders one or more columns of vertical time slots
  13737. ----------------------------------------------------------------------------------------------------------------------*/
  13738. var TimeCols = /** @class */ (function (_super) {
  13739. __extends(TimeCols, _super);
  13740. function TimeCols() {
  13741. var _this = _super !== null && _super.apply(this, arguments) || this;
  13742. _this.processSlotOptions = memoize(processSlotOptions);
  13743. _this.state = {
  13744. slatCoords: null,
  13745. };
  13746. _this.handleRootEl = function (el) {
  13747. if (el) {
  13748. _this.context.registerInteractiveComponent(_this, {
  13749. el: el,
  13750. isHitComboAllowed: _this.props.isHitComboAllowed,
  13751. });
  13752. }
  13753. else {
  13754. _this.context.unregisterInteractiveComponent(_this);
  13755. }
  13756. };
  13757. _this.handleScrollRequest = function (request) {
  13758. var onScrollTopRequest = _this.props.onScrollTopRequest;
  13759. var slatCoords = _this.state.slatCoords;
  13760. if (onScrollTopRequest && slatCoords) {
  13761. if (request.time) {
  13762. var top_1 = slatCoords.computeTimeTop(request.time);
  13763. top_1 = Math.ceil(top_1); // zoom can give weird floating-point values. rather scroll a little bit further
  13764. if (top_1) {
  13765. top_1 += 1; // to overcome top border that slots beyond the first have. looks better
  13766. }
  13767. onScrollTopRequest(top_1);
  13768. }
  13769. return true;
  13770. }
  13771. return false;
  13772. };
  13773. _this.handleColCoords = function (colCoords) {
  13774. _this.colCoords = colCoords;
  13775. };
  13776. _this.handleSlatCoords = function (slatCoords) {
  13777. _this.setState({ slatCoords: slatCoords });
  13778. if (_this.props.onSlatCoords) {
  13779. _this.props.onSlatCoords(slatCoords);
  13780. }
  13781. };
  13782. return _this;
  13783. }
  13784. TimeCols.prototype.render = function () {
  13785. var _a = this, props = _a.props, state = _a.state;
  13786. return (createElement("div", { className: "fc-timegrid-body", ref: this.handleRootEl, style: {
  13787. // these props are important to give this wrapper correct dimensions for interactions
  13788. // TODO: if we set it here, can we avoid giving to inner tables?
  13789. width: props.clientWidth,
  13790. minWidth: props.tableMinWidth,
  13791. } },
  13792. createElement(TimeColsSlats, { axis: props.axis, dateProfile: props.dateProfile, slatMetas: props.slatMetas, clientWidth: props.clientWidth, minHeight: props.expandRows ? props.clientHeight : '', tableMinWidth: props.tableMinWidth, tableColGroupNode: props.axis ? props.tableColGroupNode : null /* axis depends on the colgroup's shrinking */, onCoords: this.handleSlatCoords }),
  13793. createElement(TimeColsContent, { cells: props.cells, axis: props.axis, dateProfile: props.dateProfile, businessHourSegs: props.businessHourSegs, bgEventSegs: props.bgEventSegs, fgEventSegs: props.fgEventSegs, dateSelectionSegs: props.dateSelectionSegs, eventSelection: props.eventSelection, eventDrag: props.eventDrag, eventResize: props.eventResize, todayRange: props.todayRange, nowDate: props.nowDate, nowIndicatorSegs: props.nowIndicatorSegs, clientWidth: props.clientWidth, tableMinWidth: props.tableMinWidth, tableColGroupNode: props.tableColGroupNode, slatCoords: state.slatCoords, onColCoords: this.handleColCoords, forPrint: props.forPrint })));
  13794. };
  13795. TimeCols.prototype.componentDidMount = function () {
  13796. this.scrollResponder = this.context.createScrollResponder(this.handleScrollRequest);
  13797. };
  13798. TimeCols.prototype.componentDidUpdate = function (prevProps) {
  13799. this.scrollResponder.update(prevProps.dateProfile !== this.props.dateProfile);
  13800. };
  13801. TimeCols.prototype.componentWillUnmount = function () {
  13802. this.scrollResponder.detach();
  13803. };
  13804. TimeCols.prototype.queryHit = function (positionLeft, positionTop) {
  13805. var _a = this.context, dateEnv = _a.dateEnv, options = _a.options;
  13806. var colCoords = this.colCoords;
  13807. var dateProfile = this.props.dateProfile;
  13808. var slatCoords = this.state.slatCoords;
  13809. var _b = this.processSlotOptions(this.props.slotDuration, options.snapDuration), snapDuration = _b.snapDuration, snapsPerSlot = _b.snapsPerSlot;
  13810. var colIndex = colCoords.leftToIndex(positionLeft);
  13811. var slatIndex = slatCoords.positions.topToIndex(positionTop);
  13812. if (colIndex != null && slatIndex != null) {
  13813. var cell = this.props.cells[colIndex];
  13814. var slatTop = slatCoords.positions.tops[slatIndex];
  13815. var slatHeight = slatCoords.positions.getHeight(slatIndex);
  13816. var partial = (positionTop - slatTop) / slatHeight; // floating point number between 0 and 1
  13817. var localSnapIndex = Math.floor(partial * snapsPerSlot); // the snap # relative to start of slat
  13818. var snapIndex = slatIndex * snapsPerSlot + localSnapIndex;
  13819. var dayDate = this.props.cells[colIndex].date;
  13820. var time = addDurations(dateProfile.slotMinTime, multiplyDuration(snapDuration, snapIndex));
  13821. var start = dateEnv.add(dayDate, time);
  13822. var end = dateEnv.add(start, snapDuration);
  13823. return {
  13824. dateProfile: dateProfile,
  13825. dateSpan: __assign({ range: { start: start, end: end }, allDay: false }, cell.extraDateSpan),
  13826. dayEl: colCoords.els[colIndex],
  13827. rect: {
  13828. left: colCoords.lefts[colIndex],
  13829. right: colCoords.rights[colIndex],
  13830. top: slatTop,
  13831. bottom: slatTop + slatHeight,
  13832. },
  13833. layer: 0,
  13834. };
  13835. }
  13836. return null;
  13837. };
  13838. return TimeCols;
  13839. }(DateComponent));
  13840. function processSlotOptions(slotDuration, snapDurationOverride) {
  13841. var snapDuration = snapDurationOverride || slotDuration;
  13842. var snapsPerSlot = wholeDivideDurations(slotDuration, snapDuration);
  13843. if (snapsPerSlot === null) {
  13844. snapDuration = slotDuration;
  13845. snapsPerSlot = 1;
  13846. // TODO: say warning?
  13847. }
  13848. return { snapDuration: snapDuration, snapsPerSlot: snapsPerSlot };
  13849. }
  13850. var DayTimeColsSlicer = /** @class */ (function (_super) {
  13851. __extends(DayTimeColsSlicer, _super);
  13852. function DayTimeColsSlicer() {
  13853. return _super !== null && _super.apply(this, arguments) || this;
  13854. }
  13855. DayTimeColsSlicer.prototype.sliceRange = function (range, dayRanges) {
  13856. var segs = [];
  13857. for (var col = 0; col < dayRanges.length; col += 1) {
  13858. var segRange = intersectRanges(range, dayRanges[col]);
  13859. if (segRange) {
  13860. segs.push({
  13861. start: segRange.start,
  13862. end: segRange.end,
  13863. isStart: segRange.start.valueOf() === range.start.valueOf(),
  13864. isEnd: segRange.end.valueOf() === range.end.valueOf(),
  13865. col: col,
  13866. });
  13867. }
  13868. }
  13869. return segs;
  13870. };
  13871. return DayTimeColsSlicer;
  13872. }(Slicer));
  13873. var DayTimeCols = /** @class */ (function (_super) {
  13874. __extends(DayTimeCols, _super);
  13875. function DayTimeCols() {
  13876. var _this = _super !== null && _super.apply(this, arguments) || this;
  13877. _this.buildDayRanges = memoize(buildDayRanges);
  13878. _this.slicer = new DayTimeColsSlicer();
  13879. _this.timeColsRef = createRef();
  13880. return _this;
  13881. }
  13882. DayTimeCols.prototype.render = function () {
  13883. var _this = this;
  13884. var _a = this, props = _a.props, context = _a.context;
  13885. var dateProfile = props.dateProfile, dayTableModel = props.dayTableModel;
  13886. var isNowIndicator = context.options.nowIndicator;
  13887. var dayRanges = this.buildDayRanges(dayTableModel, dateProfile, context.dateEnv);
  13888. // give it the first row of cells
  13889. // TODO: would move this further down hierarchy, but sliceNowDate needs it
  13890. return (createElement(NowTimer, { unit: isNowIndicator ? 'minute' : 'day' }, function (nowDate, todayRange) { return (createElement(TimeCols, __assign({ ref: _this.timeColsRef }, _this.slicer.sliceProps(props, dateProfile, null, context, dayRanges), { forPrint: props.forPrint, axis: props.axis, dateProfile: dateProfile, slatMetas: props.slatMetas, slotDuration: props.slotDuration, cells: dayTableModel.cells[0], tableColGroupNode: props.tableColGroupNode, tableMinWidth: props.tableMinWidth, clientWidth: props.clientWidth, clientHeight: props.clientHeight, expandRows: props.expandRows, nowDate: nowDate, nowIndicatorSegs: isNowIndicator && _this.slicer.sliceNowDate(nowDate, context, dayRanges), todayRange: todayRange, onScrollTopRequest: props.onScrollTopRequest, onSlatCoords: props.onSlatCoords }))); }));
  13891. };
  13892. return DayTimeCols;
  13893. }(DateComponent));
  13894. function buildDayRanges(dayTableModel, dateProfile, dateEnv) {
  13895. var ranges = [];
  13896. for (var _i = 0, _a = dayTableModel.headerDates; _i < _a.length; _i++) {
  13897. var date = _a[_i];
  13898. ranges.push({
  13899. start: dateEnv.add(date, dateProfile.slotMinTime),
  13900. end: dateEnv.add(date, dateProfile.slotMaxTime),
  13901. });
  13902. }
  13903. return ranges;
  13904. }
  13905. // potential nice values for the slot-duration and interval-duration
  13906. // from largest to smallest
  13907. var STOCK_SUB_DURATIONS = [
  13908. { hours: 1 },
  13909. { minutes: 30 },
  13910. { minutes: 15 },
  13911. { seconds: 30 },
  13912. { seconds: 15 },
  13913. ];
  13914. function buildSlatMetas(slotMinTime, slotMaxTime, explicitLabelInterval, slotDuration, dateEnv) {
  13915. var dayStart = new Date(0);
  13916. var slatTime = slotMinTime;
  13917. var slatIterator = createDuration(0);
  13918. var labelInterval = explicitLabelInterval || computeLabelInterval(slotDuration);
  13919. var metas = [];
  13920. while (asRoughMs(slatTime) < asRoughMs(slotMaxTime)) {
  13921. var date = dateEnv.add(dayStart, slatTime);
  13922. var isLabeled = wholeDivideDurations(slatIterator, labelInterval) !== null;
  13923. metas.push({
  13924. date: date,
  13925. time: slatTime,
  13926. key: date.toISOString(),
  13927. isoTimeStr: formatIsoTimeString(date),
  13928. isLabeled: isLabeled,
  13929. });
  13930. slatTime = addDurations(slatTime, slotDuration);
  13931. slatIterator = addDurations(slatIterator, slotDuration);
  13932. }
  13933. return metas;
  13934. }
  13935. // Computes an automatic value for slotLabelInterval
  13936. function computeLabelInterval(slotDuration) {
  13937. var i;
  13938. var labelInterval;
  13939. var slotsPerLabel;
  13940. // find the smallest stock label interval that results in more than one slots-per-label
  13941. for (i = STOCK_SUB_DURATIONS.length - 1; i >= 0; i -= 1) {
  13942. labelInterval = createDuration(STOCK_SUB_DURATIONS[i]);
  13943. slotsPerLabel = wholeDivideDurations(labelInterval, slotDuration);
  13944. if (slotsPerLabel !== null && slotsPerLabel > 1) {
  13945. return labelInterval;
  13946. }
  13947. }
  13948. return slotDuration; // fall back
  13949. }
  13950. var DayTimeColsView = /** @class */ (function (_super) {
  13951. __extends(DayTimeColsView, _super);
  13952. function DayTimeColsView() {
  13953. var _this = _super !== null && _super.apply(this, arguments) || this;
  13954. _this.buildTimeColsModel = memoize(buildTimeColsModel);
  13955. _this.buildSlatMetas = memoize(buildSlatMetas);
  13956. return _this;
  13957. }
  13958. DayTimeColsView.prototype.render = function () {
  13959. var _this = this;
  13960. var _a = this.context, options = _a.options, dateEnv = _a.dateEnv, dateProfileGenerator = _a.dateProfileGenerator;
  13961. var props = this.props;
  13962. var dateProfile = props.dateProfile;
  13963. var dayTableModel = this.buildTimeColsModel(dateProfile, dateProfileGenerator);
  13964. var splitProps = this.allDaySplitter.splitProps(props);
  13965. var slatMetas = this.buildSlatMetas(dateProfile.slotMinTime, dateProfile.slotMaxTime, options.slotLabelInterval, options.slotDuration, dateEnv);
  13966. var dayMinWidth = options.dayMinWidth;
  13967. var hasAttachedAxis = !dayMinWidth;
  13968. var hasDetachedAxis = dayMinWidth;
  13969. var headerContent = options.dayHeaders && (createElement(DayHeader, { dates: dayTableModel.headerDates, dateProfile: dateProfile, datesRepDistinctDays: true, renderIntro: hasAttachedAxis ? this.renderHeadAxis : null }));
  13970. var allDayContent = (options.allDaySlot !== false) && (function (contentArg) { return (createElement(DayTable, __assign({}, splitProps.allDay, { dateProfile: dateProfile, dayTableModel: dayTableModel, nextDayThreshold: options.nextDayThreshold, tableMinWidth: contentArg.tableMinWidth, colGroupNode: contentArg.tableColGroupNode, renderRowIntro: hasAttachedAxis ? _this.renderTableRowAxis : null, showWeekNumbers: false, expandRows: false, headerAlignElRef: _this.headerElRef, clientWidth: contentArg.clientWidth, clientHeight: contentArg.clientHeight, forPrint: props.forPrint }, _this.getAllDayMaxEventProps()))); });
  13971. var timeGridContent = function (contentArg) { return (createElement(DayTimeCols, __assign({}, splitProps.timed, { dayTableModel: dayTableModel, dateProfile: dateProfile, axis: hasAttachedAxis, slotDuration: options.slotDuration, slatMetas: slatMetas, forPrint: props.forPrint, tableColGroupNode: contentArg.tableColGroupNode, tableMinWidth: contentArg.tableMinWidth, clientWidth: contentArg.clientWidth, clientHeight: contentArg.clientHeight, onSlatCoords: _this.handleSlatCoords, expandRows: contentArg.expandRows, onScrollTopRequest: _this.handleScrollTopRequest }))); };
  13972. return hasDetachedAxis
  13973. ? this.renderHScrollLayout(headerContent, allDayContent, timeGridContent, dayTableModel.colCnt, dayMinWidth, slatMetas, this.state.slatCoords)
  13974. : this.renderSimpleLayout(headerContent, allDayContent, timeGridContent);
  13975. };
  13976. return DayTimeColsView;
  13977. }(TimeColsView));
  13978. function buildTimeColsModel(dateProfile, dateProfileGenerator) {
  13979. var daySeries = new DaySeriesModel(dateProfile.renderRange, dateProfileGenerator);
  13980. return new DayTableModel(daySeries, false);
  13981. }
  13982. var OPTION_REFINERS$2 = {
  13983. allDaySlot: Boolean,
  13984. };
  13985. var timeGridPlugin = createPlugin({
  13986. initialView: 'timeGridWeek',
  13987. optionRefiners: OPTION_REFINERS$2,
  13988. views: {
  13989. timeGrid: {
  13990. component: DayTimeColsView,
  13991. usesMinMaxTime: true,
  13992. allDaySlot: true,
  13993. slotDuration: '00:30:00',
  13994. slotEventOverlap: true, // a bad name. confused with overlap/constraint system
  13995. },
  13996. timeGridDay: {
  13997. type: 'timeGrid',
  13998. duration: { days: 1 },
  13999. },
  14000. timeGridWeek: {
  14001. type: 'timeGrid',
  14002. duration: { weeks: 1 },
  14003. },
  14004. },
  14005. });
  14006. var ListViewHeaderRow = /** @class */ (function (_super) {
  14007. __extends(ListViewHeaderRow, _super);
  14008. function ListViewHeaderRow() {
  14009. var _this = _super !== null && _super.apply(this, arguments) || this;
  14010. _this.state = {
  14011. textId: getUniqueDomId(),
  14012. };
  14013. return _this;
  14014. }
  14015. ListViewHeaderRow.prototype.render = function () {
  14016. var _a = this.context, theme = _a.theme, dateEnv = _a.dateEnv, options = _a.options, viewApi = _a.viewApi;
  14017. var _b = this.props, cellId = _b.cellId, dayDate = _b.dayDate, todayRange = _b.todayRange;
  14018. var textId = this.state.textId;
  14019. var dayMeta = getDateMeta(dayDate, todayRange);
  14020. // will ever be falsy?
  14021. var text = options.listDayFormat ? dateEnv.format(dayDate, options.listDayFormat) : '';
  14022. // will ever be falsy? also, BAD NAME "alt"
  14023. var sideText = options.listDaySideFormat ? dateEnv.format(dayDate, options.listDaySideFormat) : '';
  14024. var hookProps = __assign({ date: dateEnv.toDate(dayDate), view: viewApi, textId: textId,
  14025. text: text,
  14026. sideText: sideText, navLinkAttrs: buildNavLinkAttrs(this.context, dayDate), sideNavLinkAttrs: buildNavLinkAttrs(this.context, dayDate, 'day', false) }, dayMeta);
  14027. var classNames = ['fc-list-day'].concat(getDayClassNames(dayMeta, theme));
  14028. // TODO: make a reusable HOC for dayHeader (used in daygrid/timegrid too)
  14029. return (createElement(RenderHook, { hookProps: hookProps, classNames: options.dayHeaderClassNames, content: options.dayHeaderContent, defaultContent: renderInnerContent, didMount: options.dayHeaderDidMount, willUnmount: options.dayHeaderWillUnmount }, function (rootElRef, customClassNames, innerElRef, innerContent) { return (createElement("tr", { ref: rootElRef, className: classNames.concat(customClassNames).join(' '), "data-date": formatDayString(dayDate) },
  14030. createElement("th", { scope: "colgroup", colSpan: 3, id: cellId, "aria-labelledby": textId },
  14031. createElement("div", { className: 'fc-list-day-cushion ' + theme.getClass('tableCellShaded'), ref: innerElRef }, innerContent)))); }));
  14032. };
  14033. return ListViewHeaderRow;
  14034. }(BaseComponent));
  14035. function renderInnerContent(props) {
  14036. return (createElement(Fragment, null,
  14037. props.text && (createElement("a", __assign({ id: props.textId, className: "fc-list-day-text" }, props.navLinkAttrs), props.text)),
  14038. props.sideText && ( /* not keyboard tabbable */createElement("a", __assign({ "aria-hidden": true, className: "fc-list-day-side-text" }, props.sideNavLinkAttrs), props.sideText))));
  14039. }
  14040. var DEFAULT_TIME_FORMAT = createFormatter({
  14041. hour: 'numeric',
  14042. minute: '2-digit',
  14043. meridiem: 'short',
  14044. });
  14045. var ListViewEventRow = /** @class */ (function (_super) {
  14046. __extends(ListViewEventRow, _super);
  14047. function ListViewEventRow() {
  14048. return _super !== null && _super.apply(this, arguments) || this;
  14049. }
  14050. ListViewEventRow.prototype.render = function () {
  14051. var _a = this, props = _a.props, context = _a.context;
  14052. var seg = props.seg, timeHeaderId = props.timeHeaderId, eventHeaderId = props.eventHeaderId, dateHeaderId = props.dateHeaderId;
  14053. var timeFormat = context.options.eventTimeFormat || DEFAULT_TIME_FORMAT;
  14054. return (createElement(EventRoot, { seg: seg, timeText: "" // BAD. because of all-day content
  14055. , disableDragging: true, disableResizing: true, defaultContent: function () { return renderEventInnerContent(seg, context); } /* weird */, isPast: props.isPast, isFuture: props.isFuture, isToday: props.isToday, isSelected: props.isSelected, isDragging: props.isDragging, isResizing: props.isResizing, isDateSelecting: props.isDateSelecting }, function (rootElRef, classNames, innerElRef, innerContent, hookProps) { return (createElement("tr", { className: ['fc-list-event', hookProps.event.url ? 'fc-event-forced-url' : ''].concat(classNames).join(' '), ref: rootElRef },
  14056. buildTimeContent(seg, timeFormat, context, timeHeaderId, dateHeaderId),
  14057. createElement("td", { "aria-hidden": true, className: "fc-list-event-graphic" },
  14058. createElement("span", { className: "fc-list-event-dot", style: { borderColor: hookProps.borderColor || hookProps.backgroundColor } })),
  14059. createElement("td", { ref: innerElRef, headers: eventHeaderId + " " + dateHeaderId, className: "fc-list-event-title" }, innerContent))); }));
  14060. };
  14061. return ListViewEventRow;
  14062. }(BaseComponent));
  14063. function renderEventInnerContent(seg, context) {
  14064. var interactiveAttrs = getSegAnchorAttrs(seg, context);
  14065. return (createElement("a", __assign({}, interactiveAttrs), seg.eventRange.def.title));
  14066. }
  14067. function buildTimeContent(seg, timeFormat, context, timeHeaderId, dateHeaderId) {
  14068. var options = context.options;
  14069. if (options.displayEventTime !== false) {
  14070. var eventDef = seg.eventRange.def;
  14071. var eventInstance = seg.eventRange.instance;
  14072. var doAllDay = false;
  14073. var timeText = void 0;
  14074. if (eventDef.allDay) {
  14075. doAllDay = true;
  14076. }
  14077. else if (isMultiDayRange(seg.eventRange.range)) { // TODO: use (!isStart || !isEnd) instead?
  14078. if (seg.isStart) {
  14079. timeText = buildSegTimeText(seg, timeFormat, context, null, null, eventInstance.range.start, seg.end);
  14080. }
  14081. else if (seg.isEnd) {
  14082. timeText = buildSegTimeText(seg, timeFormat, context, null, null, seg.start, eventInstance.range.end);
  14083. }
  14084. else {
  14085. doAllDay = true;
  14086. }
  14087. }
  14088. else {
  14089. timeText = buildSegTimeText(seg, timeFormat, context);
  14090. }
  14091. if (doAllDay) {
  14092. var hookProps = {
  14093. text: context.options.allDayText,
  14094. view: context.viewApi,
  14095. };
  14096. return (createElement(RenderHook, { hookProps: hookProps, classNames: options.allDayClassNames, content: options.allDayContent, defaultContent: renderAllDayInner, didMount: options.allDayDidMount, willUnmount: options.allDayWillUnmount }, function (rootElRef, classNames, innerElRef, innerContent) { return (createElement("td", { ref: rootElRef, headers: timeHeaderId + " " + dateHeaderId, className: ['fc-list-event-time'].concat(classNames).join(' ') }, innerContent)); }));
  14097. }
  14098. return (createElement("td", { className: "fc-list-event-time" }, timeText));
  14099. }
  14100. return null;
  14101. }
  14102. function renderAllDayInner(hookProps) {
  14103. return hookProps.text;
  14104. }
  14105. /*
  14106. Responsible for the scroller, and forwarding event-related actions into the "grid".
  14107. */
  14108. var ListView = /** @class */ (function (_super) {
  14109. __extends(ListView, _super);
  14110. function ListView() {
  14111. var _this = _super !== null && _super.apply(this, arguments) || this;
  14112. _this.computeDateVars = memoize(computeDateVars);
  14113. _this.eventStoreToSegs = memoize(_this._eventStoreToSegs);
  14114. _this.state = {
  14115. timeHeaderId: getUniqueDomId(),
  14116. eventHeaderId: getUniqueDomId(),
  14117. dateHeaderIdRoot: getUniqueDomId(),
  14118. };
  14119. _this.setRootEl = function (rootEl) {
  14120. if (rootEl) {
  14121. _this.context.registerInteractiveComponent(_this, {
  14122. el: rootEl,
  14123. });
  14124. }
  14125. else {
  14126. _this.context.unregisterInteractiveComponent(_this);
  14127. }
  14128. };
  14129. return _this;
  14130. }
  14131. ListView.prototype.render = function () {
  14132. var _this = this;
  14133. var _a = this, props = _a.props, context = _a.context;
  14134. var extraClassNames = [
  14135. 'fc-list',
  14136. context.theme.getClass('table'),
  14137. context.options.stickyHeaderDates !== false ? 'fc-list-sticky' : '',
  14138. ];
  14139. var _b = this.computeDateVars(props.dateProfile), dayDates = _b.dayDates, dayRanges = _b.dayRanges;
  14140. var eventSegs = this.eventStoreToSegs(props.eventStore, props.eventUiBases, dayRanges);
  14141. return (createElement(ViewRoot, { viewSpec: context.viewSpec, elRef: this.setRootEl }, function (rootElRef, classNames) { return (createElement("div", { ref: rootElRef, className: extraClassNames.concat(classNames).join(' ') },
  14142. createElement(Scroller, { liquid: !props.isHeightAuto, overflowX: props.isHeightAuto ? 'visible' : 'hidden', overflowY: props.isHeightAuto ? 'visible' : 'auto' }, eventSegs.length > 0 ?
  14143. _this.renderSegList(eventSegs, dayDates) :
  14144. _this.renderEmptyMessage()))); }));
  14145. };
  14146. ListView.prototype.renderEmptyMessage = function () {
  14147. var _a = this.context, options = _a.options, viewApi = _a.viewApi;
  14148. var hookProps = {
  14149. text: options.noEventsText,
  14150. view: viewApi,
  14151. };
  14152. return (createElement(RenderHook, { hookProps: hookProps, classNames: options.noEventsClassNames, content: options.noEventsContent, defaultContent: renderNoEventsInner, didMount: options.noEventsDidMount, willUnmount: options.noEventsWillUnmount }, function (rootElRef, classNames, innerElRef, innerContent) { return (createElement("div", { className: ['fc-list-empty'].concat(classNames).join(' '), ref: rootElRef },
  14153. createElement("div", { className: "fc-list-empty-cushion", ref: innerElRef }, innerContent))); }));
  14154. };
  14155. ListView.prototype.renderSegList = function (allSegs, dayDates) {
  14156. var _a = this.context, theme = _a.theme, options = _a.options;
  14157. var _b = this.state, timeHeaderId = _b.timeHeaderId, eventHeaderId = _b.eventHeaderId, dateHeaderIdRoot = _b.dateHeaderIdRoot;
  14158. var segsByDay = groupSegsByDay(allSegs); // sparse array
  14159. return (createElement(NowTimer, { unit: "day" }, function (nowDate, todayRange) {
  14160. var innerNodes = [];
  14161. for (var dayIndex = 0; dayIndex < segsByDay.length; dayIndex += 1) {
  14162. var daySegs = segsByDay[dayIndex];
  14163. if (daySegs) { // sparse array, so might be undefined
  14164. var dayStr = formatDayString(dayDates[dayIndex]);
  14165. var dateHeaderId = dateHeaderIdRoot + '-' + dayStr;
  14166. // append a day header
  14167. innerNodes.push(createElement(ListViewHeaderRow, { key: dayStr, cellId: dateHeaderId, dayDate: dayDates[dayIndex], todayRange: todayRange }));
  14168. daySegs = sortEventSegs(daySegs, options.eventOrder);
  14169. for (var _i = 0, daySegs_1 = daySegs; _i < daySegs_1.length; _i++) {
  14170. var seg = daySegs_1[_i];
  14171. innerNodes.push(createElement(ListViewEventRow, __assign({ key: dayStr + ':' + seg.eventRange.instance.instanceId /* are multiple segs for an instanceId */, seg: seg, isDragging: false, isResizing: false, isDateSelecting: false, isSelected: false, timeHeaderId: timeHeaderId, eventHeaderId: eventHeaderId, dateHeaderId: dateHeaderId }, getSegMeta(seg, todayRange, nowDate))));
  14172. }
  14173. }
  14174. }
  14175. return (createElement("table", { className: 'fc-list-table ' + theme.getClass('table') },
  14176. createElement("thead", null,
  14177. createElement("tr", null,
  14178. createElement("th", { scope: "col", id: timeHeaderId }, options.timeHint),
  14179. createElement("th", { scope: "col", "aria-hidden": true }),
  14180. createElement("th", { scope: "col", id: eventHeaderId }, options.eventHint))),
  14181. createElement("tbody", null, innerNodes)));
  14182. }));
  14183. };
  14184. ListView.prototype._eventStoreToSegs = function (eventStore, eventUiBases, dayRanges) {
  14185. return this.eventRangesToSegs(sliceEventStore(eventStore, eventUiBases, this.props.dateProfile.activeRange, this.context.options.nextDayThreshold).fg, dayRanges);
  14186. };
  14187. ListView.prototype.eventRangesToSegs = function (eventRanges, dayRanges) {
  14188. var segs = [];
  14189. for (var _i = 0, eventRanges_1 = eventRanges; _i < eventRanges_1.length; _i++) {
  14190. var eventRange = eventRanges_1[_i];
  14191. segs.push.apply(segs, this.eventRangeToSegs(eventRange, dayRanges));
  14192. }
  14193. return segs;
  14194. };
  14195. ListView.prototype.eventRangeToSegs = function (eventRange, dayRanges) {
  14196. var dateEnv = this.context.dateEnv;
  14197. var nextDayThreshold = this.context.options.nextDayThreshold;
  14198. var range = eventRange.range;
  14199. var allDay = eventRange.def.allDay;
  14200. var dayIndex;
  14201. var segRange;
  14202. var seg;
  14203. var segs = [];
  14204. for (dayIndex = 0; dayIndex < dayRanges.length; dayIndex += 1) {
  14205. segRange = intersectRanges(range, dayRanges[dayIndex]);
  14206. if (segRange) {
  14207. seg = {
  14208. component: this,
  14209. eventRange: eventRange,
  14210. start: segRange.start,
  14211. end: segRange.end,
  14212. isStart: eventRange.isStart && segRange.start.valueOf() === range.start.valueOf(),
  14213. isEnd: eventRange.isEnd && segRange.end.valueOf() === range.end.valueOf(),
  14214. dayIndex: dayIndex,
  14215. };
  14216. segs.push(seg);
  14217. // detect when range won't go fully into the next day,
  14218. // and mutate the latest seg to the be the end.
  14219. if (!seg.isEnd && !allDay &&
  14220. dayIndex + 1 < dayRanges.length &&
  14221. range.end <
  14222. dateEnv.add(dayRanges[dayIndex + 1].start, nextDayThreshold)) {
  14223. seg.end = range.end;
  14224. seg.isEnd = true;
  14225. break;
  14226. }
  14227. }
  14228. }
  14229. return segs;
  14230. };
  14231. return ListView;
  14232. }(DateComponent));
  14233. function renderNoEventsInner(hookProps) {
  14234. return hookProps.text;
  14235. }
  14236. function computeDateVars(dateProfile) {
  14237. var dayStart = startOfDay(dateProfile.renderRange.start);
  14238. var viewEnd = dateProfile.renderRange.end;
  14239. var dayDates = [];
  14240. var dayRanges = [];
  14241. while (dayStart < viewEnd) {
  14242. dayDates.push(dayStart);
  14243. dayRanges.push({
  14244. start: dayStart,
  14245. end: addDays(dayStart, 1),
  14246. });
  14247. dayStart = addDays(dayStart, 1);
  14248. }
  14249. return { dayDates: dayDates, dayRanges: dayRanges };
  14250. }
  14251. // Returns a sparse array of arrays, segs grouped by their dayIndex
  14252. function groupSegsByDay(segs) {
  14253. var segsByDay = []; // sparse array
  14254. var i;
  14255. var seg;
  14256. for (i = 0; i < segs.length; i += 1) {
  14257. seg = segs[i];
  14258. (segsByDay[seg.dayIndex] || (segsByDay[seg.dayIndex] = []))
  14259. .push(seg);
  14260. }
  14261. return segsByDay;
  14262. }
  14263. var OPTION_REFINERS$1 = {
  14264. listDayFormat: createFalsableFormatter,
  14265. listDaySideFormat: createFalsableFormatter,
  14266. noEventsClassNames: identity,
  14267. noEventsContent: identity,
  14268. noEventsDidMount: identity,
  14269. noEventsWillUnmount: identity,
  14270. // noEventsText is defined in base options
  14271. };
  14272. function createFalsableFormatter(input) {
  14273. return input === false ? null : createFormatter(input);
  14274. }
  14275. var listPlugin = createPlugin({
  14276. optionRefiners: OPTION_REFINERS$1,
  14277. views: {
  14278. list: {
  14279. component: ListView,
  14280. buttonTextKey: 'list',
  14281. listDayFormat: { month: 'long', day: 'numeric', year: 'numeric' }, // like "January 1, 2016"
  14282. },
  14283. listDay: {
  14284. type: 'list',
  14285. duration: { days: 1 },
  14286. listDayFormat: { weekday: 'long' }, // day-of-week is all we need. full date is probably in headerToolbar
  14287. },
  14288. listWeek: {
  14289. type: 'list',
  14290. duration: { weeks: 1 },
  14291. listDayFormat: { weekday: 'long' },
  14292. listDaySideFormat: { month: 'long', day: 'numeric', year: 'numeric' },
  14293. },
  14294. listMonth: {
  14295. type: 'list',
  14296. duration: { month: 1 },
  14297. listDaySideFormat: { weekday: 'long' }, // day-of-week is nice-to-have
  14298. },
  14299. listYear: {
  14300. type: 'list',
  14301. duration: { year: 1 },
  14302. listDaySideFormat: { weekday: 'long' }, // day-of-week is nice-to-have
  14303. },
  14304. },
  14305. });
  14306. var BootstrapTheme = /** @class */ (function (_super) {
  14307. __extends(BootstrapTheme, _super);
  14308. function BootstrapTheme() {
  14309. return _super !== null && _super.apply(this, arguments) || this;
  14310. }
  14311. return BootstrapTheme;
  14312. }(Theme));
  14313. BootstrapTheme.prototype.classes = {
  14314. root: 'fc-theme-bootstrap',
  14315. table: 'table-bordered',
  14316. tableCellShaded: 'table-active',
  14317. buttonGroup: 'btn-group',
  14318. button: 'btn btn-primary',
  14319. buttonActive: 'active',
  14320. popover: 'popover',
  14321. popoverHeader: 'popover-header',
  14322. popoverContent: 'popover-body',
  14323. };
  14324. BootstrapTheme.prototype.baseIconClass = 'fa';
  14325. BootstrapTheme.prototype.iconClasses = {
  14326. close: 'fa-times',
  14327. prev: 'fa-chevron-left',
  14328. next: 'fa-chevron-right',
  14329. prevYear: 'fa-angle-double-left',
  14330. nextYear: 'fa-angle-double-right',
  14331. };
  14332. BootstrapTheme.prototype.rtlIconClasses = {
  14333. prev: 'fa-chevron-right',
  14334. next: 'fa-chevron-left',
  14335. prevYear: 'fa-angle-double-right',
  14336. nextYear: 'fa-angle-double-left',
  14337. };
  14338. BootstrapTheme.prototype.iconOverrideOption = 'bootstrapFontAwesome'; // TODO: make TS-friendly. move the option-processing into this plugin
  14339. BootstrapTheme.prototype.iconOverrideCustomButtonOption = 'bootstrapFontAwesome';
  14340. BootstrapTheme.prototype.iconOverridePrefix = 'fa-';
  14341. var plugin = createPlugin({
  14342. themeClasses: {
  14343. bootstrap: BootstrapTheme,
  14344. },
  14345. });
  14346. // rename this file to options.ts like other packages?
  14347. var OPTION_REFINERS = {
  14348. googleCalendarApiKey: String,
  14349. };
  14350. var EVENT_SOURCE_REFINERS = {
  14351. googleCalendarApiKey: String,
  14352. googleCalendarId: String,
  14353. googleCalendarApiBase: String,
  14354. extraParams: identity,
  14355. };
  14356. // TODO: expose somehow
  14357. var API_BASE = 'https://www.googleapis.com/calendar/v3/calendars';
  14358. var eventSourceDef = {
  14359. parseMeta: function (refined) {
  14360. var googleCalendarId = refined.googleCalendarId;
  14361. if (!googleCalendarId && refined.url) {
  14362. googleCalendarId = parseGoogleCalendarId(refined.url);
  14363. }
  14364. if (googleCalendarId) {
  14365. return {
  14366. googleCalendarId: googleCalendarId,
  14367. googleCalendarApiKey: refined.googleCalendarApiKey,
  14368. googleCalendarApiBase: refined.googleCalendarApiBase,
  14369. extraParams: refined.extraParams,
  14370. };
  14371. }
  14372. return null;
  14373. },
  14374. fetch: function (arg, onSuccess, onFailure) {
  14375. var _a = arg.context, dateEnv = _a.dateEnv, options = _a.options;
  14376. var meta = arg.eventSource.meta;
  14377. var apiKey = meta.googleCalendarApiKey || options.googleCalendarApiKey;
  14378. if (!apiKey) {
  14379. onFailure({
  14380. message: 'Specify a googleCalendarApiKey. See http://fullcalendar.io/docs/google_calendar/',
  14381. });
  14382. }
  14383. else {
  14384. var url = buildUrl(meta);
  14385. // TODO: make DRY with json-feed-event-source
  14386. var extraParams = meta.extraParams;
  14387. var extraParamsObj = typeof extraParams === 'function' ? extraParams() : extraParams;
  14388. var requestParams_1 = buildRequestParams(arg.range, apiKey, extraParamsObj, dateEnv);
  14389. requestJson('GET', url, requestParams_1, function (body, xhr) {
  14390. if (body.error) {
  14391. onFailure({
  14392. message: 'Google Calendar API: ' + body.error.message,
  14393. errors: body.error.errors,
  14394. xhr: xhr,
  14395. });
  14396. }
  14397. else {
  14398. onSuccess({
  14399. rawEvents: gcalItemsToRawEventDefs(body.items, requestParams_1.timeZone),
  14400. xhr: xhr,
  14401. });
  14402. }
  14403. }, function (message, xhr) {
  14404. onFailure({ message: message, xhr: xhr });
  14405. });
  14406. }
  14407. },
  14408. };
  14409. function parseGoogleCalendarId(url) {
  14410. var match;
  14411. // detect if the ID was specified as a single string.
  14412. // will match calendars like "asdf1234@calendar.google.com" in addition to person email calendars.
  14413. if (/^[^/]+@([^/.]+\.)*(google|googlemail|gmail)\.com$/.test(url)) {
  14414. return url;
  14415. }
  14416. if ((match = /^https:\/\/www.googleapis.com\/calendar\/v3\/calendars\/([^/]*)/.exec(url)) ||
  14417. (match = /^https?:\/\/www.google.com\/calendar\/feeds\/([^/]*)/.exec(url))) {
  14418. return decodeURIComponent(match[1]);
  14419. }
  14420. return null;
  14421. }
  14422. function buildUrl(meta) {
  14423. var apiBase = meta.googleCalendarApiBase;
  14424. if (!apiBase) {
  14425. apiBase = API_BASE;
  14426. }
  14427. return apiBase + '/' + encodeURIComponent(meta.googleCalendarId) + '/events';
  14428. }
  14429. function buildRequestParams(range, apiKey, extraParams, dateEnv) {
  14430. var params;
  14431. var startStr;
  14432. var endStr;
  14433. if (dateEnv.canComputeOffset) {
  14434. // strings will naturally have offsets, which GCal needs
  14435. startStr = dateEnv.formatIso(range.start);
  14436. endStr = dateEnv.formatIso(range.end);
  14437. }
  14438. else {
  14439. // when timezone isn't known, we don't know what the UTC offset should be, so ask for +/- 1 day
  14440. // from the UTC day-start to guarantee we're getting all the events
  14441. // (start/end will be UTC-coerced dates, so toISOString is okay)
  14442. startStr = addDays(range.start, -1).toISOString();
  14443. endStr = addDays(range.end, 1).toISOString();
  14444. }
  14445. params = __assign(__assign({}, (extraParams || {})), { key: apiKey, timeMin: startStr, timeMax: endStr, singleEvents: true, maxResults: 9999 });
  14446. if (dateEnv.timeZone !== 'local') {
  14447. params.timeZone = dateEnv.timeZone;
  14448. }
  14449. return params;
  14450. }
  14451. function gcalItemsToRawEventDefs(items, gcalTimezone) {
  14452. return items.map(function (item) { return gcalItemToRawEventDef(item, gcalTimezone); });
  14453. }
  14454. function gcalItemToRawEventDef(item, gcalTimezone) {
  14455. var url = item.htmlLink || null;
  14456. // make the URLs for each event show times in the correct timezone
  14457. if (url && gcalTimezone) {
  14458. url = injectQsComponent(url, 'ctz=' + gcalTimezone);
  14459. }
  14460. return {
  14461. id: item.id,
  14462. title: item.summary,
  14463. start: item.start.dateTime || item.start.date,
  14464. end: item.end.dateTime || item.end.date,
  14465. url: url,
  14466. location: item.location,
  14467. description: item.description,
  14468. attachments: item.attachments || [],
  14469. extendedProps: (item.extendedProperties || {}).shared || {},
  14470. };
  14471. }
  14472. // Injects a string like "arg=value" into the querystring of a URL
  14473. // TODO: move to a general util file?
  14474. function injectQsComponent(url, component) {
  14475. // inject it after the querystring but before the fragment
  14476. return url.replace(/(\?.*?)?(#|$)/, function (whole, qs, hash) { return (qs ? qs + '&' : '?') + component + hash; });
  14477. }
  14478. var googleCalendarPlugin = createPlugin({
  14479. eventSourceDefs: [eventSourceDef],
  14480. optionRefiners: OPTION_REFINERS,
  14481. eventSourceRefiners: EVENT_SOURCE_REFINERS,
  14482. });
  14483. globalPlugins.push(interactionPlugin, dayGridPlugin, timeGridPlugin, listPlugin, plugin, googleCalendarPlugin);
  14484. exports.BASE_OPTION_DEFAULTS = BASE_OPTION_DEFAULTS;
  14485. exports.BASE_OPTION_REFINERS = BASE_OPTION_REFINERS;
  14486. exports.BaseComponent = BaseComponent;
  14487. exports.BgEvent = BgEvent;
  14488. exports.BootstrapTheme = BootstrapTheme;
  14489. exports.Calendar = Calendar;
  14490. exports.CalendarApi = CalendarApi;
  14491. exports.CalendarContent = CalendarContent;
  14492. exports.CalendarDataManager = CalendarDataManager;
  14493. exports.CalendarDataProvider = CalendarDataProvider;
  14494. exports.CalendarRoot = CalendarRoot;
  14495. exports.Component = Component;
  14496. exports.ContentHook = ContentHook;
  14497. exports.CustomContentRenderContext = CustomContentRenderContext;
  14498. exports.DateComponent = DateComponent;
  14499. exports.DateEnv = DateEnv;
  14500. exports.DateProfileGenerator = DateProfileGenerator;
  14501. exports.DayCellContent = DayCellContent;
  14502. exports.DayCellRoot = DayCellRoot;
  14503. exports.DayGridView = DayTableView;
  14504. exports.DayHeader = DayHeader;
  14505. exports.DaySeriesModel = DaySeriesModel;
  14506. exports.DayTable = DayTable;
  14507. exports.DayTableModel = DayTableModel;
  14508. exports.DayTableSlicer = DayTableSlicer;
  14509. exports.DayTimeCols = DayTimeCols;
  14510. exports.DayTimeColsSlicer = DayTimeColsSlicer;
  14511. exports.DayTimeColsView = DayTimeColsView;
  14512. exports.DelayedRunner = DelayedRunner;
  14513. exports.Draggable = ExternalDraggable;
  14514. exports.ElementDragging = ElementDragging;
  14515. exports.ElementScrollController = ElementScrollController;
  14516. exports.Emitter = Emitter;
  14517. exports.EventApi = EventApi;
  14518. exports.EventRoot = EventRoot;
  14519. exports.EventSourceApi = EventSourceApi;
  14520. exports.FeaturefulElementDragging = FeaturefulElementDragging;
  14521. exports.Fragment = Fragment;
  14522. exports.Interaction = Interaction;
  14523. exports.ListView = ListView;
  14524. exports.MoreLinkRoot = MoreLinkRoot;
  14525. exports.MountHook = MountHook;
  14526. exports.NamedTimeZoneImpl = NamedTimeZoneImpl;
  14527. exports.NowIndicatorRoot = NowIndicatorRoot;
  14528. exports.NowTimer = NowTimer;
  14529. exports.PointerDragging = PointerDragging;
  14530. exports.PositionCache = PositionCache;
  14531. exports.RefMap = RefMap;
  14532. exports.RenderHook = RenderHook;
  14533. exports.ScrollController = ScrollController;
  14534. exports.ScrollResponder = ScrollResponder;
  14535. exports.Scroller = Scroller;
  14536. exports.SegHierarchy = SegHierarchy;
  14537. exports.SimpleScrollGrid = SimpleScrollGrid;
  14538. exports.Slicer = Slicer;
  14539. exports.Splitter = Splitter;
  14540. exports.StandardEvent = StandardEvent;
  14541. exports.Table = Table;
  14542. exports.TableDateCell = TableDateCell;
  14543. exports.TableDowCell = TableDowCell;
  14544. exports.TableView = TableView;
  14545. exports.Theme = Theme;
  14546. exports.ThirdPartyDraggable = ThirdPartyDraggable;
  14547. exports.TimeCols = TimeCols;
  14548. exports.TimeColsSlatsCoords = TimeColsSlatsCoords;
  14549. exports.TimeColsView = TimeColsView;
  14550. exports.ViewApi = ViewApi;
  14551. exports.ViewContextType = ViewContextType;
  14552. exports.ViewRoot = ViewRoot;
  14553. exports.WeekNumberRoot = WeekNumberRoot;
  14554. exports.WindowScrollController = WindowScrollController;
  14555. exports.addDays = addDays;
  14556. exports.addDurations = addDurations;
  14557. exports.addMs = addMs;
  14558. exports.addWeeks = addWeeks;
  14559. exports.allowContextMenu = allowContextMenu;
  14560. exports.allowSelection = allowSelection;
  14561. exports.applyMutationToEventStore = applyMutationToEventStore;
  14562. exports.applyStyle = applyStyle;
  14563. exports.applyStyleProp = applyStyleProp;
  14564. exports.asCleanDays = asCleanDays;
  14565. exports.asRoughMinutes = asRoughMinutes;
  14566. exports.asRoughMs = asRoughMs;
  14567. exports.asRoughSeconds = asRoughSeconds;
  14568. exports.binarySearch = binarySearch;
  14569. exports.buildClassNameNormalizer = buildClassNameNormalizer;
  14570. exports.buildDayRanges = buildDayRanges;
  14571. exports.buildDayTableModel = buildDayTableModel;
  14572. exports.buildEntryKey = buildEntryKey;
  14573. exports.buildEventApis = buildEventApis;
  14574. exports.buildEventRangeKey = buildEventRangeKey;
  14575. exports.buildHashFromArray = buildHashFromArray;
  14576. exports.buildIsoString = buildIsoString;
  14577. exports.buildNavLinkAttrs = buildNavLinkAttrs;
  14578. exports.buildSegCompareObj = buildSegCompareObj;
  14579. exports.buildSegTimeText = buildSegTimeText;
  14580. exports.buildSlatMetas = buildSlatMetas;
  14581. exports.buildTimeColsModel = buildTimeColsModel;
  14582. exports.collectFromHash = collectFromHash;
  14583. exports.combineEventUis = combineEventUis;
  14584. exports.compareByFieldSpec = compareByFieldSpec;
  14585. exports.compareByFieldSpecs = compareByFieldSpecs;
  14586. exports.compareNumbers = compareNumbers;
  14587. exports.compareObjs = compareObjs;
  14588. exports.computeEarliestSegStart = computeEarliestSegStart;
  14589. exports.computeEdges = computeEdges;
  14590. exports.computeFallbackHeaderFormat = computeFallbackHeaderFormat;
  14591. exports.computeHeightAndMargins = computeHeightAndMargins;
  14592. exports.computeInnerRect = computeInnerRect;
  14593. exports.computeRect = computeRect;
  14594. exports.computeSegDraggable = computeSegDraggable;
  14595. exports.computeSegEndResizable = computeSegEndResizable;
  14596. exports.computeSegStartResizable = computeSegStartResizable;
  14597. exports.computeShrinkWidth = computeShrinkWidth;
  14598. exports.computeSmallestCellWidth = computeSmallestCellWidth;
  14599. exports.computeVisibleDayRange = computeVisibleDayRange;
  14600. exports.config = config;
  14601. exports.constrainPoint = constrainPoint;
  14602. exports.createAriaClickAttrs = createAriaClickAttrs;
  14603. exports.createContext = createContext;
  14604. exports.createDuration = createDuration;
  14605. exports.createElement = createElement;
  14606. exports.createEmptyEventStore = createEmptyEventStore;
  14607. exports.createEventInstance = createEventInstance;
  14608. exports.createEventUi = createEventUi;
  14609. exports.createFormatter = createFormatter;
  14610. exports.createPlugin = createPlugin;
  14611. exports.createPortal = createPortal;
  14612. exports.createRef = createRef;
  14613. exports.diffDates = diffDates;
  14614. exports.diffDayAndTime = diffDayAndTime;
  14615. exports.diffDays = diffDays;
  14616. exports.diffPoints = diffPoints;
  14617. exports.diffWeeks = diffWeeks;
  14618. exports.diffWholeDays = diffWholeDays;
  14619. exports.diffWholeWeeks = diffWholeWeeks;
  14620. exports.disableCursor = disableCursor;
  14621. exports.elementClosest = elementClosest;
  14622. exports.elementMatches = elementMatches;
  14623. exports.enableCursor = enableCursor;
  14624. exports.eventTupleToStore = eventTupleToStore;
  14625. exports.filterEventStoreDefs = filterEventStoreDefs;
  14626. exports.filterHash = filterHash;
  14627. exports.findDirectChildren = findDirectChildren;
  14628. exports.findElements = findElements;
  14629. exports.flexibleCompare = flexibleCompare;
  14630. exports.flushToDom = flushToDom;
  14631. exports.formatDate = formatDate;
  14632. exports.formatDayString = formatDayString;
  14633. exports.formatIsoTimeString = formatIsoTimeString;
  14634. exports.formatRange = formatRange;
  14635. exports.getAllowYScrolling = getAllowYScrolling;
  14636. exports.getCanVGrowWithinCell = getCanVGrowWithinCell;
  14637. exports.getClippingParents = getClippingParents;
  14638. exports.getDateMeta = getDateMeta;
  14639. exports.getDayClassNames = getDayClassNames;
  14640. exports.getDefaultEventEnd = getDefaultEventEnd;
  14641. exports.getElRoot = getElRoot;
  14642. exports.getElSeg = getElSeg;
  14643. exports.getEntrySpanEnd = getEntrySpanEnd;
  14644. exports.getEventClassNames = getEventClassNames;
  14645. exports.getEventTargetViaRoot = getEventTargetViaRoot;
  14646. exports.getIsRtlScrollbarOnLeft = getIsRtlScrollbarOnLeft;
  14647. exports.getRectCenter = getRectCenter;
  14648. exports.getRelevantEvents = getRelevantEvents;
  14649. exports.getScrollGridClassNames = getScrollGridClassNames;
  14650. exports.getScrollbarWidths = getScrollbarWidths;
  14651. exports.getSectionClassNames = getSectionClassNames;
  14652. exports.getSectionHasLiquidHeight = getSectionHasLiquidHeight;
  14653. exports.getSegAnchorAttrs = getSegAnchorAttrs;
  14654. exports.getSegMeta = getSegMeta;
  14655. exports.getSlotClassNames = getSlotClassNames;
  14656. exports.getStickyFooterScrollbar = getStickyFooterScrollbar;
  14657. exports.getStickyHeaderDates = getStickyHeaderDates;
  14658. exports.getUnequalProps = getUnequalProps;
  14659. exports.getUniqueDomId = getUniqueDomId;
  14660. exports.globalLocales = globalLocales;
  14661. exports.globalPlugins = globalPlugins;
  14662. exports.greatestDurationDenominator = greatestDurationDenominator;
  14663. exports.groupIntersectingEntries = groupIntersectingEntries;
  14664. exports.guid = guid;
  14665. exports.hasBgRendering = hasBgRendering;
  14666. exports.hasShrinkWidth = hasShrinkWidth;
  14667. exports.identity = identity;
  14668. exports.interactionSettingsStore = interactionSettingsStore;
  14669. exports.interactionSettingsToStore = interactionSettingsToStore;
  14670. exports.intersectRanges = intersectRanges;
  14671. exports.intersectRects = intersectRects;
  14672. exports.intersectSpans = intersectSpans;
  14673. exports.isArraysEqual = isArraysEqual;
  14674. exports.isColPropsEqual = isColPropsEqual;
  14675. exports.isDateSelectionValid = isDateSelectionValid;
  14676. exports.isDateSpansEqual = isDateSpansEqual;
  14677. exports.isInt = isInt;
  14678. exports.isInteractionValid = isInteractionValid;
  14679. exports.isMultiDayRange = isMultiDayRange;
  14680. exports.isPropsEqual = isPropsEqual;
  14681. exports.isPropsValid = isPropsValid;
  14682. exports.isValidDate = isValidDate;
  14683. exports.joinSpans = joinSpans;
  14684. exports.listenBySelector = listenBySelector;
  14685. exports.mapHash = mapHash;
  14686. exports.memoize = memoize;
  14687. exports.memoizeArraylike = memoizeArraylike;
  14688. exports.memoizeHashlike = memoizeHashlike;
  14689. exports.memoizeObjArg = memoizeObjArg;
  14690. exports.mergeEventStores = mergeEventStores;
  14691. exports.multiplyDuration = multiplyDuration;
  14692. exports.padStart = padStart;
  14693. exports.parseBusinessHours = parseBusinessHours;
  14694. exports.parseClassNames = parseClassNames;
  14695. exports.parseDragMeta = parseDragMeta;
  14696. exports.parseEventDef = parseEventDef;
  14697. exports.parseFieldSpecs = parseFieldSpecs;
  14698. exports.parseMarker = parse;
  14699. exports.pointInsideRect = pointInsideRect;
  14700. exports.preventContextMenu = preventContextMenu;
  14701. exports.preventDefault = preventDefault;
  14702. exports.preventSelection = preventSelection;
  14703. exports.rangeContainsMarker = rangeContainsMarker;
  14704. exports.rangeContainsRange = rangeContainsRange;
  14705. exports.rangesEqual = rangesEqual;
  14706. exports.rangesIntersect = rangesIntersect;
  14707. exports.refineEventDef = refineEventDef;
  14708. exports.refineProps = refineProps;
  14709. exports.removeElement = removeElement;
  14710. exports.removeExact = removeExact;
  14711. exports.render = render;
  14712. exports.renderChunkContent = renderChunkContent;
  14713. exports.renderFill = renderFill;
  14714. exports.renderMicroColGroup = renderMicroColGroup;
  14715. exports.renderScrollShim = renderScrollShim;
  14716. exports.requestJson = requestJson;
  14717. exports.sanitizeShrinkWidth = sanitizeShrinkWidth;
  14718. exports.setElSeg = setElSeg;
  14719. exports.setRef = setRef;
  14720. exports.sliceEventStore = sliceEventStore;
  14721. exports.sliceEvents = sliceEvents;
  14722. exports.sortEventSegs = sortEventSegs;
  14723. exports.startOfDay = startOfDay;
  14724. exports.translateRect = translateRect;
  14725. exports.triggerDateSelect = triggerDateSelect;
  14726. exports.unmountComponentAtNode = unmountComponentAtNode;
  14727. exports.unpromisify = unpromisify;
  14728. exports.version = version;
  14729. exports.whenTransitionDone = whenTransitionDone;
  14730. exports.wholeDivideDurations = wholeDivideDurations;
  14731. Object.defineProperty(exports, '__esModule', { value: true });
  14732. return exports;
  14733. }({}));