fullcalendar.js 681 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775
  1. /*!
  2. FullCalendar Standard Bundle v6.1.17
  3. Docs & License: https://fullcalendar.io/docs/initialize-globals
  4. (c) 2024 Adam Shaw
  5. */
  6. var FullCalendar = (function (exports) {
  7. 'use strict';
  8. var n,l$1,u$1,i$1,t,r$1,o,f$1,e$1,c$1={},s=[],a$1=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i;function h(n,l){for(var u in l)n[u]=l[u];return n}function v$1(n){var l=n.parentNode;l&&l.removeChild(n);}function y(l,u,i){var t,r,o,f={};for(o in u)"key"==o?t=u[o]:"ref"==o?r=u[o]:f[o]=u[o];if(arguments.length>2&&(f.children=arguments.length>3?n.call(arguments,2):i),"function"==typeof l&&null!=l.defaultProps)for(o in l.defaultProps)void 0===f[o]&&(f[o]=l.defaultProps[o]);return p(l,f,t,r,null)}function p(n,i,t,r,o){var f={type:n,props:i,key:t,ref:r,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,__h:null,constructor:void 0,__v:null==o?++u$1:o};return null==o&&null!=l$1.vnode&&l$1.vnode(f),f}function d(){return {current:null}}function _(n){return n.children}function k$1(n,l,u,i,t){var r;for(r in u)"children"===r||"key"===r||r in l||g$2(n,r,null,u[r],i);for(r in l)t&&"function"!=typeof l[r]||"children"===r||"key"===r||"value"===r||"checked"===r||u[r]===l[r]||g$2(n,r,l[r],u[r],i);}function b$1(n,l,u){"-"===l[0]?n.setProperty(l,null==u?"":u):n[l]=null==u?"":"number"!=typeof u||a$1.test(l)?u:u+"px";}function g$2(n,l,u,i,t){var r;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||b$1(n.style,l,"");if(u)for(l in u)i&&u[l]===i[l]||b$1(n.style,l,u[l]);}else if("o"===l[0]&&"n"===l[1])r=l!==(l=l.replace(/Capture$/,"")),l=l.toLowerCase()in n?l.toLowerCase().slice(2):l.slice(2),n.l||(n.l={}),n.l[l+r]=u,u?i||n.addEventListener(l,r?w$2:m$1,r):n.removeEventListener(l,r?w$2:m$1,r);else if("dangerouslySetInnerHTML"!==l){if(t)l=l.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if("width"!==l&&"height"!==l&&"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&&-1==l.indexOf("-")?n.removeAttribute(l):n.setAttribute(l,u));}}function m$1(n){t=!0;try{return this.l[n.type+!1](l$1.event?l$1.event(n):n)}finally{t=!1;}}function w$2(n){t=!0;try{return this.l[n.type+!0](l$1.event?l$1.event(n):n)}finally{t=!1;}}function x$1(n,l){this.props=n,this.context=l;}function A(n,l){if(null==l)return n.__?A(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?A(n):null}function P$1(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 P$1(n)}}function C$1(n){t?setTimeout(n):f$1(n);}function T$1(n){(!n.__d&&(n.__d=!0)&&r$1.push(n)&&!$$1.__r++||o!==l$1.debounceRendering)&&((o=l$1.debounceRendering)||C$1)($$1);}function $$1(){var n,l,u,i,t,o,f,e;for(r$1.sort(function(n,l){return n.__v.__b-l.__v.__b});n=r$1.shift();)n.__d&&(l=r$1.length,i=void 0,t=void 0,f=(o=(u=n).__v).__e,(e=u.__P)&&(i=[],(t=h({},o)).__v=o.__v+1,M(e,o,t,u.__n,void 0!==e.ownerSVGElement,null!=o.__h?[f]:null,i,null==f?A(o):f,o.__h),N(i,o),o.__e!=f&&P$1(o)),r$1.length>l&&r$1.sort(function(n,l){return n.__v.__b-l.__v.__b}));$$1.__r=0;}function H$1(n,l,u,i,t,r,o,f,e,a){var h,v,y,d,k,b,g,m=i&&i.__k||s,w=m.length;for(u.__k=[],h=0;h<l.length;h++)if(null!=(d=u.__k[h]=null==(d=l[h])||"boolean"==typeof d?null:"string"==typeof d||"number"==typeof d||"bigint"==typeof d?p(null,d,null,null,d):Array.isArray(d)?p(_,{children:d},null,null,null):d.__b>0?p(d.type,d.props,d.key,d.ref?d.ref:null,d.__v):d)){if(d.__=u,d.__b=u.__b+1,null===(y=m[h])||y&&d.key==y.key&&d.type===y.type)m[h]=void 0;else for(v=0;v<w;v++){if((y=m[v])&&d.key==y.key&&d.type===y.type){m[v]=void 0;break}y=null;}M(n,d,y=y||c$1,t,r,o,f,e,a),k=d.__e,(v=d.ref)&&y.ref!=v&&(g||(g=[]),y.ref&&g.push(y.ref,null,d),g.push(v,d.__c||k,d)),null!=k?(null==b&&(b=k),"function"==typeof d.type&&d.__k===y.__k?d.__d=e=I$1(d,e,n):e=z$1(n,d,y,m,k,e),"function"==typeof u.type&&(u.__d=e)):e&&y.__e==e&&e.parentNode!=n&&(e=A(y));}for(u.__e=b,h=w;h--;)null!=m[h]&&("function"==typeof u.type&&null!=m[h].__e&&m[h].__e==u.__d&&(u.__d=L$1(i).nextSibling),q(m[h],m[h]));if(g)for(h=0;h<g.length;h++)S(g[h],g[++h],g[++h]);}function I$1(n,l,u){for(var i,t=n.__k,r=0;t&&r<t.length;r++)(i=t[r])&&(i.__=n,l="function"==typeof i.type?I$1(i,l,u):z$1(u,i,i,t,i.__e,l));return l}function j$2(n,l){return l=l||[],null==n||"boolean"==typeof n||(Array.isArray(n)?n.some(function(n){j$2(n,l);}):l.push(n)),l}function z$1(n,l,u,i,t,r){var o,f,e;if(void 0!==l.__d)o=l.__d,l.__d=void 0;else if(null==u||t!=r||null==t.parentNode)n:if(null==r||r.parentNode!==n)n.appendChild(t),o=null;else {for(f=r,e=0;(f=f.nextSibling)&&e<i.length;e+=1)if(f==t)break n;n.insertBefore(t,r),o=r;}return void 0!==o?o:t.nextSibling}function L$1(n){var l,u,i;if(null==n.type||"string"==typeof n.type)return n.__e;if(n.__k)for(l=n.__k.length-1;l>=0;l--)if((u=n.__k[l])&&(i=L$1(u)))return i;return null}function M(n,u,i,t,r,o,f,e,c){var s,a,v,y,p,d,k,b,g,m,w,A,P,C,T,$=u.type;if(void 0!==u.constructor)return null;null!=i.__h&&(c=i.__h,e=u.__e=i.__e,u.__h=null,o=[e]),(s=l$1.__b)&&s(u);try{n:if("function"==typeof $){if(b=u.props,g=(s=$.contextType)&&t[s.__c],m=s?g?g.props.value:s.__:t,i.__c?k=(a=u.__c=i.__c).__=a.__E:("prototype"in $&&$.prototype.render?u.__c=a=new $(b,m):(u.__c=a=new x$1(b,m),a.constructor=$,a.render=B$1),g&&g.sub(a),a.props=b,a.state||(a.state={}),a.context=m,a.__n=t,v=a.__d=!0,a.__h=[],a._sb=[]),null==a.__s&&(a.__s=a.state),null!=$.getDerivedStateFromProps&&(a.__s==a.state&&(a.__s=h({},a.__s)),h(a.__s,$.getDerivedStateFromProps(b,a.__s))),y=a.props,p=a.state,a.__v=u,v)null==$.getDerivedStateFromProps&&null!=a.componentWillMount&&a.componentWillMount(),null!=a.componentDidMount&&a.__h.push(a.componentDidMount);else {if(null==$.getDerivedStateFromProps&&b!==y&&null!=a.componentWillReceiveProps&&a.componentWillReceiveProps(b,m),!a.__e&&null!=a.shouldComponentUpdate&&!1===a.shouldComponentUpdate(b,a.__s,m)||u.__v===i.__v){for(u.__v!==i.__v&&(a.props=b,a.state=a.__s,a.__d=!1),u.__e=i.__e,u.__k=i.__k,u.__k.forEach(function(n){n&&(n.__=u);}),w=0;w<a._sb.length;w++)a.__h.push(a._sb[w]);a._sb=[],a.__h.length&&f.push(a);break n}null!=a.componentWillUpdate&&a.componentWillUpdate(b,a.__s,m),null!=a.componentDidUpdate&&a.__h.push(function(){a.componentDidUpdate(y,p,d);});}if(a.context=m,a.props=b,a.__P=n,A=l$1.__r,P=0,"prototype"in $&&$.prototype.render){for(a.state=a.__s,a.__d=!1,A&&A(u),s=a.render(a.props,a.state,a.context),C=0;C<a._sb.length;C++)a.__h.push(a._sb[C]);a._sb=[];}else do{a.__d=!1,A&&A(u),s=a.render(a.props,a.state,a.context),a.state=a.__s;}while(a.__d&&++P<25);a.state=a.__s,null!=a.getChildContext&&(t=h(h({},t),a.getChildContext())),v||null==a.getSnapshotBeforeUpdate||(d=a.getSnapshotBeforeUpdate(y,p)),T=null!=s&&s.type===_&&null==s.key?s.props.children:s,H$1(n,Array.isArray(T)?T:[T],u,i,t,r,o,f,e,c),a.base=u.__e,u.__h=null,a.__h.length&&f.push(a),k&&(a.__E=a.__=null),a.__e=!1;}else null==o&&u.__v===i.__v?(u.__k=i.__k,u.__e=i.__e):u.__e=O(i.__e,u,i,t,r,o,f,c);(s=l$1.diffed)&&s(u);}catch(n){u.__v=null,(c||null!=o)&&(u.__e=e,u.__h=!!c,o[o.indexOf(e)]=null),l$1.__e(n,u,i);}}function N(n,u){l$1.__c&&l$1.__c(u,n),n.some(function(u){try{n=u.__h,u.__h=[],n.some(function(n){n.call(u);});}catch(n){l$1.__e(n,u.__v);}});}function O(l,u,i,t,r,o,f,e){var s,a,h,y=i.props,p=u.props,d=u.type,_=0;if("svg"===d&&(r=!0),null!=o)for(;_<o.length;_++)if((s=o[_])&&"setAttribute"in s==!!d&&(d?s.localName===d:3===s.nodeType)){l=s,o[_]=null;break}if(null==l){if(null===d)return document.createTextNode(p);l=r?document.createElementNS("http://www.w3.org/2000/svg",d):document.createElement(d,p.is&&p),o=null,e=!1;}if(null===d)y===p||e&&l.data===p||(l.data=p);else {if(o=o&&n.call(l.childNodes),a=(y=i.props||c$1).dangerouslySetInnerHTML,h=p.dangerouslySetInnerHTML,!e){if(null!=o)for(y={},_=0;_<l.attributes.length;_++)y[l.attributes[_].name]=l.attributes[_].value;(h||a)&&(h&&(a&&h.__html==a.__html||h.__html===l.innerHTML)||(l.innerHTML=h&&h.__html||""));}if(k$1(l,p,y,r,e),h)u.__k=[];else if(_=u.props.children,H$1(l,Array.isArray(_)?_:[_],u,i,t,r&&"foreignObject"!==d,o,f,o?o[0]:i.__k&&A(i,0),e),null!=o)for(_=o.length;_--;)null!=o[_]&&v$1(o[_]);e||("value"in p&&void 0!==(_=p.value)&&(_!==l.value||"progress"===d&&!_||"option"===d&&_!==y.value)&&g$2(l,"value",_,y.value,!1),"checked"in p&&void 0!==(_=p.checked)&&_!==l.checked&&g$2(l,"checked",_,y.checked,!1));}return l}function S(n,u,i){try{"function"==typeof n?n(u):n.current=u;}catch(n){l$1.__e(n,i);}}function q(n,u,i){var t,r;if(l$1.unmount&&l$1.unmount(n),(t=n.ref)&&(t.current&&t.current!==n.__e||S(t,null,u)),null!=(t=n.__c)){if(t.componentWillUnmount)try{t.componentWillUnmount();}catch(n){l$1.__e(n,u);}t.base=t.__P=null,n.__c=void 0;}if(t=n.__k)for(r=0;r<t.length;r++)t[r]&&q(t[r],u,i||"function"!=typeof n.type);i||null==n.__e||v$1(n.__e),n.__=n.__e=n.__d=void 0;}function B$1(n,l,u){return this.constructor(n,u)}function D$1(u,i,t){var r,o,f;l$1.__&&l$1.__(u,i),o=(r="function"==typeof t)?null:t&&t.__k||i.__k,f=[],M(i,u=(!r&&t||i).__k=y(_,null,[u]),o||c$1,c$1,void 0!==i.ownerSVGElement,!r&&t?[t]:o?null:i.firstChild?n.call(i.childNodes):null,f,!r&&t?t:o?o.__e:i.firstChild,r),N(f,u);}function E(n,l){D$1(n,l,E);}function F$1(l,u,i){var t,r,o,f=h({},l.props);for(o in u)"key"==o?t=u[o]:"ref"==o?r=u[o]:f[o]=u[o];return arguments.length>2&&(f.children=arguments.length>3?n.call(arguments,2):i),p(l.type,f,t||l.key,r||l.ref,null)}function G$1(n,l){var u={__c:l="__cC"+e$1++,__: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(function(n){n.__e=!0,T$1(n);});},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=s.slice,l$1={__e:function(n,l,u,i){for(var t,r,o;l=l.__;)if((t=l.__c)&&!t.__)try{if((r=t.constructor)&&null!=r.getDerivedStateFromError&&(t.setState(r.getDerivedStateFromError(n)),o=t.__d),null!=t.componentDidCatch&&(t.componentDidCatch(n,i||{}),o=t.__d),o)return t.__E=t}catch(l){n=l;}throw n}},u$1=0,i$1=function(n){return null!=n&&void 0===n.constructor},t=!1,x$1.prototype.setState=function(n,l){var u;u=null!=this.__s&&this.__s!==this.state?this.__s:this.__s=h({},this.state),"function"==typeof n&&(n=n(h({},u),this.props)),n&&h(u,n),null!=n&&this.__v&&(l&&this._sb.push(l),T$1(this));},x$1.prototype.forceUpdate=function(n){this.__v&&(this.__e=!0,n&&this.__h.push(n),T$1(this));},x$1.prototype.render=_,r$1=[],f$1="function"==typeof Promise?Promise.prototype.then.bind(Promise.resolve()):setTimeout,$$1.__r=0,e$1=0;
  9. var r,u,i,f=[],c=[],e=l$1.__b,a=l$1.__r,v=l$1.diffed,l=l$1.__c,m=l$1.unmount;function b(){for(var t;t=f.shift();)if(t.__P&&t.__H)try{t.__H.__h.forEach(k),t.__H.__h.forEach(w$1),t.__H.__h=[];}catch(r){t.__H.__h=[],l$1.__e(r,t.__v);}}l$1.__b=function(n){r=null,e&&e(n);},l$1.__r=function(n){a&&a(n);var i=(r=n.__c).__H;i&&(u===r?(i.__h=[],r.__h=[],i.__.forEach(function(n){n.__N&&(n.__=n.__N),n.__V=c,n.__N=n.i=void 0;})):(i.__h.forEach(k),i.__h.forEach(w$1),i.__h=[])),u=r;},l$1.diffed=function(t){v&&v(t);var o=t.__c;o&&o.__H&&(o.__H.__h.length&&(1!==f.push(o)&&i===l$1.requestAnimationFrame||((i=l$1.requestAnimationFrame)||j$1)(b)),o.__H.__.forEach(function(n){n.i&&(n.__H=n.i),n.__V!==c&&(n.__=n.__V),n.i=void 0,n.__V=c;})),u=r=null;},l$1.__c=function(t,r){r.some(function(t){try{t.__h.forEach(k),t.__h=t.__h.filter(function(n){return !n.__||w$1(n)});}catch(u){r.some(function(n){n.__h&&(n.__h=[]);}),r=[],l$1.__e(u,t.__v);}}),l&&l(t,r);},l$1.unmount=function(t){m&&m(t);var r,u=t.__c;u&&u.__H&&(u.__H.__.forEach(function(n){try{k(n);}catch(n){r=n;}}),u.__H=void 0,r&&l$1.__e(r,u.__v));};var g$1="function"==typeof requestAnimationFrame;function j$1(n){var t,r=function(){clearTimeout(u),g$1&&cancelAnimationFrame(t),setTimeout(n);},u=setTimeout(r,100);g$1&&(t=requestAnimationFrame(r));}function k(n){var t=r,u=n.__c;"function"==typeof u&&(n.__c=void 0,u()),r=t;}function w$1(n){var t=r;n.__c=n.__(),r=t;}
  10. function g(n,t){for(var e in t)n[e]=t[e];return n}function C(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 w(n){this.props=n;}(w.prototype=new x$1).isPureReactComponent=!0,w.prototype.shouldComponentUpdate=function(n,t){return C(this.props,n)||C(this.state,t)};var x=l$1.__b;l$1.__b=function(n){n.type&&n.type.__f&&n.ref&&(n.props.ref=n.ref,n.ref=null),x&&x(n);};var T=l$1.__e;l$1.__e=function(n,t,e,r){if(n.then)for(var u,o=t;o=o.__;)if((u=o.__c)&&u.__c)return null==t.__e&&(t.__e=e.__e,t.__k=e.__k),u.__c(n,t);T(n,t,e,r);};var I=l$1.unmount;function L(n,t,e){return n&&(n.__c&&n.__c.__H&&(n.__c.__H.__.forEach(function(n){"function"==typeof n.__c&&n.__c();}),n.__c.__H=null),null!=(n=g({},n)).__c&&(n.__c.__P===e&&(n.__c.__P=t),n.__c=null),n.__k=n.__k&&n.__k.map(function(n){return L(n,t,e)})),n}function U(n,t,e){return n&&(n.__v=null,n.__k=n.__k&&n.__k.map(function(n){return U(n,t,e)}),n.__c&&n.__c.__P===t&&(n.__e&&e.insertBefore(n.__e,n.__d),n.__c.__e=!0,n.__c.__P=e)),n}function D(){this.__u=0,this.t=null,this.__b=null;}function F(n){var t=n.__.__c;return t&&t.__a&&t.__a(n)}function V(){this.u=null,this.o=null;}l$1.unmount=function(n){var t=n.__c;t&&t.__R&&t.__R(),t&&!0===n.__h&&(n.type=null),I&&I(n);},(D.prototype=new x$1).__c=function(n,t){var e=t.__c,r=this;null==r.t&&(r.t=[]),r.t.push(e);var u=F(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.__a){var n=r.state.__a;r.__v.__k[0]=U(n,n.__c.__P,n.__c.__O);}var t;for(r.setState({__a:r.__b=null});t=r.t.pop();)t.forceUpdate();}},c=!0===t.__h;r.__u++||c||r.setState({__a:r.__b=r.__v.__k[0]}),n.then(i,i);},D.prototype.componentWillUnmount=function(){this.t=[];},D.prototype.render=function(n,e){if(this.__b){if(this.__v.__k){var r=document.createElement("div"),o=this.__v.__k[0].__c;this.__v.__k[0]=L(this.__b,r,o.__O=o.__P);}this.__b=null;}var i=e.__a&&y(_,null,n.fallback);return i&&(i.__h=null),[y(_,null,e.__a?null:n.children),i]};var W=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 P(n){return this.getChildContext=function(){return n.context},n.children}function $(n){var e=this,r=n.i;e.componentWillUnmount=function(){D$1(null,e.l),e.l=null,e.i=null;},e.i&&e.i!==r&&e.componentWillUnmount(),n.__v?(e.l||(e.i=r,e.l={nodeType:1,parentNode:r,childNodes:[],appendChild:function(n){this.childNodes.push(n),e.i.appendChild(n);},insertBefore:function(n,t){this.childNodes.push(n),e.i.appendChild(n);},removeChild:function(n){this.childNodes.splice(this.childNodes.indexOf(n)>>>1,1),e.i.removeChild(n);}}),D$1(y(P,{context:e.context},n.__v),e.l)):e.l&&e.componentWillUnmount();}function j(n,e){var r=y($,{__v:n,i:e});return r.containerInfo=e,r}(V.prototype=new x$1).__a=function(n){var t=this,e=F(t.__v),r=t.o.get(n);return r[0]++,function(u){var o=function(){t.props.revealOrder?(r.push(u),W(t,n,r)):u();};e?e(o):o();}},V.prototype.render=function(n){this.u=null,this.o=new Map;var t=j$2(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},V.prototype.componentDidUpdate=V.prototype.componentDidMount=function(){var n=this;this.o.forEach(function(t,e){W(n,e,t);});};var z="undefined"!=typeof Symbol&&Symbol.for&&Symbol.for("react.element")||60103,B=/^(?:accent|alignment|arabic|baseline|cap|clip(?!PathU)|color|dominant|fill|flood|font|glyph(?!R)|horiz|image|letter|lighting|marker(?!H|W|U)|overline|paint|pointer|shape|stop|strikethrough|stroke|text(?!L)|transform|underline|unicode|units|v|vector|vert|word|writing|x(?!C))[A-Z]/,H="undefined"!=typeof document,Z=function(n){return ("undefined"!=typeof Symbol&&"symbol"==typeof Symbol()?/fil|che|rad/i:/fil|che|ra/i).test(n)};x$1.prototype.isReactComponent={},["componentWillMount","componentWillReceiveProps","componentWillUpdate"].forEach(function(t){Object.defineProperty(x$1.prototype,t,{configurable:!0,get:function(){return this["UNSAFE_"+t]},set:function(n){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:n});}});});var G=l$1.event;function J(){}function K(){return this.cancelBubble}function Q(){return this.defaultPrevented}l$1.event=function(n){return G&&(n=G(n)),n.persist=J,n.isPropagationStopped=K,n.isDefaultPrevented=Q,n.nativeEvent=n};var nn={configurable:!0,get:function(){return this.class}},tn=l$1.vnode;l$1.vnode=function(n){var t=n.type,e=n.props,u=e;if("string"==typeof t){var o=-1===t.indexOf("-");for(var i in u={},e){var l=e[i];H&&"children"===i&&"noscript"===t||"value"===i&&"defaultValue"in e&&null==l||("defaultValue"===i&&"value"in e&&null==e.value?i="value":"download"===i&&!0===l?l="":/ondoubleclick/i.test(i)?i="ondblclick":/^onchange(textarea|input)/i.test(i+t)&&!Z(e.type)?i="oninput":/^onfocus$/i.test(i)?i="onfocusin":/^onblur$/i.test(i)?i="onfocusout":/^on(Ani|Tra|Tou|BeforeInp|Compo)/.test(i)?i=i.toLowerCase():o&&B.test(i)?i=i.replace(/[A-Z0-9]/g,"-$&").toLowerCase():null===l&&(l=void 0),/^oninput$/i.test(i)&&(i=i.toLowerCase(),u[i]&&(i="oninputCapture")),u[i]=l);}"select"==t&&u.multiple&&Array.isArray(u.value)&&(u.value=j$2(e.children).forEach(function(n){n.props.selected=-1!=u.value.indexOf(n.props.value);})),"select"==t&&null!=u.defaultValue&&(u.value=j$2(e.children).forEach(function(n){n.props.selected=u.multiple?-1!=u.defaultValue.indexOf(n.props.value):u.defaultValue==n.props.value;})),n.props=u,e.class!=e.className&&(nn.enumerable="className"in e,null!=e.className&&(u.class=e.className),Object.defineProperty(u,"className",nn));}n.$$typeof=z,tn&&tn(n);};var en=l$1.__r;l$1.__r=function(n){en&&en(n),n.__c;};
  11. const styleTexts = [];
  12. const styleEls = new Map();
  13. function injectStyles(styleText) {
  14. styleTexts.push(styleText);
  15. styleEls.forEach((styleEl) => {
  16. appendStylesTo(styleEl, styleText);
  17. });
  18. }
  19. function ensureElHasStyles(el) {
  20. if (el.isConnected && // sometimes true if SSR system simulates DOM
  21. el.getRootNode // sometimes undefined if SSR system simulates DOM
  22. ) {
  23. registerStylesRoot(el.getRootNode());
  24. }
  25. }
  26. function registerStylesRoot(rootNode) {
  27. let styleEl = styleEls.get(rootNode);
  28. if (!styleEl || !styleEl.isConnected) {
  29. styleEl = rootNode.querySelector('style[data-fullcalendar]');
  30. if (!styleEl) {
  31. styleEl = document.createElement('style');
  32. styleEl.setAttribute('data-fullcalendar', '');
  33. const nonce = getNonceValue();
  34. if (nonce) {
  35. styleEl.nonce = nonce;
  36. }
  37. const parentEl = rootNode === document ? document.head : rootNode;
  38. const insertBefore = rootNode === document
  39. ? parentEl.querySelector('script,link[rel=stylesheet],link[as=style],style')
  40. : parentEl.firstChild;
  41. parentEl.insertBefore(styleEl, insertBefore);
  42. }
  43. styleEls.set(rootNode, styleEl);
  44. hydrateStylesRoot(styleEl);
  45. }
  46. }
  47. function hydrateStylesRoot(styleEl) {
  48. for (const styleText of styleTexts) {
  49. appendStylesTo(styleEl, styleText);
  50. }
  51. }
  52. function appendStylesTo(styleEl, styleText) {
  53. const { sheet } = styleEl;
  54. const ruleCnt = sheet.cssRules.length;
  55. styleText.split('}').forEach((styleStr, i) => {
  56. styleStr = styleStr.trim();
  57. if (styleStr) {
  58. sheet.insertRule(styleStr + '}', ruleCnt + i);
  59. }
  60. });
  61. }
  62. // nonce
  63. // -------------------------------------------------------------------------------------------------
  64. let queriedNonceValue;
  65. function getNonceValue() {
  66. if (queriedNonceValue === undefined) {
  67. queriedNonceValue = queryNonceValue();
  68. }
  69. return queriedNonceValue;
  70. }
  71. /*
  72. TODO: discourage meta tag and instead put nonce attribute on placeholder <style> tag
  73. */
  74. function queryNonceValue() {
  75. const metaWithNonce = document.querySelector('meta[name="csp-nonce"]');
  76. if (metaWithNonce && metaWithNonce.hasAttribute('content')) {
  77. return metaWithNonce.getAttribute('content');
  78. }
  79. const elWithNonce = document.querySelector('script[nonce]');
  80. if (elWithNonce) {
  81. return elWithNonce.nonce || '';
  82. }
  83. return '';
  84. }
  85. // main
  86. // -------------------------------------------------------------------------------------------------
  87. if (typeof document !== 'undefined') {
  88. registerStylesRoot(document);
  89. }
  90. var css_248z$4 = ":root{--fc-small-font-size:.85em;--fc-page-bg-color:#fff;--fc-neutral-bg-color:hsla(0,0%,82%,.3);--fc-neutral-text-color:grey;--fc-border-color:#ddd;--fc-button-text-color:#fff;--fc-button-bg-color:#2c3e50;--fc-button-border-color:#2c3e50;--fc-button-hover-bg-color:#1e2b37;--fc-button-hover-border-color:#1a252f;--fc-button-active-bg-color:#1a252f;--fc-button-active-border-color:#151e27;--fc-event-bg-color:#3788d8;--fc-event-border-color:#3788d8;--fc-event-text-color:#fff;--fc-event-selected-overlay-color:rgba(0,0,0,.25);--fc-more-link-bg-color:#d0d0d0;--fc-more-link-text-color:inherit;--fc-event-resizer-thickness:8px;--fc-event-resizer-dot-total-width:8px;--fc-event-resizer-dot-border-width:1px;--fc-non-business-color:hsla(0,0%,84%,.3);--fc-bg-event-color:#8fdf82;--fc-bg-event-opacity:0.3;--fc-highlight-color:rgba(188,232,241,.3);--fc-today-bg-color:rgba(255,220,40,.15);--fc-now-indicator-color:red}.fc-not-allowed,.fc-not-allowed .fc-event{cursor:not-allowed}.fc{display:flex;flex-direction:column;font-size:1em}.fc,.fc *,.fc :after,.fc :before{box-sizing:border-box}.fc table{border-collapse:collapse;border-spacing:0;font-size:1em}.fc th{text-align:center}.fc td,.fc th{padding:0;vertical-align:top}.fc a[data-navlink]{cursor:pointer}.fc a[data-navlink]:hover{text-decoration:underline}.fc-direction-ltr{direction:ltr;text-align:left}.fc-direction-rtl{direction:rtl;text-align:right}.fc-theme-standard td,.fc-theme-standard th{border:1px solid var(--fc-border-color)}.fc-liquid-hack td,.fc-liquid-hack th{position:relative}@font-face{font-family:fcicons;font-style:normal;font-weight:400;src:url(\"data:application/x-font-ttf;charset=utf-8;base64,AAEAAAALAIAAAwAwT1MvMg8SBfAAAAC8AAAAYGNtYXAXVtKNAAABHAAAAFRnYXNwAAAAEAAAAXAAAAAIZ2x5ZgYydxIAAAF4AAAFNGhlYWQUJ7cIAAAGrAAAADZoaGVhB20DzAAABuQAAAAkaG10eCIABhQAAAcIAAAALGxvY2ED4AU6AAAHNAAAABhtYXhwAA8AjAAAB0wAAAAgbmFtZXsr690AAAdsAAABhnBvc3QAAwAAAAAI9AAAACAAAwPAAZAABQAAApkCzAAAAI8CmQLMAAAB6wAzAQkAAAAAAAAAAAAAAAAAAAABEAAAAAAAAAAAAAAAAAAAAABAAADpBgPA/8AAQAPAAEAAAAABAAAAAAAAAAAAAAAgAAAAAAADAAAAAwAAABwAAQADAAAAHAADAAEAAAAcAAQAOAAAAAoACAACAAIAAQAg6Qb//f//AAAAAAAg6QD//f//AAH/4xcEAAMAAQAAAAAAAAAAAAAAAQAB//8ADwABAAAAAAAAAAAAAgAANzkBAAAAAAEAAAAAAAAAAAACAAA3OQEAAAAAAQAAAAAAAAAAAAIAADc5AQAAAAABAWIAjQKeAskAEwAAJSc3NjQnJiIHAQYUFwEWMjc2NCcCnuLiDQ0MJAz/AA0NAQAMJAwNDcni4gwjDQwM/wANIwz/AA0NDCMNAAAAAQFiAI0CngLJABMAACUBNjQnASYiBwYUHwEHBhQXFjI3AZ4BAA0N/wAMJAwNDeLiDQ0MJAyNAQAMIw0BAAwMDSMM4uINIwwNDQAAAAIA4gC3Ax4CngATACcAACUnNzY0JyYiDwEGFB8BFjI3NjQnISc3NjQnJiIPAQYUHwEWMjc2NCcB87e3DQ0MIw3VDQ3VDSMMDQ0BK7e3DQ0MJAzVDQ3VDCQMDQ3zuLcMJAwNDdUNIwzWDAwNIwy4twwkDA0N1Q0jDNYMDA0jDAAAAgDiALcDHgKeABMAJwAAJTc2NC8BJiIHBhQfAQcGFBcWMjchNzY0LwEmIgcGFB8BBwYUFxYyNwJJ1Q0N1Q0jDA0Nt7cNDQwjDf7V1Q0N1QwkDA0Nt7cNDQwkDLfWDCMN1Q0NDCQMt7gMIw0MDNYMIw3VDQ0MJAy3uAwjDQwMAAADAFUAAAOrA1UAMwBoAHcAABMiBgcOAQcOAQcOARURFBYXHgEXHgEXHgEzITI2Nz4BNz4BNz4BNRE0JicuAScuAScuASMFITIWFx4BFx4BFx4BFREUBgcOAQcOAQcOASMhIiYnLgEnLgEnLgE1ETQ2Nz4BNz4BNz4BMxMhMjY1NCYjISIGFRQWM9UNGAwLFQkJDgUFBQUFBQ4JCRULDBgNAlYNGAwLFQkJDgUFBQUFBQ4JCRULDBgN/aoCVgQIBAQHAwMFAQIBAQIBBQMDBwQECAT9qgQIBAQHAwMFAQIBAQIBBQMDBwQECASAAVYRGRkR/qoRGRkRA1UFBAUOCQkVDAsZDf2rDRkLDBUJCA4FBQUFBQUOCQgVDAsZDQJVDRkLDBUJCQ4FBAVVAgECBQMCBwQECAX9qwQJAwQHAwMFAQICAgIBBQMDBwQDCQQCVQUIBAQHAgMFAgEC/oAZEhEZGRESGQAAAAADAFUAAAOrA1UAMwBoAIkAABMiBgcOAQcOAQcOARURFBYXHgEXHgEXHgEzITI2Nz4BNz4BNz4BNRE0JicuAScuAScuASMFITIWFx4BFx4BFx4BFREUBgcOAQcOAQcOASMhIiYnLgEnLgEnLgE1ETQ2Nz4BNz4BNz4BMxMzFRQWMzI2PQEzMjY1NCYrATU0JiMiBh0BIyIGFRQWM9UNGAwLFQkJDgUFBQUFBQ4JCRULDBgNAlYNGAwLFQkJDgUFBQUFBQ4JCRULDBgN/aoCVgQIBAQHAwMFAQIBAQIBBQMDBwQECAT9qgQIBAQHAwMFAQIBAQIBBQMDBwQECASAgBkSEhmAERkZEYAZEhIZgBEZGREDVQUEBQ4JCRUMCxkN/asNGQsMFQkIDgUFBQUFBQ4JCBUMCxkNAlUNGQsMFQkJDgUEBVUCAQIFAwIHBAQIBf2rBAkDBAcDAwUBAgICAgEFAwMHBAMJBAJVBQgEBAcCAwUCAQL+gIASGRkSgBkSERmAEhkZEoAZERIZAAABAOIAjQMeAskAIAAAExcHBhQXFjI/ARcWMjc2NC8BNzY0JyYiDwEnJiIHBhQX4uLiDQ0MJAzi4gwkDA0N4uINDQwkDOLiDCQMDQ0CjeLiDSMMDQ3h4Q0NDCMN4uIMIw0MDOLiDAwNIwwAAAABAAAAAQAAa5n0y18PPPUACwQAAAAAANivOVsAAAAA2K85WwAAAAADqwNVAAAACAACAAAAAAAAAAEAAAPA/8AAAAQAAAAAAAOrAAEAAAAAAAAAAAAAAAAAAAALBAAAAAAAAAAAAAAAAgAAAAQAAWIEAAFiBAAA4gQAAOIEAABVBAAAVQQAAOIAAAAAAAoAFAAeAEQAagCqAOoBngJkApoAAQAAAAsAigADAAAAAAACAAAAAAAAAAAAAAAAAAAAAAAAAA4ArgABAAAAAAABAAcAAAABAAAAAAACAAcAYAABAAAAAAADAAcANgABAAAAAAAEAAcAdQABAAAAAAAFAAsAFQABAAAAAAAGAAcASwABAAAAAAAKABoAigADAAEECQABAA4ABwADAAEECQACAA4AZwADAAEECQADAA4APQADAAEECQAEAA4AfAADAAEECQAFABYAIAADAAEECQAGAA4AUgADAAEECQAKADQApGZjaWNvbnMAZgBjAGkAYwBvAG4Ac1ZlcnNpb24gMS4wAFYAZQByAHMAaQBvAG4AIAAxAC4AMGZjaWNvbnMAZgBjAGkAYwBvAG4Ac2ZjaWNvbnMAZgBjAGkAYwBvAG4Ac1JlZ3VsYXIAUgBlAGcAdQBsAGEAcmZjaWNvbnMAZgBjAGkAYwBvAG4Ac0ZvbnQgZ2VuZXJhdGVkIGJ5IEljb01vb24uAEYAbwBuAHQAIABnAGUAbgBlAHIAYQB0AGUAZAAgAGIAeQAgAEkAYwBvAE0AbwBvAG4ALgAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=\") format(\"truetype\")}.fc-icon{speak:none;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;display:inline-block;font-family:fcicons!important;font-style:normal;font-variant:normal;font-weight:400;height:1em;line-height:1;text-align:center;text-transform:none;-webkit-user-select:none;-moz-user-select:none;user-select:none;width:1em}.fc-icon-chevron-left:before{content:\"\\e900\"}.fc-icon-chevron-right:before{content:\"\\e901\"}.fc-icon-chevrons-left:before{content:\"\\e902\"}.fc-icon-chevrons-right:before{content:\"\\e903\"}.fc-icon-minus-square:before{content:\"\\e904\"}.fc-icon-plus-square:before{content:\"\\e905\"}.fc-icon-x:before{content:\"\\e906\"}.fc .fc-button{border-radius:0;font-family:inherit;font-size:inherit;line-height:inherit;margin:0;overflow:visible;text-transform:none}.fc .fc-button:focus{outline:1px dotted;outline:5px auto -webkit-focus-ring-color}.fc .fc-button{-webkit-appearance:button}.fc .fc-button:not(:disabled){cursor:pointer}.fc .fc-button{background-color:transparent;border:1px solid transparent;border-radius:.25em;display:inline-block;font-size:1em;font-weight:400;line-height:1.5;padding:.4em .65em;text-align:center;-webkit-user-select:none;-moz-user-select:none;user-select:none;vertical-align:middle}.fc .fc-button:hover{text-decoration:none}.fc .fc-button:focus{box-shadow:0 0 0 .2rem rgba(44,62,80,.25);outline:0}.fc .fc-button:disabled{opacity:.65}.fc .fc-button-primary{background-color:var(--fc-button-bg-color);border-color:var(--fc-button-border-color);color:var(--fc-button-text-color)}.fc .fc-button-primary:hover{background-color:var(--fc-button-hover-bg-color);border-color:var(--fc-button-hover-border-color);color:var(--fc-button-text-color)}.fc .fc-button-primary:disabled{background-color:var(--fc-button-bg-color);border-color:var(--fc-button-border-color);color:var(--fc-button-text-color)}.fc .fc-button-primary:focus{box-shadow:0 0 0 .2rem rgba(76,91,106,.5)}.fc .fc-button-primary:not(:disabled).fc-button-active,.fc .fc-button-primary:not(:disabled):active{background-color:var(--fc-button-active-bg-color);border-color:var(--fc-button-active-border-color);color:var(--fc-button-text-color)}.fc .fc-button-primary:not(:disabled).fc-button-active:focus,.fc .fc-button-primary:not(:disabled):active:focus{box-shadow:0 0 0 .2rem rgba(76,91,106,.5)}.fc .fc-button .fc-icon{font-size:1.5em;vertical-align:middle}.fc .fc-button-group{display:inline-flex;position:relative;vertical-align:middle}.fc .fc-button-group>.fc-button{flex:1 1 auto;position:relative}.fc .fc-button-group>.fc-button.fc-button-active,.fc .fc-button-group>.fc-button:active,.fc .fc-button-group>.fc-button:focus,.fc .fc-button-group>.fc-button:hover{z-index:1}.fc-direction-ltr .fc-button-group>.fc-button:not(:first-child){border-bottom-left-radius:0;border-top-left-radius:0;margin-left:-1px}.fc-direction-ltr .fc-button-group>.fc-button:not(:last-child){border-bottom-right-radius:0;border-top-right-radius:0}.fc-direction-rtl .fc-button-group>.fc-button:not(:first-child){border-bottom-right-radius:0;border-top-right-radius:0;margin-right:-1px}.fc-direction-rtl .fc-button-group>.fc-button:not(:last-child){border-bottom-left-radius:0;border-top-left-radius:0}.fc .fc-toolbar{align-items:center;display:flex;justify-content:space-between}.fc .fc-toolbar.fc-header-toolbar{margin-bottom:1.5em}.fc .fc-toolbar.fc-footer-toolbar{margin-top:1.5em}.fc .fc-toolbar-title{font-size:1.75em;margin:0}.fc-direction-ltr .fc-toolbar>*>:not(:first-child){margin-left:.75em}.fc-direction-rtl .fc-toolbar>*>:not(:first-child){margin-right:.75em}.fc-direction-rtl .fc-toolbar-ltr{flex-direction:row-reverse}.fc .fc-scroller{-webkit-overflow-scrolling:touch;position:relative}.fc .fc-scroller-liquid{height:100%}.fc .fc-scroller-liquid-absolute{bottom:0;left:0;position:absolute;right:0;top:0}.fc .fc-scroller-harness{direction:ltr;overflow:hidden;position:relative}.fc .fc-scroller-harness-liquid{height:100%}.fc-direction-rtl .fc-scroller-harness>.fc-scroller{direction:rtl}.fc-theme-standard .fc-scrollgrid{border:1px solid var(--fc-border-color)}.fc .fc-scrollgrid,.fc .fc-scrollgrid table{table-layout:fixed;width:100%}.fc .fc-scrollgrid table{border-left-style:hidden;border-right-style:hidden;border-top-style:hidden}.fc .fc-scrollgrid{border-bottom-width:0;border-collapse:separate;border-right-width:0}.fc .fc-scrollgrid-liquid{height:100%}.fc .fc-scrollgrid-section,.fc .fc-scrollgrid-section table,.fc .fc-scrollgrid-section>td{height:1px}.fc .fc-scrollgrid-section-liquid>td{height:100%}.fc .fc-scrollgrid-section>*{border-left-width:0;border-top-width:0}.fc .fc-scrollgrid-section-footer>*,.fc .fc-scrollgrid-section-header>*{border-bottom-width:0}.fc .fc-scrollgrid-section-body table,.fc .fc-scrollgrid-section-footer table{border-bottom-style:hidden}.fc .fc-scrollgrid-section-sticky>*{background:var(--fc-page-bg-color);position:sticky;z-index:3}.fc .fc-scrollgrid-section-header.fc-scrollgrid-section-sticky>*{top:0}.fc .fc-scrollgrid-section-footer.fc-scrollgrid-section-sticky>*{bottom:0}.fc .fc-scrollgrid-sticky-shim{height:1px;margin-bottom:-1px}.fc-sticky{position:sticky}.fc .fc-view-harness{flex-grow:1;position:relative}.fc .fc-view-harness-active>.fc-view{bottom:0;left:0;position:absolute;right:0;top:0}.fc .fc-col-header-cell-cushion{display:inline-block;padding:2px 4px}.fc .fc-bg-event,.fc .fc-highlight,.fc .fc-non-business{bottom:0;left:0;position:absolute;right:0;top:0}.fc .fc-non-business{background:var(--fc-non-business-color)}.fc .fc-bg-event{background:var(--fc-bg-event-color);opacity:var(--fc-bg-event-opacity)}.fc .fc-bg-event .fc-event-title{font-size:var(--fc-small-font-size);font-style:italic;margin:.5em}.fc .fc-highlight{background:var(--fc-highlight-color)}.fc .fc-cell-shaded,.fc .fc-day-disabled{background:var(--fc-neutral-bg-color)}a.fc-event,a.fc-event:hover{text-decoration:none}.fc-event.fc-event-draggable,.fc-event[href]{cursor:pointer}.fc-event .fc-event-main{position:relative;z-index:2}.fc-event-dragging:not(.fc-event-selected){opacity:.75}.fc-event-dragging.fc-event-selected{box-shadow:0 2px 7px rgba(0,0,0,.3)}.fc-event .fc-event-resizer{display:none;position:absolute;z-index:4}.fc-event-selected .fc-event-resizer,.fc-event:hover .fc-event-resizer{display:block}.fc-event-selected .fc-event-resizer{background:var(--fc-page-bg-color);border-color:inherit;border-radius:calc(var(--fc-event-resizer-dot-total-width)/2);border-style:solid;border-width:var(--fc-event-resizer-dot-border-width);height:var(--fc-event-resizer-dot-total-width);width:var(--fc-event-resizer-dot-total-width)}.fc-event-selected .fc-event-resizer:before{bottom:-20px;content:\"\";left:-20px;position:absolute;right:-20px;top:-20px}.fc-event-selected,.fc-event:focus{box-shadow:0 2px 5px rgba(0,0,0,.2)}.fc-event-selected:before,.fc-event:focus:before{bottom:0;content:\"\";left:0;position:absolute;right:0;top:0;z-index:3}.fc-event-selected:after,.fc-event:focus:after{background:var(--fc-event-selected-overlay-color);bottom:-1px;content:\"\";left:-1px;position:absolute;right:-1px;top:-1px;z-index:1}.fc-h-event{background-color:var(--fc-event-bg-color);border:1px solid var(--fc-event-border-color);display:block}.fc-h-event .fc-event-main{color:var(--fc-event-text-color)}.fc-h-event .fc-event-main-frame{display:flex}.fc-h-event .fc-event-time{max-width:100%;overflow:hidden}.fc-h-event .fc-event-title-container{flex-grow:1;flex-shrink:1;min-width:0}.fc-h-event .fc-event-title{display:inline-block;left:0;max-width:100%;overflow:hidden;right:0;vertical-align:top}.fc-h-event.fc-event-selected:before{bottom:-10px;top:-10px}.fc-direction-ltr .fc-daygrid-block-event:not(.fc-event-start),.fc-direction-rtl .fc-daygrid-block-event:not(.fc-event-end){border-bottom-left-radius:0;border-left-width:0;border-top-left-radius:0}.fc-direction-ltr .fc-daygrid-block-event:not(.fc-event-end),.fc-direction-rtl .fc-daygrid-block-event:not(.fc-event-start){border-bottom-right-radius:0;border-right-width:0;border-top-right-radius:0}.fc-h-event:not(.fc-event-selected) .fc-event-resizer{bottom:0;top:0;width:var(--fc-event-resizer-thickness)}.fc-direction-ltr .fc-h-event:not(.fc-event-selected) .fc-event-resizer-start,.fc-direction-rtl .fc-h-event:not(.fc-event-selected) .fc-event-resizer-end{cursor:w-resize;left:calc(var(--fc-event-resizer-thickness)*-.5)}.fc-direction-ltr .fc-h-event:not(.fc-event-selected) .fc-event-resizer-end,.fc-direction-rtl .fc-h-event:not(.fc-event-selected) .fc-event-resizer-start{cursor:e-resize;right:calc(var(--fc-event-resizer-thickness)*-.5)}.fc-h-event.fc-event-selected .fc-event-resizer{margin-top:calc(var(--fc-event-resizer-dot-total-width)*-.5);top:50%}.fc-direction-ltr .fc-h-event.fc-event-selected .fc-event-resizer-start,.fc-direction-rtl .fc-h-event.fc-event-selected .fc-event-resizer-end{left:calc(var(--fc-event-resizer-dot-total-width)*-.5)}.fc-direction-ltr .fc-h-event.fc-event-selected .fc-event-resizer-end,.fc-direction-rtl .fc-h-event.fc-event-selected .fc-event-resizer-start{right:calc(var(--fc-event-resizer-dot-total-width)*-.5)}.fc .fc-popover{box-shadow:0 2px 6px rgba(0,0,0,.15);position:absolute;z-index:9999}.fc .fc-popover-header{align-items:center;display:flex;flex-direction:row;justify-content:space-between;padding:3px 4px}.fc .fc-popover-title{margin:0 2px}.fc .fc-popover-close{cursor:pointer;font-size:1.1em;opacity:.65}.fc-theme-standard .fc-popover{background:var(--fc-page-bg-color);border:1px solid var(--fc-border-color)}.fc-theme-standard .fc-popover-header{background:var(--fc-neutral-bg-color)}";
  91. injectStyles(css_248z$4);
  92. class DelayedRunner {
  93. constructor(drainedOption) {
  94. this.drainedOption = drainedOption;
  95. this.isRunning = false;
  96. this.isDirty = false;
  97. this.pauseDepths = {};
  98. this.timeoutId = 0;
  99. }
  100. request(delay) {
  101. this.isDirty = true;
  102. if (!this.isPaused()) {
  103. this.clearTimeout();
  104. if (delay == null) {
  105. this.tryDrain();
  106. }
  107. else {
  108. this.timeoutId = setTimeout(// NOT OPTIMAL! TODO: look at debounce
  109. this.tryDrain.bind(this), delay);
  110. }
  111. }
  112. }
  113. pause(scope = '') {
  114. let { pauseDepths } = this;
  115. pauseDepths[scope] = (pauseDepths[scope] || 0) + 1;
  116. this.clearTimeout();
  117. }
  118. resume(scope = '', force) {
  119. let { pauseDepths } = this;
  120. if (scope in pauseDepths) {
  121. if (force) {
  122. delete pauseDepths[scope];
  123. }
  124. else {
  125. pauseDepths[scope] -= 1;
  126. let depth = pauseDepths[scope];
  127. if (depth <= 0) {
  128. delete pauseDepths[scope];
  129. }
  130. }
  131. this.tryDrain();
  132. }
  133. }
  134. isPaused() {
  135. return Object.keys(this.pauseDepths).length;
  136. }
  137. tryDrain() {
  138. if (!this.isRunning && !this.isPaused()) {
  139. this.isRunning = true;
  140. while (this.isDirty) {
  141. this.isDirty = false;
  142. this.drained(); // might set isDirty to true again
  143. }
  144. this.isRunning = false;
  145. }
  146. }
  147. clear() {
  148. this.clearTimeout();
  149. this.isDirty = false;
  150. this.pauseDepths = {};
  151. }
  152. clearTimeout() {
  153. if (this.timeoutId) {
  154. clearTimeout(this.timeoutId);
  155. this.timeoutId = 0;
  156. }
  157. }
  158. drained() {
  159. if (this.drainedOption) {
  160. this.drainedOption();
  161. }
  162. }
  163. }
  164. function removeElement(el) {
  165. if (el.parentNode) {
  166. el.parentNode.removeChild(el);
  167. }
  168. }
  169. // Querying
  170. // ----------------------------------------------------------------------------------------------------------------
  171. function elementClosest(el, selector) {
  172. if (el.closest) {
  173. return el.closest(selector);
  174. // really bad fallback for IE
  175. // from https://developer.mozilla.org/en-US/docs/Web/API/Element/closest
  176. }
  177. if (!document.documentElement.contains(el)) {
  178. return null;
  179. }
  180. do {
  181. if (elementMatches(el, selector)) {
  182. return el;
  183. }
  184. el = (el.parentElement || el.parentNode);
  185. } while (el !== null && el.nodeType === 1);
  186. return null;
  187. }
  188. function elementMatches(el, selector) {
  189. let method = el.matches || el.matchesSelector || el.msMatchesSelector;
  190. return method.call(el, selector);
  191. }
  192. // accepts multiple subject els
  193. // returns a real array. good for methods like forEach
  194. // TODO: accept the document
  195. function findElements(container, selector) {
  196. let containers = container instanceof HTMLElement ? [container] : container;
  197. let allMatches = [];
  198. for (let i = 0; i < containers.length; i += 1) {
  199. let matches = containers[i].querySelectorAll(selector);
  200. for (let j = 0; j < matches.length; j += 1) {
  201. allMatches.push(matches[j]);
  202. }
  203. }
  204. return allMatches;
  205. }
  206. // accepts multiple subject els
  207. // only queries direct child elements // TODO: rename to findDirectChildren!
  208. function findDirectChildren(parent, selector) {
  209. let parents = parent instanceof HTMLElement ? [parent] : parent;
  210. let allMatches = [];
  211. for (let i = 0; i < parents.length; i += 1) {
  212. let childNodes = parents[i].children; // only ever elements
  213. for (let j = 0; j < childNodes.length; j += 1) {
  214. let childNode = childNodes[j];
  215. if (!selector || elementMatches(childNode, selector)) {
  216. allMatches.push(childNode);
  217. }
  218. }
  219. }
  220. return allMatches;
  221. }
  222. // Style
  223. // ----------------------------------------------------------------------------------------------------------------
  224. const PIXEL_PROP_RE = /(top|left|right|bottom|width|height)$/i;
  225. function applyStyle(el, props) {
  226. for (let propName in props) {
  227. applyStyleProp(el, propName, props[propName]);
  228. }
  229. }
  230. function applyStyleProp(el, name, val) {
  231. if (val == null) {
  232. el.style[name] = '';
  233. }
  234. else if (typeof val === 'number' && PIXEL_PROP_RE.test(name)) {
  235. el.style[name] = `${val}px`;
  236. }
  237. else {
  238. el.style[name] = val;
  239. }
  240. }
  241. // Event Handling
  242. // ----------------------------------------------------------------------------------------------------------------
  243. // if intercepting bubbled events at the document/window/body level,
  244. // and want to see originating element (the 'target'), use this util instead
  245. // of `ev.target` because it goes within web-component boundaries.
  246. function getEventTargetViaRoot(ev) {
  247. var _a, _b;
  248. return (_b = (_a = ev.composedPath) === null || _a === void 0 ? void 0 : _a.call(ev)[0]) !== null && _b !== void 0 ? _b : ev.target;
  249. }
  250. // Unique ID for DOM attribute
  251. let guid$1 = 0;
  252. function getUniqueDomId() {
  253. guid$1 += 1;
  254. return 'fc-dom-' + guid$1;
  255. }
  256. // Stops a mouse/touch event from doing it's native browser action
  257. function preventDefault(ev) {
  258. ev.preventDefault();
  259. }
  260. // Event Delegation
  261. // ----------------------------------------------------------------------------------------------------------------
  262. function buildDelegationHandler(selector, handler) {
  263. return (ev) => {
  264. let matchedChild = elementClosest(ev.target, selector);
  265. if (matchedChild) {
  266. handler.call(matchedChild, ev, matchedChild);
  267. }
  268. };
  269. }
  270. function listenBySelector(container, eventType, selector, handler) {
  271. let attachedHandler = buildDelegationHandler(selector, handler);
  272. container.addEventListener(eventType, attachedHandler);
  273. return () => {
  274. container.removeEventListener(eventType, attachedHandler);
  275. };
  276. }
  277. function listenToHoverBySelector(container, selector, onMouseEnter, onMouseLeave) {
  278. let currentMatchedChild;
  279. return listenBySelector(container, 'mouseover', selector, (mouseOverEv, matchedChild) => {
  280. if (matchedChild !== currentMatchedChild) {
  281. currentMatchedChild = matchedChild;
  282. onMouseEnter(mouseOverEv, matchedChild);
  283. let realOnMouseLeave = (mouseLeaveEv) => {
  284. currentMatchedChild = null;
  285. onMouseLeave(mouseLeaveEv, matchedChild);
  286. matchedChild.removeEventListener('mouseleave', realOnMouseLeave);
  287. };
  288. // listen to the next mouseleave, and then unattach
  289. matchedChild.addEventListener('mouseleave', realOnMouseLeave);
  290. }
  291. });
  292. }
  293. // Animation
  294. // ----------------------------------------------------------------------------------------------------------------
  295. const transitionEventNames = [
  296. 'webkitTransitionEnd',
  297. 'otransitionend',
  298. 'oTransitionEnd',
  299. 'msTransitionEnd',
  300. 'transitionend',
  301. ];
  302. // triggered only when the next single subsequent transition finishes
  303. function whenTransitionDone(el, callback) {
  304. let realCallback = (ev) => {
  305. callback(ev);
  306. transitionEventNames.forEach((eventName) => {
  307. el.removeEventListener(eventName, realCallback);
  308. });
  309. };
  310. transitionEventNames.forEach((eventName) => {
  311. el.addEventListener(eventName, realCallback); // cross-browser way to determine when the transition finishes
  312. });
  313. }
  314. // ARIA workarounds
  315. // ----------------------------------------------------------------------------------------------------------------
  316. function createAriaClickAttrs(handler) {
  317. return Object.assign({ onClick: handler }, createAriaKeyboardAttrs(handler));
  318. }
  319. function createAriaKeyboardAttrs(handler) {
  320. return {
  321. tabIndex: 0,
  322. onKeyDown(ev) {
  323. if (ev.key === 'Enter' || ev.key === ' ') {
  324. handler(ev);
  325. ev.preventDefault(); // if space, don't scroll down page
  326. }
  327. },
  328. };
  329. }
  330. let guidNumber = 0;
  331. function guid() {
  332. guidNumber += 1;
  333. return String(guidNumber);
  334. }
  335. /* FullCalendar-specific DOM Utilities
  336. ----------------------------------------------------------------------------------------------------------------------*/
  337. // Make the mouse cursor express that an event is not allowed in the current area
  338. function disableCursor() {
  339. document.body.classList.add('fc-not-allowed');
  340. }
  341. // Returns the mouse cursor to its original look
  342. function enableCursor() {
  343. document.body.classList.remove('fc-not-allowed');
  344. }
  345. /* Selection
  346. ----------------------------------------------------------------------------------------------------------------------*/
  347. function preventSelection(el) {
  348. el.style.userSelect = 'none';
  349. el.style.webkitUserSelect = 'none';
  350. el.addEventListener('selectstart', preventDefault);
  351. }
  352. function allowSelection(el) {
  353. el.style.userSelect = '';
  354. el.style.webkitUserSelect = '';
  355. el.removeEventListener('selectstart', preventDefault);
  356. }
  357. /* Context Menu
  358. ----------------------------------------------------------------------------------------------------------------------*/
  359. function preventContextMenu(el) {
  360. el.addEventListener('contextmenu', preventDefault);
  361. }
  362. function allowContextMenu(el) {
  363. el.removeEventListener('contextmenu', preventDefault);
  364. }
  365. function parseFieldSpecs(input) {
  366. let specs = [];
  367. let tokens = [];
  368. let i;
  369. let token;
  370. if (typeof input === 'string') {
  371. tokens = input.split(/\s*,\s*/);
  372. }
  373. else if (typeof input === 'function') {
  374. tokens = [input];
  375. }
  376. else if (Array.isArray(input)) {
  377. tokens = input;
  378. }
  379. for (i = 0; i < tokens.length; i += 1) {
  380. token = tokens[i];
  381. if (typeof token === 'string') {
  382. specs.push(token.charAt(0) === '-' ?
  383. { field: token.substring(1), order: -1 } :
  384. { field: token, order: 1 });
  385. }
  386. else if (typeof token === 'function') {
  387. specs.push({ func: token });
  388. }
  389. }
  390. return specs;
  391. }
  392. function compareByFieldSpecs(obj0, obj1, fieldSpecs) {
  393. let i;
  394. let cmp;
  395. for (i = 0; i < fieldSpecs.length; i += 1) {
  396. cmp = compareByFieldSpec(obj0, obj1, fieldSpecs[i]);
  397. if (cmp) {
  398. return cmp;
  399. }
  400. }
  401. return 0;
  402. }
  403. function compareByFieldSpec(obj0, obj1, fieldSpec) {
  404. if (fieldSpec.func) {
  405. return fieldSpec.func(obj0, obj1);
  406. }
  407. return flexibleCompare(obj0[fieldSpec.field], obj1[fieldSpec.field])
  408. * (fieldSpec.order || 1);
  409. }
  410. function flexibleCompare(a, b) {
  411. if (!a && !b) {
  412. return 0;
  413. }
  414. if (b == null) {
  415. return -1;
  416. }
  417. if (a == null) {
  418. return 1;
  419. }
  420. if (typeof a === 'string' || typeof b === 'string') {
  421. return String(a).localeCompare(String(b));
  422. }
  423. return a - b;
  424. }
  425. /* String Utilities
  426. ----------------------------------------------------------------------------------------------------------------------*/
  427. function padStart(val, len) {
  428. let s = String(val);
  429. return '000'.substr(0, len - s.length) + s;
  430. }
  431. function formatWithOrdinals(formatter, args, fallbackText) {
  432. if (typeof formatter === 'function') {
  433. return formatter(...args);
  434. }
  435. if (typeof formatter === 'string') { // non-blank string
  436. return args.reduce((str, arg, index) => (str.replace('$' + index, arg || '')), formatter);
  437. }
  438. return fallbackText;
  439. }
  440. /* Number Utilities
  441. ----------------------------------------------------------------------------------------------------------------------*/
  442. function compareNumbers(a, b) {
  443. return a - b;
  444. }
  445. function isInt(n) {
  446. return n % 1 === 0;
  447. }
  448. /* FC-specific DOM dimension stuff
  449. ----------------------------------------------------------------------------------------------------------------------*/
  450. function computeSmallestCellWidth(cellEl) {
  451. let allWidthEl = cellEl.querySelector('.fc-scrollgrid-shrink-frame');
  452. let contentWidthEl = cellEl.querySelector('.fc-scrollgrid-shrink-cushion');
  453. if (!allWidthEl) {
  454. throw new Error('needs fc-scrollgrid-shrink-frame className'); // TODO: use const
  455. }
  456. if (!contentWidthEl) {
  457. throw new Error('needs fc-scrollgrid-shrink-cushion className');
  458. }
  459. return cellEl.getBoundingClientRect().width - allWidthEl.getBoundingClientRect().width + // the cell padding+border
  460. contentWidthEl.getBoundingClientRect().width;
  461. }
  462. const INTERNAL_UNITS = ['years', 'months', 'days', 'milliseconds'];
  463. const PARSE_RE = /^(-?)(?:(\d+)\.)?(\d+):(\d\d)(?::(\d\d)(?:\.(\d\d\d))?)?/;
  464. // Parsing and Creation
  465. function createDuration(input, unit) {
  466. if (typeof input === 'string') {
  467. return parseString(input);
  468. }
  469. if (typeof input === 'object' && input) { // non-null object
  470. return parseObject(input);
  471. }
  472. if (typeof input === 'number') {
  473. return parseObject({ [unit || 'milliseconds']: input });
  474. }
  475. return null;
  476. }
  477. function parseString(s) {
  478. let m = PARSE_RE.exec(s);
  479. if (m) {
  480. let sign = m[1] ? -1 : 1;
  481. return {
  482. years: 0,
  483. months: 0,
  484. days: sign * (m[2] ? parseInt(m[2], 10) : 0),
  485. milliseconds: sign * ((m[3] ? parseInt(m[3], 10) : 0) * 60 * 60 * 1000 + // hours
  486. (m[4] ? parseInt(m[4], 10) : 0) * 60 * 1000 + // minutes
  487. (m[5] ? parseInt(m[5], 10) : 0) * 1000 + // seconds
  488. (m[6] ? parseInt(m[6], 10) : 0) // ms
  489. ),
  490. };
  491. }
  492. return null;
  493. }
  494. function parseObject(obj) {
  495. let duration = {
  496. years: obj.years || obj.year || 0,
  497. months: obj.months || obj.month || 0,
  498. days: obj.days || obj.day || 0,
  499. milliseconds: (obj.hours || obj.hour || 0) * 60 * 60 * 1000 + // hours
  500. (obj.minutes || obj.minute || 0) * 60 * 1000 + // minutes
  501. (obj.seconds || obj.second || 0) * 1000 + // seconds
  502. (obj.milliseconds || obj.millisecond || obj.ms || 0), // ms
  503. };
  504. let weeks = obj.weeks || obj.week;
  505. if (weeks) {
  506. duration.days += weeks * 7;
  507. duration.specifiedWeeks = true;
  508. }
  509. return duration;
  510. }
  511. // Equality
  512. function durationsEqual(d0, d1) {
  513. return d0.years === d1.years &&
  514. d0.months === d1.months &&
  515. d0.days === d1.days &&
  516. d0.milliseconds === d1.milliseconds;
  517. }
  518. function asCleanDays(dur) {
  519. if (!dur.years && !dur.months && !dur.milliseconds) {
  520. return dur.days;
  521. }
  522. return 0;
  523. }
  524. // Simple Math
  525. function addDurations(d0, d1) {
  526. return {
  527. years: d0.years + d1.years,
  528. months: d0.months + d1.months,
  529. days: d0.days + d1.days,
  530. milliseconds: d0.milliseconds + d1.milliseconds,
  531. };
  532. }
  533. function subtractDurations(d1, d0) {
  534. return {
  535. years: d1.years - d0.years,
  536. months: d1.months - d0.months,
  537. days: d1.days - d0.days,
  538. milliseconds: d1.milliseconds - d0.milliseconds,
  539. };
  540. }
  541. function multiplyDuration(d, n) {
  542. return {
  543. years: d.years * n,
  544. months: d.months * n,
  545. days: d.days * n,
  546. milliseconds: d.milliseconds * n,
  547. };
  548. }
  549. // Conversions
  550. // "Rough" because they are based on average-case Gregorian months/years
  551. function asRoughYears(dur) {
  552. return asRoughDays(dur) / 365;
  553. }
  554. function asRoughMonths(dur) {
  555. return asRoughDays(dur) / 30;
  556. }
  557. function asRoughDays(dur) {
  558. return asRoughMs(dur) / 864e5;
  559. }
  560. function asRoughMinutes(dur) {
  561. return asRoughMs(dur) / (1000 * 60);
  562. }
  563. function asRoughSeconds(dur) {
  564. return asRoughMs(dur) / 1000;
  565. }
  566. function asRoughMs(dur) {
  567. return dur.years * (365 * 864e5) +
  568. dur.months * (30 * 864e5) +
  569. dur.days * 864e5 +
  570. dur.milliseconds;
  571. }
  572. // Advanced Math
  573. function wholeDivideDurations(numerator, denominator) {
  574. let res = null;
  575. for (let i = 0; i < INTERNAL_UNITS.length; i += 1) {
  576. let unit = INTERNAL_UNITS[i];
  577. if (denominator[unit]) {
  578. let localRes = numerator[unit] / denominator[unit];
  579. if (!isInt(localRes) || (res !== null && res !== localRes)) {
  580. return null;
  581. }
  582. res = localRes;
  583. }
  584. else if (numerator[unit]) {
  585. // needs to divide by something but can't!
  586. return null;
  587. }
  588. }
  589. return res;
  590. }
  591. function greatestDurationDenominator(dur) {
  592. let ms = dur.milliseconds;
  593. if (ms) {
  594. if (ms % 1000 !== 0) {
  595. return { unit: 'millisecond', value: ms };
  596. }
  597. if (ms % (1000 * 60) !== 0) {
  598. return { unit: 'second', value: ms / 1000 };
  599. }
  600. if (ms % (1000 * 60 * 60) !== 0) {
  601. return { unit: 'minute', value: ms / (1000 * 60) };
  602. }
  603. if (ms) {
  604. return { unit: 'hour', value: ms / (1000 * 60 * 60) };
  605. }
  606. }
  607. if (dur.days) {
  608. if (dur.specifiedWeeks && dur.days % 7 === 0) {
  609. return { unit: 'week', value: dur.days / 7 };
  610. }
  611. return { unit: 'day', value: dur.days };
  612. }
  613. if (dur.months) {
  614. return { unit: 'month', value: dur.months };
  615. }
  616. if (dur.years) {
  617. return { unit: 'year', value: dur.years };
  618. }
  619. return { unit: 'millisecond', value: 0 };
  620. }
  621. // TODO: new util arrayify?
  622. function removeExact(array, exactVal) {
  623. let removeCnt = 0;
  624. let i = 0;
  625. while (i < array.length) {
  626. if (array[i] === exactVal) {
  627. array.splice(i, 1);
  628. removeCnt += 1;
  629. }
  630. else {
  631. i += 1;
  632. }
  633. }
  634. return removeCnt;
  635. }
  636. function isArraysEqual(a0, a1, equalityFunc) {
  637. if (a0 === a1) {
  638. return true;
  639. }
  640. let len = a0.length;
  641. let i;
  642. if (len !== a1.length) { // not array? or not same length?
  643. return false;
  644. }
  645. for (i = 0; i < len; i += 1) {
  646. if (!(equalityFunc ? equalityFunc(a0[i], a1[i]) : a0[i] === a1[i])) {
  647. return false;
  648. }
  649. }
  650. return true;
  651. }
  652. const DAY_IDS = ['sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat'];
  653. // Adding
  654. function addWeeks(m, n) {
  655. let a = dateToUtcArray(m);
  656. a[2] += n * 7;
  657. return arrayToUtcDate(a);
  658. }
  659. function addDays(m, n) {
  660. let a = dateToUtcArray(m);
  661. a[2] += n;
  662. return arrayToUtcDate(a);
  663. }
  664. function addMs(m, n) {
  665. let a = dateToUtcArray(m);
  666. a[6] += n;
  667. return arrayToUtcDate(a);
  668. }
  669. // Diffing (all return floats)
  670. // TODO: why not use ranges?
  671. function diffWeeks(m0, m1) {
  672. return diffDays(m0, m1) / 7;
  673. }
  674. function diffDays(m0, m1) {
  675. return (m1.valueOf() - m0.valueOf()) / (1000 * 60 * 60 * 24);
  676. }
  677. function diffHours(m0, m1) {
  678. return (m1.valueOf() - m0.valueOf()) / (1000 * 60 * 60);
  679. }
  680. function diffMinutes(m0, m1) {
  681. return (m1.valueOf() - m0.valueOf()) / (1000 * 60);
  682. }
  683. function diffSeconds(m0, m1) {
  684. return (m1.valueOf() - m0.valueOf()) / 1000;
  685. }
  686. function diffDayAndTime(m0, m1) {
  687. let m0day = startOfDay(m0);
  688. let m1day = startOfDay(m1);
  689. return {
  690. years: 0,
  691. months: 0,
  692. days: Math.round(diffDays(m0day, m1day)),
  693. milliseconds: (m1.valueOf() - m1day.valueOf()) - (m0.valueOf() - m0day.valueOf()),
  694. };
  695. }
  696. // Diffing Whole Units
  697. function diffWholeWeeks(m0, m1) {
  698. let d = diffWholeDays(m0, m1);
  699. if (d !== null && d % 7 === 0) {
  700. return d / 7;
  701. }
  702. return null;
  703. }
  704. function diffWholeDays(m0, m1) {
  705. if (timeAsMs(m0) === timeAsMs(m1)) {
  706. return Math.round(diffDays(m0, m1));
  707. }
  708. return null;
  709. }
  710. // Start-Of
  711. function startOfDay(m) {
  712. return arrayToUtcDate([
  713. m.getUTCFullYear(),
  714. m.getUTCMonth(),
  715. m.getUTCDate(),
  716. ]);
  717. }
  718. function startOfHour(m) {
  719. return arrayToUtcDate([
  720. m.getUTCFullYear(),
  721. m.getUTCMonth(),
  722. m.getUTCDate(),
  723. m.getUTCHours(),
  724. ]);
  725. }
  726. function startOfMinute(m) {
  727. return arrayToUtcDate([
  728. m.getUTCFullYear(),
  729. m.getUTCMonth(),
  730. m.getUTCDate(),
  731. m.getUTCHours(),
  732. m.getUTCMinutes(),
  733. ]);
  734. }
  735. function startOfSecond(m) {
  736. return arrayToUtcDate([
  737. m.getUTCFullYear(),
  738. m.getUTCMonth(),
  739. m.getUTCDate(),
  740. m.getUTCHours(),
  741. m.getUTCMinutes(),
  742. m.getUTCSeconds(),
  743. ]);
  744. }
  745. // Week Computation
  746. function weekOfYear(marker, dow, doy) {
  747. let y = marker.getUTCFullYear();
  748. let w = weekOfGivenYear(marker, y, dow, doy);
  749. if (w < 1) {
  750. return weekOfGivenYear(marker, y - 1, dow, doy);
  751. }
  752. let nextW = weekOfGivenYear(marker, y + 1, dow, doy);
  753. if (nextW >= 1) {
  754. return Math.min(w, nextW);
  755. }
  756. return w;
  757. }
  758. function weekOfGivenYear(marker, year, dow, doy) {
  759. let firstWeekStart = arrayToUtcDate([year, 0, 1 + firstWeekOffset(year, dow, doy)]);
  760. let dayStart = startOfDay(marker);
  761. let days = Math.round(diffDays(firstWeekStart, dayStart));
  762. return Math.floor(days / 7) + 1; // zero-indexed
  763. }
  764. // start-of-first-week - start-of-year
  765. function firstWeekOffset(year, dow, doy) {
  766. // first-week day -- which january is always in the first week (4 for iso, 1 for other)
  767. let fwd = 7 + dow - doy;
  768. // first-week day local weekday -- which local weekday is fwd
  769. let fwdlw = (7 + arrayToUtcDate([year, 0, fwd]).getUTCDay() - dow) % 7;
  770. return -fwdlw + fwd - 1;
  771. }
  772. // Array Conversion
  773. function dateToLocalArray(date) {
  774. return [
  775. date.getFullYear(),
  776. date.getMonth(),
  777. date.getDate(),
  778. date.getHours(),
  779. date.getMinutes(),
  780. date.getSeconds(),
  781. date.getMilliseconds(),
  782. ];
  783. }
  784. function arrayToLocalDate(a) {
  785. return new Date(a[0], a[1] || 0, a[2] == null ? 1 : a[2], // day of month
  786. a[3] || 0, a[4] || 0, a[5] || 0);
  787. }
  788. function dateToUtcArray(date) {
  789. return [
  790. date.getUTCFullYear(),
  791. date.getUTCMonth(),
  792. date.getUTCDate(),
  793. date.getUTCHours(),
  794. date.getUTCMinutes(),
  795. date.getUTCSeconds(),
  796. date.getUTCMilliseconds(),
  797. ];
  798. }
  799. function arrayToUtcDate(a) {
  800. // according to web standards (and Safari), a month index is required.
  801. // massage if only given a year.
  802. if (a.length === 1) {
  803. a = a.concat([0]);
  804. }
  805. return new Date(Date.UTC(...a));
  806. }
  807. // Other Utils
  808. function isValidDate(m) {
  809. return !isNaN(m.valueOf());
  810. }
  811. function timeAsMs(m) {
  812. return m.getUTCHours() * 1000 * 60 * 60 +
  813. m.getUTCMinutes() * 1000 * 60 +
  814. m.getUTCSeconds() * 1000 +
  815. m.getUTCMilliseconds();
  816. }
  817. // timeZoneOffset is in minutes
  818. function buildIsoString(marker, timeZoneOffset, stripZeroTime = false) {
  819. let s = marker.toISOString();
  820. s = s.replace('.000', '');
  821. if (stripZeroTime) {
  822. s = s.replace('T00:00:00Z', '');
  823. }
  824. if (s.length > 10) { // time part wasn't stripped, can add timezone info
  825. if (timeZoneOffset == null) {
  826. s = s.replace('Z', '');
  827. }
  828. else if (timeZoneOffset !== 0) {
  829. s = s.replace('Z', formatTimeZoneOffset(timeZoneOffset, true));
  830. }
  831. // otherwise, its UTC-0 and we want to keep the Z
  832. }
  833. return s;
  834. }
  835. // formats the date, but with no time part
  836. // TODO: somehow merge with buildIsoString and stripZeroTime
  837. // TODO: rename. omit "string"
  838. function formatDayString(marker) {
  839. return marker.toISOString().replace(/T.*$/, '');
  840. }
  841. function formatIsoMonthStr(marker) {
  842. return marker.toISOString().match(/^\d{4}-\d{2}/)[0];
  843. }
  844. // TODO: use Date::toISOString and use everything after the T?
  845. function formatIsoTimeString(marker) {
  846. return padStart(marker.getUTCHours(), 2) + ':' +
  847. padStart(marker.getUTCMinutes(), 2) + ':' +
  848. padStart(marker.getUTCSeconds(), 2);
  849. }
  850. function formatTimeZoneOffset(minutes, doIso = false) {
  851. let sign = minutes < 0 ? '-' : '+';
  852. let abs = Math.abs(minutes);
  853. let hours = Math.floor(abs / 60);
  854. let mins = Math.round(abs % 60);
  855. if (doIso) {
  856. return `${sign + padStart(hours, 2)}:${padStart(mins, 2)}`;
  857. }
  858. return `GMT${sign}${hours}${mins ? `:${padStart(mins, 2)}` : ''}`;
  859. }
  860. function memoize(workerFunc, resEquality, teardownFunc) {
  861. let currentArgs;
  862. let currentRes;
  863. return function (...newArgs) {
  864. if (!currentArgs) {
  865. currentRes = workerFunc.apply(this, newArgs);
  866. }
  867. else if (!isArraysEqual(currentArgs, newArgs)) {
  868. if (teardownFunc) {
  869. teardownFunc(currentRes);
  870. }
  871. let res = workerFunc.apply(this, newArgs);
  872. if (!resEquality || !resEquality(res, currentRes)) {
  873. currentRes = res;
  874. }
  875. }
  876. currentArgs = newArgs;
  877. return currentRes;
  878. };
  879. }
  880. function memoizeObjArg(workerFunc, resEquality, teardownFunc) {
  881. let currentArg;
  882. let currentRes;
  883. return (newArg) => {
  884. if (!currentArg) {
  885. currentRes = workerFunc.call(this, newArg);
  886. }
  887. else if (!isPropsEqual(currentArg, newArg)) {
  888. if (teardownFunc) {
  889. teardownFunc(currentRes);
  890. }
  891. let res = workerFunc.call(this, newArg);
  892. if (!resEquality || !resEquality(res, currentRes)) {
  893. currentRes = res;
  894. }
  895. }
  896. currentArg = newArg;
  897. return currentRes;
  898. };
  899. }
  900. function memoizeArraylike(// used at all?
  901. workerFunc, resEquality, teardownFunc) {
  902. let currentArgSets = [];
  903. let currentResults = [];
  904. return (newArgSets) => {
  905. let currentLen = currentArgSets.length;
  906. let newLen = newArgSets.length;
  907. let i = 0;
  908. for (; i < currentLen; i += 1) {
  909. if (!newArgSets[i]) { // one of the old sets no longer exists
  910. if (teardownFunc) {
  911. teardownFunc(currentResults[i]);
  912. }
  913. }
  914. else if (!isArraysEqual(currentArgSets[i], newArgSets[i])) {
  915. if (teardownFunc) {
  916. teardownFunc(currentResults[i]);
  917. }
  918. let res = workerFunc.apply(this, newArgSets[i]);
  919. if (!resEquality || !resEquality(res, currentResults[i])) {
  920. currentResults[i] = res;
  921. }
  922. }
  923. }
  924. for (; i < newLen; i += 1) {
  925. currentResults[i] = workerFunc.apply(this, newArgSets[i]);
  926. }
  927. currentArgSets = newArgSets;
  928. currentResults.splice(newLen); // remove excess
  929. return currentResults;
  930. };
  931. }
  932. function memoizeHashlike(workerFunc, resEquality, teardownFunc) {
  933. let currentArgHash = {};
  934. let currentResHash = {};
  935. return (newArgHash) => {
  936. let newResHash = {};
  937. for (let key in newArgHash) {
  938. if (!currentResHash[key]) {
  939. newResHash[key] = workerFunc.apply(this, newArgHash[key]);
  940. }
  941. else if (!isArraysEqual(currentArgHash[key], newArgHash[key])) {
  942. if (teardownFunc) {
  943. teardownFunc(currentResHash[key]);
  944. }
  945. let res = workerFunc.apply(this, newArgHash[key]);
  946. newResHash[key] = (resEquality && resEquality(res, currentResHash[key]))
  947. ? currentResHash[key]
  948. : res;
  949. }
  950. else {
  951. newResHash[key] = currentResHash[key];
  952. }
  953. }
  954. currentArgHash = newArgHash;
  955. currentResHash = newResHash;
  956. return newResHash;
  957. };
  958. }
  959. const EXTENDED_SETTINGS_AND_SEVERITIES = {
  960. week: 3,
  961. separator: 9,
  962. omitZeroMinute: 9,
  963. meridiem: 9,
  964. omitCommas: 9,
  965. };
  966. const STANDARD_DATE_PROP_SEVERITIES = {
  967. timeZoneName: 7,
  968. era: 6,
  969. year: 5,
  970. month: 4,
  971. day: 2,
  972. weekday: 2,
  973. hour: 1,
  974. minute: 1,
  975. second: 1,
  976. };
  977. const MERIDIEM_RE = /\s*([ap])\.?m\.?/i; // eats up leading spaces too
  978. const COMMA_RE = /,/g; // we need re for globalness
  979. const MULTI_SPACE_RE = /\s+/g;
  980. const LTR_RE = /\u200e/g; // control character
  981. const UTC_RE = /UTC|GMT/;
  982. class NativeFormatter {
  983. constructor(formatSettings) {
  984. let standardDateProps = {};
  985. let extendedSettings = {};
  986. let smallestUnitNum = 9; // the smallest unit in the formatter (9 is a sentinel, beyond max)
  987. for (let name in formatSettings) {
  988. if (name in EXTENDED_SETTINGS_AND_SEVERITIES) {
  989. extendedSettings[name] = formatSettings[name];
  990. const severity = EXTENDED_SETTINGS_AND_SEVERITIES[name];
  991. if (severity < 9) {
  992. smallestUnitNum = Math.min(EXTENDED_SETTINGS_AND_SEVERITIES[name], smallestUnitNum);
  993. }
  994. }
  995. else {
  996. standardDateProps[name] = formatSettings[name];
  997. if (name in STANDARD_DATE_PROP_SEVERITIES) { // TODO: what about hour12? no severity
  998. smallestUnitNum = Math.min(STANDARD_DATE_PROP_SEVERITIES[name], smallestUnitNum);
  999. }
  1000. }
  1001. }
  1002. this.standardDateProps = standardDateProps;
  1003. this.extendedSettings = extendedSettings;
  1004. this.smallestUnitNum = smallestUnitNum;
  1005. this.buildFormattingFunc = memoize(buildFormattingFunc);
  1006. }
  1007. format(date, context) {
  1008. return this.buildFormattingFunc(this.standardDateProps, this.extendedSettings, context)(date);
  1009. }
  1010. formatRange(start, end, context, betterDefaultSeparator) {
  1011. let { standardDateProps, extendedSettings } = this;
  1012. let diffSeverity = computeMarkerDiffSeverity(start.marker, end.marker, context.calendarSystem);
  1013. if (!diffSeverity) {
  1014. return this.format(start, context);
  1015. }
  1016. let biggestUnitForPartial = diffSeverity;
  1017. if (biggestUnitForPartial > 1 && // the two dates are different in a way that's larger scale than time
  1018. (standardDateProps.year === 'numeric' || standardDateProps.year === '2-digit') &&
  1019. (standardDateProps.month === 'numeric' || standardDateProps.month === '2-digit') &&
  1020. (standardDateProps.day === 'numeric' || standardDateProps.day === '2-digit')) {
  1021. biggestUnitForPartial = 1; // make it look like the dates are only different in terms of time
  1022. }
  1023. let full0 = this.format(start, context);
  1024. let full1 = this.format(end, context);
  1025. if (full0 === full1) {
  1026. return full0;
  1027. }
  1028. let partialDateProps = computePartialFormattingOptions(standardDateProps, biggestUnitForPartial);
  1029. let partialFormattingFunc = buildFormattingFunc(partialDateProps, extendedSettings, context);
  1030. let partial0 = partialFormattingFunc(start);
  1031. let partial1 = partialFormattingFunc(end);
  1032. let insertion = findCommonInsertion(full0, partial0, full1, partial1);
  1033. let separator = extendedSettings.separator || betterDefaultSeparator || context.defaultSeparator || '';
  1034. if (insertion) {
  1035. return insertion.before + partial0 + separator + partial1 + insertion.after;
  1036. }
  1037. return full0 + separator + full1;
  1038. }
  1039. getSmallestUnit() {
  1040. switch (this.smallestUnitNum) {
  1041. case 7:
  1042. case 6:
  1043. case 5:
  1044. return 'year';
  1045. case 4:
  1046. return 'month';
  1047. case 3:
  1048. return 'week';
  1049. case 2:
  1050. return 'day';
  1051. default:
  1052. return 'time'; // really?
  1053. }
  1054. }
  1055. }
  1056. function buildFormattingFunc(standardDateProps, extendedSettings, context) {
  1057. let standardDatePropCnt = Object.keys(standardDateProps).length;
  1058. if (standardDatePropCnt === 1 && standardDateProps.timeZoneName === 'short') {
  1059. return (date) => (formatTimeZoneOffset(date.timeZoneOffset));
  1060. }
  1061. if (standardDatePropCnt === 0 && extendedSettings.week) {
  1062. return (date) => (formatWeekNumber(context.computeWeekNumber(date.marker), context.weekText, context.weekTextLong, context.locale, extendedSettings.week));
  1063. }
  1064. return buildNativeFormattingFunc(standardDateProps, extendedSettings, context);
  1065. }
  1066. function buildNativeFormattingFunc(standardDateProps, extendedSettings, context) {
  1067. standardDateProps = Object.assign({}, standardDateProps); // copy
  1068. extendedSettings = Object.assign({}, extendedSettings); // copy
  1069. sanitizeSettings(standardDateProps, extendedSettings);
  1070. standardDateProps.timeZone = 'UTC'; // we leverage the only guaranteed timeZone for our UTC markers
  1071. let normalFormat = new Intl.DateTimeFormat(context.locale.codes, standardDateProps);
  1072. let zeroFormat; // needed?
  1073. if (extendedSettings.omitZeroMinute) {
  1074. let zeroProps = Object.assign({}, standardDateProps);
  1075. delete zeroProps.minute; // seconds and ms were already considered in sanitizeSettings
  1076. zeroFormat = new Intl.DateTimeFormat(context.locale.codes, zeroProps);
  1077. }
  1078. return (date) => {
  1079. let { marker } = date;
  1080. let format;
  1081. if (zeroFormat && !marker.getUTCMinutes()) {
  1082. format = zeroFormat;
  1083. }
  1084. else {
  1085. format = normalFormat;
  1086. }
  1087. let s = format.format(marker);
  1088. return postProcess(s, date, standardDateProps, extendedSettings, context);
  1089. };
  1090. }
  1091. function sanitizeSettings(standardDateProps, extendedSettings) {
  1092. // deal with a browser inconsistency where formatting the timezone
  1093. // requires that the hour/minute be present.
  1094. if (standardDateProps.timeZoneName) {
  1095. if (!standardDateProps.hour) {
  1096. standardDateProps.hour = '2-digit';
  1097. }
  1098. if (!standardDateProps.minute) {
  1099. standardDateProps.minute = '2-digit';
  1100. }
  1101. }
  1102. // only support short timezone names
  1103. if (standardDateProps.timeZoneName === 'long') {
  1104. standardDateProps.timeZoneName = 'short';
  1105. }
  1106. // if requesting to display seconds, MUST display minutes
  1107. if (extendedSettings.omitZeroMinute && (standardDateProps.second || standardDateProps.millisecond)) {
  1108. delete extendedSettings.omitZeroMinute;
  1109. }
  1110. }
  1111. function postProcess(s, date, standardDateProps, extendedSettings, context) {
  1112. s = s.replace(LTR_RE, ''); // remove left-to-right control chars. do first. good for other regexes
  1113. if (standardDateProps.timeZoneName === 'short') {
  1114. s = injectTzoStr(s, (context.timeZone === 'UTC' || date.timeZoneOffset == null) ?
  1115. 'UTC' : // important to normalize for IE, which does "GMT"
  1116. formatTimeZoneOffset(date.timeZoneOffset));
  1117. }
  1118. if (extendedSettings.omitCommas) {
  1119. s = s.replace(COMMA_RE, '').trim();
  1120. }
  1121. if (extendedSettings.omitZeroMinute) {
  1122. s = s.replace(':00', ''); // zeroFormat doesn't always achieve this
  1123. }
  1124. // ^ do anything that might create adjacent spaces before this point,
  1125. // because MERIDIEM_RE likes to eat up loading spaces
  1126. if (extendedSettings.meridiem === false) {
  1127. s = s.replace(MERIDIEM_RE, '').trim();
  1128. }
  1129. else if (extendedSettings.meridiem === 'narrow') { // a/p
  1130. s = s.replace(MERIDIEM_RE, (m0, m1) => m1.toLocaleLowerCase());
  1131. }
  1132. else if (extendedSettings.meridiem === 'short') { // am/pm
  1133. s = s.replace(MERIDIEM_RE, (m0, m1) => `${m1.toLocaleLowerCase()}m`);
  1134. }
  1135. else if (extendedSettings.meridiem === 'lowercase') { // other meridiem transformers already converted to lowercase
  1136. s = s.replace(MERIDIEM_RE, (m0) => m0.toLocaleLowerCase());
  1137. }
  1138. s = s.replace(MULTI_SPACE_RE, ' ');
  1139. s = s.trim();
  1140. return s;
  1141. }
  1142. function injectTzoStr(s, tzoStr) {
  1143. let replaced = false;
  1144. s = s.replace(UTC_RE, () => {
  1145. replaced = true;
  1146. return tzoStr;
  1147. });
  1148. // IE11 doesn't include UTC/GMT in the original string, so append to end
  1149. if (!replaced) {
  1150. s += ` ${tzoStr}`;
  1151. }
  1152. return s;
  1153. }
  1154. function formatWeekNumber(num, weekText, weekTextLong, locale, display) {
  1155. let parts = [];
  1156. if (display === 'long') {
  1157. parts.push(weekTextLong);
  1158. }
  1159. else if (display === 'short' || display === 'narrow') {
  1160. parts.push(weekText);
  1161. }
  1162. if (display === 'long' || display === 'short') {
  1163. parts.push(' ');
  1164. }
  1165. parts.push(locale.simpleNumberFormat.format(num));
  1166. if (locale.options.direction === 'rtl') { // TODO: use control characters instead?
  1167. parts.reverse();
  1168. }
  1169. return parts.join('');
  1170. }
  1171. // Range Formatting Utils
  1172. // 0 = exactly the same
  1173. // 1 = different by time
  1174. // and bigger
  1175. function computeMarkerDiffSeverity(d0, d1, ca) {
  1176. if (ca.getMarkerYear(d0) !== ca.getMarkerYear(d1)) {
  1177. return 5;
  1178. }
  1179. if (ca.getMarkerMonth(d0) !== ca.getMarkerMonth(d1)) {
  1180. return 4;
  1181. }
  1182. if (ca.getMarkerDay(d0) !== ca.getMarkerDay(d1)) {
  1183. return 2;
  1184. }
  1185. if (timeAsMs(d0) !== timeAsMs(d1)) {
  1186. return 1;
  1187. }
  1188. return 0;
  1189. }
  1190. function computePartialFormattingOptions(options, biggestUnit) {
  1191. let partialOptions = {};
  1192. for (let name in options) {
  1193. if (!(name in STANDARD_DATE_PROP_SEVERITIES) || // not a date part prop (like timeZone)
  1194. STANDARD_DATE_PROP_SEVERITIES[name] <= biggestUnit) {
  1195. partialOptions[name] = options[name];
  1196. }
  1197. }
  1198. return partialOptions;
  1199. }
  1200. function findCommonInsertion(full0, partial0, full1, partial1) {
  1201. let i0 = 0;
  1202. while (i0 < full0.length) {
  1203. let found0 = full0.indexOf(partial0, i0);
  1204. if (found0 === -1) {
  1205. break;
  1206. }
  1207. let before0 = full0.substr(0, found0);
  1208. i0 = found0 + partial0.length;
  1209. let after0 = full0.substr(i0);
  1210. let i1 = 0;
  1211. while (i1 < full1.length) {
  1212. let found1 = full1.indexOf(partial1, i1);
  1213. if (found1 === -1) {
  1214. break;
  1215. }
  1216. let before1 = full1.substr(0, found1);
  1217. i1 = found1 + partial1.length;
  1218. let after1 = full1.substr(i1);
  1219. if (before0 === before1 && after0 === after1) {
  1220. return {
  1221. before: before0,
  1222. after: after0,
  1223. };
  1224. }
  1225. }
  1226. }
  1227. return null;
  1228. }
  1229. function expandZonedMarker(dateInfo, calendarSystem) {
  1230. let a = calendarSystem.markerToArray(dateInfo.marker);
  1231. return {
  1232. marker: dateInfo.marker,
  1233. timeZoneOffset: dateInfo.timeZoneOffset,
  1234. array: a,
  1235. year: a[0],
  1236. month: a[1],
  1237. day: a[2],
  1238. hour: a[3],
  1239. minute: a[4],
  1240. second: a[5],
  1241. millisecond: a[6],
  1242. };
  1243. }
  1244. function createVerboseFormattingArg(start, end, context, betterDefaultSeparator) {
  1245. let startInfo = expandZonedMarker(start, context.calendarSystem);
  1246. let endInfo = end ? expandZonedMarker(end, context.calendarSystem) : null;
  1247. return {
  1248. date: startInfo,
  1249. start: startInfo,
  1250. end: endInfo,
  1251. timeZone: context.timeZone,
  1252. localeCodes: context.locale.codes,
  1253. defaultSeparator: betterDefaultSeparator || context.defaultSeparator,
  1254. };
  1255. }
  1256. /*
  1257. TODO: fix the terminology of "formatter" vs "formatting func"
  1258. */
  1259. /*
  1260. At the time of instantiation, this object does not know which cmd-formatting system it will use.
  1261. It receives this at the time of formatting, as a setting.
  1262. */
  1263. class CmdFormatter {
  1264. constructor(cmdStr) {
  1265. this.cmdStr = cmdStr;
  1266. }
  1267. format(date, context, betterDefaultSeparator) {
  1268. return context.cmdFormatter(this.cmdStr, createVerboseFormattingArg(date, null, context, betterDefaultSeparator));
  1269. }
  1270. formatRange(start, end, context, betterDefaultSeparator) {
  1271. return context.cmdFormatter(this.cmdStr, createVerboseFormattingArg(start, end, context, betterDefaultSeparator));
  1272. }
  1273. }
  1274. class FuncFormatter {
  1275. constructor(func) {
  1276. this.func = func;
  1277. }
  1278. format(date, context, betterDefaultSeparator) {
  1279. return this.func(createVerboseFormattingArg(date, null, context, betterDefaultSeparator));
  1280. }
  1281. formatRange(start, end, context, betterDefaultSeparator) {
  1282. return this.func(createVerboseFormattingArg(start, end, context, betterDefaultSeparator));
  1283. }
  1284. }
  1285. function createFormatter(input) {
  1286. if (typeof input === 'object' && input) { // non-null object
  1287. return new NativeFormatter(input);
  1288. }
  1289. if (typeof input === 'string') {
  1290. return new CmdFormatter(input);
  1291. }
  1292. if (typeof input === 'function') {
  1293. return new FuncFormatter(input);
  1294. }
  1295. return null;
  1296. }
  1297. // base options
  1298. // ------------
  1299. const BASE_OPTION_REFINERS = {
  1300. navLinkDayClick: identity,
  1301. navLinkWeekClick: identity,
  1302. duration: createDuration,
  1303. bootstrapFontAwesome: identity,
  1304. buttonIcons: identity,
  1305. customButtons: identity,
  1306. defaultAllDayEventDuration: createDuration,
  1307. defaultTimedEventDuration: createDuration,
  1308. nextDayThreshold: createDuration,
  1309. scrollTime: createDuration,
  1310. scrollTimeReset: Boolean,
  1311. slotMinTime: createDuration,
  1312. slotMaxTime: createDuration,
  1313. dayPopoverFormat: createFormatter,
  1314. slotDuration: createDuration,
  1315. snapDuration: createDuration,
  1316. headerToolbar: identity,
  1317. footerToolbar: identity,
  1318. defaultRangeSeparator: String,
  1319. titleRangeSeparator: String,
  1320. forceEventDuration: Boolean,
  1321. dayHeaders: Boolean,
  1322. dayHeaderFormat: createFormatter,
  1323. dayHeaderClassNames: identity,
  1324. dayHeaderContent: identity,
  1325. dayHeaderDidMount: identity,
  1326. dayHeaderWillUnmount: identity,
  1327. dayCellClassNames: identity,
  1328. dayCellContent: identity,
  1329. dayCellDidMount: identity,
  1330. dayCellWillUnmount: identity,
  1331. initialView: String,
  1332. aspectRatio: Number,
  1333. weekends: Boolean,
  1334. weekNumberCalculation: identity,
  1335. weekNumbers: Boolean,
  1336. weekNumberClassNames: identity,
  1337. weekNumberContent: identity,
  1338. weekNumberDidMount: identity,
  1339. weekNumberWillUnmount: identity,
  1340. editable: Boolean,
  1341. viewClassNames: identity,
  1342. viewDidMount: identity,
  1343. viewWillUnmount: identity,
  1344. nowIndicator: Boolean,
  1345. nowIndicatorClassNames: identity,
  1346. nowIndicatorContent: identity,
  1347. nowIndicatorDidMount: identity,
  1348. nowIndicatorWillUnmount: identity,
  1349. showNonCurrentDates: Boolean,
  1350. lazyFetching: Boolean,
  1351. startParam: String,
  1352. endParam: String,
  1353. timeZoneParam: String,
  1354. timeZone: String,
  1355. locales: identity,
  1356. locale: identity,
  1357. themeSystem: String,
  1358. dragRevertDuration: Number,
  1359. dragScroll: Boolean,
  1360. allDayMaintainDuration: Boolean,
  1361. unselectAuto: Boolean,
  1362. dropAccept: identity,
  1363. eventOrder: parseFieldSpecs,
  1364. eventOrderStrict: Boolean,
  1365. handleWindowResize: Boolean,
  1366. windowResizeDelay: Number,
  1367. longPressDelay: Number,
  1368. eventDragMinDistance: Number,
  1369. expandRows: Boolean,
  1370. height: identity,
  1371. contentHeight: identity,
  1372. direction: String,
  1373. weekNumberFormat: createFormatter,
  1374. eventResizableFromStart: Boolean,
  1375. displayEventTime: Boolean,
  1376. displayEventEnd: Boolean,
  1377. weekText: String,
  1378. weekTextLong: String,
  1379. progressiveEventRendering: Boolean,
  1380. businessHours: identity,
  1381. initialDate: identity,
  1382. now: identity,
  1383. eventDataTransform: identity,
  1384. stickyHeaderDates: identity,
  1385. stickyFooterScrollbar: identity,
  1386. viewHeight: identity,
  1387. defaultAllDay: Boolean,
  1388. eventSourceFailure: identity,
  1389. eventSourceSuccess: identity,
  1390. eventDisplay: String,
  1391. eventStartEditable: Boolean,
  1392. eventDurationEditable: Boolean,
  1393. eventOverlap: identity,
  1394. eventConstraint: identity,
  1395. eventAllow: identity,
  1396. eventBackgroundColor: String,
  1397. eventBorderColor: String,
  1398. eventTextColor: String,
  1399. eventColor: String,
  1400. eventClassNames: identity,
  1401. eventContent: identity,
  1402. eventDidMount: identity,
  1403. eventWillUnmount: identity,
  1404. selectConstraint: identity,
  1405. selectOverlap: identity,
  1406. selectAllow: identity,
  1407. droppable: Boolean,
  1408. unselectCancel: String,
  1409. slotLabelFormat: identity,
  1410. slotLaneClassNames: identity,
  1411. slotLaneContent: identity,
  1412. slotLaneDidMount: identity,
  1413. slotLaneWillUnmount: identity,
  1414. slotLabelClassNames: identity,
  1415. slotLabelContent: identity,
  1416. slotLabelDidMount: identity,
  1417. slotLabelWillUnmount: identity,
  1418. dayMaxEvents: identity,
  1419. dayMaxEventRows: identity,
  1420. dayMinWidth: Number,
  1421. slotLabelInterval: createDuration,
  1422. allDayText: String,
  1423. allDayClassNames: identity,
  1424. allDayContent: identity,
  1425. allDayDidMount: identity,
  1426. allDayWillUnmount: identity,
  1427. slotMinWidth: Number,
  1428. navLinks: Boolean,
  1429. eventTimeFormat: createFormatter,
  1430. rerenderDelay: Number,
  1431. moreLinkText: identity,
  1432. moreLinkHint: identity,
  1433. selectMinDistance: Number,
  1434. selectable: Boolean,
  1435. selectLongPressDelay: Number,
  1436. eventLongPressDelay: Number,
  1437. selectMirror: Boolean,
  1438. eventMaxStack: Number,
  1439. eventMinHeight: Number,
  1440. eventMinWidth: Number,
  1441. eventShortHeight: Number,
  1442. slotEventOverlap: Boolean,
  1443. plugins: identity,
  1444. firstDay: Number,
  1445. dayCount: Number,
  1446. dateAlignment: String,
  1447. dateIncrement: createDuration,
  1448. hiddenDays: identity,
  1449. fixedWeekCount: Boolean,
  1450. validRange: identity,
  1451. visibleRange: identity,
  1452. titleFormat: identity,
  1453. eventInteractive: Boolean,
  1454. // only used by list-view, but languages define the value, so we need it in base options
  1455. noEventsText: String,
  1456. viewHint: identity,
  1457. navLinkHint: identity,
  1458. closeHint: String,
  1459. timeHint: String,
  1460. eventHint: String,
  1461. moreLinkClick: identity,
  1462. moreLinkClassNames: identity,
  1463. moreLinkContent: identity,
  1464. moreLinkDidMount: identity,
  1465. moreLinkWillUnmount: identity,
  1466. monthStartFormat: createFormatter,
  1467. // for connectors
  1468. // (can't be part of plugin system b/c must be provided at runtime)
  1469. handleCustomRendering: identity,
  1470. customRenderingMetaMap: identity,
  1471. customRenderingReplaces: Boolean,
  1472. };
  1473. // do NOT give a type here. need `typeof BASE_OPTION_DEFAULTS` to give real results.
  1474. // raw values.
  1475. const BASE_OPTION_DEFAULTS = {
  1476. eventDisplay: 'auto',
  1477. defaultRangeSeparator: ' - ',
  1478. titleRangeSeparator: ' \u2013 ',
  1479. defaultTimedEventDuration: '01:00:00',
  1480. defaultAllDayEventDuration: { day: 1 },
  1481. forceEventDuration: false,
  1482. nextDayThreshold: '00:00:00',
  1483. dayHeaders: true,
  1484. initialView: '',
  1485. aspectRatio: 1.35,
  1486. headerToolbar: {
  1487. start: 'title',
  1488. center: '',
  1489. end: 'today prev,next',
  1490. },
  1491. weekends: true,
  1492. weekNumbers: false,
  1493. weekNumberCalculation: 'local',
  1494. editable: false,
  1495. nowIndicator: false,
  1496. scrollTime: '06:00:00',
  1497. scrollTimeReset: true,
  1498. slotMinTime: '00:00:00',
  1499. slotMaxTime: '24:00:00',
  1500. showNonCurrentDates: true,
  1501. lazyFetching: true,
  1502. startParam: 'start',
  1503. endParam: 'end',
  1504. timeZoneParam: 'timeZone',
  1505. timeZone: 'local',
  1506. locales: [],
  1507. locale: '',
  1508. themeSystem: 'standard',
  1509. dragRevertDuration: 500,
  1510. dragScroll: true,
  1511. allDayMaintainDuration: false,
  1512. unselectAuto: true,
  1513. dropAccept: '*',
  1514. eventOrder: 'start,-duration,allDay,title',
  1515. dayPopoverFormat: { month: 'long', day: 'numeric', year: 'numeric' },
  1516. handleWindowResize: true,
  1517. windowResizeDelay: 100,
  1518. longPressDelay: 1000,
  1519. eventDragMinDistance: 5,
  1520. expandRows: false,
  1521. navLinks: false,
  1522. selectable: false,
  1523. eventMinHeight: 15,
  1524. eventMinWidth: 30,
  1525. eventShortHeight: 30,
  1526. monthStartFormat: { month: 'long', day: 'numeric' },
  1527. };
  1528. // calendar listeners
  1529. // ------------------
  1530. const CALENDAR_LISTENER_REFINERS = {
  1531. datesSet: identity,
  1532. eventsSet: identity,
  1533. eventAdd: identity,
  1534. eventChange: identity,
  1535. eventRemove: identity,
  1536. windowResize: identity,
  1537. eventClick: identity,
  1538. eventMouseEnter: identity,
  1539. eventMouseLeave: identity,
  1540. select: identity,
  1541. unselect: identity,
  1542. loading: identity,
  1543. // internal
  1544. _unmount: identity,
  1545. _beforeprint: identity,
  1546. _afterprint: identity,
  1547. _noEventDrop: identity,
  1548. _noEventResize: identity,
  1549. _resize: identity,
  1550. _scrollRequest: identity,
  1551. };
  1552. // calendar-specific options
  1553. // -------------------------
  1554. const CALENDAR_OPTION_REFINERS = {
  1555. buttonText: identity,
  1556. buttonHints: identity,
  1557. views: identity,
  1558. plugins: identity,
  1559. initialEvents: identity,
  1560. events: identity,
  1561. eventSources: identity,
  1562. };
  1563. const COMPLEX_OPTION_COMPARATORS = {
  1564. headerToolbar: isMaybeObjectsEqual,
  1565. footerToolbar: isMaybeObjectsEqual,
  1566. buttonText: isMaybeObjectsEqual,
  1567. buttonHints: isMaybeObjectsEqual,
  1568. buttonIcons: isMaybeObjectsEqual,
  1569. dateIncrement: isMaybeObjectsEqual,
  1570. plugins: isMaybeArraysEqual,
  1571. events: isMaybeArraysEqual,
  1572. eventSources: isMaybeArraysEqual,
  1573. ['resources']: isMaybeArraysEqual,
  1574. };
  1575. function isMaybeObjectsEqual(a, b) {
  1576. if (typeof a === 'object' && typeof b === 'object' && a && b) { // both non-null objects
  1577. return isPropsEqual(a, b);
  1578. }
  1579. return a === b;
  1580. }
  1581. function isMaybeArraysEqual(a, b) {
  1582. if (Array.isArray(a) && Array.isArray(b)) {
  1583. return isArraysEqual(a, b);
  1584. }
  1585. return a === b;
  1586. }
  1587. // view-specific options
  1588. // ---------------------
  1589. const VIEW_OPTION_REFINERS = {
  1590. type: String,
  1591. component: identity,
  1592. buttonText: String,
  1593. buttonTextKey: String,
  1594. dateProfileGeneratorClass: identity,
  1595. usesMinMaxTime: Boolean,
  1596. classNames: identity,
  1597. content: identity,
  1598. didMount: identity,
  1599. willUnmount: identity,
  1600. };
  1601. // util funcs
  1602. // ----------------------------------------------------------------------------------------------------
  1603. function mergeRawOptions(optionSets) {
  1604. return mergeProps(optionSets, COMPLEX_OPTION_COMPARATORS);
  1605. }
  1606. function refineProps(input, refiners) {
  1607. let refined = {};
  1608. let extra = {};
  1609. for (let propName in refiners) {
  1610. if (propName in input) {
  1611. refined[propName] = refiners[propName](input[propName]);
  1612. }
  1613. }
  1614. for (let propName in input) {
  1615. if (!(propName in refiners)) {
  1616. extra[propName] = input[propName];
  1617. }
  1618. }
  1619. return { refined, extra };
  1620. }
  1621. function identity(raw) {
  1622. return raw;
  1623. }
  1624. const { hasOwnProperty } = Object.prototype;
  1625. // Merges an array of objects into a single object.
  1626. // The second argument allows for an array of property names who's object values will be merged together.
  1627. function mergeProps(propObjs, complexPropsMap) {
  1628. let dest = {};
  1629. if (complexPropsMap) {
  1630. for (let name in complexPropsMap) {
  1631. if (complexPropsMap[name] === isMaybeObjectsEqual) { // implies that it's object-mergeable
  1632. let complexObjs = [];
  1633. // collect the trailing object values, stopping when a non-object is discovered
  1634. for (let i = propObjs.length - 1; i >= 0; i -= 1) {
  1635. let val = propObjs[i][name];
  1636. if (typeof val === 'object' && val) { // non-null object
  1637. complexObjs.unshift(val);
  1638. }
  1639. else if (val !== undefined) {
  1640. dest[name] = val; // if there were no objects, this value will be used
  1641. break;
  1642. }
  1643. }
  1644. // if the trailing values were objects, use the merged value
  1645. if (complexObjs.length) {
  1646. dest[name] = mergeProps(complexObjs);
  1647. }
  1648. }
  1649. }
  1650. }
  1651. // copy values into the destination, going from last to first
  1652. for (let i = propObjs.length - 1; i >= 0; i -= 1) {
  1653. let props = propObjs[i];
  1654. for (let name in props) {
  1655. if (!(name in dest)) { // if already assigned by previous props or complex props, don't reassign
  1656. dest[name] = props[name];
  1657. }
  1658. }
  1659. }
  1660. return dest;
  1661. }
  1662. function filterHash(hash, func) {
  1663. let filtered = {};
  1664. for (let key in hash) {
  1665. if (func(hash[key], key)) {
  1666. filtered[key] = hash[key];
  1667. }
  1668. }
  1669. return filtered;
  1670. }
  1671. function mapHash(hash, func) {
  1672. let newHash = {};
  1673. for (let key in hash) {
  1674. newHash[key] = func(hash[key], key);
  1675. }
  1676. return newHash;
  1677. }
  1678. function arrayToHash(a) {
  1679. let hash = {};
  1680. for (let item of a) {
  1681. hash[item] = true;
  1682. }
  1683. return hash;
  1684. }
  1685. // TODO: reassess browser support
  1686. // https://caniuse.com/?search=object.values
  1687. function hashValuesToArray(obj) {
  1688. let a = [];
  1689. for (let key in obj) {
  1690. a.push(obj[key]);
  1691. }
  1692. return a;
  1693. }
  1694. function isPropsEqual(obj0, obj1) {
  1695. if (obj0 === obj1) {
  1696. return true;
  1697. }
  1698. for (let key in obj0) {
  1699. if (hasOwnProperty.call(obj0, key)) {
  1700. if (!(key in obj1)) {
  1701. return false;
  1702. }
  1703. }
  1704. }
  1705. for (let key in obj1) {
  1706. if (hasOwnProperty.call(obj1, key)) {
  1707. if (obj0[key] !== obj1[key]) {
  1708. return false;
  1709. }
  1710. }
  1711. }
  1712. return true;
  1713. }
  1714. const HANDLER_RE = /^on[A-Z]/;
  1715. function isNonHandlerPropsEqual(obj0, obj1) {
  1716. const keys = getUnequalProps(obj0, obj1);
  1717. for (let key of keys) {
  1718. if (!HANDLER_RE.test(key)) {
  1719. return false;
  1720. }
  1721. }
  1722. return true;
  1723. }
  1724. function getUnequalProps(obj0, obj1) {
  1725. let keys = [];
  1726. for (let key in obj0) {
  1727. if (hasOwnProperty.call(obj0, key)) {
  1728. if (!(key in obj1)) {
  1729. keys.push(key);
  1730. }
  1731. }
  1732. }
  1733. for (let key in obj1) {
  1734. if (hasOwnProperty.call(obj1, key)) {
  1735. if (obj0[key] !== obj1[key]) {
  1736. keys.push(key);
  1737. }
  1738. }
  1739. }
  1740. return keys;
  1741. }
  1742. function compareObjs(oldProps, newProps, equalityFuncs = {}) {
  1743. if (oldProps === newProps) {
  1744. return true;
  1745. }
  1746. for (let key in newProps) {
  1747. if (key in oldProps && isObjValsEqual(oldProps[key], newProps[key], equalityFuncs[key])) ;
  1748. else {
  1749. return false;
  1750. }
  1751. }
  1752. // check for props that were omitted in the new
  1753. for (let key in oldProps) {
  1754. if (!(key in newProps)) {
  1755. return false;
  1756. }
  1757. }
  1758. return true;
  1759. }
  1760. /*
  1761. assumed "true" equality for handler names like "onReceiveSomething"
  1762. */
  1763. function isObjValsEqual(val0, val1, comparator) {
  1764. if (val0 === val1 || comparator === true) {
  1765. return true;
  1766. }
  1767. if (comparator) {
  1768. return comparator(val0, val1);
  1769. }
  1770. return false;
  1771. }
  1772. function collectFromHash(hash, startIndex = 0, endIndex, step = 1) {
  1773. let res = [];
  1774. if (endIndex == null) {
  1775. endIndex = Object.keys(hash).length;
  1776. }
  1777. for (let i = startIndex; i < endIndex; i += step) {
  1778. let val = hash[i];
  1779. if (val !== undefined) { // will disregard undefined for sparse arrays
  1780. res.push(val);
  1781. }
  1782. }
  1783. return res;
  1784. }
  1785. let calendarSystemClassMap = {};
  1786. function registerCalendarSystem(name, theClass) {
  1787. calendarSystemClassMap[name] = theClass;
  1788. }
  1789. function createCalendarSystem(name) {
  1790. return new calendarSystemClassMap[name]();
  1791. }
  1792. class GregorianCalendarSystem {
  1793. getMarkerYear(d) {
  1794. return d.getUTCFullYear();
  1795. }
  1796. getMarkerMonth(d) {
  1797. return d.getUTCMonth();
  1798. }
  1799. getMarkerDay(d) {
  1800. return d.getUTCDate();
  1801. }
  1802. arrayToMarker(arr) {
  1803. return arrayToUtcDate(arr);
  1804. }
  1805. markerToArray(marker) {
  1806. return dateToUtcArray(marker);
  1807. }
  1808. }
  1809. registerCalendarSystem('gregory', GregorianCalendarSystem);
  1810. const ISO_RE = /^\s*(\d{4})(-?(\d{2})(-?(\d{2})([T ](\d{2}):?(\d{2})(:?(\d{2})(\.(\d+))?)?(Z|(([-+])(\d{2})(:?(\d{2}))?))?)?)?)?$/;
  1811. function parse(str) {
  1812. let m = ISO_RE.exec(str);
  1813. if (m) {
  1814. let 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));
  1815. if (isValidDate(marker)) {
  1816. let timeZoneOffset = null;
  1817. if (m[13]) {
  1818. timeZoneOffset = (m[15] === '-' ? -1 : 1) * (Number(m[16] || 0) * 60 +
  1819. Number(m[18] || 0));
  1820. }
  1821. return {
  1822. marker,
  1823. isTimeUnspecified: !m[6],
  1824. timeZoneOffset,
  1825. };
  1826. }
  1827. }
  1828. return null;
  1829. }
  1830. class DateEnv {
  1831. constructor(settings) {
  1832. let timeZone = this.timeZone = settings.timeZone;
  1833. let isNamedTimeZone = timeZone !== 'local' && timeZone !== 'UTC';
  1834. if (settings.namedTimeZoneImpl && isNamedTimeZone) {
  1835. this.namedTimeZoneImpl = new settings.namedTimeZoneImpl(timeZone);
  1836. }
  1837. this.canComputeOffset = Boolean(!isNamedTimeZone || this.namedTimeZoneImpl);
  1838. this.calendarSystem = createCalendarSystem(settings.calendarSystem);
  1839. this.locale = settings.locale;
  1840. this.weekDow = settings.locale.week.dow;
  1841. this.weekDoy = settings.locale.week.doy;
  1842. if (settings.weekNumberCalculation === 'ISO') {
  1843. this.weekDow = 1;
  1844. this.weekDoy = 4;
  1845. }
  1846. if (typeof settings.firstDay === 'number') {
  1847. this.weekDow = settings.firstDay;
  1848. }
  1849. if (typeof settings.weekNumberCalculation === 'function') {
  1850. this.weekNumberFunc = settings.weekNumberCalculation;
  1851. }
  1852. this.weekText = settings.weekText != null ? settings.weekText : settings.locale.options.weekText;
  1853. this.weekTextLong = (settings.weekTextLong != null ? settings.weekTextLong : settings.locale.options.weekTextLong) || this.weekText;
  1854. this.cmdFormatter = settings.cmdFormatter;
  1855. this.defaultSeparator = settings.defaultSeparator;
  1856. }
  1857. // Creating / Parsing
  1858. createMarker(input) {
  1859. let meta = this.createMarkerMeta(input);
  1860. if (meta === null) {
  1861. return null;
  1862. }
  1863. return meta.marker;
  1864. }
  1865. createNowMarker() {
  1866. if (this.canComputeOffset) {
  1867. return this.timestampToMarker(new Date().valueOf());
  1868. }
  1869. // if we can't compute the current date val for a timezone,
  1870. // better to give the current local date vals than UTC
  1871. return arrayToUtcDate(dateToLocalArray(new Date()));
  1872. }
  1873. createMarkerMeta(input) {
  1874. if (typeof input === 'string') {
  1875. return this.parse(input);
  1876. }
  1877. let marker = null;
  1878. if (typeof input === 'number') {
  1879. marker = this.timestampToMarker(input);
  1880. }
  1881. else if (input instanceof Date) {
  1882. input = input.valueOf();
  1883. if (!isNaN(input)) {
  1884. marker = this.timestampToMarker(input);
  1885. }
  1886. }
  1887. else if (Array.isArray(input)) {
  1888. marker = arrayToUtcDate(input);
  1889. }
  1890. if (marker === null || !isValidDate(marker)) {
  1891. return null;
  1892. }
  1893. return { marker, isTimeUnspecified: false, forcedTzo: null };
  1894. }
  1895. parse(s) {
  1896. let parts = parse(s);
  1897. if (parts === null) {
  1898. return null;
  1899. }
  1900. let { marker } = parts;
  1901. let forcedTzo = null;
  1902. if (parts.timeZoneOffset !== null) {
  1903. if (this.canComputeOffset) {
  1904. marker = this.timestampToMarker(marker.valueOf() - parts.timeZoneOffset * 60 * 1000);
  1905. }
  1906. else {
  1907. forcedTzo = parts.timeZoneOffset;
  1908. }
  1909. }
  1910. return { marker, isTimeUnspecified: parts.isTimeUnspecified, forcedTzo };
  1911. }
  1912. // Accessors
  1913. getYear(marker) {
  1914. return this.calendarSystem.getMarkerYear(marker);
  1915. }
  1916. getMonth(marker) {
  1917. return this.calendarSystem.getMarkerMonth(marker);
  1918. }
  1919. getDay(marker) {
  1920. return this.calendarSystem.getMarkerDay(marker);
  1921. }
  1922. // Adding / Subtracting
  1923. add(marker, dur) {
  1924. let a = this.calendarSystem.markerToArray(marker);
  1925. a[0] += dur.years;
  1926. a[1] += dur.months;
  1927. a[2] += dur.days;
  1928. a[6] += dur.milliseconds;
  1929. return this.calendarSystem.arrayToMarker(a);
  1930. }
  1931. subtract(marker, dur) {
  1932. let a = this.calendarSystem.markerToArray(marker);
  1933. a[0] -= dur.years;
  1934. a[1] -= dur.months;
  1935. a[2] -= dur.days;
  1936. a[6] -= dur.milliseconds;
  1937. return this.calendarSystem.arrayToMarker(a);
  1938. }
  1939. addYears(marker, n) {
  1940. let a = this.calendarSystem.markerToArray(marker);
  1941. a[0] += n;
  1942. return this.calendarSystem.arrayToMarker(a);
  1943. }
  1944. addMonths(marker, n) {
  1945. let a = this.calendarSystem.markerToArray(marker);
  1946. a[1] += n;
  1947. return this.calendarSystem.arrayToMarker(a);
  1948. }
  1949. // Diffing Whole Units
  1950. diffWholeYears(m0, m1) {
  1951. let { calendarSystem } = this;
  1952. if (timeAsMs(m0) === timeAsMs(m1) &&
  1953. calendarSystem.getMarkerDay(m0) === calendarSystem.getMarkerDay(m1) &&
  1954. calendarSystem.getMarkerMonth(m0) === calendarSystem.getMarkerMonth(m1)) {
  1955. return calendarSystem.getMarkerYear(m1) - calendarSystem.getMarkerYear(m0);
  1956. }
  1957. return null;
  1958. }
  1959. diffWholeMonths(m0, m1) {
  1960. let { calendarSystem } = this;
  1961. if (timeAsMs(m0) === timeAsMs(m1) &&
  1962. calendarSystem.getMarkerDay(m0) === calendarSystem.getMarkerDay(m1)) {
  1963. return (calendarSystem.getMarkerMonth(m1) - calendarSystem.getMarkerMonth(m0)) +
  1964. (calendarSystem.getMarkerYear(m1) - calendarSystem.getMarkerYear(m0)) * 12;
  1965. }
  1966. return null;
  1967. }
  1968. // Range / Duration
  1969. greatestWholeUnit(m0, m1) {
  1970. let n = this.diffWholeYears(m0, m1);
  1971. if (n !== null) {
  1972. return { unit: 'year', value: n };
  1973. }
  1974. n = this.diffWholeMonths(m0, m1);
  1975. if (n !== null) {
  1976. return { unit: 'month', value: n };
  1977. }
  1978. n = diffWholeWeeks(m0, m1);
  1979. if (n !== null) {
  1980. return { unit: 'week', value: n };
  1981. }
  1982. n = diffWholeDays(m0, m1);
  1983. if (n !== null) {
  1984. return { unit: 'day', value: n };
  1985. }
  1986. n = diffHours(m0, m1);
  1987. if (isInt(n)) {
  1988. return { unit: 'hour', value: n };
  1989. }
  1990. n = diffMinutes(m0, m1);
  1991. if (isInt(n)) {
  1992. return { unit: 'minute', value: n };
  1993. }
  1994. n = diffSeconds(m0, m1);
  1995. if (isInt(n)) {
  1996. return { unit: 'second', value: n };
  1997. }
  1998. return { unit: 'millisecond', value: m1.valueOf() - m0.valueOf() };
  1999. }
  2000. countDurationsBetween(m0, m1, d) {
  2001. // TODO: can use greatestWholeUnit
  2002. let diff;
  2003. if (d.years) {
  2004. diff = this.diffWholeYears(m0, m1);
  2005. if (diff !== null) {
  2006. return diff / asRoughYears(d);
  2007. }
  2008. }
  2009. if (d.months) {
  2010. diff = this.diffWholeMonths(m0, m1);
  2011. if (diff !== null) {
  2012. return diff / asRoughMonths(d);
  2013. }
  2014. }
  2015. if (d.days) {
  2016. diff = diffWholeDays(m0, m1);
  2017. if (diff !== null) {
  2018. return diff / asRoughDays(d);
  2019. }
  2020. }
  2021. return (m1.valueOf() - m0.valueOf()) / asRoughMs(d);
  2022. }
  2023. // Start-Of
  2024. // these DON'T return zoned-dates. only UTC start-of dates
  2025. startOf(m, unit) {
  2026. if (unit === 'year') {
  2027. return this.startOfYear(m);
  2028. }
  2029. if (unit === 'month') {
  2030. return this.startOfMonth(m);
  2031. }
  2032. if (unit === 'week') {
  2033. return this.startOfWeek(m);
  2034. }
  2035. if (unit === 'day') {
  2036. return startOfDay(m);
  2037. }
  2038. if (unit === 'hour') {
  2039. return startOfHour(m);
  2040. }
  2041. if (unit === 'minute') {
  2042. return startOfMinute(m);
  2043. }
  2044. if (unit === 'second') {
  2045. return startOfSecond(m);
  2046. }
  2047. return null;
  2048. }
  2049. startOfYear(m) {
  2050. return this.calendarSystem.arrayToMarker([
  2051. this.calendarSystem.getMarkerYear(m),
  2052. ]);
  2053. }
  2054. startOfMonth(m) {
  2055. return this.calendarSystem.arrayToMarker([
  2056. this.calendarSystem.getMarkerYear(m),
  2057. this.calendarSystem.getMarkerMonth(m),
  2058. ]);
  2059. }
  2060. startOfWeek(m) {
  2061. return this.calendarSystem.arrayToMarker([
  2062. this.calendarSystem.getMarkerYear(m),
  2063. this.calendarSystem.getMarkerMonth(m),
  2064. m.getUTCDate() - ((m.getUTCDay() - this.weekDow + 7) % 7),
  2065. ]);
  2066. }
  2067. // Week Number
  2068. computeWeekNumber(marker) {
  2069. if (this.weekNumberFunc) {
  2070. return this.weekNumberFunc(this.toDate(marker));
  2071. }
  2072. return weekOfYear(marker, this.weekDow, this.weekDoy);
  2073. }
  2074. // TODO: choke on timeZoneName: long
  2075. format(marker, formatter, dateOptions = {}) {
  2076. return formatter.format({
  2077. marker,
  2078. timeZoneOffset: dateOptions.forcedTzo != null ?
  2079. dateOptions.forcedTzo :
  2080. this.offsetForMarker(marker),
  2081. }, this);
  2082. }
  2083. formatRange(start, end, formatter, dateOptions = {}) {
  2084. if (dateOptions.isEndExclusive) {
  2085. end = addMs(end, -1);
  2086. }
  2087. return formatter.formatRange({
  2088. marker: start,
  2089. timeZoneOffset: dateOptions.forcedStartTzo != null ?
  2090. dateOptions.forcedStartTzo :
  2091. this.offsetForMarker(start),
  2092. }, {
  2093. marker: end,
  2094. timeZoneOffset: dateOptions.forcedEndTzo != null ?
  2095. dateOptions.forcedEndTzo :
  2096. this.offsetForMarker(end),
  2097. }, this, dateOptions.defaultSeparator);
  2098. }
  2099. /*
  2100. DUMB: the omitTime arg is dumb. if we omit the time, we want to omit the timezone offset. and if we do that,
  2101. might as well use buildIsoString or some other util directly
  2102. */
  2103. formatIso(marker, extraOptions = {}) {
  2104. let timeZoneOffset = null;
  2105. if (!extraOptions.omitTimeZoneOffset) {
  2106. if (extraOptions.forcedTzo != null) {
  2107. timeZoneOffset = extraOptions.forcedTzo;
  2108. }
  2109. else {
  2110. timeZoneOffset = this.offsetForMarker(marker);
  2111. }
  2112. }
  2113. return buildIsoString(marker, timeZoneOffset, extraOptions.omitTime);
  2114. }
  2115. // TimeZone
  2116. timestampToMarker(ms) {
  2117. if (this.timeZone === 'local') {
  2118. return arrayToUtcDate(dateToLocalArray(new Date(ms)));
  2119. }
  2120. if (this.timeZone === 'UTC' || !this.namedTimeZoneImpl) {
  2121. return new Date(ms);
  2122. }
  2123. return arrayToUtcDate(this.namedTimeZoneImpl.timestampToArray(ms));
  2124. }
  2125. offsetForMarker(m) {
  2126. if (this.timeZone === 'local') {
  2127. return -arrayToLocalDate(dateToUtcArray(m)).getTimezoneOffset(); // convert "inverse" offset to "normal" offset
  2128. }
  2129. if (this.timeZone === 'UTC') {
  2130. return 0;
  2131. }
  2132. if (this.namedTimeZoneImpl) {
  2133. return this.namedTimeZoneImpl.offsetForArray(dateToUtcArray(m));
  2134. }
  2135. return null;
  2136. }
  2137. // Conversion
  2138. toDate(m, forcedTzo) {
  2139. if (this.timeZone === 'local') {
  2140. return arrayToLocalDate(dateToUtcArray(m));
  2141. }
  2142. if (this.timeZone === 'UTC') {
  2143. return new Date(m.valueOf()); // make sure it's a copy
  2144. }
  2145. if (!this.namedTimeZoneImpl) {
  2146. return new Date(m.valueOf() - (forcedTzo || 0));
  2147. }
  2148. return new Date(m.valueOf() -
  2149. this.namedTimeZoneImpl.offsetForArray(dateToUtcArray(m)) * 1000 * 60);
  2150. }
  2151. }
  2152. class Theme {
  2153. constructor(calendarOptions) {
  2154. if (this.iconOverrideOption) {
  2155. this.setIconOverride(calendarOptions[this.iconOverrideOption]);
  2156. }
  2157. }
  2158. setIconOverride(iconOverrideHash) {
  2159. let iconClassesCopy;
  2160. let buttonName;
  2161. if (typeof iconOverrideHash === 'object' && iconOverrideHash) { // non-null object
  2162. iconClassesCopy = Object.assign({}, this.iconClasses);
  2163. for (buttonName in iconOverrideHash) {
  2164. iconClassesCopy[buttonName] = this.applyIconOverridePrefix(iconOverrideHash[buttonName]);
  2165. }
  2166. this.iconClasses = iconClassesCopy;
  2167. }
  2168. else if (iconOverrideHash === false) {
  2169. this.iconClasses = {};
  2170. }
  2171. }
  2172. applyIconOverridePrefix(className) {
  2173. let prefix = this.iconOverridePrefix;
  2174. if (prefix && className.indexOf(prefix) !== 0) { // if not already present
  2175. className = prefix + className;
  2176. }
  2177. return className;
  2178. }
  2179. getClass(key) {
  2180. return this.classes[key] || '';
  2181. }
  2182. getIconClass(buttonName, isRtl) {
  2183. let className;
  2184. if (isRtl && this.rtlIconClasses) {
  2185. className = this.rtlIconClasses[buttonName] || this.iconClasses[buttonName];
  2186. }
  2187. else {
  2188. className = this.iconClasses[buttonName];
  2189. }
  2190. if (className) {
  2191. return `${this.baseIconClass} ${className}`;
  2192. }
  2193. return '';
  2194. }
  2195. getCustomButtonIconClass(customButtonProps) {
  2196. let className;
  2197. if (this.iconOverrideCustomButtonOption) {
  2198. className = customButtonProps[this.iconOverrideCustomButtonOption];
  2199. if (className) {
  2200. return `${this.baseIconClass} ${this.applyIconOverridePrefix(className)}`;
  2201. }
  2202. }
  2203. return '';
  2204. }
  2205. }
  2206. Theme.prototype.classes = {};
  2207. Theme.prototype.iconClasses = {};
  2208. Theme.prototype.baseIconClass = '';
  2209. Theme.prototype.iconOverridePrefix = '';
  2210. /*
  2211. NOTE: this can be a public API, especially createElement for hooks.
  2212. See examples/typescript-scheduler/src/index.ts
  2213. */
  2214. function flushSync(runBeforeFlush) {
  2215. runBeforeFlush();
  2216. let oldDebounceRendering = l$1.debounceRendering; // orig
  2217. let callbackQ = [];
  2218. function execCallbackSync(callback) {
  2219. callbackQ.push(callback);
  2220. }
  2221. l$1.debounceRendering = execCallbackSync;
  2222. D$1(y(FakeComponent, {}), document.createElement('div'));
  2223. while (callbackQ.length) {
  2224. callbackQ.shift()();
  2225. }
  2226. l$1.debounceRendering = oldDebounceRendering;
  2227. }
  2228. class FakeComponent extends x$1 {
  2229. render() { return y('div', {}); }
  2230. componentDidMount() { this.setState({}); }
  2231. }
  2232. // TODO: use preact/compat instead?
  2233. function createContext(defaultValue) {
  2234. let ContextType = G$1(defaultValue);
  2235. let origProvider = ContextType.Provider;
  2236. ContextType.Provider = function () {
  2237. let isNew = !this.getChildContext;
  2238. let children = origProvider.apply(this, arguments); // eslint-disable-line prefer-rest-params
  2239. if (isNew) {
  2240. let subs = [];
  2241. this.shouldComponentUpdate = (_props) => {
  2242. if (this.props.value !== _props.value) {
  2243. subs.forEach((c) => {
  2244. c.context = _props.value;
  2245. c.forceUpdate();
  2246. });
  2247. }
  2248. };
  2249. this.sub = (c) => {
  2250. subs.push(c);
  2251. let old = c.componentWillUnmount;
  2252. c.componentWillUnmount = () => {
  2253. subs.splice(subs.indexOf(c), 1);
  2254. old && old.call(c);
  2255. };
  2256. };
  2257. }
  2258. return children;
  2259. };
  2260. return ContextType;
  2261. }
  2262. class ScrollResponder {
  2263. constructor(execFunc, emitter, scrollTime, scrollTimeReset) {
  2264. this.execFunc = execFunc;
  2265. this.emitter = emitter;
  2266. this.scrollTime = scrollTime;
  2267. this.scrollTimeReset = scrollTimeReset;
  2268. this.handleScrollRequest = (request) => {
  2269. this.queuedRequest = Object.assign({}, this.queuedRequest || {}, request);
  2270. this.drain();
  2271. };
  2272. emitter.on('_scrollRequest', this.handleScrollRequest);
  2273. this.fireInitialScroll();
  2274. }
  2275. detach() {
  2276. this.emitter.off('_scrollRequest', this.handleScrollRequest);
  2277. }
  2278. update(isDatesNew) {
  2279. if (isDatesNew && this.scrollTimeReset) {
  2280. this.fireInitialScroll(); // will drain
  2281. }
  2282. else {
  2283. this.drain();
  2284. }
  2285. }
  2286. fireInitialScroll() {
  2287. this.handleScrollRequest({
  2288. time: this.scrollTime,
  2289. });
  2290. }
  2291. drain() {
  2292. if (this.queuedRequest && this.execFunc(this.queuedRequest)) {
  2293. this.queuedRequest = null;
  2294. }
  2295. }
  2296. }
  2297. const ViewContextType = createContext({}); // for Components
  2298. function buildViewContext(viewSpec, viewApi, viewOptions, dateProfileGenerator, dateEnv, nowManager, theme, pluginHooks, dispatch, getCurrentData, emitter, calendarApi, registerInteractiveComponent, unregisterInteractiveComponent) {
  2299. return {
  2300. dateEnv,
  2301. nowManager,
  2302. options: viewOptions,
  2303. pluginHooks,
  2304. emitter,
  2305. dispatch,
  2306. getCurrentData,
  2307. calendarApi,
  2308. viewSpec,
  2309. viewApi,
  2310. dateProfileGenerator,
  2311. theme,
  2312. isRtl: viewOptions.direction === 'rtl',
  2313. addResizeHandler(handler) {
  2314. emitter.on('_resize', handler);
  2315. },
  2316. removeResizeHandler(handler) {
  2317. emitter.off('_resize', handler);
  2318. },
  2319. createScrollResponder(execFunc) {
  2320. return new ScrollResponder(execFunc, emitter, createDuration(viewOptions.scrollTime), viewOptions.scrollTimeReset);
  2321. },
  2322. registerInteractiveComponent,
  2323. unregisterInteractiveComponent,
  2324. };
  2325. }
  2326. /* eslint max-classes-per-file: off */
  2327. class PureComponent extends x$1 {
  2328. shouldComponentUpdate(nextProps, nextState) {
  2329. if (this.debug) {
  2330. // eslint-disable-next-line no-console
  2331. console.log(getUnequalProps(nextProps, this.props), getUnequalProps(nextState, this.state));
  2332. }
  2333. return !compareObjs(this.props, nextProps, this.propEquality) ||
  2334. !compareObjs(this.state, nextState, this.stateEquality);
  2335. }
  2336. // HACK for freakin' React StrictMode
  2337. safeSetState(newState) {
  2338. if (!compareObjs(this.state, Object.assign(Object.assign({}, this.state), newState), this.stateEquality)) {
  2339. this.setState(newState);
  2340. }
  2341. }
  2342. }
  2343. PureComponent.addPropsEquality = addPropsEquality;
  2344. PureComponent.addStateEquality = addStateEquality;
  2345. PureComponent.contextType = ViewContextType;
  2346. PureComponent.prototype.propEquality = {};
  2347. PureComponent.prototype.stateEquality = {};
  2348. class BaseComponent extends PureComponent {
  2349. }
  2350. BaseComponent.contextType = ViewContextType;
  2351. function addPropsEquality(propEquality) {
  2352. let hash = Object.create(this.prototype.propEquality);
  2353. Object.assign(hash, propEquality);
  2354. this.prototype.propEquality = hash;
  2355. }
  2356. function addStateEquality(stateEquality) {
  2357. let hash = Object.create(this.prototype.stateEquality);
  2358. Object.assign(hash, stateEquality);
  2359. this.prototype.stateEquality = hash;
  2360. }
  2361. // use other one
  2362. function setRef(ref, current) {
  2363. if (typeof ref === 'function') {
  2364. ref(current);
  2365. }
  2366. else if (ref) {
  2367. // see https://github.com/facebook/react/issues/13029
  2368. ref.current = current;
  2369. }
  2370. }
  2371. class ContentInjector extends BaseComponent {
  2372. constructor() {
  2373. super(...arguments);
  2374. this.id = guid();
  2375. this.queuedDomNodes = [];
  2376. this.currentDomNodes = [];
  2377. this.handleEl = (el) => {
  2378. const { options } = this.context;
  2379. const { generatorName } = this.props;
  2380. if (!options.customRenderingReplaces || !hasCustomRenderingHandler(generatorName, options)) {
  2381. this.updateElRef(el);
  2382. }
  2383. };
  2384. this.updateElRef = (el) => {
  2385. if (this.props.elRef) {
  2386. setRef(this.props.elRef, el);
  2387. }
  2388. };
  2389. }
  2390. render() {
  2391. const { props, context } = this;
  2392. const { options } = context;
  2393. const { customGenerator, defaultGenerator, renderProps } = props;
  2394. const attrs = buildElAttrs(props, [], this.handleEl);
  2395. let useDefault = false;
  2396. let innerContent;
  2397. let queuedDomNodes = [];
  2398. let currentGeneratorMeta;
  2399. if (customGenerator != null) {
  2400. const customGeneratorRes = typeof customGenerator === 'function' ?
  2401. customGenerator(renderProps, y) :
  2402. customGenerator;
  2403. if (customGeneratorRes === true) {
  2404. useDefault = true;
  2405. }
  2406. else {
  2407. const isObject = customGeneratorRes && typeof customGeneratorRes === 'object'; // non-null
  2408. if (isObject && ('html' in customGeneratorRes)) {
  2409. attrs.dangerouslySetInnerHTML = { __html: customGeneratorRes.html };
  2410. }
  2411. else if (isObject && ('domNodes' in customGeneratorRes)) {
  2412. queuedDomNodes = Array.prototype.slice.call(customGeneratorRes.domNodes);
  2413. }
  2414. else if (isObject
  2415. ? i$1(customGeneratorRes) // vdom node
  2416. : typeof customGeneratorRes !== 'function' // primitive value (like string or number)
  2417. ) {
  2418. // use in vdom
  2419. innerContent = customGeneratorRes;
  2420. }
  2421. else {
  2422. // an exotic object for handleCustomRendering
  2423. currentGeneratorMeta = customGeneratorRes;
  2424. }
  2425. }
  2426. }
  2427. else {
  2428. useDefault = !hasCustomRenderingHandler(props.generatorName, options);
  2429. }
  2430. if (useDefault && defaultGenerator) {
  2431. innerContent = defaultGenerator(renderProps);
  2432. }
  2433. this.queuedDomNodes = queuedDomNodes;
  2434. this.currentGeneratorMeta = currentGeneratorMeta;
  2435. return y(props.elTag, attrs, innerContent);
  2436. }
  2437. componentDidMount() {
  2438. this.applyQueueudDomNodes();
  2439. this.triggerCustomRendering(true);
  2440. }
  2441. componentDidUpdate() {
  2442. this.applyQueueudDomNodes();
  2443. this.triggerCustomRendering(true);
  2444. }
  2445. componentWillUnmount() {
  2446. this.triggerCustomRendering(false); // TODO: different API for removal?
  2447. }
  2448. triggerCustomRendering(isActive) {
  2449. var _a;
  2450. const { props, context } = this;
  2451. const { handleCustomRendering, customRenderingMetaMap } = context.options;
  2452. if (handleCustomRendering) {
  2453. const generatorMeta = (_a = this.currentGeneratorMeta) !== null && _a !== void 0 ? _a : customRenderingMetaMap === null || customRenderingMetaMap === void 0 ? void 0 : customRenderingMetaMap[props.generatorName];
  2454. if (generatorMeta) {
  2455. handleCustomRendering(Object.assign(Object.assign({ id: this.id, isActive, containerEl: this.base, reportNewContainerEl: this.updateElRef, // front-end framework tells us about new container els
  2456. generatorMeta }, props), { elClasses: (props.elClasses || []).filter(isTruthy) }));
  2457. }
  2458. }
  2459. }
  2460. applyQueueudDomNodes() {
  2461. const { queuedDomNodes, currentDomNodes } = this;
  2462. const el = this.base;
  2463. if (!isArraysEqual(queuedDomNodes, currentDomNodes)) {
  2464. currentDomNodes.forEach(removeElement);
  2465. for (let newNode of queuedDomNodes) {
  2466. el.appendChild(newNode);
  2467. }
  2468. this.currentDomNodes = queuedDomNodes;
  2469. }
  2470. }
  2471. }
  2472. ContentInjector.addPropsEquality({
  2473. elClasses: isArraysEqual,
  2474. elStyle: isPropsEqual,
  2475. elAttrs: isNonHandlerPropsEqual,
  2476. renderProps: isPropsEqual,
  2477. });
  2478. // Util
  2479. /*
  2480. Does UI-framework provide custom way of rendering that does not use Preact VDOM
  2481. AND does the calendar's options define custom rendering?
  2482. AKA. Should we NOT render the default content?
  2483. */
  2484. function hasCustomRenderingHandler(generatorName, options) {
  2485. var _a;
  2486. return Boolean(options.handleCustomRendering &&
  2487. generatorName &&
  2488. ((_a = options.customRenderingMetaMap) === null || _a === void 0 ? void 0 : _a[generatorName]));
  2489. }
  2490. function buildElAttrs(props, extraClassNames, elRef) {
  2491. const attrs = Object.assign(Object.assign({}, props.elAttrs), { ref: elRef });
  2492. if (props.elClasses || extraClassNames) {
  2493. attrs.className = (props.elClasses || [])
  2494. .concat(extraClassNames || [])
  2495. .concat(attrs.className || [])
  2496. .filter(Boolean)
  2497. .join(' ');
  2498. }
  2499. if (props.elStyle) {
  2500. attrs.style = props.elStyle;
  2501. }
  2502. return attrs;
  2503. }
  2504. function isTruthy(val) {
  2505. return Boolean(val);
  2506. }
  2507. const RenderId = createContext(0);
  2508. class ContentContainer extends x$1 {
  2509. constructor() {
  2510. super(...arguments);
  2511. this.InnerContent = InnerContentInjector.bind(undefined, this);
  2512. this.handleEl = (el) => {
  2513. this.el = el;
  2514. if (this.props.elRef) {
  2515. setRef(this.props.elRef, el);
  2516. if (el && this.didMountMisfire) {
  2517. this.componentDidMount();
  2518. }
  2519. }
  2520. };
  2521. }
  2522. render() {
  2523. const { props } = this;
  2524. const generatedClassNames = generateClassNames(props.classNameGenerator, props.renderProps);
  2525. if (props.children) {
  2526. const elAttrs = buildElAttrs(props, generatedClassNames, this.handleEl);
  2527. const children = props.children(this.InnerContent, props.renderProps, elAttrs);
  2528. if (props.elTag) {
  2529. return y(props.elTag, elAttrs, children);
  2530. }
  2531. else {
  2532. return children;
  2533. }
  2534. }
  2535. else {
  2536. return y((ContentInjector), Object.assign(Object.assign({}, props), { elRef: this.handleEl, elTag: props.elTag || 'div', elClasses: (props.elClasses || []).concat(generatedClassNames), renderId: this.context }));
  2537. }
  2538. }
  2539. componentDidMount() {
  2540. var _a, _b;
  2541. if (this.el) {
  2542. (_b = (_a = this.props).didMount) === null || _b === void 0 ? void 0 : _b.call(_a, Object.assign(Object.assign({}, this.props.renderProps), { el: this.el }));
  2543. }
  2544. else {
  2545. this.didMountMisfire = true;
  2546. }
  2547. }
  2548. componentWillUnmount() {
  2549. var _a, _b;
  2550. (_b = (_a = this.props).willUnmount) === null || _b === void 0 ? void 0 : _b.call(_a, Object.assign(Object.assign({}, this.props.renderProps), { el: this.el }));
  2551. }
  2552. }
  2553. ContentContainer.contextType = RenderId;
  2554. function InnerContentInjector(containerComponent, props) {
  2555. const parentProps = containerComponent.props;
  2556. return y((ContentInjector), Object.assign({ renderProps: parentProps.renderProps, generatorName: parentProps.generatorName, customGenerator: parentProps.customGenerator, defaultGenerator: parentProps.defaultGenerator, renderId: containerComponent.context }, props));
  2557. }
  2558. // Utils
  2559. function generateClassNames(classNameGenerator, renderProps) {
  2560. const classNames = typeof classNameGenerator === 'function' ?
  2561. classNameGenerator(renderProps) :
  2562. classNameGenerator || [];
  2563. return typeof classNames === 'string' ? [classNames] : classNames;
  2564. }
  2565. class ViewContainer extends BaseComponent {
  2566. render() {
  2567. let { props, context } = this;
  2568. let { options } = context;
  2569. let renderProps = { view: context.viewApi };
  2570. return (y(ContentContainer, Object.assign({}, props, { elTag: props.elTag || 'div', elClasses: [
  2571. ...buildViewClassNames(props.viewSpec),
  2572. ...(props.elClasses || []),
  2573. ], renderProps: renderProps, classNameGenerator: options.viewClassNames, generatorName: undefined, didMount: options.viewDidMount, willUnmount: options.viewWillUnmount }), () => props.children));
  2574. }
  2575. }
  2576. function buildViewClassNames(viewSpec) {
  2577. return [
  2578. `fc-${viewSpec.type}-view`,
  2579. 'fc-view',
  2580. ];
  2581. }
  2582. function parseRange(input, dateEnv) {
  2583. let start = null;
  2584. let end = null;
  2585. if (input.start) {
  2586. start = dateEnv.createMarker(input.start);
  2587. }
  2588. if (input.end) {
  2589. end = dateEnv.createMarker(input.end);
  2590. }
  2591. if (!start && !end) {
  2592. return null;
  2593. }
  2594. if (start && end && end < start) {
  2595. return null;
  2596. }
  2597. return { start, end };
  2598. }
  2599. // SIDE-EFFECT: will mutate ranges.
  2600. // Will return a new array result.
  2601. function invertRanges(ranges, constraintRange) {
  2602. let invertedRanges = [];
  2603. let { start } = constraintRange; // the end of the previous range. the start of the new range
  2604. let i;
  2605. let dateRange;
  2606. // ranges need to be in order. required for our date-walking algorithm
  2607. ranges.sort(compareRanges);
  2608. for (i = 0; i < ranges.length; i += 1) {
  2609. dateRange = ranges[i];
  2610. // add the span of time before the event (if there is any)
  2611. if (dateRange.start > start) { // compare millisecond time (skip any ambig logic)
  2612. invertedRanges.push({ start, end: dateRange.start });
  2613. }
  2614. if (dateRange.end > start) {
  2615. start = dateRange.end;
  2616. }
  2617. }
  2618. // add the span of time after the last event (if there is any)
  2619. if (start < constraintRange.end) { // compare millisecond time (skip any ambig logic)
  2620. invertedRanges.push({ start, end: constraintRange.end });
  2621. }
  2622. return invertedRanges;
  2623. }
  2624. function compareRanges(range0, range1) {
  2625. return range0.start.valueOf() - range1.start.valueOf(); // earlier ranges go first
  2626. }
  2627. function intersectRanges(range0, range1) {
  2628. let { start, end } = range0;
  2629. let newRange = null;
  2630. if (range1.start !== null) {
  2631. if (start === null) {
  2632. start = range1.start;
  2633. }
  2634. else {
  2635. start = new Date(Math.max(start.valueOf(), range1.start.valueOf()));
  2636. }
  2637. }
  2638. if (range1.end != null) {
  2639. if (end === null) {
  2640. end = range1.end;
  2641. }
  2642. else {
  2643. end = new Date(Math.min(end.valueOf(), range1.end.valueOf()));
  2644. }
  2645. }
  2646. if (start === null || end === null || start < end) {
  2647. newRange = { start, end };
  2648. }
  2649. return newRange;
  2650. }
  2651. function rangesEqual(range0, range1) {
  2652. return (range0.start === null ? null : range0.start.valueOf()) === (range1.start === null ? null : range1.start.valueOf()) &&
  2653. (range0.end === null ? null : range0.end.valueOf()) === (range1.end === null ? null : range1.end.valueOf());
  2654. }
  2655. function rangesIntersect(range0, range1) {
  2656. return (range0.end === null || range1.start === null || range0.end > range1.start) &&
  2657. (range0.start === null || range1.end === null || range0.start < range1.end);
  2658. }
  2659. function rangeContainsRange(outerRange, innerRange) {
  2660. return (outerRange.start === null || (innerRange.start !== null && innerRange.start >= outerRange.start)) &&
  2661. (outerRange.end === null || (innerRange.end !== null && innerRange.end <= outerRange.end));
  2662. }
  2663. function rangeContainsMarker(range, date) {
  2664. return (range.start === null || date >= range.start) &&
  2665. (range.end === null || date < range.end);
  2666. }
  2667. // If the given date is not within the given range, move it inside.
  2668. // (If it's past the end, make it one millisecond before the end).
  2669. function constrainMarkerToRange(date, range) {
  2670. if (range.start != null && date < range.start) {
  2671. return range.start;
  2672. }
  2673. if (range.end != null && date >= range.end) {
  2674. return new Date(range.end.valueOf() - 1);
  2675. }
  2676. return date;
  2677. }
  2678. /* Date stuff that doesn't belong in datelib core
  2679. ----------------------------------------------------------------------------------------------------------------------*/
  2680. // given a timed range, computes an all-day range that has the same exact duration,
  2681. // but whose start time is aligned with the start of the day.
  2682. function computeAlignedDayRange(timedRange) {
  2683. let dayCnt = Math.floor(diffDays(timedRange.start, timedRange.end)) || 1;
  2684. let start = startOfDay(timedRange.start);
  2685. let end = addDays(start, dayCnt);
  2686. return { start, end };
  2687. }
  2688. // given a timed range, computes an all-day range based on how for the end date bleeds into the next day
  2689. // TODO: give nextDayThreshold a default arg
  2690. function computeVisibleDayRange(timedRange, nextDayThreshold = createDuration(0)) {
  2691. let startDay = null;
  2692. let endDay = null;
  2693. if (timedRange.end) {
  2694. endDay = startOfDay(timedRange.end);
  2695. let endTimeMS = timedRange.end.valueOf() - endDay.valueOf(); // # of milliseconds into `endDay`
  2696. // If the end time is actually inclusively part of the next day and is equal to or
  2697. // beyond the next day threshold, adjust the end to be the exclusive end of `endDay`.
  2698. // Otherwise, leaving it as inclusive will cause it to exclude `endDay`.
  2699. if (endTimeMS && endTimeMS >= asRoughMs(nextDayThreshold)) {
  2700. endDay = addDays(endDay, 1);
  2701. }
  2702. }
  2703. if (timedRange.start) {
  2704. startDay = startOfDay(timedRange.start); // the beginning of the day the range starts
  2705. // If end is within `startDay` but not past nextDayThreshold, assign the default duration of one day.
  2706. if (endDay && endDay <= startDay) {
  2707. endDay = addDays(startDay, 1);
  2708. }
  2709. }
  2710. return { start: startDay, end: endDay };
  2711. }
  2712. // spans from one day into another?
  2713. function isMultiDayRange(range) {
  2714. let visibleRange = computeVisibleDayRange(range);
  2715. return diffDays(visibleRange.start, visibleRange.end) > 1;
  2716. }
  2717. function diffDates(date0, date1, dateEnv, largeUnit) {
  2718. if (largeUnit === 'year') {
  2719. return createDuration(dateEnv.diffWholeYears(date0, date1), 'year');
  2720. }
  2721. if (largeUnit === 'month') {
  2722. return createDuration(dateEnv.diffWholeMonths(date0, date1), 'month');
  2723. }
  2724. return diffDayAndTime(date0, date1); // returns a duration
  2725. }
  2726. class DateProfileGenerator {
  2727. constructor(props) {
  2728. this.props = props;
  2729. this.initHiddenDays();
  2730. }
  2731. /* Date Range Computation
  2732. ------------------------------------------------------------------------------------------------------------------*/
  2733. // Builds a structure with info about what the dates/ranges will be for the "prev" view.
  2734. buildPrev(currentDateProfile, currentDate, forceToValid) {
  2735. let { dateEnv } = this.props;
  2736. let prevDate = dateEnv.subtract(dateEnv.startOf(currentDate, currentDateProfile.currentRangeUnit), // important for start-of-month
  2737. currentDateProfile.dateIncrement);
  2738. return this.build(prevDate, -1, forceToValid);
  2739. }
  2740. // Builds a structure with info about what the dates/ranges will be for the "next" view.
  2741. buildNext(currentDateProfile, currentDate, forceToValid) {
  2742. let { dateEnv } = this.props;
  2743. let nextDate = dateEnv.add(dateEnv.startOf(currentDate, currentDateProfile.currentRangeUnit), // important for start-of-month
  2744. currentDateProfile.dateIncrement);
  2745. return this.build(nextDate, 1, forceToValid);
  2746. }
  2747. // Builds a structure holding dates/ranges for rendering around the given date.
  2748. // Optional direction param indicates whether the date is being incremented/decremented
  2749. // from its previous value. decremented = -1, incremented = 1 (default).
  2750. build(currentDate, direction, forceToValid = true) {
  2751. let { props } = this;
  2752. let validRange;
  2753. let currentInfo;
  2754. let isRangeAllDay;
  2755. let renderRange;
  2756. let activeRange;
  2757. let isValid;
  2758. validRange = this.buildValidRange();
  2759. validRange = this.trimHiddenDays(validRange);
  2760. if (forceToValid) {
  2761. currentDate = constrainMarkerToRange(currentDate, validRange);
  2762. }
  2763. currentInfo = this.buildCurrentRangeInfo(currentDate, direction);
  2764. isRangeAllDay = /^(year|month|week|day)$/.test(currentInfo.unit);
  2765. renderRange = this.buildRenderRange(this.trimHiddenDays(currentInfo.range), currentInfo.unit, isRangeAllDay);
  2766. renderRange = this.trimHiddenDays(renderRange);
  2767. activeRange = renderRange;
  2768. if (!props.showNonCurrentDates) {
  2769. activeRange = intersectRanges(activeRange, currentInfo.range);
  2770. }
  2771. activeRange = this.adjustActiveRange(activeRange);
  2772. activeRange = intersectRanges(activeRange, validRange); // might return null
  2773. // it's invalid if the originally requested date is not contained,
  2774. // or if the range is completely outside of the valid range.
  2775. isValid = rangesIntersect(currentInfo.range, validRange);
  2776. // HACK: constrain to render-range so `currentDate` is more useful to view rendering
  2777. if (!rangeContainsMarker(renderRange, currentDate)) {
  2778. currentDate = renderRange.start;
  2779. }
  2780. return {
  2781. currentDate,
  2782. // constraint for where prev/next operations can go and where events can be dragged/resized to.
  2783. // an object with optional start and end properties.
  2784. validRange,
  2785. // range the view is formally responsible for.
  2786. // for example, a month view might have 1st-31st, excluding padded dates
  2787. currentRange: currentInfo.range,
  2788. // name of largest unit being displayed, like "month" or "week"
  2789. currentRangeUnit: currentInfo.unit,
  2790. isRangeAllDay,
  2791. // dates that display events and accept drag-n-drop
  2792. // will be `null` if no dates accept events
  2793. activeRange,
  2794. // date range with a rendered skeleton
  2795. // includes not-active days that need some sort of DOM
  2796. renderRange,
  2797. // Duration object that denotes the first visible time of any given day
  2798. slotMinTime: props.slotMinTime,
  2799. // Duration object that denotes the exclusive visible end time of any given day
  2800. slotMaxTime: props.slotMaxTime,
  2801. isValid,
  2802. // how far the current date will move for a prev/next operation
  2803. dateIncrement: this.buildDateIncrement(currentInfo.duration),
  2804. // pass a fallback (might be null) ^
  2805. };
  2806. }
  2807. // Builds an object with optional start/end properties.
  2808. // Indicates the minimum/maximum dates to display.
  2809. // not responsible for trimming hidden days.
  2810. buildValidRange() {
  2811. let input = this.props.validRangeInput;
  2812. let simpleInput = typeof input === 'function'
  2813. ? input.call(this.props.calendarApi, this.props.dateEnv.toDate(this.props.nowManager.getDateMarker()))
  2814. : input;
  2815. return this.refineRange(simpleInput) ||
  2816. { start: null, end: null }; // completely open-ended
  2817. }
  2818. // Builds a structure with info about the "current" range, the range that is
  2819. // highlighted as being the current month for example.
  2820. // See build() for a description of `direction`.
  2821. // Guaranteed to have `range` and `unit` properties. `duration` is optional.
  2822. buildCurrentRangeInfo(date, direction) {
  2823. let { props } = this;
  2824. let duration = null;
  2825. let unit = null;
  2826. let range = null;
  2827. let dayCount;
  2828. if (props.duration) {
  2829. duration = props.duration;
  2830. unit = props.durationUnit;
  2831. range = this.buildRangeFromDuration(date, direction, duration, unit);
  2832. }
  2833. else if ((dayCount = this.props.dayCount)) {
  2834. unit = 'day';
  2835. range = this.buildRangeFromDayCount(date, direction, dayCount);
  2836. }
  2837. else if ((range = this.buildCustomVisibleRange(date))) {
  2838. unit = props.dateEnv.greatestWholeUnit(range.start, range.end).unit;
  2839. }
  2840. else {
  2841. duration = this.getFallbackDuration();
  2842. unit = greatestDurationDenominator(duration).unit;
  2843. range = this.buildRangeFromDuration(date, direction, duration, unit);
  2844. }
  2845. return { duration, unit, range };
  2846. }
  2847. getFallbackDuration() {
  2848. return createDuration({ day: 1 });
  2849. }
  2850. // Returns a new activeRange to have time values (un-ambiguate)
  2851. // slotMinTime or slotMaxTime causes the range to expand.
  2852. adjustActiveRange(range) {
  2853. let { dateEnv, usesMinMaxTime, slotMinTime, slotMaxTime } = this.props;
  2854. let { start, end } = range;
  2855. if (usesMinMaxTime) {
  2856. // expand active range if slotMinTime is negative (why not when positive?)
  2857. if (asRoughDays(slotMinTime) < 0) {
  2858. start = startOfDay(start); // necessary?
  2859. start = dateEnv.add(start, slotMinTime);
  2860. }
  2861. // expand active range if slotMaxTime is beyond one day (why not when negative?)
  2862. if (asRoughDays(slotMaxTime) > 1) {
  2863. end = startOfDay(end); // necessary?
  2864. end = addDays(end, -1);
  2865. end = dateEnv.add(end, slotMaxTime);
  2866. }
  2867. }
  2868. return { start, end };
  2869. }
  2870. // Builds the "current" range when it is specified as an explicit duration.
  2871. // `unit` is the already-computed greatestDurationDenominator unit of duration.
  2872. buildRangeFromDuration(date, direction, duration, unit) {
  2873. let { dateEnv, dateAlignment } = this.props;
  2874. let start;
  2875. let end;
  2876. let res;
  2877. // compute what the alignment should be
  2878. if (!dateAlignment) {
  2879. let { dateIncrement } = this.props;
  2880. if (dateIncrement) {
  2881. // use the smaller of the two units
  2882. if (asRoughMs(dateIncrement) < asRoughMs(duration)) {
  2883. dateAlignment = greatestDurationDenominator(dateIncrement).unit;
  2884. }
  2885. else {
  2886. dateAlignment = unit;
  2887. }
  2888. }
  2889. else {
  2890. dateAlignment = unit;
  2891. }
  2892. }
  2893. // if the view displays a single day or smaller
  2894. if (asRoughDays(duration) <= 1) {
  2895. if (this.isHiddenDay(start)) {
  2896. start = this.skipHiddenDays(start, direction);
  2897. start = startOfDay(start);
  2898. }
  2899. }
  2900. function computeRes() {
  2901. start = dateEnv.startOf(date, dateAlignment);
  2902. end = dateEnv.add(start, duration);
  2903. res = { start, end };
  2904. }
  2905. computeRes();
  2906. // if range is completely enveloped by hidden days, go past the hidden days
  2907. if (!this.trimHiddenDays(res)) {
  2908. date = this.skipHiddenDays(date, direction);
  2909. computeRes();
  2910. }
  2911. return res;
  2912. }
  2913. // Builds the "current" range when a dayCount is specified.
  2914. buildRangeFromDayCount(date, direction, dayCount) {
  2915. let { dateEnv, dateAlignment } = this.props;
  2916. let runningCount = 0;
  2917. let start = date;
  2918. let end;
  2919. if (dateAlignment) {
  2920. start = dateEnv.startOf(start, dateAlignment);
  2921. }
  2922. start = startOfDay(start);
  2923. start = this.skipHiddenDays(start, direction);
  2924. end = start;
  2925. do {
  2926. end = addDays(end, 1);
  2927. if (!this.isHiddenDay(end)) {
  2928. runningCount += 1;
  2929. }
  2930. } while (runningCount < dayCount);
  2931. return { start, end };
  2932. }
  2933. // Builds a normalized range object for the "visible" range,
  2934. // which is a way to define the currentRange and activeRange at the same time.
  2935. buildCustomVisibleRange(date) {
  2936. let { props } = this;
  2937. let input = props.visibleRangeInput;
  2938. let simpleInput = typeof input === 'function'
  2939. ? input.call(props.calendarApi, props.dateEnv.toDate(date))
  2940. : input;
  2941. let range = this.refineRange(simpleInput);
  2942. if (range && (range.start == null || range.end == null)) {
  2943. return null;
  2944. }
  2945. return range;
  2946. }
  2947. // Computes the range that will represent the element/cells for *rendering*,
  2948. // but which may have voided days/times.
  2949. // not responsible for trimming hidden days.
  2950. buildRenderRange(currentRange, currentRangeUnit, isRangeAllDay) {
  2951. return currentRange;
  2952. }
  2953. // Compute the duration value that should be added/substracted to the current date
  2954. // when a prev/next operation happens.
  2955. buildDateIncrement(fallback) {
  2956. let { dateIncrement } = this.props;
  2957. let customAlignment;
  2958. if (dateIncrement) {
  2959. return dateIncrement;
  2960. }
  2961. if ((customAlignment = this.props.dateAlignment)) {
  2962. return createDuration(1, customAlignment);
  2963. }
  2964. if (fallback) {
  2965. return fallback;
  2966. }
  2967. return createDuration({ days: 1 });
  2968. }
  2969. refineRange(rangeInput) {
  2970. if (rangeInput) {
  2971. let range = parseRange(rangeInput, this.props.dateEnv);
  2972. if (range) {
  2973. range = computeVisibleDayRange(range);
  2974. }
  2975. return range;
  2976. }
  2977. return null;
  2978. }
  2979. /* Hidden Days
  2980. ------------------------------------------------------------------------------------------------------------------*/
  2981. // Initializes internal variables related to calculating hidden days-of-week
  2982. initHiddenDays() {
  2983. let hiddenDays = this.props.hiddenDays || []; // array of day-of-week indices that are hidden
  2984. let isHiddenDayHash = []; // is the day-of-week hidden? (hash with day-of-week-index -> bool)
  2985. let dayCnt = 0;
  2986. let i;
  2987. if (this.props.weekends === false) {
  2988. hiddenDays.push(0, 6); // 0=sunday, 6=saturday
  2989. }
  2990. for (i = 0; i < 7; i += 1) {
  2991. if (!(isHiddenDayHash[i] = hiddenDays.indexOf(i) !== -1)) {
  2992. dayCnt += 1;
  2993. }
  2994. }
  2995. if (!dayCnt) {
  2996. throw new Error('invalid hiddenDays'); // all days were hidden? bad.
  2997. }
  2998. this.isHiddenDayHash = isHiddenDayHash;
  2999. }
  3000. // Remove days from the beginning and end of the range that are computed as hidden.
  3001. // If the whole range is trimmed off, returns null
  3002. trimHiddenDays(range) {
  3003. let { start, end } = range;
  3004. if (start) {
  3005. start = this.skipHiddenDays(start);
  3006. }
  3007. if (end) {
  3008. end = this.skipHiddenDays(end, -1, true);
  3009. }
  3010. if (start == null || end == null || start < end) {
  3011. return { start, end };
  3012. }
  3013. return null;
  3014. }
  3015. // Is the current day hidden?
  3016. // `day` is a day-of-week index (0-6), or a Date (used for UTC)
  3017. isHiddenDay(day) {
  3018. if (day instanceof Date) {
  3019. day = day.getUTCDay();
  3020. }
  3021. return this.isHiddenDayHash[day];
  3022. }
  3023. // Incrementing the current day until it is no longer a hidden day, returning a copy.
  3024. // DOES NOT CONSIDER validRange!
  3025. // If the initial value of `date` is not a hidden day, don't do anything.
  3026. // Pass `isExclusive` as `true` if you are dealing with an end date.
  3027. // `inc` defaults to `1` (increment one day forward each time)
  3028. skipHiddenDays(date, inc = 1, isExclusive = false) {
  3029. while (this.isHiddenDayHash[(date.getUTCDay() + (isExclusive ? inc : 0) + 7) % 7]) {
  3030. date = addDays(date, inc);
  3031. }
  3032. return date;
  3033. }
  3034. }
  3035. function createEventInstance(defId, range, forcedStartTzo, forcedEndTzo) {
  3036. return {
  3037. instanceId: guid(),
  3038. defId,
  3039. range,
  3040. forcedStartTzo: forcedStartTzo == null ? null : forcedStartTzo,
  3041. forcedEndTzo: forcedEndTzo == null ? null : forcedEndTzo,
  3042. };
  3043. }
  3044. function parseRecurring(refined, defaultAllDay, dateEnv, recurringTypes) {
  3045. for (let i = 0; i < recurringTypes.length; i += 1) {
  3046. let parsed = recurringTypes[i].parse(refined, dateEnv);
  3047. if (parsed) {
  3048. let { allDay } = refined;
  3049. if (allDay == null) {
  3050. allDay = defaultAllDay;
  3051. if (allDay == null) {
  3052. allDay = parsed.allDayGuess;
  3053. if (allDay == null) {
  3054. allDay = false;
  3055. }
  3056. }
  3057. }
  3058. return {
  3059. allDay,
  3060. duration: parsed.duration,
  3061. typeData: parsed.typeData,
  3062. typeId: i,
  3063. };
  3064. }
  3065. }
  3066. return null;
  3067. }
  3068. function expandRecurring(eventStore, framingRange, context) {
  3069. let { dateEnv, pluginHooks, options } = context;
  3070. let { defs, instances } = eventStore;
  3071. // remove existing recurring instances
  3072. // TODO: bad. always expand events as a second step
  3073. instances = filterHash(instances, (instance) => !defs[instance.defId].recurringDef);
  3074. for (let defId in defs) {
  3075. let def = defs[defId];
  3076. if (def.recurringDef) {
  3077. let { duration } = def.recurringDef;
  3078. if (!duration) {
  3079. duration = def.allDay ?
  3080. options.defaultAllDayEventDuration :
  3081. options.defaultTimedEventDuration;
  3082. }
  3083. let starts = expandRecurringRanges(def, duration, framingRange, dateEnv, pluginHooks.recurringTypes);
  3084. for (let start of starts) {
  3085. let instance = createEventInstance(defId, {
  3086. start,
  3087. end: dateEnv.add(start, duration),
  3088. });
  3089. instances[instance.instanceId] = instance;
  3090. }
  3091. }
  3092. }
  3093. return { defs, instances };
  3094. }
  3095. /*
  3096. Event MUST have a recurringDef
  3097. */
  3098. function expandRecurringRanges(eventDef, duration, framingRange, dateEnv, recurringTypes) {
  3099. let typeDef = recurringTypes[eventDef.recurringDef.typeId];
  3100. let markers = typeDef.expand(eventDef.recurringDef.typeData, {
  3101. start: dateEnv.subtract(framingRange.start, duration),
  3102. end: framingRange.end,
  3103. }, dateEnv);
  3104. // the recurrence plugins don't guarantee that all-day events are start-of-day, so we have to
  3105. if (eventDef.allDay) {
  3106. markers = markers.map(startOfDay);
  3107. }
  3108. return markers;
  3109. }
  3110. const EVENT_NON_DATE_REFINERS = {
  3111. id: String,
  3112. groupId: String,
  3113. title: String,
  3114. url: String,
  3115. interactive: Boolean,
  3116. };
  3117. const EVENT_DATE_REFINERS = {
  3118. start: identity,
  3119. end: identity,
  3120. date: identity,
  3121. allDay: Boolean,
  3122. };
  3123. const EVENT_REFINERS = Object.assign(Object.assign(Object.assign({}, EVENT_NON_DATE_REFINERS), EVENT_DATE_REFINERS), { extendedProps: identity });
  3124. function parseEvent(raw, eventSource, context, allowOpenRange, refiners = buildEventRefiners(context), defIdMap, instanceIdMap) {
  3125. let { refined, extra } = refineEventDef(raw, context, refiners);
  3126. let defaultAllDay = computeIsDefaultAllDay(eventSource, context);
  3127. let recurringRes = parseRecurring(refined, defaultAllDay, context.dateEnv, context.pluginHooks.recurringTypes);
  3128. if (recurringRes) {
  3129. let def = parseEventDef(refined, extra, eventSource ? eventSource.sourceId : '', recurringRes.allDay, Boolean(recurringRes.duration), context, defIdMap);
  3130. def.recurringDef = {
  3131. typeId: recurringRes.typeId,
  3132. typeData: recurringRes.typeData,
  3133. duration: recurringRes.duration,
  3134. };
  3135. return { def, instance: null };
  3136. }
  3137. let singleRes = parseSingle(refined, defaultAllDay, context, allowOpenRange);
  3138. if (singleRes) {
  3139. let def = parseEventDef(refined, extra, eventSource ? eventSource.sourceId : '', singleRes.allDay, singleRes.hasEnd, context, defIdMap);
  3140. let instance = createEventInstance(def.defId, singleRes.range, singleRes.forcedStartTzo, singleRes.forcedEndTzo);
  3141. if (instanceIdMap && def.publicId && instanceIdMap[def.publicId]) {
  3142. instance.instanceId = instanceIdMap[def.publicId];
  3143. }
  3144. return { def, instance };
  3145. }
  3146. return null;
  3147. }
  3148. function refineEventDef(raw, context, refiners = buildEventRefiners(context)) {
  3149. return refineProps(raw, refiners);
  3150. }
  3151. function buildEventRefiners(context) {
  3152. return Object.assign(Object.assign(Object.assign({}, EVENT_UI_REFINERS), EVENT_REFINERS), context.pluginHooks.eventRefiners);
  3153. }
  3154. /*
  3155. Will NOT populate extendedProps with the leftover properties.
  3156. Will NOT populate date-related props.
  3157. */
  3158. function parseEventDef(refined, extra, sourceId, allDay, hasEnd, context, defIdMap) {
  3159. let def = {
  3160. title: refined.title || '',
  3161. groupId: refined.groupId || '',
  3162. publicId: refined.id || '',
  3163. url: refined.url || '',
  3164. recurringDef: null,
  3165. defId: ((defIdMap && refined.id) ? defIdMap[refined.id] : '') || guid(),
  3166. sourceId,
  3167. allDay,
  3168. hasEnd,
  3169. interactive: refined.interactive,
  3170. ui: createEventUi(refined, context),
  3171. extendedProps: Object.assign(Object.assign({}, (refined.extendedProps || {})), extra),
  3172. };
  3173. for (let memberAdder of context.pluginHooks.eventDefMemberAdders) {
  3174. Object.assign(def, memberAdder(refined));
  3175. }
  3176. // help out EventImpl from having user modify props
  3177. Object.freeze(def.ui.classNames);
  3178. Object.freeze(def.extendedProps);
  3179. return def;
  3180. }
  3181. function parseSingle(refined, defaultAllDay, context, allowOpenRange) {
  3182. let { allDay } = refined;
  3183. let startMeta;
  3184. let startMarker = null;
  3185. let hasEnd = false;
  3186. let endMeta;
  3187. let endMarker = null;
  3188. let startInput = refined.start != null ? refined.start : refined.date;
  3189. startMeta = context.dateEnv.createMarkerMeta(startInput);
  3190. if (startMeta) {
  3191. startMarker = startMeta.marker;
  3192. }
  3193. else if (!allowOpenRange) {
  3194. return null;
  3195. }
  3196. if (refined.end != null) {
  3197. endMeta = context.dateEnv.createMarkerMeta(refined.end);
  3198. }
  3199. if (allDay == null) {
  3200. if (defaultAllDay != null) {
  3201. allDay = defaultAllDay;
  3202. }
  3203. else {
  3204. // fall back to the date props LAST
  3205. allDay = (!startMeta || startMeta.isTimeUnspecified) &&
  3206. (!endMeta || endMeta.isTimeUnspecified);
  3207. }
  3208. }
  3209. if (allDay && startMarker) {
  3210. startMarker = startOfDay(startMarker);
  3211. }
  3212. if (endMeta) {
  3213. endMarker = endMeta.marker;
  3214. if (allDay) {
  3215. endMarker = startOfDay(endMarker);
  3216. }
  3217. if (startMarker && endMarker <= startMarker) {
  3218. endMarker = null;
  3219. }
  3220. }
  3221. if (endMarker) {
  3222. hasEnd = true;
  3223. }
  3224. else if (!allowOpenRange) {
  3225. hasEnd = context.options.forceEventDuration || false;
  3226. endMarker = context.dateEnv.add(startMarker, allDay ?
  3227. context.options.defaultAllDayEventDuration :
  3228. context.options.defaultTimedEventDuration);
  3229. }
  3230. return {
  3231. allDay,
  3232. hasEnd,
  3233. range: { start: startMarker, end: endMarker },
  3234. forcedStartTzo: startMeta ? startMeta.forcedTzo : null,
  3235. forcedEndTzo: endMeta ? endMeta.forcedTzo : null,
  3236. };
  3237. }
  3238. function computeIsDefaultAllDay(eventSource, context) {
  3239. let res = null;
  3240. if (eventSource) {
  3241. res = eventSource.defaultAllDay;
  3242. }
  3243. if (res == null) {
  3244. res = context.options.defaultAllDay;
  3245. }
  3246. return res;
  3247. }
  3248. function parseEvents(rawEvents, eventSource, context, allowOpenRange, defIdMap, instanceIdMap) {
  3249. let eventStore = createEmptyEventStore();
  3250. let eventRefiners = buildEventRefiners(context);
  3251. for (let rawEvent of rawEvents) {
  3252. let tuple = parseEvent(rawEvent, eventSource, context, allowOpenRange, eventRefiners, defIdMap, instanceIdMap);
  3253. if (tuple) {
  3254. eventTupleToStore(tuple, eventStore);
  3255. }
  3256. }
  3257. return eventStore;
  3258. }
  3259. function eventTupleToStore(tuple, eventStore = createEmptyEventStore()) {
  3260. eventStore.defs[tuple.def.defId] = tuple.def;
  3261. if (tuple.instance) {
  3262. eventStore.instances[tuple.instance.instanceId] = tuple.instance;
  3263. }
  3264. return eventStore;
  3265. }
  3266. // retrieves events that have the same groupId as the instance specified by `instanceId`
  3267. // or they are the same as the instance.
  3268. // why might instanceId not be in the store? an event from another calendar?
  3269. function getRelevantEvents(eventStore, instanceId) {
  3270. let instance = eventStore.instances[instanceId];
  3271. if (instance) {
  3272. let def = eventStore.defs[instance.defId];
  3273. // get events/instances with same group
  3274. let newStore = filterEventStoreDefs(eventStore, (lookDef) => isEventDefsGrouped(def, lookDef));
  3275. // add the original
  3276. // TODO: wish we could use eventTupleToStore or something like it
  3277. newStore.defs[def.defId] = def;
  3278. newStore.instances[instance.instanceId] = instance;
  3279. return newStore;
  3280. }
  3281. return createEmptyEventStore();
  3282. }
  3283. function isEventDefsGrouped(def0, def1) {
  3284. return Boolean(def0.groupId && def0.groupId === def1.groupId);
  3285. }
  3286. function createEmptyEventStore() {
  3287. return { defs: {}, instances: {} };
  3288. }
  3289. function mergeEventStores(store0, store1) {
  3290. return {
  3291. defs: Object.assign(Object.assign({}, store0.defs), store1.defs),
  3292. instances: Object.assign(Object.assign({}, store0.instances), store1.instances),
  3293. };
  3294. }
  3295. function filterEventStoreDefs(eventStore, filterFunc) {
  3296. let defs = filterHash(eventStore.defs, filterFunc);
  3297. let instances = filterHash(eventStore.instances, (instance) => (defs[instance.defId] // still exists?
  3298. ));
  3299. return { defs, instances };
  3300. }
  3301. function excludeSubEventStore(master, sub) {
  3302. let { defs, instances } = master;
  3303. let filteredDefs = {};
  3304. let filteredInstances = {};
  3305. for (let defId in defs) {
  3306. if (!sub.defs[defId]) { // not explicitly excluded
  3307. filteredDefs[defId] = defs[defId];
  3308. }
  3309. }
  3310. for (let instanceId in instances) {
  3311. if (!sub.instances[instanceId] && // not explicitly excluded
  3312. filteredDefs[instances[instanceId].defId] // def wasn't filtered away
  3313. ) {
  3314. filteredInstances[instanceId] = instances[instanceId];
  3315. }
  3316. }
  3317. return {
  3318. defs: filteredDefs,
  3319. instances: filteredInstances,
  3320. };
  3321. }
  3322. function normalizeConstraint(input, context) {
  3323. if (Array.isArray(input)) {
  3324. return parseEvents(input, null, context, true); // allowOpenRange=true
  3325. }
  3326. if (typeof input === 'object' && input) { // non-null object
  3327. return parseEvents([input], null, context, true); // allowOpenRange=true
  3328. }
  3329. if (input != null) {
  3330. return String(input);
  3331. }
  3332. return null;
  3333. }
  3334. function parseClassNames(raw) {
  3335. if (Array.isArray(raw)) {
  3336. return raw;
  3337. }
  3338. if (typeof raw === 'string') {
  3339. return raw.split(/\s+/);
  3340. }
  3341. return [];
  3342. }
  3343. // TODO: better called "EventSettings" or "EventConfig"
  3344. // TODO: move this file into structs
  3345. // TODO: separate constraint/overlap/allow, because selection uses only that, not other props
  3346. const EVENT_UI_REFINERS = {
  3347. display: String,
  3348. editable: Boolean,
  3349. startEditable: Boolean,
  3350. durationEditable: Boolean,
  3351. constraint: identity,
  3352. overlap: identity,
  3353. allow: identity,
  3354. className: parseClassNames,
  3355. classNames: parseClassNames,
  3356. color: String,
  3357. backgroundColor: String,
  3358. borderColor: String,
  3359. textColor: String,
  3360. };
  3361. const EMPTY_EVENT_UI = {
  3362. display: null,
  3363. startEditable: null,
  3364. durationEditable: null,
  3365. constraints: [],
  3366. overlap: null,
  3367. allows: [],
  3368. backgroundColor: '',
  3369. borderColor: '',
  3370. textColor: '',
  3371. classNames: [],
  3372. };
  3373. function createEventUi(refined, context) {
  3374. let constraint = normalizeConstraint(refined.constraint, context);
  3375. return {
  3376. display: refined.display || null,
  3377. startEditable: refined.startEditable != null ? refined.startEditable : refined.editable,
  3378. durationEditable: refined.durationEditable != null ? refined.durationEditable : refined.editable,
  3379. constraints: constraint != null ? [constraint] : [],
  3380. overlap: refined.overlap != null ? refined.overlap : null,
  3381. allows: refined.allow != null ? [refined.allow] : [],
  3382. backgroundColor: refined.backgroundColor || refined.color || '',
  3383. borderColor: refined.borderColor || refined.color || '',
  3384. textColor: refined.textColor || '',
  3385. classNames: (refined.className || []).concat(refined.classNames || []), // join singular and plural
  3386. };
  3387. }
  3388. // TODO: prevent against problems with <2 args!
  3389. function combineEventUis(uis) {
  3390. return uis.reduce(combineTwoEventUis, EMPTY_EVENT_UI);
  3391. }
  3392. function combineTwoEventUis(item0, item1) {
  3393. return {
  3394. display: item1.display != null ? item1.display : item0.display,
  3395. startEditable: item1.startEditable != null ? item1.startEditable : item0.startEditable,
  3396. durationEditable: item1.durationEditable != null ? item1.durationEditable : item0.durationEditable,
  3397. constraints: item0.constraints.concat(item1.constraints),
  3398. overlap: typeof item1.overlap === 'boolean' ? item1.overlap : item0.overlap,
  3399. allows: item0.allows.concat(item1.allows),
  3400. backgroundColor: item1.backgroundColor || item0.backgroundColor,
  3401. borderColor: item1.borderColor || item0.borderColor,
  3402. textColor: item1.textColor || item0.textColor,
  3403. classNames: item0.classNames.concat(item1.classNames),
  3404. };
  3405. }
  3406. const EVENT_SOURCE_REFINERS = {
  3407. id: String,
  3408. defaultAllDay: Boolean,
  3409. url: String,
  3410. format: String,
  3411. events: identity,
  3412. eventDataTransform: identity,
  3413. // for any network-related sources
  3414. success: identity,
  3415. failure: identity,
  3416. };
  3417. function parseEventSource(raw, context, refiners = buildEventSourceRefiners(context)) {
  3418. let rawObj;
  3419. if (typeof raw === 'string') {
  3420. rawObj = { url: raw };
  3421. }
  3422. else if (typeof raw === 'function' || Array.isArray(raw)) {
  3423. rawObj = { events: raw };
  3424. }
  3425. else if (typeof raw === 'object' && raw) { // not null
  3426. rawObj = raw;
  3427. }
  3428. if (rawObj) {
  3429. let { refined, extra } = refineProps(rawObj, refiners);
  3430. let metaRes = buildEventSourceMeta(refined, context);
  3431. if (metaRes) {
  3432. return {
  3433. _raw: raw,
  3434. isFetching: false,
  3435. latestFetchId: '',
  3436. fetchRange: null,
  3437. defaultAllDay: refined.defaultAllDay,
  3438. eventDataTransform: refined.eventDataTransform,
  3439. success: refined.success,
  3440. failure: refined.failure,
  3441. publicId: refined.id || '',
  3442. sourceId: guid(),
  3443. sourceDefId: metaRes.sourceDefId,
  3444. meta: metaRes.meta,
  3445. ui: createEventUi(refined, context),
  3446. extendedProps: extra,
  3447. };
  3448. }
  3449. }
  3450. return null;
  3451. }
  3452. function buildEventSourceRefiners(context) {
  3453. return Object.assign(Object.assign(Object.assign({}, EVENT_UI_REFINERS), EVENT_SOURCE_REFINERS), context.pluginHooks.eventSourceRefiners);
  3454. }
  3455. function buildEventSourceMeta(raw, context) {
  3456. let defs = context.pluginHooks.eventSourceDefs;
  3457. for (let i = defs.length - 1; i >= 0; i -= 1) { // later-added plugins take precedence
  3458. let def = defs[i];
  3459. let meta = def.parseMeta(raw);
  3460. if (meta) {
  3461. return { sourceDefId: i, meta };
  3462. }
  3463. }
  3464. return null;
  3465. }
  3466. function reduceEventStore(eventStore, action, eventSources, dateProfile, context) {
  3467. switch (action.type) {
  3468. case 'RECEIVE_EVENTS': // raw
  3469. return receiveRawEvents(eventStore, eventSources[action.sourceId], action.fetchId, action.fetchRange, action.rawEvents, context);
  3470. case 'RESET_RAW_EVENTS':
  3471. return resetRawEvents(eventStore, eventSources[action.sourceId], action.rawEvents, dateProfile.activeRange, context);
  3472. case 'ADD_EVENTS': // already parsed, but not expanded
  3473. return addEvent(eventStore, action.eventStore, // new ones
  3474. dateProfile ? dateProfile.activeRange : null, context);
  3475. case 'RESET_EVENTS':
  3476. return action.eventStore;
  3477. case 'MERGE_EVENTS': // already parsed and expanded
  3478. return mergeEventStores(eventStore, action.eventStore);
  3479. case 'PREV': // TODO: how do we track all actions that affect dateProfile :(
  3480. case 'NEXT':
  3481. case 'CHANGE_DATE':
  3482. case 'CHANGE_VIEW_TYPE':
  3483. if (dateProfile) {
  3484. return expandRecurring(eventStore, dateProfile.activeRange, context);
  3485. }
  3486. return eventStore;
  3487. case 'REMOVE_EVENTS':
  3488. return excludeSubEventStore(eventStore, action.eventStore);
  3489. case 'REMOVE_EVENT_SOURCE':
  3490. return excludeEventsBySourceId(eventStore, action.sourceId);
  3491. case 'REMOVE_ALL_EVENT_SOURCES':
  3492. return filterEventStoreDefs(eventStore, (eventDef) => (!eventDef.sourceId // only keep events with no source id
  3493. ));
  3494. case 'REMOVE_ALL_EVENTS':
  3495. return createEmptyEventStore();
  3496. default:
  3497. return eventStore;
  3498. }
  3499. }
  3500. function receiveRawEvents(eventStore, eventSource, fetchId, fetchRange, rawEvents, context) {
  3501. if (eventSource && // not already removed
  3502. fetchId === eventSource.latestFetchId // TODO: wish this logic was always in event-sources
  3503. ) {
  3504. let subset = parseEvents(transformRawEvents(rawEvents, eventSource, context), eventSource, context);
  3505. if (fetchRange) {
  3506. subset = expandRecurring(subset, fetchRange, context);
  3507. }
  3508. return mergeEventStores(excludeEventsBySourceId(eventStore, eventSource.sourceId), subset);
  3509. }
  3510. return eventStore;
  3511. }
  3512. function resetRawEvents(existingEventStore, eventSource, rawEvents, activeRange, context) {
  3513. const { defIdMap, instanceIdMap } = buildPublicIdMaps(existingEventStore);
  3514. let newEventStore = parseEvents(transformRawEvents(rawEvents, eventSource, context), eventSource, context, false, defIdMap, instanceIdMap);
  3515. return expandRecurring(newEventStore, activeRange, context);
  3516. }
  3517. function transformRawEvents(rawEvents, eventSource, context) {
  3518. let calEachTransform = context.options.eventDataTransform;
  3519. let sourceEachTransform = eventSource ? eventSource.eventDataTransform : null;
  3520. if (sourceEachTransform) {
  3521. rawEvents = transformEachRawEvent(rawEvents, sourceEachTransform);
  3522. }
  3523. if (calEachTransform) {
  3524. rawEvents = transformEachRawEvent(rawEvents, calEachTransform);
  3525. }
  3526. return rawEvents;
  3527. }
  3528. function transformEachRawEvent(rawEvents, func) {
  3529. let refinedEvents;
  3530. if (!func) {
  3531. refinedEvents = rawEvents;
  3532. }
  3533. else {
  3534. refinedEvents = [];
  3535. for (let rawEvent of rawEvents) {
  3536. let refinedEvent = func(rawEvent);
  3537. if (refinedEvent) {
  3538. refinedEvents.push(refinedEvent);
  3539. }
  3540. else if (refinedEvent == null) {
  3541. refinedEvents.push(rawEvent);
  3542. } // if a different falsy value, do nothing
  3543. }
  3544. }
  3545. return refinedEvents;
  3546. }
  3547. function addEvent(eventStore, subset, expandRange, context) {
  3548. if (expandRange) {
  3549. subset = expandRecurring(subset, expandRange, context);
  3550. }
  3551. return mergeEventStores(eventStore, subset);
  3552. }
  3553. function rezoneEventStoreDates(eventStore, oldDateEnv, newDateEnv) {
  3554. let { defs } = eventStore;
  3555. let instances = mapHash(eventStore.instances, (instance) => {
  3556. let def = defs[instance.defId];
  3557. if (def.allDay) {
  3558. return instance; // isn't dependent on timezone
  3559. }
  3560. return Object.assign(Object.assign({}, instance), { range: {
  3561. start: newDateEnv.createMarker(oldDateEnv.toDate(instance.range.start, instance.forcedStartTzo)),
  3562. end: newDateEnv.createMarker(oldDateEnv.toDate(instance.range.end, instance.forcedEndTzo)),
  3563. }, forcedStartTzo: newDateEnv.canComputeOffset ? null : instance.forcedStartTzo, forcedEndTzo: newDateEnv.canComputeOffset ? null : instance.forcedEndTzo });
  3564. });
  3565. return { defs, instances };
  3566. }
  3567. function excludeEventsBySourceId(eventStore, sourceId) {
  3568. return filterEventStoreDefs(eventStore, (eventDef) => eventDef.sourceId !== sourceId);
  3569. }
  3570. // QUESTION: why not just return instances? do a general object-property-exclusion util
  3571. function excludeInstances(eventStore, removals) {
  3572. return {
  3573. defs: eventStore.defs,
  3574. instances: filterHash(eventStore.instances, (instance) => !removals[instance.instanceId]),
  3575. };
  3576. }
  3577. function buildPublicIdMaps(eventStore) {
  3578. const { defs, instances } = eventStore;
  3579. const defIdMap = {};
  3580. const instanceIdMap = {};
  3581. for (let defId in defs) {
  3582. const def = defs[defId];
  3583. const { publicId } = def;
  3584. if (publicId) {
  3585. defIdMap[publicId] = defId;
  3586. }
  3587. }
  3588. for (let instanceId in instances) {
  3589. const instance = instances[instanceId];
  3590. const def = defs[instance.defId];
  3591. const { publicId } = def;
  3592. if (publicId) {
  3593. instanceIdMap[publicId] = instanceId;
  3594. }
  3595. }
  3596. return { defIdMap, instanceIdMap };
  3597. }
  3598. class Emitter {
  3599. constructor() {
  3600. this.handlers = {};
  3601. this.thisContext = null;
  3602. }
  3603. setThisContext(thisContext) {
  3604. this.thisContext = thisContext;
  3605. }
  3606. setOptions(options) {
  3607. this.options = options;
  3608. }
  3609. on(type, handler) {
  3610. addToHash(this.handlers, type, handler);
  3611. }
  3612. off(type, handler) {
  3613. removeFromHash(this.handlers, type, handler);
  3614. }
  3615. trigger(type, ...args) {
  3616. let attachedHandlers = this.handlers[type] || [];
  3617. let optionHandler = this.options && this.options[type];
  3618. let handlers = [].concat(optionHandler || [], attachedHandlers);
  3619. for (let handler of handlers) {
  3620. handler.apply(this.thisContext, args);
  3621. }
  3622. }
  3623. hasHandlers(type) {
  3624. return Boolean((this.handlers[type] && this.handlers[type].length) ||
  3625. (this.options && this.options[type]));
  3626. }
  3627. }
  3628. function addToHash(hash, type, handler) {
  3629. (hash[type] || (hash[type] = []))
  3630. .push(handler);
  3631. }
  3632. function removeFromHash(hash, type, handler) {
  3633. if (handler) {
  3634. if (hash[type]) {
  3635. hash[type] = hash[type].filter((func) => func !== handler);
  3636. }
  3637. }
  3638. else {
  3639. delete hash[type]; // remove all handler funcs for this type
  3640. }
  3641. }
  3642. const DEF_DEFAULTS = {
  3643. startTime: '09:00',
  3644. endTime: '17:00',
  3645. daysOfWeek: [1, 2, 3, 4, 5],
  3646. display: 'inverse-background',
  3647. classNames: 'fc-non-business',
  3648. groupId: '_businessHours', // so multiple defs get grouped
  3649. };
  3650. /*
  3651. TODO: pass around as EventDefHash!!!
  3652. */
  3653. function parseBusinessHours(input, context) {
  3654. return parseEvents(refineInputs(input), null, context);
  3655. }
  3656. function refineInputs(input) {
  3657. let rawDefs;
  3658. if (input === true) {
  3659. rawDefs = [{}]; // will get DEF_DEFAULTS verbatim
  3660. }
  3661. else if (Array.isArray(input)) {
  3662. // if specifying an array, every sub-definition NEEDS a day-of-week
  3663. rawDefs = input.filter((rawDef) => rawDef.daysOfWeek);
  3664. }
  3665. else if (typeof input === 'object' && input) { // non-null object
  3666. rawDefs = [input];
  3667. }
  3668. else { // is probably false
  3669. rawDefs = [];
  3670. }
  3671. rawDefs = rawDefs.map((rawDef) => (Object.assign(Object.assign({}, DEF_DEFAULTS), rawDef)));
  3672. return rawDefs;
  3673. }
  3674. function triggerDateSelect(selection, pev, context) {
  3675. context.emitter.trigger('select', Object.assign(Object.assign({}, buildDateSpanApiWithContext(selection, context)), { jsEvent: pev ? pev.origEvent : null, view: context.viewApi || context.calendarApi.view }));
  3676. }
  3677. function triggerDateUnselect(pev, context) {
  3678. context.emitter.trigger('unselect', {
  3679. jsEvent: pev ? pev.origEvent : null,
  3680. view: context.viewApi || context.calendarApi.view,
  3681. });
  3682. }
  3683. function buildDateSpanApiWithContext(dateSpan, context) {
  3684. let props = {};
  3685. for (let transform of context.pluginHooks.dateSpanTransforms) {
  3686. Object.assign(props, transform(dateSpan, context));
  3687. }
  3688. Object.assign(props, buildDateSpanApi(dateSpan, context.dateEnv));
  3689. return props;
  3690. }
  3691. // Given an event's allDay status and start date, return what its fallback end date should be.
  3692. // TODO: rename to computeDefaultEventEnd
  3693. function getDefaultEventEnd(allDay, marker, context) {
  3694. let { dateEnv, options } = context;
  3695. let end = marker;
  3696. if (allDay) {
  3697. end = startOfDay(end);
  3698. end = dateEnv.add(end, options.defaultAllDayEventDuration);
  3699. }
  3700. else {
  3701. end = dateEnv.add(end, options.defaultTimedEventDuration);
  3702. }
  3703. return end;
  3704. }
  3705. // applies the mutation to ALL defs/instances within the event store
  3706. function applyMutationToEventStore(eventStore, eventConfigBase, mutation, context) {
  3707. let eventConfigs = compileEventUis(eventStore.defs, eventConfigBase);
  3708. let dest = createEmptyEventStore();
  3709. for (let defId in eventStore.defs) {
  3710. let def = eventStore.defs[defId];
  3711. dest.defs[defId] = applyMutationToEventDef(def, eventConfigs[defId], mutation, context);
  3712. }
  3713. for (let instanceId in eventStore.instances) {
  3714. let instance = eventStore.instances[instanceId];
  3715. let def = dest.defs[instance.defId]; // important to grab the newly modified def
  3716. dest.instances[instanceId] = applyMutationToEventInstance(instance, def, eventConfigs[instance.defId], mutation, context);
  3717. }
  3718. return dest;
  3719. }
  3720. function applyMutationToEventDef(eventDef, eventConfig, mutation, context) {
  3721. let standardProps = mutation.standardProps || {};
  3722. // if hasEnd has not been specified, guess a good value based on deltas.
  3723. // if duration will change, there's no way the default duration will persist,
  3724. // and thus, we need to mark the event as having a real end
  3725. if (standardProps.hasEnd == null &&
  3726. eventConfig.durationEditable &&
  3727. (mutation.startDelta || mutation.endDelta)) {
  3728. standardProps.hasEnd = true; // TODO: is this mutation okay?
  3729. }
  3730. let copy = Object.assign(Object.assign(Object.assign({}, eventDef), standardProps), { ui: Object.assign(Object.assign({}, eventDef.ui), standardProps.ui) });
  3731. if (mutation.extendedProps) {
  3732. copy.extendedProps = Object.assign(Object.assign({}, copy.extendedProps), mutation.extendedProps);
  3733. }
  3734. for (let applier of context.pluginHooks.eventDefMutationAppliers) {
  3735. applier(copy, mutation, context);
  3736. }
  3737. if (!copy.hasEnd && context.options.forceEventDuration) {
  3738. copy.hasEnd = true;
  3739. }
  3740. return copy;
  3741. }
  3742. function applyMutationToEventInstance(eventInstance, eventDef, // must first be modified by applyMutationToEventDef
  3743. eventConfig, mutation, context) {
  3744. let { dateEnv } = context;
  3745. let forceAllDay = mutation.standardProps && mutation.standardProps.allDay === true;
  3746. let clearEnd = mutation.standardProps && mutation.standardProps.hasEnd === false;
  3747. let copy = Object.assign({}, eventInstance);
  3748. if (forceAllDay) {
  3749. copy.range = computeAlignedDayRange(copy.range);
  3750. }
  3751. if (mutation.datesDelta && eventConfig.startEditable) {
  3752. copy.range = {
  3753. start: dateEnv.add(copy.range.start, mutation.datesDelta),
  3754. end: dateEnv.add(copy.range.end, mutation.datesDelta),
  3755. };
  3756. }
  3757. if (mutation.startDelta && eventConfig.durationEditable) {
  3758. copy.range = {
  3759. start: dateEnv.add(copy.range.start, mutation.startDelta),
  3760. end: copy.range.end,
  3761. };
  3762. }
  3763. if (mutation.endDelta && eventConfig.durationEditable) {
  3764. copy.range = {
  3765. start: copy.range.start,
  3766. end: dateEnv.add(copy.range.end, mutation.endDelta),
  3767. };
  3768. }
  3769. if (clearEnd) {
  3770. copy.range = {
  3771. start: copy.range.start,
  3772. end: getDefaultEventEnd(eventDef.allDay, copy.range.start, context),
  3773. };
  3774. }
  3775. // in case event was all-day but the supplied deltas were not
  3776. // better util for this?
  3777. if (eventDef.allDay) {
  3778. copy.range = {
  3779. start: startOfDay(copy.range.start),
  3780. end: startOfDay(copy.range.end),
  3781. };
  3782. }
  3783. // handle invalid durations
  3784. if (copy.range.end < copy.range.start) {
  3785. copy.range.end = getDefaultEventEnd(eventDef.allDay, copy.range.start, context);
  3786. }
  3787. return copy;
  3788. }
  3789. class EventSourceImpl {
  3790. constructor(context, internalEventSource) {
  3791. this.context = context;
  3792. this.internalEventSource = internalEventSource;
  3793. }
  3794. remove() {
  3795. this.context.dispatch({
  3796. type: 'REMOVE_EVENT_SOURCE',
  3797. sourceId: this.internalEventSource.sourceId,
  3798. });
  3799. }
  3800. refetch() {
  3801. this.context.dispatch({
  3802. type: 'FETCH_EVENT_SOURCES',
  3803. sourceIds: [this.internalEventSource.sourceId],
  3804. isRefetch: true,
  3805. });
  3806. }
  3807. get id() {
  3808. return this.internalEventSource.publicId;
  3809. }
  3810. get url() {
  3811. return this.internalEventSource.meta.url;
  3812. }
  3813. get format() {
  3814. return this.internalEventSource.meta.format; // TODO: bad. not guaranteed
  3815. }
  3816. }
  3817. class EventImpl {
  3818. // instance will be null if expressing a recurring event that has no current instances,
  3819. // OR if trying to validate an incoming external event that has no dates assigned
  3820. constructor(context, def, instance) {
  3821. this._context = context;
  3822. this._def = def;
  3823. this._instance = instance || null;
  3824. }
  3825. /*
  3826. TODO: make event struct more responsible for this
  3827. */
  3828. setProp(name, val) {
  3829. if (name in EVENT_DATE_REFINERS) {
  3830. console.warn('Could not set date-related prop \'name\'. Use one of the date-related methods instead.');
  3831. // TODO: make proper aliasing system?
  3832. }
  3833. else if (name === 'id') {
  3834. val = EVENT_NON_DATE_REFINERS[name](val);
  3835. this.mutate({
  3836. standardProps: { publicId: val }, // hardcoded internal name
  3837. });
  3838. }
  3839. else if (name in EVENT_NON_DATE_REFINERS) {
  3840. val = EVENT_NON_DATE_REFINERS[name](val);
  3841. this.mutate({
  3842. standardProps: { [name]: val },
  3843. });
  3844. }
  3845. else if (name in EVENT_UI_REFINERS) {
  3846. let ui = EVENT_UI_REFINERS[name](val);
  3847. if (name === 'color') {
  3848. ui = { backgroundColor: val, borderColor: val };
  3849. }
  3850. else if (name === 'editable') {
  3851. ui = { startEditable: val, durationEditable: val };
  3852. }
  3853. else {
  3854. ui = { [name]: val };
  3855. }
  3856. this.mutate({
  3857. standardProps: { ui },
  3858. });
  3859. }
  3860. else {
  3861. console.warn(`Could not set prop '${name}'. Use setExtendedProp instead.`);
  3862. }
  3863. }
  3864. setExtendedProp(name, val) {
  3865. this.mutate({
  3866. extendedProps: { [name]: val },
  3867. });
  3868. }
  3869. setStart(startInput, options = {}) {
  3870. let { dateEnv } = this._context;
  3871. let start = dateEnv.createMarker(startInput);
  3872. if (start && this._instance) { // TODO: warning if parsed bad
  3873. let instanceRange = this._instance.range;
  3874. let startDelta = diffDates(instanceRange.start, start, dateEnv, options.granularity); // what if parsed bad!?
  3875. if (options.maintainDuration) {
  3876. this.mutate({ datesDelta: startDelta });
  3877. }
  3878. else {
  3879. this.mutate({ startDelta });
  3880. }
  3881. }
  3882. }
  3883. setEnd(endInput, options = {}) {
  3884. let { dateEnv } = this._context;
  3885. let end;
  3886. if (endInput != null) {
  3887. end = dateEnv.createMarker(endInput);
  3888. if (!end) {
  3889. return; // TODO: warning if parsed bad
  3890. }
  3891. }
  3892. if (this._instance) {
  3893. if (end) {
  3894. let endDelta = diffDates(this._instance.range.end, end, dateEnv, options.granularity);
  3895. this.mutate({ endDelta });
  3896. }
  3897. else {
  3898. this.mutate({ standardProps: { hasEnd: false } });
  3899. }
  3900. }
  3901. }
  3902. setDates(startInput, endInput, options = {}) {
  3903. let { dateEnv } = this._context;
  3904. let standardProps = { allDay: options.allDay };
  3905. let start = dateEnv.createMarker(startInput);
  3906. let end;
  3907. if (!start) {
  3908. return; // TODO: warning if parsed bad
  3909. }
  3910. if (endInput != null) {
  3911. end = dateEnv.createMarker(endInput);
  3912. if (!end) { // TODO: warning if parsed bad
  3913. return;
  3914. }
  3915. }
  3916. if (this._instance) {
  3917. let instanceRange = this._instance.range;
  3918. // when computing the diff for an event being converted to all-day,
  3919. // compute diff off of the all-day values the way event-mutation does.
  3920. if (options.allDay === true) {
  3921. instanceRange = computeAlignedDayRange(instanceRange);
  3922. }
  3923. let startDelta = diffDates(instanceRange.start, start, dateEnv, options.granularity);
  3924. if (end) {
  3925. let endDelta = diffDates(instanceRange.end, end, dateEnv, options.granularity);
  3926. if (durationsEqual(startDelta, endDelta)) {
  3927. this.mutate({ datesDelta: startDelta, standardProps });
  3928. }
  3929. else {
  3930. this.mutate({ startDelta, endDelta, standardProps });
  3931. }
  3932. }
  3933. else { // means "clear the end"
  3934. standardProps.hasEnd = false;
  3935. this.mutate({ datesDelta: startDelta, standardProps });
  3936. }
  3937. }
  3938. }
  3939. moveStart(deltaInput) {
  3940. let delta = createDuration(deltaInput);
  3941. if (delta) { // TODO: warning if parsed bad
  3942. this.mutate({ startDelta: delta });
  3943. }
  3944. }
  3945. moveEnd(deltaInput) {
  3946. let delta = createDuration(deltaInput);
  3947. if (delta) { // TODO: warning if parsed bad
  3948. this.mutate({ endDelta: delta });
  3949. }
  3950. }
  3951. moveDates(deltaInput) {
  3952. let delta = createDuration(deltaInput);
  3953. if (delta) { // TODO: warning if parsed bad
  3954. this.mutate({ datesDelta: delta });
  3955. }
  3956. }
  3957. setAllDay(allDay, options = {}) {
  3958. let standardProps = { allDay };
  3959. let { maintainDuration } = options;
  3960. if (maintainDuration == null) {
  3961. maintainDuration = this._context.options.allDayMaintainDuration;
  3962. }
  3963. if (this._def.allDay !== allDay) {
  3964. standardProps.hasEnd = maintainDuration;
  3965. }
  3966. this.mutate({ standardProps });
  3967. }
  3968. formatRange(formatInput) {
  3969. let { dateEnv } = this._context;
  3970. let instance = this._instance;
  3971. let formatter = createFormatter(formatInput);
  3972. if (this._def.hasEnd) {
  3973. return dateEnv.formatRange(instance.range.start, instance.range.end, formatter, {
  3974. forcedStartTzo: instance.forcedStartTzo,
  3975. forcedEndTzo: instance.forcedEndTzo,
  3976. });
  3977. }
  3978. return dateEnv.format(instance.range.start, formatter, {
  3979. forcedTzo: instance.forcedStartTzo,
  3980. });
  3981. }
  3982. mutate(mutation) {
  3983. let instance = this._instance;
  3984. if (instance) {
  3985. let def = this._def;
  3986. let context = this._context;
  3987. let { eventStore } = context.getCurrentData();
  3988. let relevantEvents = getRelevantEvents(eventStore, instance.instanceId);
  3989. let eventConfigBase = {
  3990. '': {
  3991. display: '',
  3992. startEditable: true,
  3993. durationEditable: true,
  3994. constraints: [],
  3995. overlap: null,
  3996. allows: [],
  3997. backgroundColor: '',
  3998. borderColor: '',
  3999. textColor: '',
  4000. classNames: [],
  4001. },
  4002. };
  4003. relevantEvents = applyMutationToEventStore(relevantEvents, eventConfigBase, mutation, context);
  4004. let oldEvent = new EventImpl(context, def, instance); // snapshot
  4005. this._def = relevantEvents.defs[def.defId];
  4006. this._instance = relevantEvents.instances[instance.instanceId];
  4007. context.dispatch({
  4008. type: 'MERGE_EVENTS',
  4009. eventStore: relevantEvents,
  4010. });
  4011. context.emitter.trigger('eventChange', {
  4012. oldEvent,
  4013. event: this,
  4014. relatedEvents: buildEventApis(relevantEvents, context, instance),
  4015. revert() {
  4016. context.dispatch({
  4017. type: 'RESET_EVENTS',
  4018. eventStore, // the ORIGINAL store
  4019. });
  4020. },
  4021. });
  4022. }
  4023. }
  4024. remove() {
  4025. let context = this._context;
  4026. let asStore = eventApiToStore(this);
  4027. context.dispatch({
  4028. type: 'REMOVE_EVENTS',
  4029. eventStore: asStore,
  4030. });
  4031. context.emitter.trigger('eventRemove', {
  4032. event: this,
  4033. relatedEvents: [],
  4034. revert() {
  4035. context.dispatch({
  4036. type: 'MERGE_EVENTS',
  4037. eventStore: asStore,
  4038. });
  4039. },
  4040. });
  4041. }
  4042. get source() {
  4043. let { sourceId } = this._def;
  4044. if (sourceId) {
  4045. return new EventSourceImpl(this._context, this._context.getCurrentData().eventSources[sourceId]);
  4046. }
  4047. return null;
  4048. }
  4049. get start() {
  4050. return this._instance ?
  4051. this._context.dateEnv.toDate(this._instance.range.start) :
  4052. null;
  4053. }
  4054. get end() {
  4055. return (this._instance && this._def.hasEnd) ?
  4056. this._context.dateEnv.toDate(this._instance.range.end) :
  4057. null;
  4058. }
  4059. get startStr() {
  4060. let instance = this._instance;
  4061. if (instance) {
  4062. return this._context.dateEnv.formatIso(instance.range.start, {
  4063. omitTime: this._def.allDay,
  4064. forcedTzo: instance.forcedStartTzo,
  4065. });
  4066. }
  4067. return '';
  4068. }
  4069. get endStr() {
  4070. let instance = this._instance;
  4071. if (instance && this._def.hasEnd) {
  4072. return this._context.dateEnv.formatIso(instance.range.end, {
  4073. omitTime: this._def.allDay,
  4074. forcedTzo: instance.forcedEndTzo,
  4075. });
  4076. }
  4077. return '';
  4078. }
  4079. // computable props that all access the def
  4080. // TODO: find a TypeScript-compatible way to do this at scale
  4081. get id() { return this._def.publicId; }
  4082. get groupId() { return this._def.groupId; }
  4083. get allDay() { return this._def.allDay; }
  4084. get title() { return this._def.title; }
  4085. get url() { return this._def.url; }
  4086. get display() { return this._def.ui.display || 'auto'; } // bad. just normalize the type earlier
  4087. get startEditable() { return this._def.ui.startEditable; }
  4088. get durationEditable() { return this._def.ui.durationEditable; }
  4089. get constraint() { return this._def.ui.constraints[0] || null; }
  4090. get overlap() { return this._def.ui.overlap; }
  4091. get allow() { return this._def.ui.allows[0] || null; }
  4092. get backgroundColor() { return this._def.ui.backgroundColor; }
  4093. get borderColor() { return this._def.ui.borderColor; }
  4094. get textColor() { return this._def.ui.textColor; }
  4095. // NOTE: user can't modify these because Object.freeze was called in event-def parsing
  4096. get classNames() { return this._def.ui.classNames; }
  4097. get extendedProps() { return this._def.extendedProps; }
  4098. toPlainObject(settings = {}) {
  4099. let def = this._def;
  4100. let { ui } = def;
  4101. let { startStr, endStr } = this;
  4102. let res = {
  4103. allDay: def.allDay,
  4104. };
  4105. if (def.title) {
  4106. res.title = def.title;
  4107. }
  4108. if (startStr) {
  4109. res.start = startStr;
  4110. }
  4111. if (endStr) {
  4112. res.end = endStr;
  4113. }
  4114. if (def.publicId) {
  4115. res.id = def.publicId;
  4116. }
  4117. if (def.groupId) {
  4118. res.groupId = def.groupId;
  4119. }
  4120. if (def.url) {
  4121. res.url = def.url;
  4122. }
  4123. if (ui.display && ui.display !== 'auto') {
  4124. res.display = ui.display;
  4125. }
  4126. // TODO: what about recurring-event properties???
  4127. // TODO: include startEditable/durationEditable/constraint/overlap/allow
  4128. if (settings.collapseColor && ui.backgroundColor && ui.backgroundColor === ui.borderColor) {
  4129. res.color = ui.backgroundColor;
  4130. }
  4131. else {
  4132. if (ui.backgroundColor) {
  4133. res.backgroundColor = ui.backgroundColor;
  4134. }
  4135. if (ui.borderColor) {
  4136. res.borderColor = ui.borderColor;
  4137. }
  4138. }
  4139. if (ui.textColor) {
  4140. res.textColor = ui.textColor;
  4141. }
  4142. if (ui.classNames.length) {
  4143. res.classNames = ui.classNames;
  4144. }
  4145. if (Object.keys(def.extendedProps).length) {
  4146. if (settings.collapseExtendedProps) {
  4147. Object.assign(res, def.extendedProps);
  4148. }
  4149. else {
  4150. res.extendedProps = def.extendedProps;
  4151. }
  4152. }
  4153. return res;
  4154. }
  4155. toJSON() {
  4156. return this.toPlainObject();
  4157. }
  4158. }
  4159. function eventApiToStore(eventApi) {
  4160. let def = eventApi._def;
  4161. let instance = eventApi._instance;
  4162. return {
  4163. defs: { [def.defId]: def },
  4164. instances: instance
  4165. ? { [instance.instanceId]: instance }
  4166. : {},
  4167. };
  4168. }
  4169. function buildEventApis(eventStore, context, excludeInstance) {
  4170. let { defs, instances } = eventStore;
  4171. let eventApis = [];
  4172. let excludeInstanceId = excludeInstance ? excludeInstance.instanceId : '';
  4173. for (let id in instances) {
  4174. let instance = instances[id];
  4175. let def = defs[instance.defId];
  4176. if (instance.instanceId !== excludeInstanceId) {
  4177. eventApis.push(new EventImpl(context, def, instance));
  4178. }
  4179. }
  4180. return eventApis;
  4181. }
  4182. /*
  4183. Specifying nextDayThreshold signals that all-day ranges should be sliced.
  4184. */
  4185. function sliceEventStore(eventStore, eventUiBases, framingRange, nextDayThreshold) {
  4186. let inverseBgByGroupId = {};
  4187. let inverseBgByDefId = {};
  4188. let defByGroupId = {};
  4189. let bgRanges = [];
  4190. let fgRanges = [];
  4191. let eventUis = compileEventUis(eventStore.defs, eventUiBases);
  4192. for (let defId in eventStore.defs) {
  4193. let def = eventStore.defs[defId];
  4194. let ui = eventUis[def.defId];
  4195. if (ui.display === 'inverse-background') {
  4196. if (def.groupId) {
  4197. inverseBgByGroupId[def.groupId] = [];
  4198. if (!defByGroupId[def.groupId]) {
  4199. defByGroupId[def.groupId] = def;
  4200. }
  4201. }
  4202. else {
  4203. inverseBgByDefId[defId] = [];
  4204. }
  4205. }
  4206. }
  4207. for (let instanceId in eventStore.instances) {
  4208. let instance = eventStore.instances[instanceId];
  4209. let def = eventStore.defs[instance.defId];
  4210. let ui = eventUis[def.defId];
  4211. let origRange = instance.range;
  4212. let normalRange = (!def.allDay && nextDayThreshold) ?
  4213. computeVisibleDayRange(origRange, nextDayThreshold) :
  4214. origRange;
  4215. let slicedRange = intersectRanges(normalRange, framingRange);
  4216. if (slicedRange) {
  4217. if (ui.display === 'inverse-background') {
  4218. if (def.groupId) {
  4219. inverseBgByGroupId[def.groupId].push(slicedRange);
  4220. }
  4221. else {
  4222. inverseBgByDefId[instance.defId].push(slicedRange);
  4223. }
  4224. }
  4225. else if (ui.display !== 'none') {
  4226. (ui.display === 'background' ? bgRanges : fgRanges).push({
  4227. def,
  4228. ui,
  4229. instance,
  4230. range: slicedRange,
  4231. isStart: normalRange.start && normalRange.start.valueOf() === slicedRange.start.valueOf(),
  4232. isEnd: normalRange.end && normalRange.end.valueOf() === slicedRange.end.valueOf(),
  4233. });
  4234. }
  4235. }
  4236. }
  4237. for (let groupId in inverseBgByGroupId) { // BY GROUP
  4238. let ranges = inverseBgByGroupId[groupId];
  4239. let invertedRanges = invertRanges(ranges, framingRange);
  4240. for (let invertedRange of invertedRanges) {
  4241. let def = defByGroupId[groupId];
  4242. let ui = eventUis[def.defId];
  4243. bgRanges.push({
  4244. def,
  4245. ui,
  4246. instance: null,
  4247. range: invertedRange,
  4248. isStart: false,
  4249. isEnd: false,
  4250. });
  4251. }
  4252. }
  4253. for (let defId in inverseBgByDefId) {
  4254. let ranges = inverseBgByDefId[defId];
  4255. let invertedRanges = invertRanges(ranges, framingRange);
  4256. for (let invertedRange of invertedRanges) {
  4257. bgRanges.push({
  4258. def: eventStore.defs[defId],
  4259. ui: eventUis[defId],
  4260. instance: null,
  4261. range: invertedRange,
  4262. isStart: false,
  4263. isEnd: false,
  4264. });
  4265. }
  4266. }
  4267. return { bg: bgRanges, fg: fgRanges };
  4268. }
  4269. function hasBgRendering(def) {
  4270. return def.ui.display === 'background' || def.ui.display === 'inverse-background';
  4271. }
  4272. function setElSeg(el, seg) {
  4273. el.fcSeg = seg;
  4274. }
  4275. function getElSeg(el) {
  4276. return el.fcSeg ||
  4277. el.parentNode.fcSeg || // for the harness
  4278. null;
  4279. }
  4280. // event ui computation
  4281. function compileEventUis(eventDefs, eventUiBases) {
  4282. return mapHash(eventDefs, (eventDef) => compileEventUi(eventDef, eventUiBases));
  4283. }
  4284. function compileEventUi(eventDef, eventUiBases) {
  4285. let uis = [];
  4286. if (eventUiBases['']) {
  4287. uis.push(eventUiBases['']);
  4288. }
  4289. if (eventUiBases[eventDef.defId]) {
  4290. uis.push(eventUiBases[eventDef.defId]);
  4291. }
  4292. uis.push(eventDef.ui);
  4293. return combineEventUis(uis);
  4294. }
  4295. function sortEventSegs(segs, eventOrderSpecs) {
  4296. let objs = segs.map(buildSegCompareObj);
  4297. objs.sort((obj0, obj1) => compareByFieldSpecs(obj0, obj1, eventOrderSpecs));
  4298. return objs.map((c) => c._seg);
  4299. }
  4300. // returns a object with all primitive props that can be compared
  4301. function buildSegCompareObj(seg) {
  4302. let { eventRange } = seg;
  4303. let eventDef = eventRange.def;
  4304. let range = eventRange.instance ? eventRange.instance.range : eventRange.range;
  4305. let start = range.start ? range.start.valueOf() : 0; // TODO: better support for open-range events
  4306. let end = range.end ? range.end.valueOf() : 0; // "
  4307. return Object.assign(Object.assign(Object.assign({}, eventDef.extendedProps), eventDef), { id: eventDef.publicId, start,
  4308. end, duration: end - start, allDay: Number(eventDef.allDay), _seg: seg });
  4309. }
  4310. function computeSegDraggable(seg, context) {
  4311. let { pluginHooks } = context;
  4312. let transformers = pluginHooks.isDraggableTransformers;
  4313. let { def, ui } = seg.eventRange;
  4314. let val = ui.startEditable;
  4315. for (let transformer of transformers) {
  4316. val = transformer(val, def, ui, context);
  4317. }
  4318. return val;
  4319. }
  4320. function computeSegStartResizable(seg, context) {
  4321. return seg.isStart && seg.eventRange.ui.durationEditable && context.options.eventResizableFromStart;
  4322. }
  4323. function computeSegEndResizable(seg, context) {
  4324. return seg.isEnd && seg.eventRange.ui.durationEditable;
  4325. }
  4326. function buildSegTimeText(seg, timeFormat, context, defaultDisplayEventTime, // defaults to true
  4327. defaultDisplayEventEnd, // defaults to true
  4328. startOverride, endOverride) {
  4329. let { dateEnv, options } = context;
  4330. let { displayEventTime, displayEventEnd } = options;
  4331. let eventDef = seg.eventRange.def;
  4332. let eventInstance = seg.eventRange.instance;
  4333. if (displayEventTime == null) {
  4334. displayEventTime = defaultDisplayEventTime !== false;
  4335. }
  4336. if (displayEventEnd == null) {
  4337. displayEventEnd = defaultDisplayEventEnd !== false;
  4338. }
  4339. let wholeEventStart = eventInstance.range.start;
  4340. let wholeEventEnd = eventInstance.range.end;
  4341. let segStart = startOverride || seg.start || seg.eventRange.range.start;
  4342. let segEnd = endOverride || seg.end || seg.eventRange.range.end;
  4343. let isStartDay = startOfDay(wholeEventStart).valueOf() === startOfDay(segStart).valueOf();
  4344. let isEndDay = startOfDay(addMs(wholeEventEnd, -1)).valueOf() === startOfDay(addMs(segEnd, -1)).valueOf();
  4345. if (displayEventTime && !eventDef.allDay && (isStartDay || isEndDay)) {
  4346. segStart = isStartDay ? wholeEventStart : segStart;
  4347. segEnd = isEndDay ? wholeEventEnd : segEnd;
  4348. if (displayEventEnd && eventDef.hasEnd) {
  4349. return dateEnv.formatRange(segStart, segEnd, timeFormat, {
  4350. forcedStartTzo: startOverride ? null : eventInstance.forcedStartTzo,
  4351. forcedEndTzo: endOverride ? null : eventInstance.forcedEndTzo,
  4352. });
  4353. }
  4354. return dateEnv.format(segStart, timeFormat, {
  4355. forcedTzo: startOverride ? null : eventInstance.forcedStartTzo, // nooooo, same
  4356. });
  4357. }
  4358. return '';
  4359. }
  4360. function getSegMeta(seg, todayRange, nowDate) {
  4361. let segRange = seg.eventRange.range;
  4362. return {
  4363. isPast: segRange.end <= (nowDate || todayRange.start),
  4364. isFuture: segRange.start >= (nowDate || todayRange.end),
  4365. isToday: todayRange && rangeContainsMarker(todayRange, segRange.start),
  4366. };
  4367. }
  4368. function getEventClassNames(props) {
  4369. let classNames = ['fc-event'];
  4370. if (props.isMirror) {
  4371. classNames.push('fc-event-mirror');
  4372. }
  4373. if (props.isDraggable) {
  4374. classNames.push('fc-event-draggable');
  4375. }
  4376. if (props.isStartResizable || props.isEndResizable) {
  4377. classNames.push('fc-event-resizable');
  4378. }
  4379. if (props.isDragging) {
  4380. classNames.push('fc-event-dragging');
  4381. }
  4382. if (props.isResizing) {
  4383. classNames.push('fc-event-resizing');
  4384. }
  4385. if (props.isSelected) {
  4386. classNames.push('fc-event-selected');
  4387. }
  4388. if (props.isStart) {
  4389. classNames.push('fc-event-start');
  4390. }
  4391. if (props.isEnd) {
  4392. classNames.push('fc-event-end');
  4393. }
  4394. if (props.isPast) {
  4395. classNames.push('fc-event-past');
  4396. }
  4397. if (props.isToday) {
  4398. classNames.push('fc-event-today');
  4399. }
  4400. if (props.isFuture) {
  4401. classNames.push('fc-event-future');
  4402. }
  4403. return classNames;
  4404. }
  4405. function buildEventRangeKey(eventRange) {
  4406. return eventRange.instance
  4407. ? eventRange.instance.instanceId
  4408. : `${eventRange.def.defId}:${eventRange.range.start.toISOString()}`;
  4409. // inverse-background events don't have specific instances. TODO: better solution
  4410. }
  4411. function getSegAnchorAttrs(seg, context) {
  4412. let { def, instance } = seg.eventRange;
  4413. let { url } = def;
  4414. if (url) {
  4415. return { href: url };
  4416. }
  4417. let { emitter, options } = context;
  4418. let { eventInteractive } = options;
  4419. if (eventInteractive == null) {
  4420. eventInteractive = def.interactive;
  4421. if (eventInteractive == null) {
  4422. eventInteractive = Boolean(emitter.hasHandlers('eventClick'));
  4423. }
  4424. }
  4425. // mock what happens in EventClicking
  4426. if (eventInteractive) {
  4427. // only attach keyboard-related handlers because click handler is already done in EventClicking
  4428. return createAriaKeyboardAttrs((ev) => {
  4429. emitter.trigger('eventClick', {
  4430. el: ev.target,
  4431. event: new EventImpl(context, def, instance),
  4432. jsEvent: ev,
  4433. view: context.viewApi,
  4434. });
  4435. });
  4436. }
  4437. return {};
  4438. }
  4439. const STANDARD_PROPS = {
  4440. start: identity,
  4441. end: identity,
  4442. allDay: Boolean,
  4443. };
  4444. function parseDateSpan(raw, dateEnv, defaultDuration) {
  4445. let span = parseOpenDateSpan(raw, dateEnv);
  4446. let { range } = span;
  4447. if (!range.start) {
  4448. return null;
  4449. }
  4450. if (!range.end) {
  4451. if (defaultDuration == null) {
  4452. return null;
  4453. }
  4454. range.end = dateEnv.add(range.start, defaultDuration);
  4455. }
  4456. return span;
  4457. }
  4458. /*
  4459. TODO: somehow combine with parseRange?
  4460. Will return null if the start/end props were present but parsed invalidly.
  4461. */
  4462. function parseOpenDateSpan(raw, dateEnv) {
  4463. let { refined: standardProps, extra } = refineProps(raw, STANDARD_PROPS);
  4464. let startMeta = standardProps.start ? dateEnv.createMarkerMeta(standardProps.start) : null;
  4465. let endMeta = standardProps.end ? dateEnv.createMarkerMeta(standardProps.end) : null;
  4466. let { allDay } = standardProps;
  4467. if (allDay == null) {
  4468. allDay = (startMeta && startMeta.isTimeUnspecified) &&
  4469. (!endMeta || endMeta.isTimeUnspecified);
  4470. }
  4471. return Object.assign({ range: {
  4472. start: startMeta ? startMeta.marker : null,
  4473. end: endMeta ? endMeta.marker : null,
  4474. }, allDay }, extra);
  4475. }
  4476. function isDateSpansEqual(span0, span1) {
  4477. return rangesEqual(span0.range, span1.range) &&
  4478. span0.allDay === span1.allDay &&
  4479. isSpanPropsEqual(span0, span1);
  4480. }
  4481. // the NON-DATE-RELATED props
  4482. function isSpanPropsEqual(span0, span1) {
  4483. for (let propName in span1) {
  4484. if (propName !== 'range' && propName !== 'allDay') {
  4485. if (span0[propName] !== span1[propName]) {
  4486. return false;
  4487. }
  4488. }
  4489. }
  4490. // are there any props that span0 has that span1 DOESN'T have?
  4491. // both have range/allDay, so no need to special-case.
  4492. for (let propName in span0) {
  4493. if (!(propName in span1)) {
  4494. return false;
  4495. }
  4496. }
  4497. return true;
  4498. }
  4499. function buildDateSpanApi(span, dateEnv) {
  4500. return Object.assign(Object.assign({}, buildRangeApi(span.range, dateEnv, span.allDay)), { allDay: span.allDay });
  4501. }
  4502. function buildRangeApiWithTimeZone(range, dateEnv, omitTime) {
  4503. return Object.assign(Object.assign({}, buildRangeApi(range, dateEnv, omitTime)), { timeZone: dateEnv.timeZone });
  4504. }
  4505. function buildRangeApi(range, dateEnv, omitTime) {
  4506. return {
  4507. start: dateEnv.toDate(range.start),
  4508. end: dateEnv.toDate(range.end),
  4509. startStr: dateEnv.formatIso(range.start, { omitTime }),
  4510. endStr: dateEnv.formatIso(range.end, { omitTime }),
  4511. };
  4512. }
  4513. function fabricateEventRange(dateSpan, eventUiBases, context) {
  4514. let res = refineEventDef({ editable: false }, context);
  4515. let def = parseEventDef(res.refined, res.extra, '', // sourceId
  4516. dateSpan.allDay, true, // hasEnd
  4517. context);
  4518. return {
  4519. def,
  4520. ui: compileEventUi(def, eventUiBases),
  4521. instance: createEventInstance(def.defId, dateSpan.range),
  4522. range: dateSpan.range,
  4523. isStart: true,
  4524. isEnd: true,
  4525. };
  4526. }
  4527. /*
  4528. given a function that resolves a result asynchronously.
  4529. the function can either call passed-in success and failure callbacks,
  4530. or it can return a promise.
  4531. if you need to pass additional params to func, bind them first.
  4532. */
  4533. function unpromisify(func, normalizedSuccessCallback, normalizedFailureCallback) {
  4534. // guard against success/failure callbacks being called more than once
  4535. // and guard against a promise AND callback being used together.
  4536. let isResolved = false;
  4537. let wrappedSuccess = function (res) {
  4538. if (!isResolved) {
  4539. isResolved = true;
  4540. normalizedSuccessCallback(res);
  4541. }
  4542. };
  4543. let wrappedFailure = function (error) {
  4544. if (!isResolved) {
  4545. isResolved = true;
  4546. normalizedFailureCallback(error);
  4547. }
  4548. };
  4549. let res = func(wrappedSuccess, wrappedFailure);
  4550. if (res && typeof res.then === 'function') {
  4551. res.then(wrappedSuccess, wrappedFailure);
  4552. }
  4553. }
  4554. class JsonRequestError extends Error {
  4555. constructor(message, response) {
  4556. super(message);
  4557. this.response = response;
  4558. }
  4559. }
  4560. function requestJson(method, url, params) {
  4561. method = method.toUpperCase();
  4562. const fetchOptions = {
  4563. method,
  4564. };
  4565. if (method === 'GET') {
  4566. url += (url.indexOf('?') === -1 ? '?' : '&') +
  4567. new URLSearchParams(params);
  4568. }
  4569. else {
  4570. fetchOptions.body = new URLSearchParams(params);
  4571. fetchOptions.headers = {
  4572. 'Content-Type': 'application/x-www-form-urlencoded',
  4573. };
  4574. }
  4575. return fetch(url, fetchOptions).then((fetchRes) => {
  4576. if (fetchRes.ok) {
  4577. return fetchRes.json().then((parsedResponse) => {
  4578. return [parsedResponse, fetchRes];
  4579. }, () => {
  4580. throw new JsonRequestError('Failure parsing JSON', fetchRes);
  4581. });
  4582. }
  4583. else {
  4584. throw new JsonRequestError('Request failed', fetchRes);
  4585. }
  4586. });
  4587. }
  4588. let canVGrowWithinCell;
  4589. function getCanVGrowWithinCell() {
  4590. if (canVGrowWithinCell == null) {
  4591. canVGrowWithinCell = computeCanVGrowWithinCell();
  4592. }
  4593. return canVGrowWithinCell;
  4594. }
  4595. function computeCanVGrowWithinCell() {
  4596. // for SSR, because this function is call immediately at top-level
  4597. // TODO: just make this logic execute top-level, immediately, instead of doing lazily
  4598. if (typeof document === 'undefined') {
  4599. return true;
  4600. }
  4601. let el = document.createElement('div');
  4602. el.style.position = 'absolute';
  4603. el.style.top = '0px';
  4604. el.style.left = '0px';
  4605. el.innerHTML = '<table><tr><td><div></div></td></tr></table>';
  4606. el.querySelector('table').style.height = '100px';
  4607. el.querySelector('div').style.height = '100%';
  4608. document.body.appendChild(el);
  4609. let div = el.querySelector('div');
  4610. let possible = div.offsetHeight > 0;
  4611. document.body.removeChild(el);
  4612. return possible;
  4613. }
  4614. class CalendarRoot extends BaseComponent {
  4615. constructor() {
  4616. super(...arguments);
  4617. this.state = {
  4618. forPrint: false,
  4619. };
  4620. this.handleBeforePrint = () => {
  4621. flushSync(() => {
  4622. this.setState({ forPrint: true });
  4623. });
  4624. };
  4625. this.handleAfterPrint = () => {
  4626. flushSync(() => {
  4627. this.setState({ forPrint: false });
  4628. });
  4629. };
  4630. }
  4631. render() {
  4632. let { props } = this;
  4633. let { options } = props;
  4634. let { forPrint } = this.state;
  4635. let isHeightAuto = forPrint || options.height === 'auto' || options.contentHeight === 'auto';
  4636. let height = (!isHeightAuto && options.height != null) ? options.height : '';
  4637. let classNames = [
  4638. 'fc',
  4639. forPrint ? 'fc-media-print' : 'fc-media-screen',
  4640. `fc-direction-${options.direction}`,
  4641. props.theme.getClass('root'),
  4642. ];
  4643. if (!getCanVGrowWithinCell()) {
  4644. classNames.push('fc-liquid-hack');
  4645. }
  4646. return props.children(classNames, height, isHeightAuto, forPrint);
  4647. }
  4648. componentDidMount() {
  4649. let { emitter } = this.props;
  4650. emitter.on('_beforeprint', this.handleBeforePrint);
  4651. emitter.on('_afterprint', this.handleAfterPrint);
  4652. }
  4653. componentWillUnmount() {
  4654. let { emitter } = this.props;
  4655. emitter.off('_beforeprint', this.handleBeforePrint);
  4656. emitter.off('_afterprint', this.handleAfterPrint);
  4657. }
  4658. }
  4659. class Interaction {
  4660. constructor(settings) {
  4661. this.component = settings.component;
  4662. this.isHitComboAllowed = settings.isHitComboAllowed || null;
  4663. }
  4664. destroy() {
  4665. }
  4666. }
  4667. function parseInteractionSettings(component, input) {
  4668. return {
  4669. component,
  4670. el: input.el,
  4671. useEventCenter: input.useEventCenter != null ? input.useEventCenter : true,
  4672. isHitComboAllowed: input.isHitComboAllowed || null,
  4673. };
  4674. }
  4675. function interactionSettingsToStore(settings) {
  4676. return {
  4677. [settings.component.uid]: settings,
  4678. };
  4679. }
  4680. // global state
  4681. const interactionSettingsStore = {};
  4682. class NowTimer extends x$1 {
  4683. constructor(props, context) {
  4684. super(props, context);
  4685. this.handleRefresh = () => {
  4686. let timing = this.computeTiming();
  4687. if (timing.state.nowDate.valueOf() !== this.state.nowDate.valueOf()) {
  4688. this.setState(timing.state);
  4689. }
  4690. this.clearTimeout();
  4691. this.setTimeout(timing.waitMs);
  4692. };
  4693. this.handleVisibilityChange = () => {
  4694. if (!document.hidden) {
  4695. this.handleRefresh();
  4696. }
  4697. };
  4698. this.state = this.computeTiming().state;
  4699. }
  4700. render() {
  4701. let { props, state } = this;
  4702. return props.children(state.nowDate, state.todayRange);
  4703. }
  4704. componentDidMount() {
  4705. this.setTimeout();
  4706. this.context.nowManager.addResetListener(this.handleRefresh);
  4707. // fired tab becomes visible after being hidden
  4708. document.addEventListener('visibilitychange', this.handleVisibilityChange);
  4709. }
  4710. componentDidUpdate(prevProps) {
  4711. if (prevProps.unit !== this.props.unit) {
  4712. this.clearTimeout();
  4713. this.setTimeout();
  4714. }
  4715. }
  4716. componentWillUnmount() {
  4717. this.clearTimeout();
  4718. this.context.nowManager.removeResetListener(this.handleRefresh);
  4719. document.removeEventListener('visibilitychange', this.handleVisibilityChange);
  4720. }
  4721. computeTiming() {
  4722. let { props, context } = this;
  4723. let unroundedNow = context.nowManager.getDateMarker();
  4724. let currentUnitStart = context.dateEnv.startOf(unroundedNow, props.unit);
  4725. let nextUnitStart = context.dateEnv.add(currentUnitStart, createDuration(1, props.unit));
  4726. let waitMs = nextUnitStart.valueOf() - unroundedNow.valueOf();
  4727. // there is a max setTimeout ms value (https://stackoverflow.com/a/3468650/96342)
  4728. // ensure no longer than a day
  4729. waitMs = Math.min(1000 * 60 * 60 * 24, waitMs);
  4730. return {
  4731. state: { nowDate: currentUnitStart, todayRange: buildDayRange(currentUnitStart) },
  4732. waitMs,
  4733. };
  4734. }
  4735. setTimeout(waitMs = this.computeTiming().waitMs) {
  4736. // NOTE: timeout could take longer than expected if tab sleeps,
  4737. // which is why we listen to 'visibilitychange'
  4738. this.timeoutId = setTimeout(() => {
  4739. // NOTE: timeout could also return *earlier* than expected, and we need to wait 2 ms more
  4740. // This is why use use same waitMs from computeTiming, so we don't skip an interval while
  4741. // .setState() is executing
  4742. const timing = this.computeTiming();
  4743. this.setState(timing.state, () => {
  4744. this.setTimeout(timing.waitMs);
  4745. });
  4746. }, waitMs);
  4747. }
  4748. clearTimeout() {
  4749. if (this.timeoutId) {
  4750. clearTimeout(this.timeoutId);
  4751. }
  4752. }
  4753. }
  4754. NowTimer.contextType = ViewContextType;
  4755. function buildDayRange(date) {
  4756. let start = startOfDay(date);
  4757. let end = addDays(start, 1);
  4758. return { start, end };
  4759. }
  4760. class CalendarImpl {
  4761. getCurrentData() {
  4762. return this.currentDataManager.getCurrentData();
  4763. }
  4764. dispatch(action) {
  4765. this.currentDataManager.dispatch(action);
  4766. }
  4767. get view() { return this.getCurrentData().viewApi; }
  4768. batchRendering(callback) {
  4769. callback();
  4770. }
  4771. updateSize() {
  4772. this.trigger('_resize', true);
  4773. }
  4774. // Options
  4775. // -----------------------------------------------------------------------------------------------------------------
  4776. setOption(name, val) {
  4777. this.dispatch({
  4778. type: 'SET_OPTION',
  4779. optionName: name,
  4780. rawOptionValue: val,
  4781. });
  4782. }
  4783. getOption(name) {
  4784. return this.currentDataManager.currentCalendarOptionsInput[name];
  4785. }
  4786. getAvailableLocaleCodes() {
  4787. return Object.keys(this.getCurrentData().availableRawLocales);
  4788. }
  4789. // Trigger
  4790. // -----------------------------------------------------------------------------------------------------------------
  4791. on(handlerName, handler) {
  4792. let { currentDataManager } = this;
  4793. if (currentDataManager.currentCalendarOptionsRefiners[handlerName]) {
  4794. currentDataManager.emitter.on(handlerName, handler);
  4795. }
  4796. else {
  4797. console.warn(`Unknown listener name '${handlerName}'`);
  4798. }
  4799. }
  4800. off(handlerName, handler) {
  4801. this.currentDataManager.emitter.off(handlerName, handler);
  4802. }
  4803. // not meant for public use
  4804. trigger(handlerName, ...args) {
  4805. this.currentDataManager.emitter.trigger(handlerName, ...args);
  4806. }
  4807. // View
  4808. // -----------------------------------------------------------------------------------------------------------------
  4809. changeView(viewType, dateOrRange) {
  4810. this.batchRendering(() => {
  4811. this.unselect();
  4812. if (dateOrRange) {
  4813. if (dateOrRange.start && dateOrRange.end) { // a range
  4814. this.dispatch({
  4815. type: 'CHANGE_VIEW_TYPE',
  4816. viewType,
  4817. });
  4818. this.dispatch({
  4819. type: 'SET_OPTION',
  4820. optionName: 'visibleRange',
  4821. rawOptionValue: dateOrRange,
  4822. });
  4823. }
  4824. else {
  4825. let { dateEnv } = this.getCurrentData();
  4826. this.dispatch({
  4827. type: 'CHANGE_VIEW_TYPE',
  4828. viewType,
  4829. dateMarker: dateEnv.createMarker(dateOrRange),
  4830. });
  4831. }
  4832. }
  4833. else {
  4834. this.dispatch({
  4835. type: 'CHANGE_VIEW_TYPE',
  4836. viewType,
  4837. });
  4838. }
  4839. });
  4840. }
  4841. // Forces navigation to a view for the given date.
  4842. // `viewType` can be a specific view name or a generic one like "week" or "day".
  4843. // needs to change
  4844. zoomTo(dateMarker, viewType) {
  4845. let state = this.getCurrentData();
  4846. let spec;
  4847. viewType = viewType || 'day'; // day is default zoom
  4848. spec = state.viewSpecs[viewType] || this.getUnitViewSpec(viewType);
  4849. this.unselect();
  4850. if (spec) {
  4851. this.dispatch({
  4852. type: 'CHANGE_VIEW_TYPE',
  4853. viewType: spec.type,
  4854. dateMarker,
  4855. });
  4856. }
  4857. else {
  4858. this.dispatch({
  4859. type: 'CHANGE_DATE',
  4860. dateMarker,
  4861. });
  4862. }
  4863. }
  4864. // Given a duration singular unit, like "week" or "day", finds a matching view spec.
  4865. // Preference is given to views that have corresponding buttons.
  4866. getUnitViewSpec(unit) {
  4867. let { viewSpecs, toolbarConfig } = this.getCurrentData();
  4868. let viewTypes = [].concat(toolbarConfig.header ? toolbarConfig.header.viewsWithButtons : [], toolbarConfig.footer ? toolbarConfig.footer.viewsWithButtons : []);
  4869. let i;
  4870. let spec;
  4871. for (let viewType in viewSpecs) {
  4872. viewTypes.push(viewType);
  4873. }
  4874. for (i = 0; i < viewTypes.length; i += 1) {
  4875. spec = viewSpecs[viewTypes[i]];
  4876. if (spec) {
  4877. if (spec.singleUnit === unit) {
  4878. return spec;
  4879. }
  4880. }
  4881. }
  4882. return null;
  4883. }
  4884. // Current Date
  4885. // -----------------------------------------------------------------------------------------------------------------
  4886. prev() {
  4887. this.unselect();
  4888. this.dispatch({ type: 'PREV' });
  4889. }
  4890. next() {
  4891. this.unselect();
  4892. this.dispatch({ type: 'NEXT' });
  4893. }
  4894. prevYear() {
  4895. let state = this.getCurrentData();
  4896. this.unselect();
  4897. this.dispatch({
  4898. type: 'CHANGE_DATE',
  4899. dateMarker: state.dateEnv.addYears(state.currentDate, -1),
  4900. });
  4901. }
  4902. nextYear() {
  4903. let state = this.getCurrentData();
  4904. this.unselect();
  4905. this.dispatch({
  4906. type: 'CHANGE_DATE',
  4907. dateMarker: state.dateEnv.addYears(state.currentDate, 1),
  4908. });
  4909. }
  4910. today() {
  4911. let state = this.getCurrentData();
  4912. this.unselect();
  4913. this.dispatch({
  4914. type: 'CHANGE_DATE',
  4915. dateMarker: state.nowManager.getDateMarker(),
  4916. });
  4917. }
  4918. gotoDate(zonedDateInput) {
  4919. let state = this.getCurrentData();
  4920. this.unselect();
  4921. this.dispatch({
  4922. type: 'CHANGE_DATE',
  4923. dateMarker: state.dateEnv.createMarker(zonedDateInput),
  4924. });
  4925. }
  4926. incrementDate(deltaInput) {
  4927. let state = this.getCurrentData();
  4928. let delta = createDuration(deltaInput);
  4929. if (delta) { // else, warn about invalid input?
  4930. this.unselect();
  4931. this.dispatch({
  4932. type: 'CHANGE_DATE',
  4933. dateMarker: state.dateEnv.add(state.currentDate, delta),
  4934. });
  4935. }
  4936. }
  4937. getDate() {
  4938. let state = this.getCurrentData();
  4939. return state.dateEnv.toDate(state.currentDate);
  4940. }
  4941. // Date Formatting Utils
  4942. // -----------------------------------------------------------------------------------------------------------------
  4943. formatDate(d, formatter) {
  4944. let { dateEnv } = this.getCurrentData();
  4945. return dateEnv.format(dateEnv.createMarker(d), createFormatter(formatter));
  4946. }
  4947. // `settings` is for formatter AND isEndExclusive
  4948. formatRange(d0, d1, settings) {
  4949. let { dateEnv } = this.getCurrentData();
  4950. return dateEnv.formatRange(dateEnv.createMarker(d0), dateEnv.createMarker(d1), createFormatter(settings), settings);
  4951. }
  4952. formatIso(d, omitTime) {
  4953. let { dateEnv } = this.getCurrentData();
  4954. return dateEnv.formatIso(dateEnv.createMarker(d), { omitTime });
  4955. }
  4956. // Date Selection / Event Selection / DayClick
  4957. // -----------------------------------------------------------------------------------------------------------------
  4958. select(dateOrObj, endDate) {
  4959. let selectionInput;
  4960. if (endDate == null) {
  4961. if (dateOrObj.start != null) {
  4962. selectionInput = dateOrObj;
  4963. }
  4964. else {
  4965. selectionInput = {
  4966. start: dateOrObj,
  4967. end: null,
  4968. };
  4969. }
  4970. }
  4971. else {
  4972. selectionInput = {
  4973. start: dateOrObj,
  4974. end: endDate,
  4975. };
  4976. }
  4977. let state = this.getCurrentData();
  4978. let selection = parseDateSpan(selectionInput, state.dateEnv, createDuration({ days: 1 }));
  4979. if (selection) { // throw parse error otherwise?
  4980. this.dispatch({ type: 'SELECT_DATES', selection });
  4981. triggerDateSelect(selection, null, state);
  4982. }
  4983. }
  4984. unselect(pev) {
  4985. let state = this.getCurrentData();
  4986. if (state.dateSelection) {
  4987. this.dispatch({ type: 'UNSELECT_DATES' });
  4988. triggerDateUnselect(pev, state);
  4989. }
  4990. }
  4991. // Public Events API
  4992. // -----------------------------------------------------------------------------------------------------------------
  4993. addEvent(eventInput, sourceInput) {
  4994. if (eventInput instanceof EventImpl) {
  4995. let def = eventInput._def;
  4996. let instance = eventInput._instance;
  4997. let currentData = this.getCurrentData();
  4998. // not already present? don't want to add an old snapshot
  4999. if (!currentData.eventStore.defs[def.defId]) {
  5000. this.dispatch({
  5001. type: 'ADD_EVENTS',
  5002. eventStore: eventTupleToStore({ def, instance }), // TODO: better util for two args?
  5003. });
  5004. this.triggerEventAdd(eventInput);
  5005. }
  5006. return eventInput;
  5007. }
  5008. let state = this.getCurrentData();
  5009. let eventSource;
  5010. if (sourceInput instanceof EventSourceImpl) {
  5011. eventSource = sourceInput.internalEventSource;
  5012. }
  5013. else if (typeof sourceInput === 'boolean') {
  5014. if (sourceInput) { // true. part of the first event source
  5015. [eventSource] = hashValuesToArray(state.eventSources);
  5016. }
  5017. }
  5018. else if (sourceInput != null) { // an ID. accepts a number too
  5019. let sourceApi = this.getEventSourceById(sourceInput); // TODO: use an internal function
  5020. if (!sourceApi) {
  5021. console.warn(`Could not find an event source with ID "${sourceInput}"`); // TODO: test
  5022. return null;
  5023. }
  5024. eventSource = sourceApi.internalEventSource;
  5025. }
  5026. let tuple = parseEvent(eventInput, eventSource, state, false);
  5027. if (tuple) {
  5028. let newEventApi = new EventImpl(state, tuple.def, tuple.def.recurringDef ? null : tuple.instance);
  5029. this.dispatch({
  5030. type: 'ADD_EVENTS',
  5031. eventStore: eventTupleToStore(tuple),
  5032. });
  5033. this.triggerEventAdd(newEventApi);
  5034. return newEventApi;
  5035. }
  5036. return null;
  5037. }
  5038. triggerEventAdd(eventApi) {
  5039. let { emitter } = this.getCurrentData();
  5040. emitter.trigger('eventAdd', {
  5041. event: eventApi,
  5042. relatedEvents: [],
  5043. revert: () => {
  5044. this.dispatch({
  5045. type: 'REMOVE_EVENTS',
  5046. eventStore: eventApiToStore(eventApi),
  5047. });
  5048. },
  5049. });
  5050. }
  5051. // TODO: optimize
  5052. getEventById(id) {
  5053. let state = this.getCurrentData();
  5054. let { defs, instances } = state.eventStore;
  5055. id = String(id);
  5056. for (let defId in defs) {
  5057. let def = defs[defId];
  5058. if (def.publicId === id) {
  5059. if (def.recurringDef) {
  5060. return new EventImpl(state, def, null);
  5061. }
  5062. for (let instanceId in instances) {
  5063. let instance = instances[instanceId];
  5064. if (instance.defId === def.defId) {
  5065. return new EventImpl(state, def, instance);
  5066. }
  5067. }
  5068. }
  5069. }
  5070. return null;
  5071. }
  5072. getEvents() {
  5073. let currentData = this.getCurrentData();
  5074. return buildEventApis(currentData.eventStore, currentData);
  5075. }
  5076. removeAllEvents() {
  5077. this.dispatch({ type: 'REMOVE_ALL_EVENTS' });
  5078. }
  5079. // Public Event Sources API
  5080. // -----------------------------------------------------------------------------------------------------------------
  5081. getEventSources() {
  5082. let state = this.getCurrentData();
  5083. let sourceHash = state.eventSources;
  5084. let sourceApis = [];
  5085. for (let internalId in sourceHash) {
  5086. sourceApis.push(new EventSourceImpl(state, sourceHash[internalId]));
  5087. }
  5088. return sourceApis;
  5089. }
  5090. getEventSourceById(id) {
  5091. let state = this.getCurrentData();
  5092. let sourceHash = state.eventSources;
  5093. id = String(id);
  5094. for (let sourceId in sourceHash) {
  5095. if (sourceHash[sourceId].publicId === id) {
  5096. return new EventSourceImpl(state, sourceHash[sourceId]);
  5097. }
  5098. }
  5099. return null;
  5100. }
  5101. addEventSource(sourceInput) {
  5102. let state = this.getCurrentData();
  5103. if (sourceInput instanceof EventSourceImpl) {
  5104. // not already present? don't want to add an old snapshot
  5105. if (!state.eventSources[sourceInput.internalEventSource.sourceId]) {
  5106. this.dispatch({
  5107. type: 'ADD_EVENT_SOURCES',
  5108. sources: [sourceInput.internalEventSource],
  5109. });
  5110. }
  5111. return sourceInput;
  5112. }
  5113. let eventSource = parseEventSource(sourceInput, state);
  5114. if (eventSource) { // TODO: error otherwise?
  5115. this.dispatch({ type: 'ADD_EVENT_SOURCES', sources: [eventSource] });
  5116. return new EventSourceImpl(state, eventSource);
  5117. }
  5118. return null;
  5119. }
  5120. removeAllEventSources() {
  5121. this.dispatch({ type: 'REMOVE_ALL_EVENT_SOURCES' });
  5122. }
  5123. refetchEvents() {
  5124. this.dispatch({ type: 'FETCH_EVENT_SOURCES', isRefetch: true });
  5125. }
  5126. // Scroll
  5127. // -----------------------------------------------------------------------------------------------------------------
  5128. scrollToTime(timeInput) {
  5129. let time = createDuration(timeInput);
  5130. if (time) {
  5131. this.trigger('_scrollRequest', { time });
  5132. }
  5133. }
  5134. }
  5135. function pointInsideRect(point, rect) {
  5136. return point.left >= rect.left &&
  5137. point.left < rect.right &&
  5138. point.top >= rect.top &&
  5139. point.top < rect.bottom;
  5140. }
  5141. // Returns a new rectangle that is the intersection of the two rectangles. If they don't intersect, returns false
  5142. function intersectRects(rect1, rect2) {
  5143. let res = {
  5144. left: Math.max(rect1.left, rect2.left),
  5145. right: Math.min(rect1.right, rect2.right),
  5146. top: Math.max(rect1.top, rect2.top),
  5147. bottom: Math.min(rect1.bottom, rect2.bottom),
  5148. };
  5149. if (res.left < res.right && res.top < res.bottom) {
  5150. return res;
  5151. }
  5152. return false;
  5153. }
  5154. function translateRect(rect, deltaX, deltaY) {
  5155. return {
  5156. left: rect.left + deltaX,
  5157. right: rect.right + deltaX,
  5158. top: rect.top + deltaY,
  5159. bottom: rect.bottom + deltaY,
  5160. };
  5161. }
  5162. // Returns a new point that will have been moved to reside within the given rectangle
  5163. function constrainPoint(point, rect) {
  5164. return {
  5165. left: Math.min(Math.max(point.left, rect.left), rect.right),
  5166. top: Math.min(Math.max(point.top, rect.top), rect.bottom),
  5167. };
  5168. }
  5169. // Returns a point that is the center of the given rectangle
  5170. function getRectCenter(rect) {
  5171. return {
  5172. left: (rect.left + rect.right) / 2,
  5173. top: (rect.top + rect.bottom) / 2,
  5174. };
  5175. }
  5176. // Subtracts point2's coordinates from point1's coordinates, returning a delta
  5177. function diffPoints(point1, point2) {
  5178. return {
  5179. left: point1.left - point2.left,
  5180. top: point1.top - point2.top,
  5181. };
  5182. }
  5183. const EMPTY_EVENT_STORE = createEmptyEventStore(); // for purecomponents. TODO: keep elsewhere
  5184. class Splitter {
  5185. constructor() {
  5186. this.getKeysForEventDefs = memoize(this._getKeysForEventDefs);
  5187. this.splitDateSelection = memoize(this._splitDateSpan);
  5188. this.splitEventStore = memoize(this._splitEventStore);
  5189. this.splitIndividualUi = memoize(this._splitIndividualUi);
  5190. this.splitEventDrag = memoize(this._splitInteraction);
  5191. this.splitEventResize = memoize(this._splitInteraction);
  5192. this.eventUiBuilders = {}; // TODO: typescript protection
  5193. }
  5194. splitProps(props) {
  5195. let keyInfos = this.getKeyInfo(props);
  5196. let defKeys = this.getKeysForEventDefs(props.eventStore);
  5197. let dateSelections = this.splitDateSelection(props.dateSelection);
  5198. let individualUi = this.splitIndividualUi(props.eventUiBases, defKeys); // the individual *bases*
  5199. let eventStores = this.splitEventStore(props.eventStore, defKeys);
  5200. let eventDrags = this.splitEventDrag(props.eventDrag);
  5201. let eventResizes = this.splitEventResize(props.eventResize);
  5202. let splitProps = {};
  5203. this.eventUiBuilders = mapHash(keyInfos, (info, key) => this.eventUiBuilders[key] || memoize(buildEventUiForKey));
  5204. for (let key in keyInfos) {
  5205. let keyInfo = keyInfos[key];
  5206. let eventStore = eventStores[key] || EMPTY_EVENT_STORE;
  5207. let buildEventUi = this.eventUiBuilders[key];
  5208. splitProps[key] = {
  5209. businessHours: keyInfo.businessHours || props.businessHours,
  5210. dateSelection: dateSelections[key] || null,
  5211. eventStore,
  5212. eventUiBases: buildEventUi(props.eventUiBases[''], keyInfo.ui, individualUi[key]),
  5213. eventSelection: eventStore.instances[props.eventSelection] ? props.eventSelection : '',
  5214. eventDrag: eventDrags[key] || null,
  5215. eventResize: eventResizes[key] || null,
  5216. };
  5217. }
  5218. return splitProps;
  5219. }
  5220. _splitDateSpan(dateSpan) {
  5221. let dateSpans = {};
  5222. if (dateSpan) {
  5223. let keys = this.getKeysForDateSpan(dateSpan);
  5224. for (let key of keys) {
  5225. dateSpans[key] = dateSpan;
  5226. }
  5227. }
  5228. return dateSpans;
  5229. }
  5230. _getKeysForEventDefs(eventStore) {
  5231. return mapHash(eventStore.defs, (eventDef) => this.getKeysForEventDef(eventDef));
  5232. }
  5233. _splitEventStore(eventStore, defKeys) {
  5234. let { defs, instances } = eventStore;
  5235. let splitStores = {};
  5236. for (let defId in defs) {
  5237. for (let key of defKeys[defId]) {
  5238. if (!splitStores[key]) {
  5239. splitStores[key] = createEmptyEventStore();
  5240. }
  5241. splitStores[key].defs[defId] = defs[defId];
  5242. }
  5243. }
  5244. for (let instanceId in instances) {
  5245. let instance = instances[instanceId];
  5246. for (let key of defKeys[instance.defId]) {
  5247. if (splitStores[key]) { // must have already been created
  5248. splitStores[key].instances[instanceId] = instance;
  5249. }
  5250. }
  5251. }
  5252. return splitStores;
  5253. }
  5254. _splitIndividualUi(eventUiBases, defKeys) {
  5255. let splitHashes = {};
  5256. for (let defId in eventUiBases) {
  5257. if (defId) { // not the '' key
  5258. for (let key of defKeys[defId]) {
  5259. if (!splitHashes[key]) {
  5260. splitHashes[key] = {};
  5261. }
  5262. splitHashes[key][defId] = eventUiBases[defId];
  5263. }
  5264. }
  5265. }
  5266. return splitHashes;
  5267. }
  5268. _splitInteraction(interaction) {
  5269. let splitStates = {};
  5270. if (interaction) {
  5271. let affectedStores = this._splitEventStore(interaction.affectedEvents, this._getKeysForEventDefs(interaction.affectedEvents));
  5272. // can't rely on defKeys because event data is mutated
  5273. let mutatedKeysByDefId = this._getKeysForEventDefs(interaction.mutatedEvents);
  5274. let mutatedStores = this._splitEventStore(interaction.mutatedEvents, mutatedKeysByDefId);
  5275. let populate = (key) => {
  5276. if (!splitStates[key]) {
  5277. splitStates[key] = {
  5278. affectedEvents: affectedStores[key] || EMPTY_EVENT_STORE,
  5279. mutatedEvents: mutatedStores[key] || EMPTY_EVENT_STORE,
  5280. isEvent: interaction.isEvent,
  5281. };
  5282. }
  5283. };
  5284. for (let key in affectedStores) {
  5285. populate(key);
  5286. }
  5287. for (let key in mutatedStores) {
  5288. populate(key);
  5289. }
  5290. }
  5291. return splitStates;
  5292. }
  5293. }
  5294. function buildEventUiForKey(allUi, eventUiForKey, individualUi) {
  5295. let baseParts = [];
  5296. if (allUi) {
  5297. baseParts.push(allUi);
  5298. }
  5299. if (eventUiForKey) {
  5300. baseParts.push(eventUiForKey);
  5301. }
  5302. let stuff = {
  5303. '': combineEventUis(baseParts),
  5304. };
  5305. if (individualUi) {
  5306. Object.assign(stuff, individualUi);
  5307. }
  5308. return stuff;
  5309. }
  5310. function getDateMeta(date, todayRange, nowDate, dateProfile) {
  5311. return {
  5312. dow: date.getUTCDay(),
  5313. isDisabled: Boolean(dateProfile && (!dateProfile.activeRange || !rangeContainsMarker(dateProfile.activeRange, date))),
  5314. isOther: Boolean(dateProfile && !rangeContainsMarker(dateProfile.currentRange, date)),
  5315. isToday: Boolean(todayRange && rangeContainsMarker(todayRange, date)),
  5316. isPast: Boolean(nowDate ? (date < nowDate) : todayRange ? (date < todayRange.start) : false),
  5317. isFuture: Boolean(nowDate ? (date > nowDate) : todayRange ? (date >= todayRange.end) : false),
  5318. };
  5319. }
  5320. function getDayClassNames(meta, theme) {
  5321. let classNames = [
  5322. 'fc-day',
  5323. `fc-day-${DAY_IDS[meta.dow]}`,
  5324. ];
  5325. if (meta.isDisabled) {
  5326. classNames.push('fc-day-disabled');
  5327. }
  5328. else {
  5329. if (meta.isToday) {
  5330. classNames.push('fc-day-today');
  5331. classNames.push(theme.getClass('today'));
  5332. }
  5333. if (meta.isPast) {
  5334. classNames.push('fc-day-past');
  5335. }
  5336. if (meta.isFuture) {
  5337. classNames.push('fc-day-future');
  5338. }
  5339. if (meta.isOther) {
  5340. classNames.push('fc-day-other');
  5341. }
  5342. }
  5343. return classNames;
  5344. }
  5345. function getSlotClassNames(meta, theme) {
  5346. let classNames = [
  5347. 'fc-slot',
  5348. `fc-slot-${DAY_IDS[meta.dow]}`,
  5349. ];
  5350. if (meta.isDisabled) {
  5351. classNames.push('fc-slot-disabled');
  5352. }
  5353. else {
  5354. if (meta.isToday) {
  5355. classNames.push('fc-slot-today');
  5356. classNames.push(theme.getClass('today'));
  5357. }
  5358. if (meta.isPast) {
  5359. classNames.push('fc-slot-past');
  5360. }
  5361. if (meta.isFuture) {
  5362. classNames.push('fc-slot-future');
  5363. }
  5364. }
  5365. return classNames;
  5366. }
  5367. const DAY_FORMAT = createFormatter({ year: 'numeric', month: 'long', day: 'numeric' });
  5368. const WEEK_FORMAT = createFormatter({ week: 'long' });
  5369. function buildNavLinkAttrs(context, dateMarker, viewType = 'day', isTabbable = true) {
  5370. const { dateEnv, options, calendarApi } = context;
  5371. let dateStr = dateEnv.format(dateMarker, viewType === 'week' ? WEEK_FORMAT : DAY_FORMAT);
  5372. if (options.navLinks) {
  5373. let zonedDate = dateEnv.toDate(dateMarker);
  5374. const handleInteraction = (ev) => {
  5375. let customAction = viewType === 'day' ? options.navLinkDayClick :
  5376. viewType === 'week' ? options.navLinkWeekClick : null;
  5377. if (typeof customAction === 'function') {
  5378. customAction.call(calendarApi, dateEnv.toDate(dateMarker), ev);
  5379. }
  5380. else {
  5381. if (typeof customAction === 'string') {
  5382. viewType = customAction;
  5383. }
  5384. calendarApi.zoomTo(dateMarker, viewType);
  5385. }
  5386. };
  5387. return Object.assign({ title: formatWithOrdinals(options.navLinkHint, [dateStr, zonedDate], dateStr), 'data-navlink': '' }, (isTabbable
  5388. ? createAriaClickAttrs(handleInteraction)
  5389. : { onClick: handleInteraction }));
  5390. }
  5391. return { 'aria-label': dateStr };
  5392. }
  5393. let _isRtlScrollbarOnLeft = null;
  5394. function getIsRtlScrollbarOnLeft() {
  5395. if (_isRtlScrollbarOnLeft === null) {
  5396. _isRtlScrollbarOnLeft = computeIsRtlScrollbarOnLeft();
  5397. }
  5398. return _isRtlScrollbarOnLeft;
  5399. }
  5400. function computeIsRtlScrollbarOnLeft() {
  5401. let outerEl = document.createElement('div');
  5402. applyStyle(outerEl, {
  5403. position: 'absolute',
  5404. top: -1000,
  5405. left: 0,
  5406. border: 0,
  5407. padding: 0,
  5408. overflow: 'scroll',
  5409. direction: 'rtl',
  5410. });
  5411. outerEl.innerHTML = '<div></div>';
  5412. document.body.appendChild(outerEl);
  5413. let innerEl = outerEl.firstChild;
  5414. let res = innerEl.getBoundingClientRect().left > outerEl.getBoundingClientRect().left;
  5415. removeElement(outerEl);
  5416. return res;
  5417. }
  5418. let _scrollbarWidths;
  5419. function getScrollbarWidths() {
  5420. if (!_scrollbarWidths) {
  5421. _scrollbarWidths = computeScrollbarWidths();
  5422. }
  5423. return _scrollbarWidths;
  5424. }
  5425. function computeScrollbarWidths() {
  5426. let el = document.createElement('div');
  5427. el.style.overflow = 'scroll';
  5428. el.style.position = 'absolute';
  5429. el.style.top = '-9999px';
  5430. el.style.left = '-9999px';
  5431. document.body.appendChild(el);
  5432. let res = computeScrollbarWidthsForEl(el);
  5433. document.body.removeChild(el);
  5434. return res;
  5435. }
  5436. // WARNING: will include border
  5437. function computeScrollbarWidthsForEl(el) {
  5438. return {
  5439. x: el.offsetHeight - el.clientHeight,
  5440. y: el.offsetWidth - el.clientWidth,
  5441. };
  5442. }
  5443. function computeEdges(el, getPadding = false) {
  5444. let computedStyle = window.getComputedStyle(el);
  5445. let borderLeft = parseInt(computedStyle.borderLeftWidth, 10) || 0;
  5446. let borderRight = parseInt(computedStyle.borderRightWidth, 10) || 0;
  5447. let borderTop = parseInt(computedStyle.borderTopWidth, 10) || 0;
  5448. let borderBottom = parseInt(computedStyle.borderBottomWidth, 10) || 0;
  5449. let badScrollbarWidths = computeScrollbarWidthsForEl(el); // includes border!
  5450. let scrollbarLeftRight = badScrollbarWidths.y - borderLeft - borderRight;
  5451. let scrollbarBottom = badScrollbarWidths.x - borderTop - borderBottom;
  5452. let res = {
  5453. borderLeft,
  5454. borderRight,
  5455. borderTop,
  5456. borderBottom,
  5457. scrollbarBottom,
  5458. scrollbarLeft: 0,
  5459. scrollbarRight: 0,
  5460. };
  5461. if (getIsRtlScrollbarOnLeft() && computedStyle.direction === 'rtl') { // is the scrollbar on the left side?
  5462. res.scrollbarLeft = scrollbarLeftRight;
  5463. }
  5464. else {
  5465. res.scrollbarRight = scrollbarLeftRight;
  5466. }
  5467. if (getPadding) {
  5468. res.paddingLeft = parseInt(computedStyle.paddingLeft, 10) || 0;
  5469. res.paddingRight = parseInt(computedStyle.paddingRight, 10) || 0;
  5470. res.paddingTop = parseInt(computedStyle.paddingTop, 10) || 0;
  5471. res.paddingBottom = parseInt(computedStyle.paddingBottom, 10) || 0;
  5472. }
  5473. return res;
  5474. }
  5475. function computeInnerRect(el, goWithinPadding = false, doFromWindowViewport) {
  5476. let outerRect = doFromWindowViewport ? el.getBoundingClientRect() : computeRect(el);
  5477. let edges = computeEdges(el, goWithinPadding);
  5478. let res = {
  5479. left: outerRect.left + edges.borderLeft + edges.scrollbarLeft,
  5480. right: outerRect.right - edges.borderRight - edges.scrollbarRight,
  5481. top: outerRect.top + edges.borderTop,
  5482. bottom: outerRect.bottom - edges.borderBottom - edges.scrollbarBottom,
  5483. };
  5484. if (goWithinPadding) {
  5485. res.left += edges.paddingLeft;
  5486. res.right -= edges.paddingRight;
  5487. res.top += edges.paddingTop;
  5488. res.bottom -= edges.paddingBottom;
  5489. }
  5490. return res;
  5491. }
  5492. function computeRect(el) {
  5493. let rect = el.getBoundingClientRect();
  5494. return {
  5495. left: rect.left + window.scrollX,
  5496. top: rect.top + window.scrollY,
  5497. right: rect.right + window.scrollX,
  5498. bottom: rect.bottom + window.scrollY,
  5499. };
  5500. }
  5501. function computeClippedClientRect(el) {
  5502. let clippingParents = getClippingParents(el);
  5503. let rect = el.getBoundingClientRect();
  5504. for (let clippingParent of clippingParents) {
  5505. let intersection = intersectRects(rect, clippingParent.getBoundingClientRect());
  5506. if (intersection) {
  5507. rect = intersection;
  5508. }
  5509. else {
  5510. return null;
  5511. }
  5512. }
  5513. return rect;
  5514. }
  5515. // does not return window
  5516. function getClippingParents(el) {
  5517. let parents = [];
  5518. while (el instanceof HTMLElement) { // will stop when gets to document or null
  5519. let computedStyle = window.getComputedStyle(el);
  5520. if (computedStyle.position === 'fixed') {
  5521. break;
  5522. }
  5523. if ((/(auto|scroll)/).test(computedStyle.overflow + computedStyle.overflowY + computedStyle.overflowX)) {
  5524. parents.push(el);
  5525. }
  5526. el = el.parentNode;
  5527. }
  5528. return parents;
  5529. }
  5530. /*
  5531. Records offset information for a set of elements, relative to an origin element.
  5532. Can record the left/right OR the top/bottom OR both.
  5533. Provides methods for querying the cache by position.
  5534. */
  5535. class PositionCache {
  5536. constructor(originEl, els, isHorizontal, isVertical) {
  5537. this.els = els;
  5538. let originClientRect = this.originClientRect = originEl.getBoundingClientRect(); // relative to viewport top-left
  5539. if (isHorizontal) {
  5540. this.buildElHorizontals(originClientRect.left);
  5541. }
  5542. if (isVertical) {
  5543. this.buildElVerticals(originClientRect.top);
  5544. }
  5545. }
  5546. // Populates the left/right internal coordinate arrays
  5547. buildElHorizontals(originClientLeft) {
  5548. let lefts = [];
  5549. let rights = [];
  5550. for (let el of this.els) {
  5551. let rect = el.getBoundingClientRect();
  5552. lefts.push(rect.left - originClientLeft);
  5553. rights.push(rect.right - originClientLeft);
  5554. }
  5555. this.lefts = lefts;
  5556. this.rights = rights;
  5557. }
  5558. // Populates the top/bottom internal coordinate arrays
  5559. buildElVerticals(originClientTop) {
  5560. let tops = [];
  5561. let bottoms = [];
  5562. for (let el of this.els) {
  5563. let rect = el.getBoundingClientRect();
  5564. tops.push(rect.top - originClientTop);
  5565. bottoms.push(rect.bottom - originClientTop);
  5566. }
  5567. this.tops = tops;
  5568. this.bottoms = bottoms;
  5569. }
  5570. // Given a left offset (from document left), returns the index of the el that it horizontally intersects.
  5571. // If no intersection is made, returns undefined.
  5572. leftToIndex(leftPosition) {
  5573. let { lefts, rights } = this;
  5574. let len = lefts.length;
  5575. let i;
  5576. for (i = 0; i < len; i += 1) {
  5577. if (leftPosition >= lefts[i] && leftPosition < rights[i]) {
  5578. return i;
  5579. }
  5580. }
  5581. return undefined; // TODO: better
  5582. }
  5583. // Given a top offset (from document top), returns the index of the el that it vertically intersects.
  5584. // If no intersection is made, returns undefined.
  5585. topToIndex(topPosition) {
  5586. let { tops, bottoms } = this;
  5587. let len = tops.length;
  5588. let i;
  5589. for (i = 0; i < len; i += 1) {
  5590. if (topPosition >= tops[i] && topPosition < bottoms[i]) {
  5591. return i;
  5592. }
  5593. }
  5594. return undefined; // TODO: better
  5595. }
  5596. // Gets the width of the element at the given index
  5597. getWidth(leftIndex) {
  5598. return this.rights[leftIndex] - this.lefts[leftIndex];
  5599. }
  5600. // Gets the height of the element at the given index
  5601. getHeight(topIndex) {
  5602. return this.bottoms[topIndex] - this.tops[topIndex];
  5603. }
  5604. similarTo(otherCache) {
  5605. return similarNumArrays(this.tops || [], otherCache.tops || []) &&
  5606. similarNumArrays(this.bottoms || [], otherCache.bottoms || []) &&
  5607. similarNumArrays(this.lefts || [], otherCache.lefts || []) &&
  5608. similarNumArrays(this.rights || [], otherCache.rights || []);
  5609. }
  5610. }
  5611. function similarNumArrays(a, b) {
  5612. const len = a.length;
  5613. if (len !== b.length) {
  5614. return false;
  5615. }
  5616. for (let i = 0; i < len; i++) {
  5617. if (Math.round(a[i]) !== Math.round(b[i])) {
  5618. return false;
  5619. }
  5620. }
  5621. return true;
  5622. }
  5623. /* eslint max-classes-per-file: "off" */
  5624. /*
  5625. An object for getting/setting scroll-related information for an element.
  5626. Internally, this is done very differently for window versus DOM element,
  5627. so this object serves as a common interface.
  5628. */
  5629. class ScrollController {
  5630. getMaxScrollTop() {
  5631. return this.getScrollHeight() - this.getClientHeight();
  5632. }
  5633. getMaxScrollLeft() {
  5634. return this.getScrollWidth() - this.getClientWidth();
  5635. }
  5636. canScrollVertically() {
  5637. return this.getMaxScrollTop() > 0;
  5638. }
  5639. canScrollHorizontally() {
  5640. return this.getMaxScrollLeft() > 0;
  5641. }
  5642. canScrollUp() {
  5643. return this.getScrollTop() > 0;
  5644. }
  5645. canScrollDown() {
  5646. return this.getScrollTop() < this.getMaxScrollTop();
  5647. }
  5648. canScrollLeft() {
  5649. return this.getScrollLeft() > 0;
  5650. }
  5651. canScrollRight() {
  5652. return this.getScrollLeft() < this.getMaxScrollLeft();
  5653. }
  5654. }
  5655. class ElementScrollController extends ScrollController {
  5656. constructor(el) {
  5657. super();
  5658. this.el = el;
  5659. }
  5660. getScrollTop() {
  5661. return this.el.scrollTop;
  5662. }
  5663. getScrollLeft() {
  5664. return this.el.scrollLeft;
  5665. }
  5666. setScrollTop(top) {
  5667. this.el.scrollTop = top;
  5668. }
  5669. setScrollLeft(left) {
  5670. this.el.scrollLeft = left;
  5671. }
  5672. getScrollWidth() {
  5673. return this.el.scrollWidth;
  5674. }
  5675. getScrollHeight() {
  5676. return this.el.scrollHeight;
  5677. }
  5678. getClientHeight() {
  5679. return this.el.clientHeight;
  5680. }
  5681. getClientWidth() {
  5682. return this.el.clientWidth;
  5683. }
  5684. }
  5685. class WindowScrollController extends ScrollController {
  5686. getScrollTop() {
  5687. return window.scrollY;
  5688. }
  5689. getScrollLeft() {
  5690. return window.scrollX;
  5691. }
  5692. setScrollTop(n) {
  5693. window.scroll(window.scrollX, n);
  5694. }
  5695. setScrollLeft(n) {
  5696. window.scroll(n, window.scrollY);
  5697. }
  5698. getScrollWidth() {
  5699. return document.documentElement.scrollWidth;
  5700. }
  5701. getScrollHeight() {
  5702. return document.documentElement.scrollHeight;
  5703. }
  5704. getClientHeight() {
  5705. return document.documentElement.clientHeight;
  5706. }
  5707. getClientWidth() {
  5708. return document.documentElement.clientWidth;
  5709. }
  5710. }
  5711. /*
  5712. an INTERACTABLE date component
  5713. PURPOSES:
  5714. - hook up to fg, fill, and mirror renderers
  5715. - interface for dragging and hits
  5716. */
  5717. class DateComponent extends BaseComponent {
  5718. constructor() {
  5719. super(...arguments);
  5720. this.uid = guid();
  5721. }
  5722. // Hit System
  5723. // -----------------------------------------------------------------------------------------------------------------
  5724. prepareHits() {
  5725. }
  5726. queryHit(positionLeft, positionTop, elWidth, elHeight) {
  5727. return null; // this should be abstract
  5728. }
  5729. // Pointer Interaction Utils
  5730. // -----------------------------------------------------------------------------------------------------------------
  5731. isValidSegDownEl(el) {
  5732. return !this.props.eventDrag && // HACK
  5733. !this.props.eventResize && // HACK
  5734. !elementClosest(el, '.fc-event-mirror');
  5735. }
  5736. isValidDateDownEl(el) {
  5737. return !elementClosest(el, '.fc-event:not(.fc-bg-event)') &&
  5738. !elementClosest(el, '.fc-more-link') && // a "more.." link
  5739. !elementClosest(el, 'a[data-navlink]') && // a clickable nav link
  5740. !elementClosest(el, '.fc-popover'); // hack
  5741. }
  5742. }
  5743. class NamedTimeZoneImpl {
  5744. constructor(timeZoneName) {
  5745. this.timeZoneName = timeZoneName;
  5746. }
  5747. }
  5748. class SegHierarchy {
  5749. constructor(getEntryThickness = (entry) => {
  5750. // if no thickness known, assume 1 (if 0, so small it always fits)
  5751. return entry.thickness || 1;
  5752. }) {
  5753. this.getEntryThickness = getEntryThickness;
  5754. // settings
  5755. this.strictOrder = false;
  5756. this.allowReslicing = false;
  5757. this.maxCoord = -1; // -1 means no max
  5758. this.maxStackCnt = -1; // -1 means no max
  5759. this.levelCoords = []; // ordered
  5760. this.entriesByLevel = []; // parallel with levelCoords
  5761. this.stackCnts = {}; // TODO: use better technique!?
  5762. }
  5763. addSegs(inputs) {
  5764. let hiddenEntries = [];
  5765. for (let input of inputs) {
  5766. this.insertEntry(input, hiddenEntries);
  5767. }
  5768. return hiddenEntries;
  5769. }
  5770. insertEntry(entry, hiddenEntries) {
  5771. let insertion = this.findInsertion(entry);
  5772. if (this.isInsertionValid(insertion, entry)) {
  5773. this.insertEntryAt(entry, insertion);
  5774. }
  5775. else {
  5776. this.handleInvalidInsertion(insertion, entry, hiddenEntries);
  5777. }
  5778. }
  5779. isInsertionValid(insertion, entry) {
  5780. return (this.maxCoord === -1 || insertion.levelCoord + this.getEntryThickness(entry) <= this.maxCoord) &&
  5781. (this.maxStackCnt === -1 || insertion.stackCnt < this.maxStackCnt);
  5782. }
  5783. handleInvalidInsertion(insertion, entry, hiddenEntries) {
  5784. if (this.allowReslicing && insertion.touchingEntry) {
  5785. const hiddenEntry = Object.assign(Object.assign({}, entry), { span: intersectSpans(entry.span, insertion.touchingEntry.span) });
  5786. hiddenEntries.push(hiddenEntry);
  5787. this.splitEntry(entry, insertion.touchingEntry, hiddenEntries);
  5788. }
  5789. else {
  5790. hiddenEntries.push(entry);
  5791. }
  5792. }
  5793. /*
  5794. Does NOT add what hit the `barrier` into hiddenEntries. Should already be done.
  5795. */
  5796. splitEntry(entry, barrier, hiddenEntries) {
  5797. let entrySpan = entry.span;
  5798. let barrierSpan = barrier.span;
  5799. if (entrySpan.start < barrierSpan.start) {
  5800. this.insertEntry({
  5801. index: entry.index,
  5802. thickness: entry.thickness,
  5803. span: { start: entrySpan.start, end: barrierSpan.start },
  5804. }, hiddenEntries);
  5805. }
  5806. if (entrySpan.end > barrierSpan.end) {
  5807. this.insertEntry({
  5808. index: entry.index,
  5809. thickness: entry.thickness,
  5810. span: { start: barrierSpan.end, end: entrySpan.end },
  5811. }, hiddenEntries);
  5812. }
  5813. }
  5814. insertEntryAt(entry, insertion) {
  5815. let { entriesByLevel, levelCoords } = this;
  5816. if (insertion.lateral === -1) {
  5817. // create a new level
  5818. insertAt(levelCoords, insertion.level, insertion.levelCoord);
  5819. insertAt(entriesByLevel, insertion.level, [entry]);
  5820. }
  5821. else {
  5822. // insert into existing level
  5823. insertAt(entriesByLevel[insertion.level], insertion.lateral, entry);
  5824. }
  5825. this.stackCnts[buildEntryKey(entry)] = insertion.stackCnt;
  5826. }
  5827. /*
  5828. does not care about limits
  5829. */
  5830. findInsertion(newEntry) {
  5831. let { levelCoords, entriesByLevel, strictOrder, stackCnts } = this;
  5832. let levelCnt = levelCoords.length;
  5833. let candidateCoord = 0;
  5834. let touchingLevel = -1;
  5835. let touchingLateral = -1;
  5836. let touchingEntry = null;
  5837. let stackCnt = 0;
  5838. for (let trackingLevel = 0; trackingLevel < levelCnt; trackingLevel += 1) {
  5839. const trackingCoord = levelCoords[trackingLevel];
  5840. // if the current level is past the placed entry, we have found a good empty space and can stop.
  5841. // if strictOrder, keep finding more lateral intersections.
  5842. if (!strictOrder && trackingCoord >= candidateCoord + this.getEntryThickness(newEntry)) {
  5843. break;
  5844. }
  5845. let trackingEntries = entriesByLevel[trackingLevel];
  5846. let trackingEntry;
  5847. let searchRes = binarySearch(trackingEntries, newEntry.span.start, getEntrySpanEnd); // find first entry after newEntry's end
  5848. let lateralIndex = searchRes[0] + searchRes[1]; // if exact match (which doesn't collide), go to next one
  5849. while ( // loop through entries that horizontally intersect
  5850. (trackingEntry = trackingEntries[lateralIndex]) && // but not past the whole entry list
  5851. trackingEntry.span.start < newEntry.span.end // and not entirely past newEntry
  5852. ) {
  5853. let trackingEntryBottom = trackingCoord + this.getEntryThickness(trackingEntry);
  5854. // intersects into the top of the candidate?
  5855. if (trackingEntryBottom > candidateCoord) {
  5856. candidateCoord = trackingEntryBottom;
  5857. touchingEntry = trackingEntry;
  5858. touchingLevel = trackingLevel;
  5859. touchingLateral = lateralIndex;
  5860. }
  5861. // butts up against top of candidate? (will happen if just intersected as well)
  5862. if (trackingEntryBottom === candidateCoord) {
  5863. // accumulate the highest possible stackCnt of the trackingEntries that butt up
  5864. stackCnt = Math.max(stackCnt, stackCnts[buildEntryKey(trackingEntry)] + 1);
  5865. }
  5866. lateralIndex += 1;
  5867. }
  5868. }
  5869. // the destination level will be after touchingEntry's level. find it
  5870. let destLevel = 0;
  5871. if (touchingEntry) {
  5872. destLevel = touchingLevel + 1;
  5873. while (destLevel < levelCnt && levelCoords[destLevel] < candidateCoord) {
  5874. destLevel += 1;
  5875. }
  5876. }
  5877. // if adding to an existing level, find where to insert
  5878. let destLateral = -1;
  5879. if (destLevel < levelCnt && levelCoords[destLevel] === candidateCoord) {
  5880. destLateral = binarySearch(entriesByLevel[destLevel], newEntry.span.end, getEntrySpanEnd)[0];
  5881. }
  5882. return {
  5883. touchingLevel,
  5884. touchingLateral,
  5885. touchingEntry,
  5886. stackCnt,
  5887. levelCoord: candidateCoord,
  5888. level: destLevel,
  5889. lateral: destLateral,
  5890. };
  5891. }
  5892. // sorted by levelCoord (lowest to highest)
  5893. toRects() {
  5894. let { entriesByLevel, levelCoords } = this;
  5895. let levelCnt = entriesByLevel.length;
  5896. let rects = [];
  5897. for (let level = 0; level < levelCnt; level += 1) {
  5898. let entries = entriesByLevel[level];
  5899. let levelCoord = levelCoords[level];
  5900. for (let entry of entries) {
  5901. rects.push(Object.assign(Object.assign({}, entry), { thickness: this.getEntryThickness(entry), levelCoord }));
  5902. }
  5903. }
  5904. return rects;
  5905. }
  5906. }
  5907. function getEntrySpanEnd(entry) {
  5908. return entry.span.end;
  5909. }
  5910. function buildEntryKey(entry) {
  5911. return entry.index + ':' + entry.span.start;
  5912. }
  5913. // returns groups with entries sorted by input order
  5914. function groupIntersectingEntries(entries) {
  5915. let merges = [];
  5916. for (let entry of entries) {
  5917. let filteredMerges = [];
  5918. let hungryMerge = {
  5919. span: entry.span,
  5920. entries: [entry],
  5921. };
  5922. for (let merge of merges) {
  5923. if (intersectSpans(merge.span, hungryMerge.span)) {
  5924. hungryMerge = {
  5925. entries: merge.entries.concat(hungryMerge.entries),
  5926. span: joinSpans(merge.span, hungryMerge.span),
  5927. };
  5928. }
  5929. else {
  5930. filteredMerges.push(merge);
  5931. }
  5932. }
  5933. filteredMerges.push(hungryMerge);
  5934. merges = filteredMerges;
  5935. }
  5936. return merges;
  5937. }
  5938. function joinSpans(span0, span1) {
  5939. return {
  5940. start: Math.min(span0.start, span1.start),
  5941. end: Math.max(span0.end, span1.end),
  5942. };
  5943. }
  5944. function intersectSpans(span0, span1) {
  5945. let start = Math.max(span0.start, span1.start);
  5946. let end = Math.min(span0.end, span1.end);
  5947. if (start < end) {
  5948. return { start, end };
  5949. }
  5950. return null;
  5951. }
  5952. // general util
  5953. // ---------------------------------------------------------------------------------------------------------------------
  5954. function insertAt(arr, index, item) {
  5955. arr.splice(index, 0, item);
  5956. }
  5957. function binarySearch(a, searchVal, getItemVal) {
  5958. let startIndex = 0;
  5959. let endIndex = a.length; // exclusive
  5960. if (!endIndex || searchVal < getItemVal(a[startIndex])) { // no items OR before first item
  5961. return [0, 0];
  5962. }
  5963. if (searchVal > getItemVal(a[endIndex - 1])) { // after last item
  5964. return [endIndex, 0];
  5965. }
  5966. while (startIndex < endIndex) {
  5967. let middleIndex = Math.floor(startIndex + (endIndex - startIndex) / 2);
  5968. let middleVal = getItemVal(a[middleIndex]);
  5969. if (searchVal < middleVal) {
  5970. endIndex = middleIndex;
  5971. }
  5972. else if (searchVal > middleVal) {
  5973. startIndex = middleIndex + 1;
  5974. }
  5975. else { // equal!
  5976. return [middleIndex, 1];
  5977. }
  5978. }
  5979. return [startIndex, 0];
  5980. }
  5981. /*
  5982. An abstraction for a dragging interaction originating on an event.
  5983. Does higher-level things than PointerDragger, such as possibly:
  5984. - a "mirror" that moves with the pointer
  5985. - a minimum number of pixels or other criteria for a true drag to begin
  5986. subclasses must emit:
  5987. - pointerdown
  5988. - dragstart
  5989. - dragmove
  5990. - pointerup
  5991. - dragend
  5992. */
  5993. class ElementDragging {
  5994. constructor(el, selector) {
  5995. this.emitter = new Emitter();
  5996. }
  5997. destroy() {
  5998. }
  5999. setMirrorIsVisible(bool) {
  6000. // optional if subclass doesn't want to support a mirror
  6001. }
  6002. setMirrorNeedsRevert(bool) {
  6003. // optional if subclass doesn't want to support a mirror
  6004. }
  6005. setAutoScrollEnabled(bool) {
  6006. // optional
  6007. }
  6008. }
  6009. // TODO: get rid of this in favor of options system,
  6010. // tho it's really easy to access this globally rather than pass thru options.
  6011. const config = {};
  6012. /*
  6013. Information about what will happen when an external element is dragged-and-dropped
  6014. onto a calendar. Contains information for creating an event.
  6015. */
  6016. const DRAG_META_REFINERS = {
  6017. startTime: createDuration,
  6018. duration: createDuration,
  6019. create: Boolean,
  6020. sourceId: String,
  6021. };
  6022. function parseDragMeta(raw) {
  6023. let { refined, extra } = refineProps(raw, DRAG_META_REFINERS);
  6024. return {
  6025. startTime: refined.startTime || null,
  6026. duration: refined.duration || null,
  6027. create: refined.create != null ? refined.create : true,
  6028. sourceId: refined.sourceId,
  6029. leftoverProps: extra,
  6030. };
  6031. }
  6032. // Computes a default column header formatting string if `colFormat` is not explicitly defined
  6033. function computeFallbackHeaderFormat(datesRepDistinctDays, dayCnt) {
  6034. // if more than one week row, or if there are a lot of columns with not much space,
  6035. // put just the day numbers will be in each cell
  6036. if (!datesRepDistinctDays || dayCnt > 10) {
  6037. return createFormatter({ weekday: 'short' }); // "Sat"
  6038. }
  6039. if (dayCnt > 1) {
  6040. return createFormatter({ weekday: 'short', month: 'numeric', day: 'numeric', omitCommas: true }); // "Sat 11/12"
  6041. }
  6042. return createFormatter({ weekday: 'long' }); // "Saturday"
  6043. }
  6044. const CLASS_NAME = 'fc-col-header-cell'; // do the cushion too? no
  6045. function renderInner$1(renderProps) {
  6046. return renderProps.text;
  6047. }
  6048. // BAD name for this class now. used in the Header
  6049. class TableDateCell extends BaseComponent {
  6050. render() {
  6051. let { dateEnv, options, theme, viewApi } = this.context;
  6052. let { props } = this;
  6053. let { date, dateProfile } = props;
  6054. let dayMeta = getDateMeta(date, props.todayRange, null, dateProfile);
  6055. let classNames = [CLASS_NAME].concat(getDayClassNames(dayMeta, theme));
  6056. let text = dateEnv.format(date, props.dayHeaderFormat);
  6057. // if colCnt is 1, we are already in a day-view and don't need a navlink
  6058. let navLinkAttrs = (!dayMeta.isDisabled && props.colCnt > 1)
  6059. ? buildNavLinkAttrs(this.context, date)
  6060. : {};
  6061. let publicDate = dateEnv.toDate(date);
  6062. // workaround for Luxon (and maybe moment) returning prior-days when start-of-day
  6063. // in DST gap: https://github.com/fullcalendar/fullcalendar/issues/7633
  6064. if (dateEnv.namedTimeZoneImpl) {
  6065. publicDate = addMs(publicDate, 3600000); // add an hour
  6066. }
  6067. let renderProps = Object.assign(Object.assign(Object.assign({ date: publicDate, view: viewApi }, props.extraRenderProps), { text }), dayMeta);
  6068. return (y(ContentContainer, { elTag: "th", elClasses: classNames, elAttrs: Object.assign({ role: 'columnheader', colSpan: props.colSpan, 'data-date': !dayMeta.isDisabled ? formatDayString(date) : undefined }, props.extraDataAttrs), renderProps: renderProps, generatorName: "dayHeaderContent", customGenerator: options.dayHeaderContent, defaultGenerator: renderInner$1, classNameGenerator: options.dayHeaderClassNames, didMount: options.dayHeaderDidMount, willUnmount: options.dayHeaderWillUnmount }, (InnerContainer) => (y("div", { className: "fc-scrollgrid-sync-inner" }, !dayMeta.isDisabled && (y(InnerContainer, { elTag: "a", elAttrs: navLinkAttrs, elClasses: [
  6069. 'fc-col-header-cell-cushion',
  6070. props.isSticky && 'fc-sticky',
  6071. ] }))))));
  6072. }
  6073. }
  6074. const WEEKDAY_FORMAT = createFormatter({ weekday: 'long' });
  6075. class TableDowCell extends BaseComponent {
  6076. render() {
  6077. let { props } = this;
  6078. let { dateEnv, theme, viewApi, options } = this.context;
  6079. let date = addDays(new Date(259200000), props.dow); // start with Sun, 04 Jan 1970 00:00:00 GMT
  6080. let dateMeta = {
  6081. dow: props.dow,
  6082. isDisabled: false,
  6083. isFuture: false,
  6084. isPast: false,
  6085. isToday: false,
  6086. isOther: false,
  6087. };
  6088. let text = dateEnv.format(date, props.dayHeaderFormat);
  6089. let renderProps = Object.assign(Object.assign(Object.assign(Object.assign({ // TODO: make this public?
  6090. date }, dateMeta), { view: viewApi }), props.extraRenderProps), { text });
  6091. return (y(ContentContainer, { elTag: "th", elClasses: [
  6092. CLASS_NAME,
  6093. ...getDayClassNames(dateMeta, theme),
  6094. ...(props.extraClassNames || []),
  6095. ], elAttrs: Object.assign({ role: 'columnheader', colSpan: props.colSpan }, props.extraDataAttrs), renderProps: renderProps, generatorName: "dayHeaderContent", customGenerator: options.dayHeaderContent, defaultGenerator: renderInner$1, classNameGenerator: options.dayHeaderClassNames, didMount: options.dayHeaderDidMount, willUnmount: options.dayHeaderWillUnmount }, (InnerContent) => (y("div", { className: "fc-scrollgrid-sync-inner" },
  6096. y(InnerContent, { elTag: "a", elClasses: [
  6097. 'fc-col-header-cell-cushion',
  6098. props.isSticky && 'fc-sticky',
  6099. ], elAttrs: {
  6100. 'aria-label': dateEnv.format(date, WEEKDAY_FORMAT),
  6101. } })))));
  6102. }
  6103. }
  6104. class DayHeader extends BaseComponent {
  6105. constructor() {
  6106. super(...arguments);
  6107. this.createDayHeaderFormatter = memoize(createDayHeaderFormatter);
  6108. }
  6109. render() {
  6110. let { context } = this;
  6111. let { dates, dateProfile, datesRepDistinctDays, renderIntro } = this.props;
  6112. let dayHeaderFormat = this.createDayHeaderFormatter(context.options.dayHeaderFormat, datesRepDistinctDays, dates.length);
  6113. return (y(NowTimer, { unit: "day" }, (nowDate, todayRange) => (y("tr", { role: "row" },
  6114. renderIntro && renderIntro('day'),
  6115. dates.map((date) => (datesRepDistinctDays ? (y(TableDateCell, { key: date.toISOString(), date: date, dateProfile: dateProfile, todayRange: todayRange, colCnt: dates.length, dayHeaderFormat: dayHeaderFormat })) : (y(TableDowCell, { key: date.getUTCDay(), dow: date.getUTCDay(), dayHeaderFormat: dayHeaderFormat }))))))));
  6116. }
  6117. }
  6118. function createDayHeaderFormatter(explicitFormat, datesRepDistinctDays, dateCnt) {
  6119. return explicitFormat || computeFallbackHeaderFormat(datesRepDistinctDays, dateCnt);
  6120. }
  6121. class DaySeriesModel {
  6122. constructor(range, dateProfileGenerator) {
  6123. let date = range.start;
  6124. let { end } = range;
  6125. let indices = [];
  6126. let dates = [];
  6127. let dayIndex = -1;
  6128. while (date < end) { // loop each day from start to end
  6129. if (dateProfileGenerator.isHiddenDay(date)) {
  6130. indices.push(dayIndex + 0.5); // mark that it's between indices
  6131. }
  6132. else {
  6133. dayIndex += 1;
  6134. indices.push(dayIndex);
  6135. dates.push(date);
  6136. }
  6137. date = addDays(date, 1);
  6138. }
  6139. this.dates = dates;
  6140. this.indices = indices;
  6141. this.cnt = dates.length;
  6142. }
  6143. sliceRange(range) {
  6144. let firstIndex = this.getDateDayIndex(range.start); // inclusive first index
  6145. let lastIndex = this.getDateDayIndex(addDays(range.end, -1)); // inclusive last index
  6146. let clippedFirstIndex = Math.max(0, firstIndex);
  6147. let clippedLastIndex = Math.min(this.cnt - 1, lastIndex);
  6148. // deal with in-between indices
  6149. clippedFirstIndex = Math.ceil(clippedFirstIndex); // in-between starts round to next cell
  6150. clippedLastIndex = Math.floor(clippedLastIndex); // in-between ends round to prev cell
  6151. if (clippedFirstIndex <= clippedLastIndex) {
  6152. return {
  6153. firstIndex: clippedFirstIndex,
  6154. lastIndex: clippedLastIndex,
  6155. isStart: firstIndex === clippedFirstIndex,
  6156. isEnd: lastIndex === clippedLastIndex,
  6157. };
  6158. }
  6159. return null;
  6160. }
  6161. // Given a date, returns its chronolocial cell-index from the first cell of the grid.
  6162. // If the date lies between cells (because of hiddenDays), returns a floating-point value between offsets.
  6163. // If before the first offset, returns a negative number.
  6164. // If after the last offset, returns an offset past the last cell offset.
  6165. // Only works for *start* dates of cells. Will not work for exclusive end dates for cells.
  6166. getDateDayIndex(date) {
  6167. let { indices } = this;
  6168. let dayOffset = Math.floor(diffDays(this.dates[0], date));
  6169. if (dayOffset < 0) {
  6170. return indices[0] - 1;
  6171. }
  6172. if (dayOffset >= indices.length) {
  6173. return indices[indices.length - 1] + 1;
  6174. }
  6175. return indices[dayOffset];
  6176. }
  6177. }
  6178. class DayTableModel {
  6179. constructor(daySeries, breakOnWeeks) {
  6180. let { dates } = daySeries;
  6181. let daysPerRow;
  6182. let firstDay;
  6183. let rowCnt;
  6184. if (breakOnWeeks) {
  6185. // count columns until the day-of-week repeats
  6186. firstDay = dates[0].getUTCDay();
  6187. for (daysPerRow = 1; daysPerRow < dates.length; daysPerRow += 1) {
  6188. if (dates[daysPerRow].getUTCDay() === firstDay) {
  6189. break;
  6190. }
  6191. }
  6192. rowCnt = Math.ceil(dates.length / daysPerRow);
  6193. }
  6194. else {
  6195. rowCnt = 1;
  6196. daysPerRow = dates.length;
  6197. }
  6198. this.rowCnt = rowCnt;
  6199. this.colCnt = daysPerRow;
  6200. this.daySeries = daySeries;
  6201. this.cells = this.buildCells();
  6202. this.headerDates = this.buildHeaderDates();
  6203. }
  6204. buildCells() {
  6205. let rows = [];
  6206. for (let row = 0; row < this.rowCnt; row += 1) {
  6207. let cells = [];
  6208. for (let col = 0; col < this.colCnt; col += 1) {
  6209. cells.push(this.buildCell(row, col));
  6210. }
  6211. rows.push(cells);
  6212. }
  6213. return rows;
  6214. }
  6215. buildCell(row, col) {
  6216. let date = this.daySeries.dates[row * this.colCnt + col];
  6217. return {
  6218. key: date.toISOString(),
  6219. date,
  6220. };
  6221. }
  6222. buildHeaderDates() {
  6223. let dates = [];
  6224. for (let col = 0; col < this.colCnt; col += 1) {
  6225. dates.push(this.cells[0][col].date);
  6226. }
  6227. return dates;
  6228. }
  6229. sliceRange(range) {
  6230. let { colCnt } = this;
  6231. let seriesSeg = this.daySeries.sliceRange(range);
  6232. let segs = [];
  6233. if (seriesSeg) {
  6234. let { firstIndex, lastIndex } = seriesSeg;
  6235. let index = firstIndex;
  6236. while (index <= lastIndex) {
  6237. let row = Math.floor(index / colCnt);
  6238. let nextIndex = Math.min((row + 1) * colCnt, lastIndex + 1);
  6239. segs.push({
  6240. row,
  6241. firstCol: index % colCnt,
  6242. lastCol: (nextIndex - 1) % colCnt,
  6243. isStart: seriesSeg.isStart && index === firstIndex,
  6244. isEnd: seriesSeg.isEnd && (nextIndex - 1) === lastIndex,
  6245. });
  6246. index = nextIndex;
  6247. }
  6248. }
  6249. return segs;
  6250. }
  6251. }
  6252. class Slicer {
  6253. constructor() {
  6254. this.sliceBusinessHours = memoize(this._sliceBusinessHours);
  6255. this.sliceDateSelection = memoize(this._sliceDateSpan);
  6256. this.sliceEventStore = memoize(this._sliceEventStore);
  6257. this.sliceEventDrag = memoize(this._sliceInteraction);
  6258. this.sliceEventResize = memoize(this._sliceInteraction);
  6259. this.forceDayIfListItem = false; // hack
  6260. }
  6261. sliceProps(props, dateProfile, nextDayThreshold, context, ...extraArgs) {
  6262. let { eventUiBases } = props;
  6263. let eventSegs = this.sliceEventStore(props.eventStore, eventUiBases, dateProfile, nextDayThreshold, ...extraArgs);
  6264. return {
  6265. dateSelectionSegs: this.sliceDateSelection(props.dateSelection, dateProfile, nextDayThreshold, eventUiBases, context, ...extraArgs),
  6266. businessHourSegs: this.sliceBusinessHours(props.businessHours, dateProfile, nextDayThreshold, context, ...extraArgs),
  6267. fgEventSegs: eventSegs.fg,
  6268. bgEventSegs: eventSegs.bg,
  6269. eventDrag: this.sliceEventDrag(props.eventDrag, eventUiBases, dateProfile, nextDayThreshold, ...extraArgs),
  6270. eventResize: this.sliceEventResize(props.eventResize, eventUiBases, dateProfile, nextDayThreshold, ...extraArgs),
  6271. eventSelection: props.eventSelection,
  6272. }; // TODO: give interactionSegs?
  6273. }
  6274. sliceNowDate(// does not memoize
  6275. date, dateProfile, nextDayThreshold, context, ...extraArgs) {
  6276. return this._sliceDateSpan({ range: { start: date, end: addMs(date, 1) }, allDay: false }, // add 1 ms, protect against null range
  6277. dateProfile, nextDayThreshold, {}, context, ...extraArgs);
  6278. }
  6279. _sliceBusinessHours(businessHours, dateProfile, nextDayThreshold, context, ...extraArgs) {
  6280. if (!businessHours) {
  6281. return [];
  6282. }
  6283. return this._sliceEventStore(expandRecurring(businessHours, computeActiveRange(dateProfile, Boolean(nextDayThreshold)), context), {}, dateProfile, nextDayThreshold, ...extraArgs).bg;
  6284. }
  6285. _sliceEventStore(eventStore, eventUiBases, dateProfile, nextDayThreshold, ...extraArgs) {
  6286. if (eventStore) {
  6287. let rangeRes = sliceEventStore(eventStore, eventUiBases, computeActiveRange(dateProfile, Boolean(nextDayThreshold)), nextDayThreshold);
  6288. return {
  6289. bg: this.sliceEventRanges(rangeRes.bg, extraArgs),
  6290. fg: this.sliceEventRanges(rangeRes.fg, extraArgs),
  6291. };
  6292. }
  6293. return { bg: [], fg: [] };
  6294. }
  6295. _sliceInteraction(interaction, eventUiBases, dateProfile, nextDayThreshold, ...extraArgs) {
  6296. if (!interaction) {
  6297. return null;
  6298. }
  6299. let rangeRes = sliceEventStore(interaction.mutatedEvents, eventUiBases, computeActiveRange(dateProfile, Boolean(nextDayThreshold)), nextDayThreshold);
  6300. return {
  6301. segs: this.sliceEventRanges(rangeRes.fg, extraArgs),
  6302. affectedInstances: interaction.affectedEvents.instances,
  6303. isEvent: interaction.isEvent,
  6304. };
  6305. }
  6306. _sliceDateSpan(dateSpan, dateProfile, nextDayThreshold, eventUiBases, context, ...extraArgs) {
  6307. if (!dateSpan) {
  6308. return [];
  6309. }
  6310. let activeRange = computeActiveRange(dateProfile, Boolean(nextDayThreshold));
  6311. let activeDateSpanRange = intersectRanges(dateSpan.range, activeRange);
  6312. if (activeDateSpanRange) {
  6313. dateSpan = Object.assign(Object.assign({}, dateSpan), { range: activeDateSpanRange });
  6314. let eventRange = fabricateEventRange(dateSpan, eventUiBases, context);
  6315. let segs = this.sliceRange(dateSpan.range, ...extraArgs);
  6316. for (let seg of segs) {
  6317. seg.eventRange = eventRange;
  6318. }
  6319. return segs;
  6320. }
  6321. return [];
  6322. }
  6323. /*
  6324. "complete" seg means it has component and eventRange
  6325. */
  6326. sliceEventRanges(eventRanges, extraArgs) {
  6327. let segs = [];
  6328. for (let eventRange of eventRanges) {
  6329. segs.push(...this.sliceEventRange(eventRange, extraArgs));
  6330. }
  6331. return segs;
  6332. }
  6333. /*
  6334. "complete" seg means it has component and eventRange
  6335. */
  6336. sliceEventRange(eventRange, extraArgs) {
  6337. let dateRange = eventRange.range;
  6338. // hack to make multi-day events that are being force-displayed as list-items to take up only one day
  6339. if (this.forceDayIfListItem && eventRange.ui.display === 'list-item') {
  6340. dateRange = {
  6341. start: dateRange.start,
  6342. end: addDays(dateRange.start, 1),
  6343. };
  6344. }
  6345. let segs = this.sliceRange(dateRange, ...extraArgs);
  6346. for (let seg of segs) {
  6347. seg.eventRange = eventRange;
  6348. seg.isStart = eventRange.isStart && seg.isStart;
  6349. seg.isEnd = eventRange.isEnd && seg.isEnd;
  6350. }
  6351. return segs;
  6352. }
  6353. }
  6354. /*
  6355. for incorporating slotMinTime/slotMaxTime if appropriate
  6356. TODO: should be part of DateProfile!
  6357. TimelineDateProfile already does this btw
  6358. */
  6359. function computeActiveRange(dateProfile, isComponentAllDay) {
  6360. let range = dateProfile.activeRange;
  6361. if (isComponentAllDay) {
  6362. return range;
  6363. }
  6364. return {
  6365. start: addMs(range.start, dateProfile.slotMinTime.milliseconds),
  6366. end: addMs(range.end, dateProfile.slotMaxTime.milliseconds - 864e5), // 864e5 = ms in a day
  6367. };
  6368. }
  6369. // high-level segmenting-aware tester functions
  6370. // ------------------------------------------------------------------------------------------------------------------------
  6371. function isInteractionValid(interaction, dateProfile, context) {
  6372. let { instances } = interaction.mutatedEvents;
  6373. for (let instanceId in instances) {
  6374. if (!rangeContainsRange(dateProfile.validRange, instances[instanceId].range)) {
  6375. return false;
  6376. }
  6377. }
  6378. return isNewPropsValid({ eventDrag: interaction }, context); // HACK: the eventDrag props is used for ALL interactions
  6379. }
  6380. function isDateSelectionValid(dateSelection, dateProfile, context) {
  6381. if (!rangeContainsRange(dateProfile.validRange, dateSelection.range)) {
  6382. return false;
  6383. }
  6384. return isNewPropsValid({ dateSelection }, context);
  6385. }
  6386. function isNewPropsValid(newProps, context) {
  6387. let calendarState = context.getCurrentData();
  6388. let props = Object.assign({ businessHours: calendarState.businessHours, dateSelection: '', eventStore: calendarState.eventStore, eventUiBases: calendarState.eventUiBases, eventSelection: '', eventDrag: null, eventResize: null }, newProps);
  6389. return (context.pluginHooks.isPropsValid || isPropsValid)(props, context);
  6390. }
  6391. function isPropsValid(state, context, dateSpanMeta = {}, filterConfig) {
  6392. if (state.eventDrag && !isInteractionPropsValid(state, context, dateSpanMeta, filterConfig)) {
  6393. return false;
  6394. }
  6395. if (state.dateSelection && !isDateSelectionPropsValid(state, context, dateSpanMeta, filterConfig)) {
  6396. return false;
  6397. }
  6398. return true;
  6399. }
  6400. // Moving Event Validation
  6401. // ------------------------------------------------------------------------------------------------------------------------
  6402. function isInteractionPropsValid(state, context, dateSpanMeta, filterConfig) {
  6403. let currentState = context.getCurrentData();
  6404. let interaction = state.eventDrag; // HACK: the eventDrag props is used for ALL interactions
  6405. let subjectEventStore = interaction.mutatedEvents;
  6406. let subjectDefs = subjectEventStore.defs;
  6407. let subjectInstances = subjectEventStore.instances;
  6408. let subjectConfigs = compileEventUis(subjectDefs, interaction.isEvent ?
  6409. state.eventUiBases :
  6410. { '': currentState.selectionConfig });
  6411. if (filterConfig) {
  6412. subjectConfigs = mapHash(subjectConfigs, filterConfig);
  6413. }
  6414. // exclude the subject events. TODO: exclude defs too?
  6415. let otherEventStore = excludeInstances(state.eventStore, interaction.affectedEvents.instances);
  6416. let otherDefs = otherEventStore.defs;
  6417. let otherInstances = otherEventStore.instances;
  6418. let otherConfigs = compileEventUis(otherDefs, state.eventUiBases);
  6419. for (let subjectInstanceId in subjectInstances) {
  6420. let subjectInstance = subjectInstances[subjectInstanceId];
  6421. let subjectRange = subjectInstance.range;
  6422. let subjectConfig = subjectConfigs[subjectInstance.defId];
  6423. let subjectDef = subjectDefs[subjectInstance.defId];
  6424. // constraint
  6425. if (!allConstraintsPass(subjectConfig.constraints, subjectRange, otherEventStore, state.businessHours, context)) {
  6426. return false;
  6427. }
  6428. // overlap
  6429. let { eventOverlap } = context.options;
  6430. let eventOverlapFunc = typeof eventOverlap === 'function' ? eventOverlap : null;
  6431. for (let otherInstanceId in otherInstances) {
  6432. let otherInstance = otherInstances[otherInstanceId];
  6433. // intersect! evaluate
  6434. if (rangesIntersect(subjectRange, otherInstance.range)) {
  6435. let otherOverlap = otherConfigs[otherInstance.defId].overlap;
  6436. // consider the other event's overlap. only do this if the subject event is a "real" event
  6437. if (otherOverlap === false && interaction.isEvent) {
  6438. return false;
  6439. }
  6440. if (subjectConfig.overlap === false) {
  6441. return false;
  6442. }
  6443. if (eventOverlapFunc && !eventOverlapFunc(new EventImpl(context, otherDefs[otherInstance.defId], otherInstance), // still event
  6444. new EventImpl(context, subjectDef, subjectInstance))) {
  6445. return false;
  6446. }
  6447. }
  6448. }
  6449. // allow (a function)
  6450. let calendarEventStore = currentState.eventStore; // need global-to-calendar, not local to component (splittable)state
  6451. for (let subjectAllow of subjectConfig.allows) {
  6452. let subjectDateSpan = Object.assign(Object.assign({}, dateSpanMeta), { range: subjectInstance.range, allDay: subjectDef.allDay });
  6453. let origDef = calendarEventStore.defs[subjectDef.defId];
  6454. let origInstance = calendarEventStore.instances[subjectInstanceId];
  6455. let eventApi;
  6456. if (origDef) { // was previously in the calendar
  6457. eventApi = new EventImpl(context, origDef, origInstance);
  6458. }
  6459. else { // was an external event
  6460. eventApi = new EventImpl(context, subjectDef); // no instance, because had no dates
  6461. }
  6462. if (!subjectAllow(buildDateSpanApiWithContext(subjectDateSpan, context), eventApi)) {
  6463. return false;
  6464. }
  6465. }
  6466. }
  6467. return true;
  6468. }
  6469. // Date Selection Validation
  6470. // ------------------------------------------------------------------------------------------------------------------------
  6471. function isDateSelectionPropsValid(state, context, dateSpanMeta, filterConfig) {
  6472. let relevantEventStore = state.eventStore;
  6473. let relevantDefs = relevantEventStore.defs;
  6474. let relevantInstances = relevantEventStore.instances;
  6475. let selection = state.dateSelection;
  6476. let selectionRange = selection.range;
  6477. let { selectionConfig } = context.getCurrentData();
  6478. if (filterConfig) {
  6479. selectionConfig = filterConfig(selectionConfig);
  6480. }
  6481. // constraint
  6482. if (!allConstraintsPass(selectionConfig.constraints, selectionRange, relevantEventStore, state.businessHours, context)) {
  6483. return false;
  6484. }
  6485. // overlap
  6486. let { selectOverlap } = context.options;
  6487. let selectOverlapFunc = typeof selectOverlap === 'function' ? selectOverlap : null;
  6488. for (let relevantInstanceId in relevantInstances) {
  6489. let relevantInstance = relevantInstances[relevantInstanceId];
  6490. // intersect! evaluate
  6491. if (rangesIntersect(selectionRange, relevantInstance.range)) {
  6492. if (selectionConfig.overlap === false) {
  6493. return false;
  6494. }
  6495. if (selectOverlapFunc && !selectOverlapFunc(new EventImpl(context, relevantDefs[relevantInstance.defId], relevantInstance), null)) {
  6496. return false;
  6497. }
  6498. }
  6499. }
  6500. // allow (a function)
  6501. for (let selectionAllow of selectionConfig.allows) {
  6502. let fullDateSpan = Object.assign(Object.assign({}, dateSpanMeta), selection);
  6503. if (!selectionAllow(buildDateSpanApiWithContext(fullDateSpan, context), null)) {
  6504. return false;
  6505. }
  6506. }
  6507. return true;
  6508. }
  6509. // Constraint Utils
  6510. // ------------------------------------------------------------------------------------------------------------------------
  6511. function allConstraintsPass(constraints, subjectRange, otherEventStore, businessHoursUnexpanded, context) {
  6512. for (let constraint of constraints) {
  6513. if (!anyRangesContainRange(constraintToRanges(constraint, subjectRange, otherEventStore, businessHoursUnexpanded, context), subjectRange)) {
  6514. return false;
  6515. }
  6516. }
  6517. return true;
  6518. }
  6519. function constraintToRanges(constraint, subjectRange, // for expanding a recurring constraint, or expanding business hours
  6520. otherEventStore, // for if constraint is an even group ID
  6521. businessHoursUnexpanded, // for if constraint is 'businessHours'
  6522. context) {
  6523. if (constraint === 'businessHours') {
  6524. return eventStoreToRanges(expandRecurring(businessHoursUnexpanded, subjectRange, context));
  6525. }
  6526. if (typeof constraint === 'string') { // an group ID
  6527. return eventStoreToRanges(filterEventStoreDefs(otherEventStore, (eventDef) => eventDef.groupId === constraint));
  6528. }
  6529. if (typeof constraint === 'object' && constraint) { // non-null object
  6530. return eventStoreToRanges(expandRecurring(constraint, subjectRange, context));
  6531. }
  6532. return []; // if it's false
  6533. }
  6534. // TODO: move to event-store file?
  6535. function eventStoreToRanges(eventStore) {
  6536. let { instances } = eventStore;
  6537. let ranges = [];
  6538. for (let instanceId in instances) {
  6539. ranges.push(instances[instanceId].range);
  6540. }
  6541. return ranges;
  6542. }
  6543. // TODO: move to geom file?
  6544. function anyRangesContainRange(outerRanges, innerRange) {
  6545. for (let outerRange of outerRanges) {
  6546. if (rangeContainsRange(outerRange, innerRange)) {
  6547. return true;
  6548. }
  6549. }
  6550. return false;
  6551. }
  6552. const VISIBLE_HIDDEN_RE = /^(visible|hidden)$/;
  6553. class Scroller extends BaseComponent {
  6554. constructor() {
  6555. super(...arguments);
  6556. this.handleEl = (el) => {
  6557. this.el = el;
  6558. setRef(this.props.elRef, el);
  6559. };
  6560. }
  6561. render() {
  6562. let { props } = this;
  6563. let { liquid, liquidIsAbsolute } = props;
  6564. let isAbsolute = liquid && liquidIsAbsolute;
  6565. let className = ['fc-scroller'];
  6566. if (liquid) {
  6567. if (liquidIsAbsolute) {
  6568. className.push('fc-scroller-liquid-absolute');
  6569. }
  6570. else {
  6571. className.push('fc-scroller-liquid');
  6572. }
  6573. }
  6574. return (y("div", { ref: this.handleEl, className: className.join(' '), style: {
  6575. overflowX: props.overflowX,
  6576. overflowY: props.overflowY,
  6577. left: (isAbsolute && -(props.overcomeLeft || 0)) || '',
  6578. right: (isAbsolute && -(props.overcomeRight || 0)) || '',
  6579. bottom: (isAbsolute && -(props.overcomeBottom || 0)) || '',
  6580. marginLeft: (!isAbsolute && -(props.overcomeLeft || 0)) || '',
  6581. marginRight: (!isAbsolute && -(props.overcomeRight || 0)) || '',
  6582. marginBottom: (!isAbsolute && -(props.overcomeBottom || 0)) || '',
  6583. maxHeight: props.maxHeight || '',
  6584. } }, props.children));
  6585. }
  6586. needsXScrolling() {
  6587. if (VISIBLE_HIDDEN_RE.test(this.props.overflowX)) {
  6588. return false;
  6589. }
  6590. // testing scrollWidth>clientWidth is unreliable cross-browser when pixel heights aren't integers.
  6591. // much more reliable to see if children are taller than the scroller, even tho doesn't account for
  6592. // inner-child margins and absolute positioning
  6593. let { el } = this;
  6594. let realClientWidth = this.el.getBoundingClientRect().width - this.getYScrollbarWidth();
  6595. let { children } = el;
  6596. for (let i = 0; i < children.length; i += 1) {
  6597. let childEl = children[i];
  6598. if (childEl.getBoundingClientRect().width > realClientWidth) {
  6599. return true;
  6600. }
  6601. }
  6602. return false;
  6603. }
  6604. needsYScrolling() {
  6605. if (VISIBLE_HIDDEN_RE.test(this.props.overflowY)) {
  6606. return false;
  6607. }
  6608. // testing scrollHeight>clientHeight is unreliable cross-browser when pixel heights aren't integers.
  6609. // much more reliable to see if children are taller than the scroller, even tho doesn't account for
  6610. // inner-child margins and absolute positioning
  6611. let { el } = this;
  6612. let realClientHeight = this.el.getBoundingClientRect().height - this.getXScrollbarWidth();
  6613. let { children } = el;
  6614. for (let i = 0; i < children.length; i += 1) {
  6615. let childEl = children[i];
  6616. if (childEl.getBoundingClientRect().height > realClientHeight) {
  6617. return true;
  6618. }
  6619. }
  6620. return false;
  6621. }
  6622. getXScrollbarWidth() {
  6623. if (VISIBLE_HIDDEN_RE.test(this.props.overflowX)) {
  6624. return 0;
  6625. }
  6626. return this.el.offsetHeight - this.el.clientHeight; // only works because we guarantee no borders. TODO: add to CSS with important?
  6627. }
  6628. getYScrollbarWidth() {
  6629. if (VISIBLE_HIDDEN_RE.test(this.props.overflowY)) {
  6630. return 0;
  6631. }
  6632. return this.el.offsetWidth - this.el.clientWidth; // only works because we guarantee no borders. TODO: add to CSS with important?
  6633. }
  6634. }
  6635. /*
  6636. TODO: somehow infer OtherArgs from masterCallback?
  6637. TODO: infer RefType from masterCallback if provided
  6638. */
  6639. class RefMap {
  6640. constructor(masterCallback) {
  6641. this.masterCallback = masterCallback;
  6642. this.currentMap = {};
  6643. this.depths = {};
  6644. this.callbackMap = {};
  6645. this.handleValue = (val, key) => {
  6646. let { depths, currentMap } = this;
  6647. let removed = false;
  6648. let added = false;
  6649. if (val !== null) {
  6650. // for bug... ACTUALLY: can probably do away with this now that callers don't share numeric indices anymore
  6651. removed = (key in currentMap);
  6652. currentMap[key] = val;
  6653. depths[key] = (depths[key] || 0) + 1;
  6654. added = true;
  6655. }
  6656. else {
  6657. depths[key] -= 1;
  6658. if (!depths[key]) {
  6659. delete currentMap[key];
  6660. delete this.callbackMap[key];
  6661. removed = true;
  6662. }
  6663. }
  6664. if (this.masterCallback) {
  6665. if (removed) {
  6666. this.masterCallback(null, String(key));
  6667. }
  6668. if (added) {
  6669. this.masterCallback(val, String(key));
  6670. }
  6671. }
  6672. };
  6673. }
  6674. createRef(key) {
  6675. let refCallback = this.callbackMap[key];
  6676. if (!refCallback) {
  6677. refCallback = this.callbackMap[key] = (val) => {
  6678. this.handleValue(val, String(key));
  6679. };
  6680. }
  6681. return refCallback;
  6682. }
  6683. // TODO: check callers that don't care about order. should use getAll instead
  6684. // NOTE: this method has become less valuable now that we are encouraged to map order by some other index
  6685. // TODO: provide ONE array-export function, buildArray, which fails on non-numeric indexes. caller can manipulate and "collect"
  6686. collect(startIndex, endIndex, step) {
  6687. return collectFromHash(this.currentMap, startIndex, endIndex, step);
  6688. }
  6689. getAll() {
  6690. return hashValuesToArray(this.currentMap);
  6691. }
  6692. }
  6693. function computeShrinkWidth(chunkEls) {
  6694. let shrinkCells = findElements(chunkEls, '.fc-scrollgrid-shrink');
  6695. let largestWidth = 0;
  6696. for (let shrinkCell of shrinkCells) {
  6697. largestWidth = Math.max(largestWidth, computeSmallestCellWidth(shrinkCell));
  6698. }
  6699. return Math.ceil(largestWidth); // <table> elements work best with integers. round up to ensure contents fits
  6700. }
  6701. function getSectionHasLiquidHeight(props, sectionConfig) {
  6702. return props.liquid && sectionConfig.liquid; // does the section do liquid-height? (need to have whole scrollgrid liquid-height as well)
  6703. }
  6704. function getAllowYScrolling(props, sectionConfig) {
  6705. return sectionConfig.maxHeight != null || // if its possible for the height to max out, we might need scrollbars
  6706. getSectionHasLiquidHeight(props, sectionConfig); // if the section is liquid height, it might condense enough to require scrollbars
  6707. }
  6708. // TODO: ONLY use `arg`. force out internal function to use same API
  6709. function renderChunkContent(sectionConfig, chunkConfig, arg, isHeader) {
  6710. let { expandRows } = arg;
  6711. let content = typeof chunkConfig.content === 'function' ?
  6712. chunkConfig.content(arg) :
  6713. y('table', {
  6714. role: 'presentation',
  6715. className: [
  6716. chunkConfig.tableClassName,
  6717. sectionConfig.syncRowHeights ? 'fc-scrollgrid-sync-table' : '',
  6718. ].join(' '),
  6719. style: {
  6720. minWidth: arg.tableMinWidth,
  6721. width: arg.clientWidth,
  6722. height: expandRows ? arg.clientHeight : '', // css `height` on a <table> serves as a min-height
  6723. },
  6724. }, arg.tableColGroupNode, y(isHeader ? 'thead' : 'tbody', {
  6725. role: 'presentation',
  6726. }, typeof chunkConfig.rowContent === 'function'
  6727. ? chunkConfig.rowContent(arg)
  6728. : chunkConfig.rowContent));
  6729. return content;
  6730. }
  6731. function isColPropsEqual(cols0, cols1) {
  6732. return isArraysEqual(cols0, cols1, isPropsEqual);
  6733. }
  6734. function renderMicroColGroup(cols, shrinkWidth) {
  6735. let colNodes = [];
  6736. /*
  6737. for ColProps with spans, it would have been great to make a single <col span="">
  6738. HOWEVER, Chrome was getting messing up distributing the width to <td>/<th> elements with colspans.
  6739. SOLUTION: making individual <col> elements makes Chrome behave.
  6740. */
  6741. for (let colProps of cols) {
  6742. let span = colProps.span || 1;
  6743. for (let i = 0; i < span; i += 1) {
  6744. colNodes.push(y("col", { style: {
  6745. width: colProps.width === 'shrink' ? sanitizeShrinkWidth(shrinkWidth) : (colProps.width || ''),
  6746. minWidth: colProps.minWidth || '',
  6747. } }));
  6748. }
  6749. }
  6750. return y('colgroup', {}, ...colNodes);
  6751. }
  6752. function sanitizeShrinkWidth(shrinkWidth) {
  6753. /* why 4? if we do 0, it will kill any border, which are needed for computeSmallestCellWidth
  6754. 4 accounts for 2 2-pixel borders. TODO: better solution? */
  6755. return shrinkWidth == null ? 4 : shrinkWidth;
  6756. }
  6757. function hasShrinkWidth(cols) {
  6758. for (let col of cols) {
  6759. if (col.width === 'shrink') {
  6760. return true;
  6761. }
  6762. }
  6763. return false;
  6764. }
  6765. function getScrollGridClassNames(liquid, context) {
  6766. let classNames = [
  6767. 'fc-scrollgrid',
  6768. context.theme.getClass('table'),
  6769. ];
  6770. if (liquid) {
  6771. classNames.push('fc-scrollgrid-liquid');
  6772. }
  6773. return classNames;
  6774. }
  6775. function getSectionClassNames(sectionConfig, wholeTableVGrow) {
  6776. let classNames = [
  6777. 'fc-scrollgrid-section',
  6778. `fc-scrollgrid-section-${sectionConfig.type}`,
  6779. sectionConfig.className, // used?
  6780. ];
  6781. if (wholeTableVGrow && sectionConfig.liquid && sectionConfig.maxHeight == null) {
  6782. classNames.push('fc-scrollgrid-section-liquid');
  6783. }
  6784. if (sectionConfig.isSticky) {
  6785. classNames.push('fc-scrollgrid-section-sticky');
  6786. }
  6787. return classNames;
  6788. }
  6789. function renderScrollShim(arg) {
  6790. return (y("div", { className: "fc-scrollgrid-sticky-shim", style: {
  6791. width: arg.clientWidth,
  6792. minWidth: arg.tableMinWidth,
  6793. } }));
  6794. }
  6795. function getStickyHeaderDates(options) {
  6796. let { stickyHeaderDates } = options;
  6797. if (stickyHeaderDates == null || stickyHeaderDates === 'auto') {
  6798. stickyHeaderDates = options.height === 'auto' || options.viewHeight === 'auto';
  6799. }
  6800. return stickyHeaderDates;
  6801. }
  6802. function getStickyFooterScrollbar(options) {
  6803. let { stickyFooterScrollbar } = options;
  6804. if (stickyFooterScrollbar == null || stickyFooterScrollbar === 'auto') {
  6805. stickyFooterScrollbar = options.height === 'auto' || options.viewHeight === 'auto';
  6806. }
  6807. return stickyFooterScrollbar;
  6808. }
  6809. class SimpleScrollGrid extends BaseComponent {
  6810. constructor() {
  6811. super(...arguments);
  6812. this.processCols = memoize((a) => a, isColPropsEqual); // so we get same `cols` props every time
  6813. // yucky to memoize VNodes, but much more efficient for consumers
  6814. this.renderMicroColGroup = memoize(renderMicroColGroup);
  6815. this.scrollerRefs = new RefMap();
  6816. this.scrollerElRefs = new RefMap(this._handleScrollerEl.bind(this));
  6817. this.state = {
  6818. shrinkWidth: null,
  6819. forceYScrollbars: false,
  6820. scrollerClientWidths: {},
  6821. scrollerClientHeights: {},
  6822. };
  6823. // TODO: can do a really simple print-view. dont need to join rows
  6824. this.handleSizing = () => {
  6825. this.safeSetState(Object.assign({ shrinkWidth: this.computeShrinkWidth() }, this.computeScrollerDims()));
  6826. };
  6827. }
  6828. render() {
  6829. let { props, state, context } = this;
  6830. let sectionConfigs = props.sections || [];
  6831. let cols = this.processCols(props.cols);
  6832. let microColGroupNode = this.renderMicroColGroup(cols, state.shrinkWidth);
  6833. let classNames = getScrollGridClassNames(props.liquid, context);
  6834. if (props.collapsibleWidth) {
  6835. classNames.push('fc-scrollgrid-collapsible');
  6836. }
  6837. // TODO: make DRY
  6838. let configCnt = sectionConfigs.length;
  6839. let configI = 0;
  6840. let currentConfig;
  6841. let headSectionNodes = [];
  6842. let bodySectionNodes = [];
  6843. let footSectionNodes = [];
  6844. while (configI < configCnt && (currentConfig = sectionConfigs[configI]).type === 'header') {
  6845. headSectionNodes.push(this.renderSection(currentConfig, microColGroupNode, true));
  6846. configI += 1;
  6847. }
  6848. while (configI < configCnt && (currentConfig = sectionConfigs[configI]).type === 'body') {
  6849. bodySectionNodes.push(this.renderSection(currentConfig, microColGroupNode, false));
  6850. configI += 1;
  6851. }
  6852. while (configI < configCnt && (currentConfig = sectionConfigs[configI]).type === 'footer') {
  6853. footSectionNodes.push(this.renderSection(currentConfig, microColGroupNode, true));
  6854. configI += 1;
  6855. }
  6856. // firefox bug: when setting height on table and there is a thead or tfoot,
  6857. // the necessary height:100% on the liquid-height body section forces the *whole* table to be taller. (bug #5524)
  6858. // use getCanVGrowWithinCell as a way to detect table-stupid firefox.
  6859. // if so, use a simpler dom structure, jam everything into a lone tbody.
  6860. let isBuggy = !getCanVGrowWithinCell();
  6861. const roleAttrs = { role: 'rowgroup' };
  6862. return y('table', {
  6863. role: 'grid',
  6864. className: classNames.join(' '),
  6865. style: { height: props.height },
  6866. }, Boolean(!isBuggy && headSectionNodes.length) && y('thead', roleAttrs, ...headSectionNodes), Boolean(!isBuggy && bodySectionNodes.length) && y('tbody', roleAttrs, ...bodySectionNodes), Boolean(!isBuggy && footSectionNodes.length) && y('tfoot', roleAttrs, ...footSectionNodes), isBuggy && y('tbody', roleAttrs, ...headSectionNodes, ...bodySectionNodes, ...footSectionNodes));
  6867. }
  6868. renderSection(sectionConfig, microColGroupNode, isHeader) {
  6869. if ('outerContent' in sectionConfig) {
  6870. return (y(_, { key: sectionConfig.key }, sectionConfig.outerContent));
  6871. }
  6872. return (y("tr", { key: sectionConfig.key, role: "presentation", className: getSectionClassNames(sectionConfig, this.props.liquid).join(' ') }, this.renderChunkTd(sectionConfig, microColGroupNode, sectionConfig.chunk, isHeader)));
  6873. }
  6874. renderChunkTd(sectionConfig, microColGroupNode, chunkConfig, isHeader) {
  6875. if ('outerContent' in chunkConfig) {
  6876. return chunkConfig.outerContent;
  6877. }
  6878. let { props } = this;
  6879. let { forceYScrollbars, scrollerClientWidths, scrollerClientHeights } = this.state;
  6880. let needsYScrolling = getAllowYScrolling(props, sectionConfig); // TODO: do lazily. do in section config?
  6881. let isLiquid = getSectionHasLiquidHeight(props, sectionConfig);
  6882. // for `!props.liquid` - is WHOLE scrollgrid natural height?
  6883. // TODO: do same thing in advanced scrollgrid? prolly not b/c always has horizontal scrollbars
  6884. let overflowY = !props.liquid ? 'visible' :
  6885. forceYScrollbars ? 'scroll' :
  6886. !needsYScrolling ? 'hidden' :
  6887. 'auto';
  6888. let sectionKey = sectionConfig.key;
  6889. let content = renderChunkContent(sectionConfig, chunkConfig, {
  6890. tableColGroupNode: microColGroupNode,
  6891. tableMinWidth: '',
  6892. clientWidth: (!props.collapsibleWidth && scrollerClientWidths[sectionKey] !== undefined) ? scrollerClientWidths[sectionKey] : null,
  6893. clientHeight: scrollerClientHeights[sectionKey] !== undefined ? scrollerClientHeights[sectionKey] : null,
  6894. expandRows: sectionConfig.expandRows,
  6895. syncRowHeights: false,
  6896. rowSyncHeights: [],
  6897. reportRowHeightChange: () => { },
  6898. }, isHeader);
  6899. return y(isHeader ? 'th' : 'td', {
  6900. ref: chunkConfig.elRef,
  6901. role: 'presentation',
  6902. }, y("div", { className: `fc-scroller-harness${isLiquid ? ' fc-scroller-harness-liquid' : ''}` },
  6903. y(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
  6904. : true }, content)));
  6905. }
  6906. _handleScrollerEl(scrollerEl, key) {
  6907. let section = getSectionByKey(this.props.sections, key);
  6908. if (section) {
  6909. setRef(section.chunk.scrollerElRef, scrollerEl);
  6910. }
  6911. }
  6912. componentDidMount() {
  6913. this.handleSizing();
  6914. this.context.addResizeHandler(this.handleSizing);
  6915. }
  6916. componentDidUpdate() {
  6917. // TODO: need better solution when state contains non-sizing things
  6918. this.handleSizing();
  6919. }
  6920. componentWillUnmount() {
  6921. this.context.removeResizeHandler(this.handleSizing);
  6922. }
  6923. computeShrinkWidth() {
  6924. return hasShrinkWidth(this.props.cols)
  6925. ? computeShrinkWidth(this.scrollerElRefs.getAll())
  6926. : 0;
  6927. }
  6928. computeScrollerDims() {
  6929. let scrollbarWidth = getScrollbarWidths();
  6930. let { scrollerRefs, scrollerElRefs } = this;
  6931. let forceYScrollbars = false;
  6932. let scrollerClientWidths = {};
  6933. let scrollerClientHeights = {};
  6934. for (let sectionKey in scrollerRefs.currentMap) {
  6935. let scroller = scrollerRefs.currentMap[sectionKey];
  6936. if (scroller && scroller.needsYScrolling()) {
  6937. forceYScrollbars = true;
  6938. break;
  6939. }
  6940. }
  6941. for (let section of this.props.sections) {
  6942. let sectionKey = section.key;
  6943. let scrollerEl = scrollerElRefs.currentMap[sectionKey];
  6944. if (scrollerEl) {
  6945. let harnessEl = scrollerEl.parentNode; // TODO: weird way to get this. need harness b/c doesn't include table borders
  6946. scrollerClientWidths[sectionKey] = Math.floor(harnessEl.getBoundingClientRect().width - (forceYScrollbars
  6947. ? scrollbarWidth.y // use global because scroller might not have scrollbars yet but will need them in future
  6948. : 0));
  6949. scrollerClientHeights[sectionKey] = Math.floor(harnessEl.getBoundingClientRect().height);
  6950. }
  6951. }
  6952. return { forceYScrollbars, scrollerClientWidths, scrollerClientHeights };
  6953. }
  6954. }
  6955. SimpleScrollGrid.addStateEquality({
  6956. scrollerClientWidths: isPropsEqual,
  6957. scrollerClientHeights: isPropsEqual,
  6958. });
  6959. function getSectionByKey(sections, key) {
  6960. for (let section of sections) {
  6961. if (section.key === key) {
  6962. return section;
  6963. }
  6964. }
  6965. return null;
  6966. }
  6967. class EventContainer extends BaseComponent {
  6968. constructor() {
  6969. super(...arguments);
  6970. this.handleEl = (el) => {
  6971. this.el = el;
  6972. if (el) {
  6973. setElSeg(el, this.props.seg);
  6974. }
  6975. };
  6976. }
  6977. render() {
  6978. const { props, context } = this;
  6979. const { options } = context;
  6980. const { seg } = props;
  6981. const { eventRange } = seg;
  6982. const { ui } = eventRange;
  6983. const renderProps = {
  6984. event: new EventImpl(context, eventRange.def, eventRange.instance),
  6985. view: context.viewApi,
  6986. timeText: props.timeText,
  6987. textColor: ui.textColor,
  6988. backgroundColor: ui.backgroundColor,
  6989. borderColor: ui.borderColor,
  6990. isDraggable: !props.disableDragging && computeSegDraggable(seg, context),
  6991. isStartResizable: !props.disableResizing && computeSegStartResizable(seg, context),
  6992. isEndResizable: !props.disableResizing && computeSegEndResizable(seg),
  6993. isMirror: Boolean(props.isDragging || props.isResizing || props.isDateSelecting),
  6994. isStart: Boolean(seg.isStart),
  6995. isEnd: Boolean(seg.isEnd),
  6996. isPast: Boolean(props.isPast),
  6997. isFuture: Boolean(props.isFuture),
  6998. isToday: Boolean(props.isToday),
  6999. isSelected: Boolean(props.isSelected),
  7000. isDragging: Boolean(props.isDragging),
  7001. isResizing: Boolean(props.isResizing),
  7002. };
  7003. return (y(ContentContainer, Object.assign({}, props /* contains children */, { elRef: this.handleEl, elClasses: [
  7004. ...getEventClassNames(renderProps),
  7005. ...seg.eventRange.ui.classNames,
  7006. ...(props.elClasses || []),
  7007. ], renderProps: renderProps, generatorName: "eventContent", customGenerator: options.eventContent, defaultGenerator: props.defaultGenerator, classNameGenerator: options.eventClassNames, didMount: options.eventDidMount, willUnmount: options.eventWillUnmount })));
  7008. }
  7009. componentDidUpdate(prevProps) {
  7010. if (this.el && this.props.seg !== prevProps.seg) {
  7011. setElSeg(this.el, this.props.seg);
  7012. }
  7013. }
  7014. }
  7015. // should not be a purecomponent
  7016. class StandardEvent extends BaseComponent {
  7017. render() {
  7018. let { props, context } = this;
  7019. let { options } = context;
  7020. let { seg } = props;
  7021. let { ui } = seg.eventRange;
  7022. let timeFormat = options.eventTimeFormat || props.defaultTimeFormat;
  7023. let timeText = buildSegTimeText(seg, timeFormat, context, props.defaultDisplayEventTime, props.defaultDisplayEventEnd);
  7024. return (y(EventContainer, Object.assign({}, props /* includes elRef */, { elTag: "a", elStyle: {
  7025. borderColor: ui.borderColor,
  7026. backgroundColor: ui.backgroundColor,
  7027. }, elAttrs: getSegAnchorAttrs(seg, context), defaultGenerator: renderInnerContent$1$1, timeText: timeText }), (InnerContent, eventContentArg) => (y(_, null,
  7028. y(InnerContent, { elTag: "div", elClasses: ['fc-event-main'], elStyle: { color: eventContentArg.textColor } }),
  7029. Boolean(eventContentArg.isStartResizable) && (y("div", { className: "fc-event-resizer fc-event-resizer-start" })),
  7030. Boolean(eventContentArg.isEndResizable) && (y("div", { className: "fc-event-resizer fc-event-resizer-end" }))))));
  7031. }
  7032. }
  7033. function renderInnerContent$1$1(innerProps) {
  7034. return (y("div", { className: "fc-event-main-frame" },
  7035. innerProps.timeText && (y("div", { className: "fc-event-time" }, innerProps.timeText)),
  7036. y("div", { className: "fc-event-title-container" },
  7037. y("div", { className: "fc-event-title fc-sticky" }, innerProps.event.title || y(_, null, "\u00A0")))));
  7038. }
  7039. const NowIndicatorContainer = (props) => (y(ViewContextType.Consumer, null, (context) => {
  7040. let { options } = context;
  7041. let renderProps = {
  7042. isAxis: props.isAxis,
  7043. date: context.dateEnv.toDate(props.date),
  7044. view: context.viewApi,
  7045. };
  7046. return (y(ContentContainer, Object.assign({}, props /* includes children */, { elTag: props.elTag || 'div', renderProps: renderProps, generatorName: "nowIndicatorContent", customGenerator: options.nowIndicatorContent, classNameGenerator: options.nowIndicatorClassNames, didMount: options.nowIndicatorDidMount, willUnmount: options.nowIndicatorWillUnmount })));
  7047. }));
  7048. const DAY_NUM_FORMAT = createFormatter({ day: 'numeric' });
  7049. class DayCellContainer extends BaseComponent {
  7050. constructor() {
  7051. super(...arguments);
  7052. this.refineRenderProps = memoizeObjArg(refineRenderProps);
  7053. }
  7054. render() {
  7055. let { props, context } = this;
  7056. let { options } = context;
  7057. let renderProps = this.refineRenderProps({
  7058. date: props.date,
  7059. dateProfile: props.dateProfile,
  7060. todayRange: props.todayRange,
  7061. isMonthStart: props.isMonthStart || false,
  7062. showDayNumber: props.showDayNumber,
  7063. extraRenderProps: props.extraRenderProps,
  7064. viewApi: context.viewApi,
  7065. dateEnv: context.dateEnv,
  7066. monthStartFormat: options.monthStartFormat,
  7067. });
  7068. return (y(ContentContainer, Object.assign({}, props /* includes children */, { elClasses: [
  7069. ...getDayClassNames(renderProps, context.theme),
  7070. ...(props.elClasses || []),
  7071. ], elAttrs: Object.assign(Object.assign({}, props.elAttrs), (renderProps.isDisabled ? {} : { 'data-date': formatDayString(props.date) })), renderProps: renderProps, generatorName: "dayCellContent", customGenerator: options.dayCellContent, defaultGenerator: props.defaultGenerator, classNameGenerator:
  7072. // don't use custom classNames if disabled
  7073. renderProps.isDisabled ? undefined : options.dayCellClassNames, didMount: options.dayCellDidMount, willUnmount: options.dayCellWillUnmount })));
  7074. }
  7075. }
  7076. function hasCustomDayCellContent(options) {
  7077. return Boolean(options.dayCellContent || hasCustomRenderingHandler('dayCellContent', options));
  7078. }
  7079. function refineRenderProps(raw) {
  7080. let { date, dateEnv, dateProfile, isMonthStart } = raw;
  7081. let dayMeta = getDateMeta(date, raw.todayRange, null, dateProfile);
  7082. let dayNumberText = raw.showDayNumber ? (dateEnv.format(date, isMonthStart ? raw.monthStartFormat : DAY_NUM_FORMAT)) : '';
  7083. return Object.assign(Object.assign(Object.assign({ date: dateEnv.toDate(date), view: raw.viewApi }, dayMeta), { isMonthStart,
  7084. dayNumberText }), raw.extraRenderProps);
  7085. }
  7086. class BgEvent extends BaseComponent {
  7087. render() {
  7088. let { props } = this;
  7089. let { seg } = props;
  7090. return (y(EventContainer, { elTag: "div", elClasses: ['fc-bg-event'], elStyle: { backgroundColor: seg.eventRange.ui.backgroundColor }, defaultGenerator: renderInnerContent$3, seg: seg, timeText: "", isDragging: false, isResizing: false, isDateSelecting: false, isSelected: false, isPast: props.isPast, isFuture: props.isFuture, isToday: props.isToday, disableDragging: true, disableResizing: true }));
  7091. }
  7092. }
  7093. function renderInnerContent$3(props) {
  7094. let { title } = props.event;
  7095. return title && (y("div", { className: "fc-event-title" }, props.event.title));
  7096. }
  7097. function renderFill(fillType) {
  7098. return (y("div", { className: `fc-${fillType}` }));
  7099. }
  7100. const WeekNumberContainer = (props) => (y(ViewContextType.Consumer, null, (context) => {
  7101. let { dateEnv, options } = context;
  7102. let { date } = props;
  7103. let format = options.weekNumberFormat || props.defaultFormat;
  7104. let num = dateEnv.computeWeekNumber(date); // TODO: somehow use for formatting as well?
  7105. let text = dateEnv.format(date, format);
  7106. let renderProps = { num, text, date };
  7107. return (y(ContentContainer // why isn't WeekNumberContentArg being auto-detected?
  7108. , Object.assign({}, props /* includes children */, { renderProps: renderProps, generatorName: "weekNumberContent", customGenerator: options.weekNumberContent, defaultGenerator: renderInner, classNameGenerator: options.weekNumberClassNames, didMount: options.weekNumberDidMount, willUnmount: options.weekNumberWillUnmount })));
  7109. }));
  7110. function renderInner(innerProps) {
  7111. return innerProps.text;
  7112. }
  7113. const PADDING_FROM_VIEWPORT = 10;
  7114. class Popover extends BaseComponent {
  7115. constructor() {
  7116. super(...arguments);
  7117. this.state = {
  7118. titleId: getUniqueDomId(),
  7119. };
  7120. this.handleRootEl = (el) => {
  7121. this.rootEl = el;
  7122. if (this.props.elRef) {
  7123. setRef(this.props.elRef, el);
  7124. }
  7125. };
  7126. // Triggered when the user clicks *anywhere* in the document, for the autoHide feature
  7127. this.handleDocumentMouseDown = (ev) => {
  7128. // only hide the popover if the click happened outside the popover
  7129. const target = getEventTargetViaRoot(ev);
  7130. if (!this.rootEl.contains(target)) {
  7131. this.handleCloseClick();
  7132. }
  7133. };
  7134. this.handleDocumentKeyDown = (ev) => {
  7135. if (ev.key === 'Escape') {
  7136. this.handleCloseClick();
  7137. }
  7138. };
  7139. this.handleCloseClick = () => {
  7140. let { onClose } = this.props;
  7141. if (onClose) {
  7142. onClose();
  7143. }
  7144. };
  7145. }
  7146. render() {
  7147. let { theme, options } = this.context;
  7148. let { props, state } = this;
  7149. let classNames = [
  7150. 'fc-popover',
  7151. theme.getClass('popover'),
  7152. ].concat(props.extraClassNames || []);
  7153. return j(y("div", Object.assign({}, props.extraAttrs, { id: props.id, className: classNames.join(' '), "aria-labelledby": state.titleId, ref: this.handleRootEl }),
  7154. y("div", { className: 'fc-popover-header ' + theme.getClass('popoverHeader') },
  7155. y("span", { className: "fc-popover-title", id: state.titleId }, props.title),
  7156. y("span", { className: 'fc-popover-close ' + theme.getIconClass('close'), title: options.closeHint, onClick: this.handleCloseClick })),
  7157. y("div", { className: 'fc-popover-body ' + theme.getClass('popoverContent') }, props.children)), props.parentEl);
  7158. }
  7159. componentDidMount() {
  7160. document.addEventListener('mousedown', this.handleDocumentMouseDown);
  7161. document.addEventListener('keydown', this.handleDocumentKeyDown);
  7162. this.updateSize();
  7163. }
  7164. componentWillUnmount() {
  7165. document.removeEventListener('mousedown', this.handleDocumentMouseDown);
  7166. document.removeEventListener('keydown', this.handleDocumentKeyDown);
  7167. }
  7168. updateSize() {
  7169. let { isRtl } = this.context;
  7170. let { alignmentEl, alignGridTop } = this.props;
  7171. let { rootEl } = this;
  7172. let alignmentRect = computeClippedClientRect(alignmentEl);
  7173. if (alignmentRect) {
  7174. let popoverDims = rootEl.getBoundingClientRect();
  7175. // position relative to viewport
  7176. let popoverTop = alignGridTop
  7177. ? elementClosest(alignmentEl, '.fc-scrollgrid').getBoundingClientRect().top
  7178. : alignmentRect.top;
  7179. let popoverLeft = isRtl ? alignmentRect.right - popoverDims.width : alignmentRect.left;
  7180. // constrain
  7181. popoverTop = Math.max(popoverTop, PADDING_FROM_VIEWPORT);
  7182. popoverLeft = Math.min(popoverLeft, document.documentElement.clientWidth - PADDING_FROM_VIEWPORT - popoverDims.width);
  7183. popoverLeft = Math.max(popoverLeft, PADDING_FROM_VIEWPORT);
  7184. let origin = rootEl.offsetParent.getBoundingClientRect();
  7185. applyStyle(rootEl, {
  7186. top: popoverTop - origin.top,
  7187. left: popoverLeft - origin.left,
  7188. });
  7189. }
  7190. }
  7191. }
  7192. class MorePopover extends DateComponent {
  7193. constructor() {
  7194. super(...arguments);
  7195. this.handleRootEl = (rootEl) => {
  7196. this.rootEl = rootEl;
  7197. if (rootEl) {
  7198. this.context.registerInteractiveComponent(this, {
  7199. el: rootEl,
  7200. useEventCenter: false,
  7201. });
  7202. }
  7203. else {
  7204. this.context.unregisterInteractiveComponent(this);
  7205. }
  7206. };
  7207. }
  7208. render() {
  7209. let { options, dateEnv } = this.context;
  7210. let { props } = this;
  7211. let { startDate, todayRange, dateProfile } = props;
  7212. let title = dateEnv.format(startDate, options.dayPopoverFormat);
  7213. return (y(DayCellContainer, { elRef: this.handleRootEl, date: startDate, dateProfile: dateProfile, todayRange: todayRange }, (InnerContent, renderProps, elAttrs) => (y(Popover, { elRef: elAttrs.ref, id: props.id, title: title, extraClassNames: ['fc-more-popover'].concat(elAttrs.className || []), extraAttrs: elAttrs /* TODO: make these time-based when not whole-day? */, parentEl: props.parentEl, alignmentEl: props.alignmentEl, alignGridTop: props.alignGridTop, onClose: props.onClose },
  7214. hasCustomDayCellContent(options) && (y(InnerContent, { elTag: "div", elClasses: ['fc-more-popover-misc'] })),
  7215. props.children))));
  7216. }
  7217. queryHit(positionLeft, positionTop, elWidth, elHeight) {
  7218. let { rootEl, props } = this;
  7219. if (positionLeft >= 0 && positionLeft < elWidth &&
  7220. positionTop >= 0 && positionTop < elHeight) {
  7221. return {
  7222. dateProfile: props.dateProfile,
  7223. dateSpan: Object.assign({ allDay: !props.forceTimed, range: {
  7224. start: props.startDate,
  7225. end: props.endDate,
  7226. } }, props.extraDateSpan),
  7227. dayEl: rootEl,
  7228. rect: {
  7229. left: 0,
  7230. top: 0,
  7231. right: elWidth,
  7232. bottom: elHeight,
  7233. },
  7234. layer: 1, // important when comparing with hits from other components
  7235. };
  7236. }
  7237. return null;
  7238. }
  7239. }
  7240. class MoreLinkContainer extends BaseComponent {
  7241. constructor() {
  7242. super(...arguments);
  7243. this.state = {
  7244. isPopoverOpen: false,
  7245. popoverId: getUniqueDomId(),
  7246. };
  7247. this.handleLinkEl = (linkEl) => {
  7248. this.linkEl = linkEl;
  7249. if (this.props.elRef) {
  7250. setRef(this.props.elRef, linkEl);
  7251. }
  7252. };
  7253. this.handleClick = (ev) => {
  7254. let { props, context } = this;
  7255. let { moreLinkClick } = context.options;
  7256. let date = computeRange(props).start;
  7257. function buildPublicSeg(seg) {
  7258. let { def, instance, range } = seg.eventRange;
  7259. return {
  7260. event: new EventImpl(context, def, instance),
  7261. start: context.dateEnv.toDate(range.start),
  7262. end: context.dateEnv.toDate(range.end),
  7263. isStart: seg.isStart,
  7264. isEnd: seg.isEnd,
  7265. };
  7266. }
  7267. if (typeof moreLinkClick === 'function') {
  7268. moreLinkClick = moreLinkClick({
  7269. date,
  7270. allDay: Boolean(props.allDayDate),
  7271. allSegs: props.allSegs.map(buildPublicSeg),
  7272. hiddenSegs: props.hiddenSegs.map(buildPublicSeg),
  7273. jsEvent: ev,
  7274. view: context.viewApi,
  7275. });
  7276. }
  7277. if (!moreLinkClick || moreLinkClick === 'popover') {
  7278. this.setState({ isPopoverOpen: true });
  7279. }
  7280. else if (typeof moreLinkClick === 'string') { // a view name
  7281. context.calendarApi.zoomTo(date, moreLinkClick);
  7282. }
  7283. };
  7284. this.handlePopoverClose = () => {
  7285. this.setState({ isPopoverOpen: false });
  7286. };
  7287. }
  7288. render() {
  7289. let { props, state } = this;
  7290. return (y(ViewContextType.Consumer, null, (context) => {
  7291. let { viewApi, options, calendarApi } = context;
  7292. let { moreLinkText } = options;
  7293. let { moreCnt } = props;
  7294. let range = computeRange(props);
  7295. let text = typeof moreLinkText === 'function' // TODO: eventually use formatWithOrdinals
  7296. ? moreLinkText.call(calendarApi, moreCnt)
  7297. : `+${moreCnt} ${moreLinkText}`;
  7298. let hint = formatWithOrdinals(options.moreLinkHint, [moreCnt], text);
  7299. let renderProps = {
  7300. num: moreCnt,
  7301. shortText: `+${moreCnt}`,
  7302. text,
  7303. view: viewApi,
  7304. };
  7305. return (y(_, null,
  7306. Boolean(props.moreCnt) && (y(ContentContainer, { elTag: props.elTag || 'a', elRef: this.handleLinkEl, elClasses: [
  7307. ...(props.elClasses || []),
  7308. 'fc-more-link',
  7309. ], elStyle: props.elStyle, elAttrs: Object.assign(Object.assign(Object.assign({}, props.elAttrs), createAriaClickAttrs(this.handleClick)), { title: hint, 'aria-expanded': state.isPopoverOpen, 'aria-controls': state.isPopoverOpen ? state.popoverId : '' }), renderProps: renderProps, generatorName: "moreLinkContent", customGenerator: options.moreLinkContent, defaultGenerator: props.defaultGenerator || renderMoreLinkInner$1, classNameGenerator: options.moreLinkClassNames, didMount: options.moreLinkDidMount, willUnmount: options.moreLinkWillUnmount }, props.children)),
  7310. state.isPopoverOpen && (y(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 ?
  7311. props.alignmentElRef.current :
  7312. this.linkEl, alignGridTop: props.alignGridTop, forceTimed: props.forceTimed, onClose: this.handlePopoverClose }, props.popoverContent()))));
  7313. }));
  7314. }
  7315. componentDidMount() {
  7316. this.updateParentEl();
  7317. }
  7318. componentDidUpdate() {
  7319. this.updateParentEl();
  7320. }
  7321. updateParentEl() {
  7322. if (this.linkEl) {
  7323. this.parentEl = elementClosest(this.linkEl, '.fc-view-harness');
  7324. }
  7325. }
  7326. }
  7327. function renderMoreLinkInner$1(props) {
  7328. return props.text;
  7329. }
  7330. function computeRange(props) {
  7331. if (props.allDayDate) {
  7332. return {
  7333. start: props.allDayDate,
  7334. end: addDays(props.allDayDate, 1),
  7335. };
  7336. }
  7337. let { hiddenSegs } = props;
  7338. return {
  7339. start: computeEarliestSegStart(hiddenSegs),
  7340. end: computeLatestSegEnd(hiddenSegs),
  7341. };
  7342. }
  7343. function computeEarliestSegStart(segs) {
  7344. return segs.reduce(pickEarliestStart).eventRange.range.start;
  7345. }
  7346. function pickEarliestStart(seg0, seg1) {
  7347. return seg0.eventRange.range.start < seg1.eventRange.range.start ? seg0 : seg1;
  7348. }
  7349. function computeLatestSegEnd(segs) {
  7350. return segs.reduce(pickLatestEnd).eventRange.range.end;
  7351. }
  7352. function pickLatestEnd(seg0, seg1) {
  7353. return seg0.eventRange.range.end > seg1.eventRange.range.end ? seg0 : seg1;
  7354. }
  7355. class Store {
  7356. constructor() {
  7357. this.handlers = [];
  7358. }
  7359. set(value) {
  7360. this.currentValue = value;
  7361. for (let handler of this.handlers) {
  7362. handler(value);
  7363. }
  7364. }
  7365. subscribe(handler) {
  7366. this.handlers.push(handler);
  7367. if (this.currentValue !== undefined) {
  7368. handler(this.currentValue);
  7369. }
  7370. }
  7371. }
  7372. /*
  7373. Subscribers will get a LIST of CustomRenderings
  7374. */
  7375. class CustomRenderingStore extends Store {
  7376. constructor() {
  7377. super(...arguments);
  7378. this.map = new Map();
  7379. }
  7380. // for consistent order
  7381. handle(customRendering) {
  7382. const { map } = this;
  7383. let updated = false;
  7384. if (customRendering.isActive) {
  7385. map.set(customRendering.id, customRendering);
  7386. updated = true;
  7387. }
  7388. else if (map.has(customRendering.id)) {
  7389. map.delete(customRendering.id);
  7390. updated = true;
  7391. }
  7392. if (updated) {
  7393. this.set(map);
  7394. }
  7395. }
  7396. }
  7397. var internal = {
  7398. __proto__: null,
  7399. BASE_OPTION_DEFAULTS: BASE_OPTION_DEFAULTS,
  7400. BaseComponent: BaseComponent,
  7401. BgEvent: BgEvent,
  7402. CalendarImpl: CalendarImpl,
  7403. CalendarRoot: CalendarRoot,
  7404. ContentContainer: ContentContainer,
  7405. CustomRenderingStore: CustomRenderingStore,
  7406. DateComponent: DateComponent,
  7407. DateEnv: DateEnv,
  7408. DateProfileGenerator: DateProfileGenerator,
  7409. DayCellContainer: DayCellContainer,
  7410. DayHeader: DayHeader,
  7411. DaySeriesModel: DaySeriesModel,
  7412. DayTableModel: DayTableModel,
  7413. DelayedRunner: DelayedRunner,
  7414. ElementDragging: ElementDragging,
  7415. ElementScrollController: ElementScrollController,
  7416. Emitter: Emitter,
  7417. EventContainer: EventContainer,
  7418. EventImpl: EventImpl,
  7419. Interaction: Interaction,
  7420. MoreLinkContainer: MoreLinkContainer,
  7421. NamedTimeZoneImpl: NamedTimeZoneImpl,
  7422. NowIndicatorContainer: NowIndicatorContainer,
  7423. NowTimer: NowTimer,
  7424. PositionCache: PositionCache,
  7425. RefMap: RefMap,
  7426. ScrollController: ScrollController,
  7427. ScrollResponder: ScrollResponder,
  7428. Scroller: Scroller,
  7429. SegHierarchy: SegHierarchy,
  7430. SimpleScrollGrid: SimpleScrollGrid,
  7431. Slicer: Slicer,
  7432. Splitter: Splitter,
  7433. StandardEvent: StandardEvent,
  7434. TableDateCell: TableDateCell,
  7435. TableDowCell: TableDowCell,
  7436. Theme: Theme,
  7437. ViewContainer: ViewContainer,
  7438. ViewContextType: ViewContextType,
  7439. WeekNumberContainer: WeekNumberContainer,
  7440. WindowScrollController: WindowScrollController,
  7441. addDays: addDays,
  7442. addDurations: addDurations,
  7443. addMs: addMs,
  7444. addWeeks: addWeeks,
  7445. allowContextMenu: allowContextMenu,
  7446. allowSelection: allowSelection,
  7447. applyMutationToEventStore: applyMutationToEventStore,
  7448. applyStyle: applyStyle,
  7449. asCleanDays: asCleanDays,
  7450. asRoughMinutes: asRoughMinutes,
  7451. asRoughMs: asRoughMs,
  7452. asRoughSeconds: asRoughSeconds,
  7453. binarySearch: binarySearch,
  7454. buildElAttrs: buildElAttrs,
  7455. buildEntryKey: buildEntryKey,
  7456. buildEventApis: buildEventApis,
  7457. buildEventRangeKey: buildEventRangeKey,
  7458. buildIsoString: buildIsoString,
  7459. buildNavLinkAttrs: buildNavLinkAttrs,
  7460. buildSegTimeText: buildSegTimeText,
  7461. collectFromHash: collectFromHash,
  7462. combineEventUis: combineEventUis,
  7463. compareByFieldSpecs: compareByFieldSpecs,
  7464. compareNumbers: compareNumbers,
  7465. compareObjs: compareObjs,
  7466. computeEarliestSegStart: computeEarliestSegStart,
  7467. computeEdges: computeEdges,
  7468. computeFallbackHeaderFormat: computeFallbackHeaderFormat,
  7469. computeInnerRect: computeInnerRect,
  7470. computeRect: computeRect,
  7471. computeShrinkWidth: computeShrinkWidth,
  7472. computeVisibleDayRange: computeVisibleDayRange,
  7473. config: config,
  7474. constrainPoint: constrainPoint,
  7475. createDuration: createDuration,
  7476. createEmptyEventStore: createEmptyEventStore,
  7477. createEventInstance: createEventInstance,
  7478. createEventUi: createEventUi,
  7479. createFormatter: createFormatter,
  7480. diffDates: diffDates,
  7481. diffDayAndTime: diffDayAndTime,
  7482. diffDays: diffDays,
  7483. diffPoints: diffPoints,
  7484. diffWeeks: diffWeeks,
  7485. diffWholeDays: diffWholeDays,
  7486. diffWholeWeeks: diffWholeWeeks,
  7487. disableCursor: disableCursor,
  7488. elementClosest: elementClosest,
  7489. elementMatches: elementMatches,
  7490. enableCursor: enableCursor,
  7491. eventTupleToStore: eventTupleToStore,
  7492. filterHash: filterHash,
  7493. findDirectChildren: findDirectChildren,
  7494. findElements: findElements,
  7495. flexibleCompare: flexibleCompare,
  7496. formatDayString: formatDayString,
  7497. formatIsoMonthStr: formatIsoMonthStr,
  7498. formatIsoTimeString: formatIsoTimeString,
  7499. getAllowYScrolling: getAllowYScrolling,
  7500. getCanVGrowWithinCell: getCanVGrowWithinCell,
  7501. getClippingParents: getClippingParents,
  7502. getDateMeta: getDateMeta,
  7503. getDayClassNames: getDayClassNames,
  7504. getDefaultEventEnd: getDefaultEventEnd,
  7505. getElSeg: getElSeg,
  7506. getEntrySpanEnd: getEntrySpanEnd,
  7507. getEventTargetViaRoot: getEventTargetViaRoot,
  7508. getIsRtlScrollbarOnLeft: getIsRtlScrollbarOnLeft,
  7509. getRectCenter: getRectCenter,
  7510. getRelevantEvents: getRelevantEvents,
  7511. getScrollGridClassNames: getScrollGridClassNames,
  7512. getScrollbarWidths: getScrollbarWidths,
  7513. getSectionClassNames: getSectionClassNames,
  7514. getSectionHasLiquidHeight: getSectionHasLiquidHeight,
  7515. getSegAnchorAttrs: getSegAnchorAttrs,
  7516. getSegMeta: getSegMeta,
  7517. getSlotClassNames: getSlotClassNames,
  7518. getStickyFooterScrollbar: getStickyFooterScrollbar,
  7519. getStickyHeaderDates: getStickyHeaderDates,
  7520. getUniqueDomId: getUniqueDomId,
  7521. greatestDurationDenominator: greatestDurationDenominator,
  7522. groupIntersectingEntries: groupIntersectingEntries,
  7523. guid: guid,
  7524. hasBgRendering: hasBgRendering,
  7525. hasCustomDayCellContent: hasCustomDayCellContent,
  7526. hasShrinkWidth: hasShrinkWidth,
  7527. identity: identity,
  7528. injectStyles: injectStyles,
  7529. interactionSettingsStore: interactionSettingsStore,
  7530. interactionSettingsToStore: interactionSettingsToStore,
  7531. intersectRanges: intersectRanges,
  7532. intersectRects: intersectRects,
  7533. intersectSpans: intersectSpans,
  7534. isArraysEqual: isArraysEqual,
  7535. isColPropsEqual: isColPropsEqual,
  7536. isDateSelectionValid: isDateSelectionValid,
  7537. isDateSpansEqual: isDateSpansEqual,
  7538. isInt: isInt,
  7539. isInteractionValid: isInteractionValid,
  7540. isMultiDayRange: isMultiDayRange,
  7541. isPropsEqual: isPropsEqual,
  7542. isPropsValid: isPropsValid,
  7543. isValidDate: isValidDate,
  7544. mapHash: mapHash,
  7545. memoize: memoize,
  7546. memoizeArraylike: memoizeArraylike,
  7547. memoizeHashlike: memoizeHashlike,
  7548. memoizeObjArg: memoizeObjArg,
  7549. mergeEventStores: mergeEventStores,
  7550. multiplyDuration: multiplyDuration,
  7551. padStart: padStart,
  7552. parseBusinessHours: parseBusinessHours,
  7553. parseClassNames: parseClassNames,
  7554. parseDragMeta: parseDragMeta,
  7555. parseEventDef: parseEventDef,
  7556. parseFieldSpecs: parseFieldSpecs,
  7557. parseMarker: parse,
  7558. pointInsideRect: pointInsideRect,
  7559. preventContextMenu: preventContextMenu,
  7560. preventDefault: preventDefault,
  7561. preventSelection: preventSelection,
  7562. rangeContainsMarker: rangeContainsMarker,
  7563. rangeContainsRange: rangeContainsRange,
  7564. rangesEqual: rangesEqual,
  7565. rangesIntersect: rangesIntersect,
  7566. refineEventDef: refineEventDef,
  7567. refineProps: refineProps,
  7568. removeElement: removeElement,
  7569. removeExact: removeExact,
  7570. renderChunkContent: renderChunkContent,
  7571. renderFill: renderFill,
  7572. renderMicroColGroup: renderMicroColGroup,
  7573. renderScrollShim: renderScrollShim,
  7574. requestJson: requestJson,
  7575. sanitizeShrinkWidth: sanitizeShrinkWidth,
  7576. setRef: setRef,
  7577. sliceEventStore: sliceEventStore,
  7578. sortEventSegs: sortEventSegs,
  7579. startOfDay: startOfDay,
  7580. translateRect: translateRect,
  7581. triggerDateSelect: triggerDateSelect,
  7582. unpromisify: unpromisify,
  7583. whenTransitionDone: whenTransitionDone,
  7584. wholeDivideDurations: wholeDivideDurations
  7585. };
  7586. var preact = {
  7587. __proto__: null,
  7588. createPortal: j,
  7589. createContext: createContext,
  7590. flushSync: flushSync,
  7591. Component: x$1,
  7592. Fragment: _,
  7593. cloneElement: F$1,
  7594. createElement: y,
  7595. createRef: d,
  7596. h: y,
  7597. hydrate: E,
  7598. get isValidElement () { return i$1; },
  7599. get options () { return l$1; },
  7600. render: D$1,
  7601. toChildArray: j$2
  7602. };
  7603. const globalLocales = [];
  7604. const MINIMAL_RAW_EN_LOCALE = {
  7605. code: 'en',
  7606. week: {
  7607. dow: 0,
  7608. doy: 4, // 4 days need to be within the year to be considered the first week
  7609. },
  7610. direction: 'ltr',
  7611. buttonText: {
  7612. prev: 'prev',
  7613. next: 'next',
  7614. prevYear: 'prev year',
  7615. nextYear: 'next year',
  7616. year: 'year',
  7617. today: 'today',
  7618. month: 'month',
  7619. week: 'week',
  7620. day: 'day',
  7621. list: 'list',
  7622. },
  7623. weekText: 'W',
  7624. weekTextLong: 'Week',
  7625. closeHint: 'Close',
  7626. timeHint: 'Time',
  7627. eventHint: 'Event',
  7628. allDayText: 'all-day',
  7629. moreLinkText: 'more',
  7630. noEventsText: 'No events to display',
  7631. };
  7632. const RAW_EN_LOCALE = Object.assign(Object.assign({}, MINIMAL_RAW_EN_LOCALE), {
  7633. // Includes things we don't want other locales to inherit,
  7634. // things that derive from other translatable strings.
  7635. buttonHints: {
  7636. prev: 'Previous $0',
  7637. next: 'Next $0',
  7638. today(buttonText, unit) {
  7639. return (unit === 'day')
  7640. ? 'Today'
  7641. : `This ${buttonText}`;
  7642. },
  7643. }, viewHint: '$0 view', navLinkHint: 'Go to $0', moreLinkHint(eventCnt) {
  7644. return `Show ${eventCnt} more event${eventCnt === 1 ? '' : 's'}`;
  7645. } });
  7646. function organizeRawLocales(explicitRawLocales) {
  7647. let defaultCode = explicitRawLocales.length > 0 ? explicitRawLocales[0].code : 'en';
  7648. let allRawLocales = globalLocales.concat(explicitRawLocales);
  7649. let rawLocaleMap = {
  7650. en: RAW_EN_LOCALE,
  7651. };
  7652. for (let rawLocale of allRawLocales) {
  7653. rawLocaleMap[rawLocale.code] = rawLocale;
  7654. }
  7655. return {
  7656. map: rawLocaleMap,
  7657. defaultCode,
  7658. };
  7659. }
  7660. function buildLocale(inputSingular, available) {
  7661. if (typeof inputSingular === 'object' && !Array.isArray(inputSingular)) {
  7662. return parseLocale(inputSingular.code, [inputSingular.code], inputSingular);
  7663. }
  7664. return queryLocale(inputSingular, available);
  7665. }
  7666. function queryLocale(codeArg, available) {
  7667. let codes = [].concat(codeArg || []); // will convert to array
  7668. let raw = queryRawLocale(codes, available) || RAW_EN_LOCALE;
  7669. return parseLocale(codeArg, codes, raw);
  7670. }
  7671. function queryRawLocale(codes, available) {
  7672. for (let i = 0; i < codes.length; i += 1) {
  7673. let parts = codes[i].toLocaleLowerCase().split('-');
  7674. for (let j = parts.length; j > 0; j -= 1) {
  7675. let simpleId = parts.slice(0, j).join('-');
  7676. if (available[simpleId]) {
  7677. return available[simpleId];
  7678. }
  7679. }
  7680. }
  7681. return null;
  7682. }
  7683. function parseLocale(codeArg, codes, raw) {
  7684. let merged = mergeProps([MINIMAL_RAW_EN_LOCALE, raw], ['buttonText']);
  7685. delete merged.code; // don't want this part of the options
  7686. let { week } = merged;
  7687. delete merged.week;
  7688. return {
  7689. codeArg,
  7690. codes,
  7691. week,
  7692. simpleNumberFormat: new Intl.NumberFormat(codeArg),
  7693. options: merged,
  7694. };
  7695. }
  7696. // TODO: easier way to add new hooks? need to update a million things
  7697. function createPlugin(input) {
  7698. return {
  7699. id: guid(),
  7700. name: input.name,
  7701. premiumReleaseDate: input.premiumReleaseDate ? new Date(input.premiumReleaseDate) : undefined,
  7702. deps: input.deps || [],
  7703. reducers: input.reducers || [],
  7704. isLoadingFuncs: input.isLoadingFuncs || [],
  7705. contextInit: [].concat(input.contextInit || []),
  7706. eventRefiners: input.eventRefiners || {},
  7707. eventDefMemberAdders: input.eventDefMemberAdders || [],
  7708. eventSourceRefiners: input.eventSourceRefiners || {},
  7709. isDraggableTransformers: input.isDraggableTransformers || [],
  7710. eventDragMutationMassagers: input.eventDragMutationMassagers || [],
  7711. eventDefMutationAppliers: input.eventDefMutationAppliers || [],
  7712. dateSelectionTransformers: input.dateSelectionTransformers || [],
  7713. datePointTransforms: input.datePointTransforms || [],
  7714. dateSpanTransforms: input.dateSpanTransforms || [],
  7715. views: input.views || {},
  7716. viewPropsTransformers: input.viewPropsTransformers || [],
  7717. isPropsValid: input.isPropsValid || null,
  7718. externalDefTransforms: input.externalDefTransforms || [],
  7719. viewContainerAppends: input.viewContainerAppends || [],
  7720. eventDropTransformers: input.eventDropTransformers || [],
  7721. componentInteractions: input.componentInteractions || [],
  7722. calendarInteractions: input.calendarInteractions || [],
  7723. themeClasses: input.themeClasses || {},
  7724. eventSourceDefs: input.eventSourceDefs || [],
  7725. cmdFormatter: input.cmdFormatter,
  7726. recurringTypes: input.recurringTypes || [],
  7727. namedTimeZonedImpl: input.namedTimeZonedImpl,
  7728. initialView: input.initialView || '',
  7729. elementDraggingImpl: input.elementDraggingImpl,
  7730. optionChangeHandlers: input.optionChangeHandlers || {},
  7731. scrollGridImpl: input.scrollGridImpl || null,
  7732. listenerRefiners: input.listenerRefiners || {},
  7733. optionRefiners: input.optionRefiners || {},
  7734. propSetHandlers: input.propSetHandlers || {},
  7735. };
  7736. }
  7737. function buildPluginHooks(pluginDefs, globalDefs) {
  7738. let currentPluginIds = {};
  7739. let hooks = {
  7740. premiumReleaseDate: undefined,
  7741. reducers: [],
  7742. isLoadingFuncs: [],
  7743. contextInit: [],
  7744. eventRefiners: {},
  7745. eventDefMemberAdders: [],
  7746. eventSourceRefiners: {},
  7747. isDraggableTransformers: [],
  7748. eventDragMutationMassagers: [],
  7749. eventDefMutationAppliers: [],
  7750. dateSelectionTransformers: [],
  7751. datePointTransforms: [],
  7752. dateSpanTransforms: [],
  7753. views: {},
  7754. viewPropsTransformers: [],
  7755. isPropsValid: null,
  7756. externalDefTransforms: [],
  7757. viewContainerAppends: [],
  7758. eventDropTransformers: [],
  7759. componentInteractions: [],
  7760. calendarInteractions: [],
  7761. themeClasses: {},
  7762. eventSourceDefs: [],
  7763. cmdFormatter: null,
  7764. recurringTypes: [],
  7765. namedTimeZonedImpl: null,
  7766. initialView: '',
  7767. elementDraggingImpl: null,
  7768. optionChangeHandlers: {},
  7769. scrollGridImpl: null,
  7770. listenerRefiners: {},
  7771. optionRefiners: {},
  7772. propSetHandlers: {},
  7773. };
  7774. function addDefs(defs) {
  7775. for (let def of defs) {
  7776. const pluginName = def.name;
  7777. const currentId = currentPluginIds[pluginName];
  7778. if (currentId === undefined) {
  7779. currentPluginIds[pluginName] = def.id;
  7780. addDefs(def.deps);
  7781. hooks = combineHooks(hooks, def);
  7782. }
  7783. else if (currentId !== def.id) {
  7784. // different ID than the one already added
  7785. console.warn(`Duplicate plugin '${pluginName}'`);
  7786. }
  7787. }
  7788. }
  7789. if (pluginDefs) {
  7790. addDefs(pluginDefs);
  7791. }
  7792. addDefs(globalDefs);
  7793. return hooks;
  7794. }
  7795. function buildBuildPluginHooks() {
  7796. let currentOverrideDefs = [];
  7797. let currentGlobalDefs = [];
  7798. let currentHooks;
  7799. return (overrideDefs, globalDefs) => {
  7800. if (!currentHooks || !isArraysEqual(overrideDefs, currentOverrideDefs) || !isArraysEqual(globalDefs, currentGlobalDefs)) {
  7801. currentHooks = buildPluginHooks(overrideDefs, globalDefs);
  7802. }
  7803. currentOverrideDefs = overrideDefs;
  7804. currentGlobalDefs = globalDefs;
  7805. return currentHooks;
  7806. };
  7807. }
  7808. function combineHooks(hooks0, hooks1) {
  7809. return {
  7810. premiumReleaseDate: compareOptionalDates(hooks0.premiumReleaseDate, hooks1.premiumReleaseDate),
  7811. reducers: hooks0.reducers.concat(hooks1.reducers),
  7812. isLoadingFuncs: hooks0.isLoadingFuncs.concat(hooks1.isLoadingFuncs),
  7813. contextInit: hooks0.contextInit.concat(hooks1.contextInit),
  7814. eventRefiners: Object.assign(Object.assign({}, hooks0.eventRefiners), hooks1.eventRefiners),
  7815. eventDefMemberAdders: hooks0.eventDefMemberAdders.concat(hooks1.eventDefMemberAdders),
  7816. eventSourceRefiners: Object.assign(Object.assign({}, hooks0.eventSourceRefiners), hooks1.eventSourceRefiners),
  7817. isDraggableTransformers: hooks0.isDraggableTransformers.concat(hooks1.isDraggableTransformers),
  7818. eventDragMutationMassagers: hooks0.eventDragMutationMassagers.concat(hooks1.eventDragMutationMassagers),
  7819. eventDefMutationAppliers: hooks0.eventDefMutationAppliers.concat(hooks1.eventDefMutationAppliers),
  7820. dateSelectionTransformers: hooks0.dateSelectionTransformers.concat(hooks1.dateSelectionTransformers),
  7821. datePointTransforms: hooks0.datePointTransforms.concat(hooks1.datePointTransforms),
  7822. dateSpanTransforms: hooks0.dateSpanTransforms.concat(hooks1.dateSpanTransforms),
  7823. views: Object.assign(Object.assign({}, hooks0.views), hooks1.views),
  7824. viewPropsTransformers: hooks0.viewPropsTransformers.concat(hooks1.viewPropsTransformers),
  7825. isPropsValid: hooks1.isPropsValid || hooks0.isPropsValid,
  7826. externalDefTransforms: hooks0.externalDefTransforms.concat(hooks1.externalDefTransforms),
  7827. viewContainerAppends: hooks0.viewContainerAppends.concat(hooks1.viewContainerAppends),
  7828. eventDropTransformers: hooks0.eventDropTransformers.concat(hooks1.eventDropTransformers),
  7829. calendarInteractions: hooks0.calendarInteractions.concat(hooks1.calendarInteractions),
  7830. componentInteractions: hooks0.componentInteractions.concat(hooks1.componentInteractions),
  7831. themeClasses: Object.assign(Object.assign({}, hooks0.themeClasses), hooks1.themeClasses),
  7832. eventSourceDefs: hooks0.eventSourceDefs.concat(hooks1.eventSourceDefs),
  7833. cmdFormatter: hooks1.cmdFormatter || hooks0.cmdFormatter,
  7834. recurringTypes: hooks0.recurringTypes.concat(hooks1.recurringTypes),
  7835. namedTimeZonedImpl: hooks1.namedTimeZonedImpl || hooks0.namedTimeZonedImpl,
  7836. initialView: hooks0.initialView || hooks1.initialView,
  7837. elementDraggingImpl: hooks0.elementDraggingImpl || hooks1.elementDraggingImpl,
  7838. optionChangeHandlers: Object.assign(Object.assign({}, hooks0.optionChangeHandlers), hooks1.optionChangeHandlers),
  7839. scrollGridImpl: hooks1.scrollGridImpl || hooks0.scrollGridImpl,
  7840. listenerRefiners: Object.assign(Object.assign({}, hooks0.listenerRefiners), hooks1.listenerRefiners),
  7841. optionRefiners: Object.assign(Object.assign({}, hooks0.optionRefiners), hooks1.optionRefiners),
  7842. propSetHandlers: Object.assign(Object.assign({}, hooks0.propSetHandlers), hooks1.propSetHandlers),
  7843. };
  7844. }
  7845. function compareOptionalDates(date0, date1) {
  7846. if (date0 === undefined) {
  7847. return date1;
  7848. }
  7849. if (date1 === undefined) {
  7850. return date0;
  7851. }
  7852. return new Date(Math.max(date0.valueOf(), date1.valueOf()));
  7853. }
  7854. class StandardTheme extends Theme {
  7855. }
  7856. StandardTheme.prototype.classes = {
  7857. root: 'fc-theme-standard',
  7858. tableCellShaded: 'fc-cell-shaded',
  7859. buttonGroup: 'fc-button-group',
  7860. button: 'fc-button fc-button-primary',
  7861. buttonActive: 'fc-button-active',
  7862. };
  7863. StandardTheme.prototype.baseIconClass = 'fc-icon';
  7864. StandardTheme.prototype.iconClasses = {
  7865. close: 'fc-icon-x',
  7866. prev: 'fc-icon-chevron-left',
  7867. next: 'fc-icon-chevron-right',
  7868. prevYear: 'fc-icon-chevrons-left',
  7869. nextYear: 'fc-icon-chevrons-right',
  7870. };
  7871. StandardTheme.prototype.rtlIconClasses = {
  7872. prev: 'fc-icon-chevron-right',
  7873. next: 'fc-icon-chevron-left',
  7874. prevYear: 'fc-icon-chevrons-right',
  7875. nextYear: 'fc-icon-chevrons-left',
  7876. };
  7877. StandardTheme.prototype.iconOverrideOption = 'buttonIcons'; // TODO: make TS-friendly
  7878. StandardTheme.prototype.iconOverrideCustomButtonOption = 'icon';
  7879. StandardTheme.prototype.iconOverridePrefix = 'fc-icon-';
  7880. function compileViewDefs(defaultConfigs, overrideConfigs) {
  7881. let hash = {};
  7882. let viewType;
  7883. for (viewType in defaultConfigs) {
  7884. ensureViewDef(viewType, hash, defaultConfigs, overrideConfigs);
  7885. }
  7886. for (viewType in overrideConfigs) {
  7887. ensureViewDef(viewType, hash, defaultConfigs, overrideConfigs);
  7888. }
  7889. return hash;
  7890. }
  7891. function ensureViewDef(viewType, hash, defaultConfigs, overrideConfigs) {
  7892. if (hash[viewType]) {
  7893. return hash[viewType];
  7894. }
  7895. let viewDef = buildViewDef(viewType, hash, defaultConfigs, overrideConfigs);
  7896. if (viewDef) {
  7897. hash[viewType] = viewDef;
  7898. }
  7899. return viewDef;
  7900. }
  7901. function buildViewDef(viewType, hash, defaultConfigs, overrideConfigs) {
  7902. let defaultConfig = defaultConfigs[viewType];
  7903. let overrideConfig = overrideConfigs[viewType];
  7904. let queryProp = (name) => ((defaultConfig && defaultConfig[name] !== null) ? defaultConfig[name] :
  7905. ((overrideConfig && overrideConfig[name] !== null) ? overrideConfig[name] : null));
  7906. let theComponent = queryProp('component');
  7907. let superType = queryProp('superType');
  7908. let superDef = null;
  7909. if (superType) {
  7910. if (superType === viewType) {
  7911. throw new Error('Can\'t have a custom view type that references itself');
  7912. }
  7913. superDef = ensureViewDef(superType, hash, defaultConfigs, overrideConfigs);
  7914. }
  7915. if (!theComponent && superDef) {
  7916. theComponent = superDef.component;
  7917. }
  7918. if (!theComponent) {
  7919. return null; // don't throw a warning, might be settings for a single-unit view
  7920. }
  7921. return {
  7922. type: viewType,
  7923. component: theComponent,
  7924. defaults: Object.assign(Object.assign({}, (superDef ? superDef.defaults : {})), (defaultConfig ? defaultConfig.rawOptions : {})),
  7925. overrides: Object.assign(Object.assign({}, (superDef ? superDef.overrides : {})), (overrideConfig ? overrideConfig.rawOptions : {})),
  7926. };
  7927. }
  7928. function parseViewConfigs(inputs) {
  7929. return mapHash(inputs, parseViewConfig);
  7930. }
  7931. function parseViewConfig(input) {
  7932. let rawOptions = typeof input === 'function' ?
  7933. { component: input } :
  7934. input;
  7935. let { component } = rawOptions;
  7936. if (rawOptions.content) {
  7937. // TODO: remove content/classNames/didMount/etc from options?
  7938. component = createViewHookComponent(rawOptions);
  7939. }
  7940. else if (component && !(component.prototype instanceof BaseComponent)) {
  7941. // WHY?: people were using `component` property for `content`
  7942. // TODO: converge on one setting name
  7943. component = createViewHookComponent(Object.assign(Object.assign({}, rawOptions), { content: component }));
  7944. }
  7945. return {
  7946. superType: rawOptions.type,
  7947. component: component,
  7948. rawOptions, // includes type and component too :(
  7949. };
  7950. }
  7951. function createViewHookComponent(options) {
  7952. return (viewProps) => (y(ViewContextType.Consumer, null, (context) => (y(ContentContainer, { elTag: "div", elClasses: buildViewClassNames(context.viewSpec), renderProps: Object.assign(Object.assign({}, viewProps), { nextDayThreshold: context.options.nextDayThreshold }), generatorName: undefined, customGenerator: options.content, classNameGenerator: options.classNames, didMount: options.didMount, willUnmount: options.willUnmount }))));
  7953. }
  7954. function buildViewSpecs(defaultInputs, optionOverrides, dynamicOptionOverrides, localeDefaults) {
  7955. let defaultConfigs = parseViewConfigs(defaultInputs);
  7956. let overrideConfigs = parseViewConfigs(optionOverrides.views);
  7957. let viewDefs = compileViewDefs(defaultConfigs, overrideConfigs);
  7958. return mapHash(viewDefs, (viewDef) => buildViewSpec(viewDef, overrideConfigs, optionOverrides, dynamicOptionOverrides, localeDefaults));
  7959. }
  7960. function buildViewSpec(viewDef, overrideConfigs, optionOverrides, dynamicOptionOverrides, localeDefaults) {
  7961. let durationInput = viewDef.overrides.duration ||
  7962. viewDef.defaults.duration ||
  7963. dynamicOptionOverrides.duration ||
  7964. optionOverrides.duration;
  7965. let duration = null;
  7966. let durationUnit = '';
  7967. let singleUnit = '';
  7968. let singleUnitOverrides = {};
  7969. if (durationInput) {
  7970. duration = createDurationCached(durationInput);
  7971. if (duration) { // valid?
  7972. let denom = greatestDurationDenominator(duration);
  7973. durationUnit = denom.unit;
  7974. if (denom.value === 1) {
  7975. singleUnit = durationUnit;
  7976. singleUnitOverrides = overrideConfigs[durationUnit] ? overrideConfigs[durationUnit].rawOptions : {};
  7977. }
  7978. }
  7979. }
  7980. let queryButtonText = (optionsSubset) => {
  7981. let buttonTextMap = optionsSubset.buttonText || {};
  7982. let buttonTextKey = viewDef.defaults.buttonTextKey;
  7983. if (buttonTextKey != null && buttonTextMap[buttonTextKey] != null) {
  7984. return buttonTextMap[buttonTextKey];
  7985. }
  7986. if (buttonTextMap[viewDef.type] != null) {
  7987. return buttonTextMap[viewDef.type];
  7988. }
  7989. if (buttonTextMap[singleUnit] != null) {
  7990. return buttonTextMap[singleUnit];
  7991. }
  7992. return null;
  7993. };
  7994. let queryButtonTitle = (optionsSubset) => {
  7995. let buttonHints = optionsSubset.buttonHints || {};
  7996. let buttonKey = viewDef.defaults.buttonTextKey; // use same key as text
  7997. if (buttonKey != null && buttonHints[buttonKey] != null) {
  7998. return buttonHints[buttonKey];
  7999. }
  8000. if (buttonHints[viewDef.type] != null) {
  8001. return buttonHints[viewDef.type];
  8002. }
  8003. if (buttonHints[singleUnit] != null) {
  8004. return buttonHints[singleUnit];
  8005. }
  8006. return null;
  8007. };
  8008. return {
  8009. type: viewDef.type,
  8010. component: viewDef.component,
  8011. duration,
  8012. durationUnit,
  8013. singleUnit,
  8014. optionDefaults: viewDef.defaults,
  8015. optionOverrides: Object.assign(Object.assign({}, singleUnitOverrides), viewDef.overrides),
  8016. buttonTextOverride: queryButtonText(dynamicOptionOverrides) ||
  8017. queryButtonText(optionOverrides) || // constructor-specified buttonText lookup hash takes precedence
  8018. viewDef.overrides.buttonText,
  8019. buttonTextDefault: queryButtonText(localeDefaults) ||
  8020. viewDef.defaults.buttonText ||
  8021. queryButtonText(BASE_OPTION_DEFAULTS) ||
  8022. viewDef.type,
  8023. // not DRY
  8024. buttonTitleOverride: queryButtonTitle(dynamicOptionOverrides) ||
  8025. queryButtonTitle(optionOverrides) ||
  8026. viewDef.overrides.buttonHint,
  8027. buttonTitleDefault: queryButtonTitle(localeDefaults) ||
  8028. viewDef.defaults.buttonHint ||
  8029. queryButtonTitle(BASE_OPTION_DEFAULTS),
  8030. // will eventually fall back to buttonText
  8031. };
  8032. }
  8033. // hack to get memoization working
  8034. let durationInputMap = {};
  8035. function createDurationCached(durationInput) {
  8036. let json = JSON.stringify(durationInput);
  8037. let res = durationInputMap[json];
  8038. if (res === undefined) {
  8039. res = createDuration(durationInput);
  8040. durationInputMap[json] = res;
  8041. }
  8042. return res;
  8043. }
  8044. function reduceViewType(viewType, action) {
  8045. switch (action.type) {
  8046. case 'CHANGE_VIEW_TYPE':
  8047. viewType = action.viewType;
  8048. }
  8049. return viewType;
  8050. }
  8051. function reduceCurrentDate(currentDate, action) {
  8052. switch (action.type) {
  8053. case 'CHANGE_DATE':
  8054. return action.dateMarker;
  8055. default:
  8056. return currentDate;
  8057. }
  8058. }
  8059. // should be initialized once and stay constant
  8060. // this will change too
  8061. function getInitialDate(options, dateEnv, nowManager) {
  8062. let initialDateInput = options.initialDate;
  8063. // compute the initial ambig-timezone date
  8064. if (initialDateInput != null) {
  8065. return dateEnv.createMarker(initialDateInput);
  8066. }
  8067. return nowManager.getDateMarker();
  8068. }
  8069. function reduceDynamicOptionOverrides(dynamicOptionOverrides, action) {
  8070. switch (action.type) {
  8071. case 'SET_OPTION':
  8072. return Object.assign(Object.assign({}, dynamicOptionOverrides), { [action.optionName]: action.rawOptionValue });
  8073. default:
  8074. return dynamicOptionOverrides;
  8075. }
  8076. }
  8077. function reduceDateProfile(currentDateProfile, action, currentDate, dateProfileGenerator) {
  8078. let dp;
  8079. switch (action.type) {
  8080. case 'CHANGE_VIEW_TYPE':
  8081. return dateProfileGenerator.build(action.dateMarker || currentDate);
  8082. case 'CHANGE_DATE':
  8083. return dateProfileGenerator.build(action.dateMarker);
  8084. case 'PREV':
  8085. dp = dateProfileGenerator.buildPrev(currentDateProfile, currentDate);
  8086. if (dp.isValid) {
  8087. return dp;
  8088. }
  8089. break;
  8090. case 'NEXT':
  8091. dp = dateProfileGenerator.buildNext(currentDateProfile, currentDate);
  8092. if (dp.isValid) {
  8093. return dp;
  8094. }
  8095. break;
  8096. }
  8097. return currentDateProfile;
  8098. }
  8099. function initEventSources(calendarOptions, dateProfile, context) {
  8100. let activeRange = dateProfile ? dateProfile.activeRange : null;
  8101. return addSources({}, parseInitialSources(calendarOptions, context), activeRange, context);
  8102. }
  8103. function reduceEventSources(eventSources, action, dateProfile, context) {
  8104. let activeRange = dateProfile ? dateProfile.activeRange : null; // need this check?
  8105. switch (action.type) {
  8106. case 'ADD_EVENT_SOURCES': // already parsed
  8107. return addSources(eventSources, action.sources, activeRange, context);
  8108. case 'REMOVE_EVENT_SOURCE':
  8109. return removeSource(eventSources, action.sourceId);
  8110. case 'PREV': // TODO: how do we track all actions that affect dateProfile :(
  8111. case 'NEXT':
  8112. case 'CHANGE_DATE':
  8113. case 'CHANGE_VIEW_TYPE':
  8114. if (dateProfile) {
  8115. return fetchDirtySources(eventSources, activeRange, context);
  8116. }
  8117. return eventSources;
  8118. case 'FETCH_EVENT_SOURCES':
  8119. return fetchSourcesByIds(eventSources, action.sourceIds ? // why no type?
  8120. arrayToHash(action.sourceIds) :
  8121. excludeStaticSources(eventSources, context), activeRange, action.isRefetch || false, context);
  8122. case 'RECEIVE_EVENTS':
  8123. case 'RECEIVE_EVENT_ERROR':
  8124. return receiveResponse(eventSources, action.sourceId, action.fetchId, action.fetchRange);
  8125. case 'REMOVE_ALL_EVENT_SOURCES':
  8126. return {};
  8127. default:
  8128. return eventSources;
  8129. }
  8130. }
  8131. function reduceEventSourcesNewTimeZone(eventSources, dateProfile, context) {
  8132. let activeRange = dateProfile ? dateProfile.activeRange : null; // need this check?
  8133. return fetchSourcesByIds(eventSources, excludeStaticSources(eventSources, context), activeRange, true, context);
  8134. }
  8135. function computeEventSourcesLoading(eventSources) {
  8136. for (let sourceId in eventSources) {
  8137. if (eventSources[sourceId].isFetching) {
  8138. return true;
  8139. }
  8140. }
  8141. return false;
  8142. }
  8143. function addSources(eventSourceHash, sources, fetchRange, context) {
  8144. let hash = {};
  8145. for (let source of sources) {
  8146. hash[source.sourceId] = source;
  8147. }
  8148. if (fetchRange) {
  8149. hash = fetchDirtySources(hash, fetchRange, context);
  8150. }
  8151. return Object.assign(Object.assign({}, eventSourceHash), hash);
  8152. }
  8153. function removeSource(eventSourceHash, sourceId) {
  8154. return filterHash(eventSourceHash, (eventSource) => eventSource.sourceId !== sourceId);
  8155. }
  8156. function fetchDirtySources(sourceHash, fetchRange, context) {
  8157. return fetchSourcesByIds(sourceHash, filterHash(sourceHash, (eventSource) => isSourceDirty(eventSource, fetchRange, context)), fetchRange, false, context);
  8158. }
  8159. function isSourceDirty(eventSource, fetchRange, context) {
  8160. if (!doesSourceNeedRange(eventSource, context)) {
  8161. return !eventSource.latestFetchId;
  8162. }
  8163. return !context.options.lazyFetching ||
  8164. !eventSource.fetchRange ||
  8165. eventSource.isFetching || // always cancel outdated in-progress fetches
  8166. fetchRange.start < eventSource.fetchRange.start ||
  8167. fetchRange.end > eventSource.fetchRange.end;
  8168. }
  8169. function fetchSourcesByIds(prevSources, sourceIdHash, fetchRange, isRefetch, context) {
  8170. let nextSources = {};
  8171. for (let sourceId in prevSources) {
  8172. let source = prevSources[sourceId];
  8173. if (sourceIdHash[sourceId]) {
  8174. nextSources[sourceId] = fetchSource(source, fetchRange, isRefetch, context);
  8175. }
  8176. else {
  8177. nextSources[sourceId] = source;
  8178. }
  8179. }
  8180. return nextSources;
  8181. }
  8182. function fetchSource(eventSource, fetchRange, isRefetch, context) {
  8183. let { options, calendarApi } = context;
  8184. let sourceDef = context.pluginHooks.eventSourceDefs[eventSource.sourceDefId];
  8185. let fetchId = guid();
  8186. sourceDef.fetch({
  8187. eventSource,
  8188. range: fetchRange,
  8189. isRefetch,
  8190. context,
  8191. }, (res) => {
  8192. let { rawEvents } = res;
  8193. if (options.eventSourceSuccess) {
  8194. rawEvents = options.eventSourceSuccess.call(calendarApi, rawEvents, res.response) || rawEvents;
  8195. }
  8196. if (eventSource.success) {
  8197. rawEvents = eventSource.success.call(calendarApi, rawEvents, res.response) || rawEvents;
  8198. }
  8199. context.dispatch({
  8200. type: 'RECEIVE_EVENTS',
  8201. sourceId: eventSource.sourceId,
  8202. fetchId,
  8203. fetchRange,
  8204. rawEvents,
  8205. });
  8206. }, (error) => {
  8207. let errorHandled = false;
  8208. if (options.eventSourceFailure) {
  8209. options.eventSourceFailure.call(calendarApi, error);
  8210. errorHandled = true;
  8211. }
  8212. if (eventSource.failure) {
  8213. eventSource.failure(error);
  8214. errorHandled = true;
  8215. }
  8216. if (!errorHandled) {
  8217. console.warn(error.message, error);
  8218. }
  8219. context.dispatch({
  8220. type: 'RECEIVE_EVENT_ERROR',
  8221. sourceId: eventSource.sourceId,
  8222. fetchId,
  8223. fetchRange,
  8224. error,
  8225. });
  8226. });
  8227. return Object.assign(Object.assign({}, eventSource), { isFetching: true, latestFetchId: fetchId });
  8228. }
  8229. function receiveResponse(sourceHash, sourceId, fetchId, fetchRange) {
  8230. let eventSource = sourceHash[sourceId];
  8231. if (eventSource && // not already removed
  8232. fetchId === eventSource.latestFetchId) {
  8233. return Object.assign(Object.assign({}, sourceHash), { [sourceId]: Object.assign(Object.assign({}, eventSource), { isFetching: false, fetchRange }) });
  8234. }
  8235. return sourceHash;
  8236. }
  8237. function excludeStaticSources(eventSources, context) {
  8238. return filterHash(eventSources, (eventSource) => doesSourceNeedRange(eventSource, context));
  8239. }
  8240. function parseInitialSources(rawOptions, context) {
  8241. let refiners = buildEventSourceRefiners(context);
  8242. let rawSources = [].concat(rawOptions.eventSources || []);
  8243. let sources = []; // parsed
  8244. if (rawOptions.initialEvents) {
  8245. rawSources.unshift(rawOptions.initialEvents);
  8246. }
  8247. if (rawOptions.events) {
  8248. rawSources.unshift(rawOptions.events);
  8249. }
  8250. for (let rawSource of rawSources) {
  8251. let source = parseEventSource(rawSource, context, refiners);
  8252. if (source) {
  8253. sources.push(source);
  8254. }
  8255. }
  8256. return sources;
  8257. }
  8258. function doesSourceNeedRange(eventSource, context) {
  8259. let defs = context.pluginHooks.eventSourceDefs;
  8260. return !defs[eventSource.sourceDefId].ignoreRange;
  8261. }
  8262. function reduceDateSelection(currentSelection, action) {
  8263. switch (action.type) {
  8264. case 'UNSELECT_DATES':
  8265. return null;
  8266. case 'SELECT_DATES':
  8267. return action.selection;
  8268. default:
  8269. return currentSelection;
  8270. }
  8271. }
  8272. function reduceSelectedEvent(currentInstanceId, action) {
  8273. switch (action.type) {
  8274. case 'UNSELECT_EVENT':
  8275. return '';
  8276. case 'SELECT_EVENT':
  8277. return action.eventInstanceId;
  8278. default:
  8279. return currentInstanceId;
  8280. }
  8281. }
  8282. function reduceEventDrag(currentDrag, action) {
  8283. let newDrag;
  8284. switch (action.type) {
  8285. case 'UNSET_EVENT_DRAG':
  8286. return null;
  8287. case 'SET_EVENT_DRAG':
  8288. newDrag = action.state;
  8289. return {
  8290. affectedEvents: newDrag.affectedEvents,
  8291. mutatedEvents: newDrag.mutatedEvents,
  8292. isEvent: newDrag.isEvent,
  8293. };
  8294. default:
  8295. return currentDrag;
  8296. }
  8297. }
  8298. function reduceEventResize(currentResize, action) {
  8299. let newResize;
  8300. switch (action.type) {
  8301. case 'UNSET_EVENT_RESIZE':
  8302. return null;
  8303. case 'SET_EVENT_RESIZE':
  8304. newResize = action.state;
  8305. return {
  8306. affectedEvents: newResize.affectedEvents,
  8307. mutatedEvents: newResize.mutatedEvents,
  8308. isEvent: newResize.isEvent,
  8309. };
  8310. default:
  8311. return currentResize;
  8312. }
  8313. }
  8314. function parseToolbars(calendarOptions, calendarOptionOverrides, theme, viewSpecs, calendarApi) {
  8315. let header = calendarOptions.headerToolbar ? parseToolbar(calendarOptions.headerToolbar, calendarOptions, calendarOptionOverrides, theme, viewSpecs, calendarApi) : null;
  8316. let footer = calendarOptions.footerToolbar ? parseToolbar(calendarOptions.footerToolbar, calendarOptions, calendarOptionOverrides, theme, viewSpecs, calendarApi) : null;
  8317. return { header, footer };
  8318. }
  8319. function parseToolbar(sectionStrHash, calendarOptions, calendarOptionOverrides, theme, viewSpecs, calendarApi) {
  8320. let sectionWidgets = {};
  8321. let viewsWithButtons = [];
  8322. let hasTitle = false;
  8323. for (let sectionName in sectionStrHash) {
  8324. let sectionStr = sectionStrHash[sectionName];
  8325. let sectionRes = parseSection(sectionStr, calendarOptions, calendarOptionOverrides, theme, viewSpecs, calendarApi);
  8326. sectionWidgets[sectionName] = sectionRes.widgets;
  8327. viewsWithButtons.push(...sectionRes.viewsWithButtons);
  8328. hasTitle = hasTitle || sectionRes.hasTitle;
  8329. }
  8330. return { sectionWidgets, viewsWithButtons, hasTitle };
  8331. }
  8332. /*
  8333. BAD: querying icons and text here. should be done at render time
  8334. */
  8335. function parseSection(sectionStr, calendarOptions, // defaults+overrides, then refined
  8336. calendarOptionOverrides, // overrides only!, unrefined :(
  8337. theme, viewSpecs, calendarApi) {
  8338. let isRtl = calendarOptions.direction === 'rtl';
  8339. let calendarCustomButtons = calendarOptions.customButtons || {};
  8340. let calendarButtonTextOverrides = calendarOptionOverrides.buttonText || {};
  8341. let calendarButtonText = calendarOptions.buttonText || {};
  8342. let calendarButtonHintOverrides = calendarOptionOverrides.buttonHints || {};
  8343. let calendarButtonHints = calendarOptions.buttonHints || {};
  8344. let sectionSubstrs = sectionStr ? sectionStr.split(' ') : [];
  8345. let viewsWithButtons = [];
  8346. let hasTitle = false;
  8347. let widgets = sectionSubstrs.map((buttonGroupStr) => (buttonGroupStr.split(',').map((buttonName) => {
  8348. if (buttonName === 'title') {
  8349. hasTitle = true;
  8350. return { buttonName };
  8351. }
  8352. let customButtonProps;
  8353. let viewSpec;
  8354. let buttonClick;
  8355. let buttonIcon; // only one of these will be set
  8356. let buttonText; // "
  8357. let buttonHint;
  8358. // ^ for the title="" attribute, for accessibility
  8359. if ((customButtonProps = calendarCustomButtons[buttonName])) {
  8360. buttonClick = (ev) => {
  8361. if (customButtonProps.click) {
  8362. customButtonProps.click.call(ev.target, ev, ev.target); // TODO: use Calendar this context?
  8363. }
  8364. };
  8365. (buttonIcon = theme.getCustomButtonIconClass(customButtonProps)) ||
  8366. (buttonIcon = theme.getIconClass(buttonName, isRtl)) ||
  8367. (buttonText = customButtonProps.text);
  8368. buttonHint = customButtonProps.hint || customButtonProps.text;
  8369. }
  8370. else if ((viewSpec = viewSpecs[buttonName])) {
  8371. viewsWithButtons.push(buttonName);
  8372. buttonClick = () => {
  8373. calendarApi.changeView(buttonName);
  8374. };
  8375. (buttonText = viewSpec.buttonTextOverride) ||
  8376. (buttonIcon = theme.getIconClass(buttonName, isRtl)) ||
  8377. (buttonText = viewSpec.buttonTextDefault);
  8378. let textFallback = viewSpec.buttonTextOverride ||
  8379. viewSpec.buttonTextDefault;
  8380. buttonHint = formatWithOrdinals(viewSpec.buttonTitleOverride ||
  8381. viewSpec.buttonTitleDefault ||
  8382. calendarOptions.viewHint, [textFallback, buttonName], // view-name = buttonName
  8383. textFallback);
  8384. }
  8385. else if (calendarApi[buttonName]) { // a calendarApi method
  8386. buttonClick = () => {
  8387. calendarApi[buttonName]();
  8388. };
  8389. (buttonText = calendarButtonTextOverrides[buttonName]) ||
  8390. (buttonIcon = theme.getIconClass(buttonName, isRtl)) ||
  8391. (buttonText = calendarButtonText[buttonName]); // everything else is considered default
  8392. if (buttonName === 'prevYear' || buttonName === 'nextYear') {
  8393. let prevOrNext = buttonName === 'prevYear' ? 'prev' : 'next';
  8394. buttonHint = formatWithOrdinals(calendarButtonHintOverrides[prevOrNext] ||
  8395. calendarButtonHints[prevOrNext], [
  8396. calendarButtonText.year || 'year',
  8397. 'year',
  8398. ], calendarButtonText[buttonName]);
  8399. }
  8400. else {
  8401. buttonHint = (navUnit) => formatWithOrdinals(calendarButtonHintOverrides[buttonName] ||
  8402. calendarButtonHints[buttonName], [
  8403. calendarButtonText[navUnit] || navUnit,
  8404. navUnit,
  8405. ], calendarButtonText[buttonName]);
  8406. }
  8407. }
  8408. return { buttonName, buttonClick, buttonIcon, buttonText, buttonHint };
  8409. })));
  8410. return { widgets, viewsWithButtons, hasTitle };
  8411. }
  8412. // always represents the current view. otherwise, it'd need to change value every time date changes
  8413. class ViewImpl {
  8414. constructor(type, getCurrentData, dateEnv) {
  8415. this.type = type;
  8416. this.getCurrentData = getCurrentData;
  8417. this.dateEnv = dateEnv;
  8418. }
  8419. get calendar() {
  8420. return this.getCurrentData().calendarApi;
  8421. }
  8422. get title() {
  8423. return this.getCurrentData().viewTitle;
  8424. }
  8425. get activeStart() {
  8426. return this.dateEnv.toDate(this.getCurrentData().dateProfile.activeRange.start);
  8427. }
  8428. get activeEnd() {
  8429. return this.dateEnv.toDate(this.getCurrentData().dateProfile.activeRange.end);
  8430. }
  8431. get currentStart() {
  8432. return this.dateEnv.toDate(this.getCurrentData().dateProfile.currentRange.start);
  8433. }
  8434. get currentEnd() {
  8435. return this.dateEnv.toDate(this.getCurrentData().dateProfile.currentRange.end);
  8436. }
  8437. getOption(name) {
  8438. return this.getCurrentData().options[name]; // are the view-specific options
  8439. }
  8440. }
  8441. let eventSourceDef$2 = {
  8442. ignoreRange: true,
  8443. parseMeta(refined) {
  8444. if (Array.isArray(refined.events)) {
  8445. return refined.events;
  8446. }
  8447. return null;
  8448. },
  8449. fetch(arg, successCallback) {
  8450. successCallback({
  8451. rawEvents: arg.eventSource.meta,
  8452. });
  8453. },
  8454. };
  8455. const arrayEventSourcePlugin = createPlugin({
  8456. name: 'array-event-source',
  8457. eventSourceDefs: [eventSourceDef$2],
  8458. });
  8459. let eventSourceDef$1 = {
  8460. parseMeta(refined) {
  8461. if (typeof refined.events === 'function') {
  8462. return refined.events;
  8463. }
  8464. return null;
  8465. },
  8466. fetch(arg, successCallback, errorCallback) {
  8467. const { dateEnv } = arg.context;
  8468. const func = arg.eventSource.meta;
  8469. unpromisify(func.bind(null, buildRangeApiWithTimeZone(arg.range, dateEnv)), (rawEvents) => successCallback({ rawEvents }), errorCallback);
  8470. },
  8471. };
  8472. const funcEventSourcePlugin = createPlugin({
  8473. name: 'func-event-source',
  8474. eventSourceDefs: [eventSourceDef$1],
  8475. });
  8476. const JSON_FEED_EVENT_SOURCE_REFINERS = {
  8477. method: String,
  8478. extraParams: identity,
  8479. startParam: String,
  8480. endParam: String,
  8481. timeZoneParam: String,
  8482. };
  8483. let eventSourceDef = {
  8484. parseMeta(refined) {
  8485. if (refined.url && (refined.format === 'json' || !refined.format)) {
  8486. return {
  8487. url: refined.url,
  8488. format: 'json',
  8489. method: (refined.method || 'GET').toUpperCase(),
  8490. extraParams: refined.extraParams,
  8491. startParam: refined.startParam,
  8492. endParam: refined.endParam,
  8493. timeZoneParam: refined.timeZoneParam,
  8494. };
  8495. }
  8496. return null;
  8497. },
  8498. fetch(arg, successCallback, errorCallback) {
  8499. const { meta } = arg.eventSource;
  8500. const requestParams = buildRequestParams(meta, arg.range, arg.context);
  8501. requestJson(meta.method, meta.url, requestParams).then(([rawEvents, response]) => {
  8502. successCallback({ rawEvents, response });
  8503. }, errorCallback);
  8504. },
  8505. };
  8506. const jsonFeedEventSourcePlugin = createPlugin({
  8507. name: 'json-event-source',
  8508. eventSourceRefiners: JSON_FEED_EVENT_SOURCE_REFINERS,
  8509. eventSourceDefs: [eventSourceDef],
  8510. });
  8511. function buildRequestParams(meta, range, context) {
  8512. let { dateEnv, options } = context;
  8513. let startParam;
  8514. let endParam;
  8515. let timeZoneParam;
  8516. let customRequestParams;
  8517. let params = {};
  8518. startParam = meta.startParam;
  8519. if (startParam == null) {
  8520. startParam = options.startParam;
  8521. }
  8522. endParam = meta.endParam;
  8523. if (endParam == null) {
  8524. endParam = options.endParam;
  8525. }
  8526. timeZoneParam = meta.timeZoneParam;
  8527. if (timeZoneParam == null) {
  8528. timeZoneParam = options.timeZoneParam;
  8529. }
  8530. // retrieve any outbound GET/POST data from the options
  8531. if (typeof meta.extraParams === 'function') {
  8532. // supplied as a function that returns a key/value object
  8533. customRequestParams = meta.extraParams();
  8534. }
  8535. else {
  8536. // probably supplied as a straight key/value object
  8537. customRequestParams = meta.extraParams || {};
  8538. }
  8539. Object.assign(params, customRequestParams);
  8540. params[startParam] = dateEnv.formatIso(range.start);
  8541. params[endParam] = dateEnv.formatIso(range.end);
  8542. if (dateEnv.timeZone !== 'local') {
  8543. params[timeZoneParam] = dateEnv.timeZone;
  8544. }
  8545. return params;
  8546. }
  8547. const SIMPLE_RECURRING_REFINERS = {
  8548. daysOfWeek: identity,
  8549. startTime: createDuration,
  8550. endTime: createDuration,
  8551. duration: createDuration,
  8552. startRecur: identity,
  8553. endRecur: identity,
  8554. };
  8555. let recurring = {
  8556. parse(refined, dateEnv) {
  8557. if (refined.daysOfWeek || refined.startTime || refined.endTime || refined.startRecur || refined.endRecur) {
  8558. let recurringData = {
  8559. daysOfWeek: refined.daysOfWeek || null,
  8560. startTime: refined.startTime || null,
  8561. endTime: refined.endTime || null,
  8562. startRecur: refined.startRecur ? dateEnv.createMarker(refined.startRecur) : null,
  8563. endRecur: refined.endRecur ? dateEnv.createMarker(refined.endRecur) : null,
  8564. dateEnv,
  8565. };
  8566. let duration;
  8567. if (refined.duration) {
  8568. duration = refined.duration;
  8569. }
  8570. if (!duration && refined.startTime && refined.endTime) {
  8571. duration = subtractDurations(refined.endTime, refined.startTime);
  8572. }
  8573. return {
  8574. allDayGuess: Boolean(!refined.startTime && !refined.endTime),
  8575. duration,
  8576. typeData: recurringData, // doesn't need endTime anymore but oh well
  8577. };
  8578. }
  8579. return null;
  8580. },
  8581. expand(typeData, framingRange, dateEnv) {
  8582. let clippedFramingRange = intersectRanges(framingRange, { start: typeData.startRecur, end: typeData.endRecur });
  8583. if (clippedFramingRange) {
  8584. return expandRanges(typeData.daysOfWeek, typeData.startTime, typeData.dateEnv, dateEnv, clippedFramingRange);
  8585. }
  8586. return [];
  8587. },
  8588. };
  8589. const simpleRecurringEventsPlugin = createPlugin({
  8590. name: 'simple-recurring-event',
  8591. recurringTypes: [recurring],
  8592. eventRefiners: SIMPLE_RECURRING_REFINERS,
  8593. });
  8594. function expandRanges(daysOfWeek, startTime, eventDateEnv, calendarDateEnv, framingRange) {
  8595. let dowHash = daysOfWeek ? arrayToHash(daysOfWeek) : null;
  8596. let dayMarker = startOfDay(framingRange.start);
  8597. let endMarker = framingRange.end;
  8598. let instanceStarts = [];
  8599. while (dayMarker < endMarker) {
  8600. let instanceStart;
  8601. // if everyday, or this particular day-of-week
  8602. if (!dowHash || dowHash[dayMarker.getUTCDay()]) {
  8603. if (startTime) {
  8604. instanceStart = calendarDateEnv.add(dayMarker, startTime);
  8605. }
  8606. else {
  8607. instanceStart = dayMarker;
  8608. }
  8609. instanceStarts.push(calendarDateEnv.createMarker(eventDateEnv.toDate(instanceStart)));
  8610. }
  8611. dayMarker = addDays(dayMarker, 1);
  8612. }
  8613. return instanceStarts;
  8614. }
  8615. const changeHandlerPlugin = createPlugin({
  8616. name: 'change-handler',
  8617. optionChangeHandlers: {
  8618. events(events, context) {
  8619. handleEventSources([events], context);
  8620. },
  8621. eventSources: handleEventSources,
  8622. },
  8623. });
  8624. /*
  8625. BUG: if `event` was supplied, all previously-given `eventSources` will be wiped out
  8626. */
  8627. function handleEventSources(inputs, context) {
  8628. let unfoundSources = hashValuesToArray(context.getCurrentData().eventSources);
  8629. if (unfoundSources.length === 1 &&
  8630. inputs.length === 1 &&
  8631. Array.isArray(unfoundSources[0]._raw) &&
  8632. Array.isArray(inputs[0])) {
  8633. context.dispatch({
  8634. type: 'RESET_RAW_EVENTS',
  8635. sourceId: unfoundSources[0].sourceId,
  8636. rawEvents: inputs[0],
  8637. });
  8638. return;
  8639. }
  8640. let newInputs = [];
  8641. for (let input of inputs) {
  8642. let inputFound = false;
  8643. for (let i = 0; i < unfoundSources.length; i += 1) {
  8644. if (unfoundSources[i]._raw === input) {
  8645. unfoundSources.splice(i, 1); // delete
  8646. inputFound = true;
  8647. break;
  8648. }
  8649. }
  8650. if (!inputFound) {
  8651. newInputs.push(input);
  8652. }
  8653. }
  8654. for (let unfoundSource of unfoundSources) {
  8655. context.dispatch({
  8656. type: 'REMOVE_EVENT_SOURCE',
  8657. sourceId: unfoundSource.sourceId,
  8658. });
  8659. }
  8660. for (let newInput of newInputs) {
  8661. context.calendarApi.addEventSource(newInput);
  8662. }
  8663. }
  8664. function handleDateProfile(dateProfile, context) {
  8665. context.emitter.trigger('datesSet', Object.assign(Object.assign({}, buildRangeApiWithTimeZone(dateProfile.activeRange, context.dateEnv)), { view: context.viewApi }));
  8666. }
  8667. function handleEventStore(eventStore, context) {
  8668. let { emitter } = context;
  8669. if (emitter.hasHandlers('eventsSet')) {
  8670. emitter.trigger('eventsSet', buildEventApis(eventStore, context));
  8671. }
  8672. }
  8673. /*
  8674. this array is exposed on the root namespace so that UMD plugins can add to it.
  8675. see the rollup-bundles script.
  8676. */
  8677. const globalPlugins = [
  8678. arrayEventSourcePlugin,
  8679. funcEventSourcePlugin,
  8680. jsonFeedEventSourcePlugin,
  8681. simpleRecurringEventsPlugin,
  8682. changeHandlerPlugin,
  8683. createPlugin({
  8684. name: 'misc',
  8685. isLoadingFuncs: [
  8686. (state) => computeEventSourcesLoading(state.eventSources),
  8687. ],
  8688. propSetHandlers: {
  8689. dateProfile: handleDateProfile,
  8690. eventStore: handleEventStore,
  8691. },
  8692. }),
  8693. ];
  8694. class TaskRunner {
  8695. constructor(runTaskOption, drainedOption) {
  8696. this.runTaskOption = runTaskOption;
  8697. this.drainedOption = drainedOption;
  8698. this.queue = [];
  8699. this.delayedRunner = new DelayedRunner(this.drain.bind(this));
  8700. }
  8701. request(task, delay) {
  8702. this.queue.push(task);
  8703. this.delayedRunner.request(delay);
  8704. }
  8705. pause(scope) {
  8706. this.delayedRunner.pause(scope);
  8707. }
  8708. resume(scope, force) {
  8709. this.delayedRunner.resume(scope, force);
  8710. }
  8711. drain() {
  8712. let { queue } = this;
  8713. while (queue.length) {
  8714. let completedTasks = [];
  8715. let task;
  8716. while ((task = queue.shift())) {
  8717. this.runTask(task);
  8718. completedTasks.push(task);
  8719. }
  8720. this.drained(completedTasks);
  8721. } // keep going, in case new tasks were added in the drained handler
  8722. }
  8723. runTask(task) {
  8724. if (this.runTaskOption) {
  8725. this.runTaskOption(task);
  8726. }
  8727. }
  8728. drained(completedTasks) {
  8729. if (this.drainedOption) {
  8730. this.drainedOption(completedTasks);
  8731. }
  8732. }
  8733. }
  8734. // Computes what the title at the top of the calendarApi should be for this view
  8735. function buildTitle(dateProfile, viewOptions, dateEnv) {
  8736. let range;
  8737. // for views that span a large unit of time, show the proper interval, ignoring stray days before and after
  8738. if (/^(year|month)$/.test(dateProfile.currentRangeUnit)) {
  8739. range = dateProfile.currentRange;
  8740. }
  8741. else { // for day units or smaller, use the actual day range
  8742. range = dateProfile.activeRange;
  8743. }
  8744. return dateEnv.formatRange(range.start, range.end, createFormatter(viewOptions.titleFormat || buildTitleFormat(dateProfile)), {
  8745. isEndExclusive: dateProfile.isRangeAllDay,
  8746. defaultSeparator: viewOptions.titleRangeSeparator,
  8747. });
  8748. }
  8749. // Generates the format string that should be used to generate the title for the current date range.
  8750. // Attempts to compute the most appropriate format if not explicitly specified with `titleFormat`.
  8751. function buildTitleFormat(dateProfile) {
  8752. let { currentRangeUnit } = dateProfile;
  8753. if (currentRangeUnit === 'year') {
  8754. return { year: 'numeric' };
  8755. }
  8756. if (currentRangeUnit === 'month') {
  8757. return { year: 'numeric', month: 'long' }; // like "September 2014"
  8758. }
  8759. let days = diffWholeDays(dateProfile.currentRange.start, dateProfile.currentRange.end);
  8760. if (days !== null && days > 1) {
  8761. // multi-day range. shorter, like "Sep 9 - 10 2014"
  8762. return { year: 'numeric', month: 'short', day: 'numeric' };
  8763. }
  8764. // one day. longer, like "September 9 2014"
  8765. return { year: 'numeric', month: 'long', day: 'numeric' };
  8766. }
  8767. /*
  8768. TODO: test switching timezones when NO timezone plugin
  8769. */
  8770. class CalendarNowManager {
  8771. constructor() {
  8772. this.resetListeners = new Set();
  8773. }
  8774. handleInput(dateEnv, // will change if timezone setup changed
  8775. nowInput) {
  8776. const oldDateEnv = this.dateEnv;
  8777. if (dateEnv !== oldDateEnv) {
  8778. if (typeof nowInput === 'function') {
  8779. this.nowFn = nowInput;
  8780. }
  8781. else if (!oldDateEnv) { // first time?
  8782. this.nowAnchorDate = dateEnv.toDate(nowInput
  8783. ? dateEnv.createMarker(nowInput)
  8784. : dateEnv.createNowMarker());
  8785. this.nowAnchorQueried = Date.now();
  8786. }
  8787. this.dateEnv = dateEnv;
  8788. // not first time? fire reset handlers
  8789. if (oldDateEnv) {
  8790. for (const resetListener of this.resetListeners.values()) {
  8791. resetListener();
  8792. }
  8793. }
  8794. }
  8795. }
  8796. getDateMarker() {
  8797. return this.nowAnchorDate
  8798. ? this.dateEnv.timestampToMarker(this.nowAnchorDate.valueOf() +
  8799. (Date.now() - this.nowAnchorQueried))
  8800. : this.dateEnv.createMarker(this.nowFn());
  8801. }
  8802. addResetListener(handler) {
  8803. this.resetListeners.add(handler);
  8804. }
  8805. removeResetListener(handler) {
  8806. this.resetListeners.delete(handler);
  8807. }
  8808. }
  8809. // in future refactor, do the redux-style function(state=initial) for initial-state
  8810. // also, whatever is happening in constructor, have it happen in action queue too
  8811. class CalendarDataManager {
  8812. constructor(props) {
  8813. this.computeCurrentViewData = memoize(this._computeCurrentViewData);
  8814. this.organizeRawLocales = memoize(organizeRawLocales);
  8815. this.buildLocale = memoize(buildLocale);
  8816. this.buildPluginHooks = buildBuildPluginHooks();
  8817. this.buildDateEnv = memoize(buildDateEnv$1);
  8818. this.buildTheme = memoize(buildTheme);
  8819. this.parseToolbars = memoize(parseToolbars);
  8820. this.buildViewSpecs = memoize(buildViewSpecs);
  8821. this.buildDateProfileGenerator = memoizeObjArg(buildDateProfileGenerator);
  8822. this.buildViewApi = memoize(buildViewApi);
  8823. this.buildViewUiProps = memoizeObjArg(buildViewUiProps);
  8824. this.buildEventUiBySource = memoize(buildEventUiBySource, isPropsEqual);
  8825. this.buildEventUiBases = memoize(buildEventUiBases);
  8826. this.parseContextBusinessHours = memoizeObjArg(parseContextBusinessHours);
  8827. this.buildTitle = memoize(buildTitle);
  8828. this.nowManager = new CalendarNowManager();
  8829. this.emitter = new Emitter();
  8830. this.actionRunner = new TaskRunner(this._handleAction.bind(this), this.updateData.bind(this));
  8831. this.currentCalendarOptionsInput = {};
  8832. this.currentCalendarOptionsRefined = {};
  8833. this.currentViewOptionsInput = {};
  8834. this.currentViewOptionsRefined = {};
  8835. this.currentCalendarOptionsRefiners = {};
  8836. this.optionsForRefining = [];
  8837. this.optionsForHandling = [];
  8838. this.getCurrentData = () => this.data;
  8839. this.dispatch = (action) => {
  8840. this.actionRunner.request(action); // protects against recursive calls to _handleAction
  8841. };
  8842. this.props = props;
  8843. this.actionRunner.pause();
  8844. this.nowManager = new CalendarNowManager();
  8845. let dynamicOptionOverrides = {};
  8846. let optionsData = this.computeOptionsData(props.optionOverrides, dynamicOptionOverrides, props.calendarApi);
  8847. let currentViewType = optionsData.calendarOptions.initialView || optionsData.pluginHooks.initialView;
  8848. let currentViewData = this.computeCurrentViewData(currentViewType, optionsData, props.optionOverrides, dynamicOptionOverrides);
  8849. // wire things up
  8850. // TODO: not DRY
  8851. props.calendarApi.currentDataManager = this;
  8852. this.emitter.setThisContext(props.calendarApi);
  8853. this.emitter.setOptions(currentViewData.options);
  8854. let calendarContext = {
  8855. nowManager: this.nowManager,
  8856. dateEnv: optionsData.dateEnv,
  8857. options: optionsData.calendarOptions,
  8858. pluginHooks: optionsData.pluginHooks,
  8859. calendarApi: props.calendarApi,
  8860. dispatch: this.dispatch,
  8861. emitter: this.emitter,
  8862. getCurrentData: this.getCurrentData,
  8863. };
  8864. let currentDate = getInitialDate(optionsData.calendarOptions, optionsData.dateEnv, this.nowManager);
  8865. let dateProfile = currentViewData.dateProfileGenerator.build(currentDate);
  8866. if (!rangeContainsMarker(dateProfile.activeRange, currentDate)) {
  8867. currentDate = dateProfile.currentRange.start;
  8868. }
  8869. // needs to be after setThisContext
  8870. for (let callback of optionsData.pluginHooks.contextInit) {
  8871. callback(calendarContext);
  8872. }
  8873. // NOT DRY
  8874. let eventSources = initEventSources(optionsData.calendarOptions, dateProfile, calendarContext);
  8875. let initialState = {
  8876. dynamicOptionOverrides,
  8877. currentViewType,
  8878. currentDate,
  8879. dateProfile,
  8880. businessHours: this.parseContextBusinessHours(calendarContext),
  8881. eventSources,
  8882. eventUiBases: {},
  8883. eventStore: createEmptyEventStore(),
  8884. renderableEventStore: createEmptyEventStore(),
  8885. dateSelection: null,
  8886. eventSelection: '',
  8887. eventDrag: null,
  8888. eventResize: null,
  8889. selectionConfig: this.buildViewUiProps(calendarContext).selectionConfig,
  8890. };
  8891. let contextAndState = Object.assign(Object.assign({}, calendarContext), initialState);
  8892. for (let reducer of optionsData.pluginHooks.reducers) {
  8893. Object.assign(initialState, reducer(null, null, contextAndState));
  8894. }
  8895. if (computeIsLoading(initialState, calendarContext)) {
  8896. this.emitter.trigger('loading', true); // NOT DRY
  8897. }
  8898. this.state = initialState;
  8899. this.updateData();
  8900. this.actionRunner.resume();
  8901. }
  8902. resetOptions(optionOverrides, changedOptionNames) {
  8903. let { props } = this;
  8904. if (changedOptionNames === undefined) {
  8905. props.optionOverrides = optionOverrides;
  8906. }
  8907. else {
  8908. props.optionOverrides = Object.assign(Object.assign({}, (props.optionOverrides || {})), optionOverrides);
  8909. this.optionsForRefining.push(...changedOptionNames);
  8910. }
  8911. if (changedOptionNames === undefined || changedOptionNames.length) {
  8912. this.actionRunner.request({
  8913. type: 'NOTHING',
  8914. });
  8915. }
  8916. }
  8917. _handleAction(action) {
  8918. let { props, state, emitter } = this;
  8919. let dynamicOptionOverrides = reduceDynamicOptionOverrides(state.dynamicOptionOverrides, action);
  8920. let optionsData = this.computeOptionsData(props.optionOverrides, dynamicOptionOverrides, props.calendarApi);
  8921. let currentViewType = reduceViewType(state.currentViewType, action);
  8922. let currentViewData = this.computeCurrentViewData(currentViewType, optionsData, props.optionOverrides, dynamicOptionOverrides);
  8923. // wire things up
  8924. // TODO: not DRY
  8925. props.calendarApi.currentDataManager = this;
  8926. emitter.setThisContext(props.calendarApi);
  8927. emitter.setOptions(currentViewData.options);
  8928. let calendarContext = {
  8929. nowManager: this.nowManager,
  8930. dateEnv: optionsData.dateEnv,
  8931. options: optionsData.calendarOptions,
  8932. pluginHooks: optionsData.pluginHooks,
  8933. calendarApi: props.calendarApi,
  8934. dispatch: this.dispatch,
  8935. emitter,
  8936. getCurrentData: this.getCurrentData,
  8937. };
  8938. let { currentDate, dateProfile } = state;
  8939. if (this.data && this.data.dateProfileGenerator !== currentViewData.dateProfileGenerator) { // hack
  8940. dateProfile = currentViewData.dateProfileGenerator.build(currentDate);
  8941. }
  8942. currentDate = reduceCurrentDate(currentDate, action);
  8943. dateProfile = reduceDateProfile(dateProfile, action, currentDate, currentViewData.dateProfileGenerator);
  8944. if (action.type === 'PREV' || // TODO: move this logic into DateProfileGenerator
  8945. action.type === 'NEXT' || // "
  8946. !rangeContainsMarker(dateProfile.currentRange, currentDate)) {
  8947. currentDate = dateProfile.currentRange.start;
  8948. }
  8949. let eventSources = reduceEventSources(state.eventSources, action, dateProfile, calendarContext);
  8950. let eventStore = reduceEventStore(state.eventStore, action, eventSources, dateProfile, calendarContext);
  8951. let isEventsLoading = computeEventSourcesLoading(eventSources); // BAD. also called in this func in computeIsLoading
  8952. let renderableEventStore = (isEventsLoading && !currentViewData.options.progressiveEventRendering) ?
  8953. (state.renderableEventStore || eventStore) : // try from previous state
  8954. eventStore;
  8955. let { eventUiSingleBase, selectionConfig } = this.buildViewUiProps(calendarContext); // will memoize obj
  8956. let eventUiBySource = this.buildEventUiBySource(eventSources);
  8957. let eventUiBases = this.buildEventUiBases(renderableEventStore.defs, eventUiSingleBase, eventUiBySource);
  8958. let newState = {
  8959. dynamicOptionOverrides,
  8960. currentViewType,
  8961. currentDate,
  8962. dateProfile,
  8963. eventSources,
  8964. eventStore,
  8965. renderableEventStore,
  8966. selectionConfig,
  8967. eventUiBases,
  8968. businessHours: this.parseContextBusinessHours(calendarContext),
  8969. dateSelection: reduceDateSelection(state.dateSelection, action),
  8970. eventSelection: reduceSelectedEvent(state.eventSelection, action),
  8971. eventDrag: reduceEventDrag(state.eventDrag, action),
  8972. eventResize: reduceEventResize(state.eventResize, action),
  8973. };
  8974. let contextAndState = Object.assign(Object.assign({}, calendarContext), newState);
  8975. for (let reducer of optionsData.pluginHooks.reducers) {
  8976. Object.assign(newState, reducer(state, action, contextAndState)); // give the OLD state, for old value
  8977. }
  8978. let wasLoading = computeIsLoading(state, calendarContext);
  8979. let isLoading = computeIsLoading(newState, calendarContext);
  8980. // TODO: use propSetHandlers in plugin system
  8981. if (!wasLoading && isLoading) {
  8982. emitter.trigger('loading', true);
  8983. }
  8984. else if (wasLoading && !isLoading) {
  8985. emitter.trigger('loading', false);
  8986. }
  8987. this.state = newState;
  8988. if (props.onAction) {
  8989. props.onAction(action);
  8990. }
  8991. }
  8992. updateData() {
  8993. let { props, state } = this;
  8994. let oldData = this.data;
  8995. let optionsData = this.computeOptionsData(props.optionOverrides, state.dynamicOptionOverrides, props.calendarApi);
  8996. let currentViewData = this.computeCurrentViewData(state.currentViewType, optionsData, props.optionOverrides, state.dynamicOptionOverrides);
  8997. let data = this.data = Object.assign(Object.assign(Object.assign({ nowManager: this.nowManager, viewTitle: this.buildTitle(state.dateProfile, currentViewData.options, optionsData.dateEnv), calendarApi: props.calendarApi, dispatch: this.dispatch, emitter: this.emitter, getCurrentData: this.getCurrentData }, optionsData), currentViewData), state);
  8998. let changeHandlers = optionsData.pluginHooks.optionChangeHandlers;
  8999. let oldCalendarOptions = oldData && oldData.calendarOptions;
  9000. let newCalendarOptions = optionsData.calendarOptions;
  9001. if (oldCalendarOptions && oldCalendarOptions !== newCalendarOptions) {
  9002. if (oldCalendarOptions.timeZone !== newCalendarOptions.timeZone) {
  9003. // hack
  9004. state.eventSources = data.eventSources = reduceEventSourcesNewTimeZone(data.eventSources, state.dateProfile, data);
  9005. state.eventStore = data.eventStore = rezoneEventStoreDates(data.eventStore, oldData.dateEnv, data.dateEnv);
  9006. state.renderableEventStore = data.renderableEventStore = rezoneEventStoreDates(data.renderableEventStore, oldData.dateEnv, data.dateEnv);
  9007. }
  9008. for (let optionName in changeHandlers) {
  9009. if (this.optionsForHandling.indexOf(optionName) !== -1 ||
  9010. oldCalendarOptions[optionName] !== newCalendarOptions[optionName]) {
  9011. changeHandlers[optionName](newCalendarOptions[optionName], data);
  9012. }
  9013. }
  9014. }
  9015. this.optionsForHandling = [];
  9016. if (props.onData) {
  9017. props.onData(data);
  9018. }
  9019. }
  9020. computeOptionsData(optionOverrides, dynamicOptionOverrides, calendarApi) {
  9021. // TODO: blacklist options that are handled by optionChangeHandlers
  9022. if (!this.optionsForRefining.length &&
  9023. optionOverrides === this.stableOptionOverrides &&
  9024. dynamicOptionOverrides === this.stableDynamicOptionOverrides) {
  9025. return this.stableCalendarOptionsData;
  9026. }
  9027. let { refinedOptions, pluginHooks, localeDefaults, availableLocaleData, extra, } = this.processRawCalendarOptions(optionOverrides, dynamicOptionOverrides);
  9028. warnUnknownOptions(extra);
  9029. let dateEnv = this.buildDateEnv(refinedOptions.timeZone, refinedOptions.locale, refinedOptions.weekNumberCalculation, refinedOptions.firstDay, refinedOptions.weekText, pluginHooks, availableLocaleData, refinedOptions.defaultRangeSeparator);
  9030. let viewSpecs = this.buildViewSpecs(pluginHooks.views, this.stableOptionOverrides, this.stableDynamicOptionOverrides, localeDefaults);
  9031. let theme = this.buildTheme(refinedOptions, pluginHooks);
  9032. let toolbarConfig = this.parseToolbars(refinedOptions, this.stableOptionOverrides, theme, viewSpecs, calendarApi);
  9033. return this.stableCalendarOptionsData = {
  9034. calendarOptions: refinedOptions,
  9035. pluginHooks,
  9036. dateEnv,
  9037. viewSpecs,
  9038. theme,
  9039. toolbarConfig,
  9040. localeDefaults,
  9041. availableRawLocales: availableLocaleData.map,
  9042. };
  9043. }
  9044. // always called from behind a memoizer
  9045. processRawCalendarOptions(optionOverrides, dynamicOptionOverrides) {
  9046. let { locales, locale } = mergeRawOptions([
  9047. BASE_OPTION_DEFAULTS,
  9048. optionOverrides,
  9049. dynamicOptionOverrides,
  9050. ]);
  9051. let availableLocaleData = this.organizeRawLocales(locales);
  9052. let availableRawLocales = availableLocaleData.map;
  9053. let localeDefaults = this.buildLocale(locale || availableLocaleData.defaultCode, availableRawLocales).options;
  9054. let pluginHooks = this.buildPluginHooks(optionOverrides.plugins || [], globalPlugins);
  9055. let refiners = this.currentCalendarOptionsRefiners = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, BASE_OPTION_REFINERS), CALENDAR_LISTENER_REFINERS), CALENDAR_OPTION_REFINERS), pluginHooks.listenerRefiners), pluginHooks.optionRefiners);
  9056. let extra = {};
  9057. let raw = mergeRawOptions([
  9058. BASE_OPTION_DEFAULTS,
  9059. localeDefaults,
  9060. optionOverrides,
  9061. dynamicOptionOverrides,
  9062. ]);
  9063. let refined = {};
  9064. let currentRaw = this.currentCalendarOptionsInput;
  9065. let currentRefined = this.currentCalendarOptionsRefined;
  9066. let anyChanges = false;
  9067. for (let optionName in raw) {
  9068. if (this.optionsForRefining.indexOf(optionName) === -1 && (raw[optionName] === currentRaw[optionName] || (COMPLEX_OPTION_COMPARATORS[optionName] &&
  9069. (optionName in currentRaw) &&
  9070. COMPLEX_OPTION_COMPARATORS[optionName](currentRaw[optionName], raw[optionName])))) {
  9071. refined[optionName] = currentRefined[optionName];
  9072. }
  9073. else if (refiners[optionName]) {
  9074. refined[optionName] = refiners[optionName](raw[optionName]);
  9075. anyChanges = true;
  9076. }
  9077. else {
  9078. extra[optionName] = currentRaw[optionName];
  9079. }
  9080. }
  9081. if (anyChanges) {
  9082. this.currentCalendarOptionsInput = raw;
  9083. this.currentCalendarOptionsRefined = refined;
  9084. this.stableOptionOverrides = optionOverrides;
  9085. this.stableDynamicOptionOverrides = dynamicOptionOverrides;
  9086. }
  9087. this.optionsForHandling.push(...this.optionsForRefining);
  9088. this.optionsForRefining = [];
  9089. return {
  9090. rawOptions: this.currentCalendarOptionsInput,
  9091. refinedOptions: this.currentCalendarOptionsRefined,
  9092. pluginHooks,
  9093. availableLocaleData,
  9094. localeDefaults,
  9095. extra,
  9096. };
  9097. }
  9098. _computeCurrentViewData(viewType, optionsData, optionOverrides, dynamicOptionOverrides) {
  9099. let viewSpec = optionsData.viewSpecs[viewType];
  9100. if (!viewSpec) {
  9101. throw new Error(`viewType "${viewType}" is not available. Please make sure you've loaded all neccessary plugins`);
  9102. }
  9103. let { refinedOptions, extra } = this.processRawViewOptions(viewSpec, optionsData.pluginHooks, optionsData.localeDefaults, optionOverrides, dynamicOptionOverrides);
  9104. warnUnknownOptions(extra);
  9105. this.nowManager.handleInput(optionsData.dateEnv, refinedOptions.now);
  9106. let dateProfileGenerator = this.buildDateProfileGenerator({
  9107. dateProfileGeneratorClass: viewSpec.optionDefaults.dateProfileGeneratorClass,
  9108. nowManager: this.nowManager,
  9109. duration: viewSpec.duration,
  9110. durationUnit: viewSpec.durationUnit,
  9111. usesMinMaxTime: viewSpec.optionDefaults.usesMinMaxTime,
  9112. dateEnv: optionsData.dateEnv,
  9113. calendarApi: this.props.calendarApi,
  9114. slotMinTime: refinedOptions.slotMinTime,
  9115. slotMaxTime: refinedOptions.slotMaxTime,
  9116. showNonCurrentDates: refinedOptions.showNonCurrentDates,
  9117. dayCount: refinedOptions.dayCount,
  9118. dateAlignment: refinedOptions.dateAlignment,
  9119. dateIncrement: refinedOptions.dateIncrement,
  9120. hiddenDays: refinedOptions.hiddenDays,
  9121. weekends: refinedOptions.weekends,
  9122. validRangeInput: refinedOptions.validRange,
  9123. visibleRangeInput: refinedOptions.visibleRange,
  9124. fixedWeekCount: refinedOptions.fixedWeekCount,
  9125. });
  9126. let viewApi = this.buildViewApi(viewType, this.getCurrentData, optionsData.dateEnv);
  9127. return { viewSpec, options: refinedOptions, dateProfileGenerator, viewApi };
  9128. }
  9129. processRawViewOptions(viewSpec, pluginHooks, localeDefaults, optionOverrides, dynamicOptionOverrides) {
  9130. let raw = mergeRawOptions([
  9131. BASE_OPTION_DEFAULTS,
  9132. viewSpec.optionDefaults,
  9133. localeDefaults,
  9134. optionOverrides,
  9135. viewSpec.optionOverrides,
  9136. dynamicOptionOverrides,
  9137. ]);
  9138. let refiners = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, BASE_OPTION_REFINERS), CALENDAR_LISTENER_REFINERS), CALENDAR_OPTION_REFINERS), VIEW_OPTION_REFINERS), pluginHooks.listenerRefiners), pluginHooks.optionRefiners);
  9139. let refined = {};
  9140. let currentRaw = this.currentViewOptionsInput;
  9141. let currentRefined = this.currentViewOptionsRefined;
  9142. let anyChanges = false;
  9143. let extra = {};
  9144. for (let optionName in raw) {
  9145. if (raw[optionName] === currentRaw[optionName] ||
  9146. (COMPLEX_OPTION_COMPARATORS[optionName] &&
  9147. COMPLEX_OPTION_COMPARATORS[optionName](raw[optionName], currentRaw[optionName]))) {
  9148. refined[optionName] = currentRefined[optionName];
  9149. }
  9150. else {
  9151. if (raw[optionName] === this.currentCalendarOptionsInput[optionName] ||
  9152. (COMPLEX_OPTION_COMPARATORS[optionName] &&
  9153. COMPLEX_OPTION_COMPARATORS[optionName](raw[optionName], this.currentCalendarOptionsInput[optionName]))) {
  9154. if (optionName in this.currentCalendarOptionsRefined) { // might be an "extra" prop
  9155. refined[optionName] = this.currentCalendarOptionsRefined[optionName];
  9156. }
  9157. }
  9158. else if (refiners[optionName]) {
  9159. refined[optionName] = refiners[optionName](raw[optionName]);
  9160. }
  9161. else {
  9162. extra[optionName] = raw[optionName];
  9163. }
  9164. anyChanges = true;
  9165. }
  9166. }
  9167. if (anyChanges) {
  9168. this.currentViewOptionsInput = raw;
  9169. this.currentViewOptionsRefined = refined;
  9170. }
  9171. return {
  9172. rawOptions: this.currentViewOptionsInput,
  9173. refinedOptions: this.currentViewOptionsRefined,
  9174. extra,
  9175. };
  9176. }
  9177. }
  9178. function buildDateEnv$1(timeZone, explicitLocale, weekNumberCalculation, firstDay, weekText, pluginHooks, availableLocaleData, defaultSeparator) {
  9179. let locale = buildLocale(explicitLocale || availableLocaleData.defaultCode, availableLocaleData.map);
  9180. return new DateEnv({
  9181. calendarSystem: 'gregory',
  9182. timeZone,
  9183. namedTimeZoneImpl: pluginHooks.namedTimeZonedImpl,
  9184. locale,
  9185. weekNumberCalculation,
  9186. firstDay,
  9187. weekText,
  9188. cmdFormatter: pluginHooks.cmdFormatter,
  9189. defaultSeparator,
  9190. });
  9191. }
  9192. function buildTheme(options, pluginHooks) {
  9193. let ThemeClass = pluginHooks.themeClasses[options.themeSystem] || StandardTheme;
  9194. return new ThemeClass(options);
  9195. }
  9196. function buildDateProfileGenerator(props) {
  9197. let DateProfileGeneratorClass = props.dateProfileGeneratorClass || DateProfileGenerator;
  9198. return new DateProfileGeneratorClass(props);
  9199. }
  9200. function buildViewApi(type, getCurrentData, dateEnv) {
  9201. return new ViewImpl(type, getCurrentData, dateEnv);
  9202. }
  9203. function buildEventUiBySource(eventSources) {
  9204. return mapHash(eventSources, (eventSource) => eventSource.ui);
  9205. }
  9206. function buildEventUiBases(eventDefs, eventUiSingleBase, eventUiBySource) {
  9207. let eventUiBases = { '': eventUiSingleBase };
  9208. for (let defId in eventDefs) {
  9209. let def = eventDefs[defId];
  9210. if (def.sourceId && eventUiBySource[def.sourceId]) {
  9211. eventUiBases[defId] = eventUiBySource[def.sourceId];
  9212. }
  9213. }
  9214. return eventUiBases;
  9215. }
  9216. function buildViewUiProps(calendarContext) {
  9217. let { options } = calendarContext;
  9218. return {
  9219. eventUiSingleBase: createEventUi({
  9220. display: options.eventDisplay,
  9221. editable: options.editable,
  9222. startEditable: options.eventStartEditable,
  9223. durationEditable: options.eventDurationEditable,
  9224. constraint: options.eventConstraint,
  9225. overlap: typeof options.eventOverlap === 'boolean' ? options.eventOverlap : undefined,
  9226. allow: options.eventAllow,
  9227. backgroundColor: options.eventBackgroundColor,
  9228. borderColor: options.eventBorderColor,
  9229. textColor: options.eventTextColor,
  9230. color: options.eventColor,
  9231. // classNames: options.eventClassNames // render hook will handle this
  9232. }, calendarContext),
  9233. selectionConfig: createEventUi({
  9234. constraint: options.selectConstraint,
  9235. overlap: typeof options.selectOverlap === 'boolean' ? options.selectOverlap : undefined,
  9236. allow: options.selectAllow,
  9237. }, calendarContext),
  9238. };
  9239. }
  9240. function computeIsLoading(state, context) {
  9241. for (let isLoadingFunc of context.pluginHooks.isLoadingFuncs) {
  9242. if (isLoadingFunc(state)) {
  9243. return true;
  9244. }
  9245. }
  9246. return false;
  9247. }
  9248. function parseContextBusinessHours(calendarContext) {
  9249. return parseBusinessHours(calendarContext.options.businessHours, calendarContext);
  9250. }
  9251. function warnUnknownOptions(options, viewName) {
  9252. for (let optionName in options) {
  9253. console.warn(`Unknown option '${optionName}'` +
  9254. (viewName ? ` for view '${viewName}'` : ''));
  9255. }
  9256. }
  9257. class ToolbarSection extends BaseComponent {
  9258. render() {
  9259. let children = this.props.widgetGroups.map((widgetGroup) => this.renderWidgetGroup(widgetGroup));
  9260. return y('div', { className: 'fc-toolbar-chunk' }, ...children);
  9261. }
  9262. renderWidgetGroup(widgetGroup) {
  9263. let { props } = this;
  9264. let { theme } = this.context;
  9265. let children = [];
  9266. let isOnlyButtons = true;
  9267. for (let widget of widgetGroup) {
  9268. let { buttonName, buttonClick, buttonText, buttonIcon, buttonHint } = widget;
  9269. if (buttonName === 'title') {
  9270. isOnlyButtons = false;
  9271. children.push(y("h2", { className: "fc-toolbar-title", id: props.titleId }, props.title));
  9272. }
  9273. else {
  9274. let isPressed = buttonName === props.activeButton;
  9275. let isDisabled = (!props.isTodayEnabled && buttonName === 'today') ||
  9276. (!props.isPrevEnabled && buttonName === 'prev') ||
  9277. (!props.isNextEnabled && buttonName === 'next');
  9278. let buttonClasses = [`fc-${buttonName}-button`, theme.getClass('button')];
  9279. if (isPressed) {
  9280. buttonClasses.push(theme.getClass('buttonActive'));
  9281. }
  9282. children.push(y("button", { type: "button", title: typeof buttonHint === 'function' ? buttonHint(props.navUnit) : buttonHint, disabled: isDisabled, "aria-pressed": isPressed, className: buttonClasses.join(' '), onClick: buttonClick }, buttonText || (buttonIcon ? y("span", { className: buttonIcon, role: "img" }) : '')));
  9283. }
  9284. }
  9285. if (children.length > 1) {
  9286. let groupClassName = (isOnlyButtons && theme.getClass('buttonGroup')) || '';
  9287. return y('div', { className: groupClassName }, ...children);
  9288. }
  9289. return children[0];
  9290. }
  9291. }
  9292. class Toolbar extends BaseComponent {
  9293. render() {
  9294. let { model, extraClassName } = this.props;
  9295. let forceLtr = false;
  9296. let startContent;
  9297. let endContent;
  9298. let sectionWidgets = model.sectionWidgets;
  9299. let centerContent = sectionWidgets.center;
  9300. if (sectionWidgets.left) {
  9301. forceLtr = true;
  9302. startContent = sectionWidgets.left;
  9303. }
  9304. else {
  9305. startContent = sectionWidgets.start;
  9306. }
  9307. if (sectionWidgets.right) {
  9308. forceLtr = true;
  9309. endContent = sectionWidgets.right;
  9310. }
  9311. else {
  9312. endContent = sectionWidgets.end;
  9313. }
  9314. let classNames = [
  9315. extraClassName || '',
  9316. 'fc-toolbar',
  9317. forceLtr ? 'fc-toolbar-ltr' : '',
  9318. ];
  9319. return (y("div", { className: classNames.join(' ') },
  9320. this.renderSection('start', startContent || []),
  9321. this.renderSection('center', centerContent || []),
  9322. this.renderSection('end', endContent || [])));
  9323. }
  9324. renderSection(key, widgetGroups) {
  9325. let { props } = this;
  9326. return (y(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 }));
  9327. }
  9328. }
  9329. class ViewHarness extends BaseComponent {
  9330. constructor() {
  9331. super(...arguments);
  9332. this.state = {
  9333. availableWidth: null,
  9334. };
  9335. this.handleEl = (el) => {
  9336. this.el = el;
  9337. setRef(this.props.elRef, el);
  9338. this.updateAvailableWidth();
  9339. };
  9340. this.handleResize = () => {
  9341. this.updateAvailableWidth();
  9342. };
  9343. }
  9344. render() {
  9345. let { props, state } = this;
  9346. let { aspectRatio } = props;
  9347. let classNames = [
  9348. 'fc-view-harness',
  9349. (aspectRatio || props.liquid || props.height)
  9350. ? 'fc-view-harness-active' // harness controls the height
  9351. : 'fc-view-harness-passive', // let the view do the height
  9352. ];
  9353. let height = '';
  9354. let paddingBottom = '';
  9355. if (aspectRatio) {
  9356. if (state.availableWidth !== null) {
  9357. height = state.availableWidth / aspectRatio;
  9358. }
  9359. else {
  9360. // while waiting to know availableWidth, we can't set height to *zero*
  9361. // because will cause lots of unnecessary scrollbars within scrollgrid.
  9362. // BETTER: don't start rendering ANYTHING yet until we know container width
  9363. // NOTE: why not always use paddingBottom? Causes height oscillation (issue 5606)
  9364. paddingBottom = `${(1 / aspectRatio) * 100}%`;
  9365. }
  9366. }
  9367. else {
  9368. height = props.height || '';
  9369. }
  9370. return (y("div", { "aria-labelledby": props.labeledById, ref: this.handleEl, className: classNames.join(' '), style: { height, paddingBottom } }, props.children));
  9371. }
  9372. componentDidMount() {
  9373. this.context.addResizeHandler(this.handleResize);
  9374. }
  9375. componentWillUnmount() {
  9376. this.context.removeResizeHandler(this.handleResize);
  9377. }
  9378. updateAvailableWidth() {
  9379. if (this.el && // needed. but why?
  9380. this.props.aspectRatio // aspectRatio is the only height setting that needs availableWidth
  9381. ) {
  9382. this.setState({ availableWidth: this.el.offsetWidth });
  9383. }
  9384. }
  9385. }
  9386. /*
  9387. Detects when the user clicks on an event within a DateComponent
  9388. */
  9389. class EventClicking extends Interaction {
  9390. constructor(settings) {
  9391. super(settings);
  9392. this.handleSegClick = (ev, segEl) => {
  9393. let { component } = this;
  9394. let { context } = component;
  9395. let seg = getElSeg(segEl);
  9396. if (seg && // might be the <div> surrounding the more link
  9397. component.isValidSegDownEl(ev.target)) {
  9398. // our way to simulate a link click for elements that can't be <a> tags
  9399. // grab before trigger fired in case trigger trashes DOM thru rerendering
  9400. let hasUrlContainer = elementClosest(ev.target, '.fc-event-forced-url');
  9401. let url = hasUrlContainer ? hasUrlContainer.querySelector('a[href]').href : '';
  9402. context.emitter.trigger('eventClick', {
  9403. el: segEl,
  9404. event: new EventImpl(component.context, seg.eventRange.def, seg.eventRange.instance),
  9405. jsEvent: ev,
  9406. view: context.viewApi,
  9407. });
  9408. if (url && !ev.defaultPrevented) {
  9409. window.location.href = url;
  9410. }
  9411. }
  9412. };
  9413. this.destroy = listenBySelector(settings.el, 'click', '.fc-event', // on both fg and bg events
  9414. this.handleSegClick);
  9415. }
  9416. }
  9417. /*
  9418. Triggers events and adds/removes core classNames when the user's pointer
  9419. enters/leaves event-elements of a component.
  9420. */
  9421. class EventHovering extends Interaction {
  9422. constructor(settings) {
  9423. super(settings);
  9424. // for simulating an eventMouseLeave when the event el is destroyed while mouse is over it
  9425. this.handleEventElRemove = (el) => {
  9426. if (el === this.currentSegEl) {
  9427. this.handleSegLeave(null, this.currentSegEl);
  9428. }
  9429. };
  9430. this.handleSegEnter = (ev, segEl) => {
  9431. if (getElSeg(segEl)) { // TODO: better way to make sure not hovering over more+ link or its wrapper
  9432. this.currentSegEl = segEl;
  9433. this.triggerEvent('eventMouseEnter', ev, segEl);
  9434. }
  9435. };
  9436. this.handleSegLeave = (ev, segEl) => {
  9437. if (this.currentSegEl) {
  9438. this.currentSegEl = null;
  9439. this.triggerEvent('eventMouseLeave', ev, segEl);
  9440. }
  9441. };
  9442. this.removeHoverListeners = listenToHoverBySelector(settings.el, '.fc-event', // on both fg and bg events
  9443. this.handleSegEnter, this.handleSegLeave);
  9444. }
  9445. destroy() {
  9446. this.removeHoverListeners();
  9447. }
  9448. triggerEvent(publicEvName, ev, segEl) {
  9449. let { component } = this;
  9450. let { context } = component;
  9451. let seg = getElSeg(segEl);
  9452. if (!ev || component.isValidSegDownEl(ev.target)) {
  9453. context.emitter.trigger(publicEvName, {
  9454. el: segEl,
  9455. event: new EventImpl(context, seg.eventRange.def, seg.eventRange.instance),
  9456. jsEvent: ev,
  9457. view: context.viewApi,
  9458. });
  9459. }
  9460. }
  9461. }
  9462. class CalendarContent extends PureComponent {
  9463. constructor() {
  9464. super(...arguments);
  9465. this.buildViewContext = memoize(buildViewContext);
  9466. this.buildViewPropTransformers = memoize(buildViewPropTransformers);
  9467. this.buildToolbarProps = memoize(buildToolbarProps);
  9468. this.headerRef = d();
  9469. this.footerRef = d();
  9470. this.interactionsStore = {};
  9471. // eslint-disable-next-line
  9472. this.state = {
  9473. viewLabelId: getUniqueDomId(),
  9474. };
  9475. // Component Registration
  9476. // -----------------------------------------------------------------------------------------------------------------
  9477. this.registerInteractiveComponent = (component, settingsInput) => {
  9478. let settings = parseInteractionSettings(component, settingsInput);
  9479. let DEFAULT_INTERACTIONS = [
  9480. EventClicking,
  9481. EventHovering,
  9482. ];
  9483. let interactionClasses = DEFAULT_INTERACTIONS.concat(this.props.pluginHooks.componentInteractions);
  9484. let interactions = interactionClasses.map((TheInteractionClass) => new TheInteractionClass(settings));
  9485. this.interactionsStore[component.uid] = interactions;
  9486. interactionSettingsStore[component.uid] = settings;
  9487. };
  9488. this.unregisterInteractiveComponent = (component) => {
  9489. let listeners = this.interactionsStore[component.uid];
  9490. if (listeners) {
  9491. for (let listener of listeners) {
  9492. listener.destroy();
  9493. }
  9494. delete this.interactionsStore[component.uid];
  9495. }
  9496. delete interactionSettingsStore[component.uid];
  9497. };
  9498. // Resizing
  9499. // -----------------------------------------------------------------------------------------------------------------
  9500. this.resizeRunner = new DelayedRunner(() => {
  9501. this.props.emitter.trigger('_resize', true); // should window resizes be considered "forced" ?
  9502. this.props.emitter.trigger('windowResize', { view: this.props.viewApi });
  9503. });
  9504. this.handleWindowResize = (ev) => {
  9505. let { options } = this.props;
  9506. if (options.handleWindowResize &&
  9507. ev.target === window // avoid jqui events
  9508. ) {
  9509. this.resizeRunner.request(options.windowResizeDelay);
  9510. }
  9511. };
  9512. }
  9513. /*
  9514. renders INSIDE of an outer div
  9515. */
  9516. render() {
  9517. let { props } = this;
  9518. let { toolbarConfig, options } = props;
  9519. let viewVGrow = false;
  9520. let viewHeight = '';
  9521. let viewAspectRatio;
  9522. if (props.isHeightAuto || props.forPrint) {
  9523. viewHeight = '';
  9524. }
  9525. else if (options.height != null) {
  9526. viewVGrow = true;
  9527. }
  9528. else if (options.contentHeight != null) {
  9529. viewHeight = options.contentHeight;
  9530. }
  9531. else {
  9532. viewAspectRatio = Math.max(options.aspectRatio, 0.5); // prevent from getting too tall
  9533. }
  9534. let viewContext = this.buildViewContext(props.viewSpec, props.viewApi, props.options, props.dateProfileGenerator, props.dateEnv, props.nowManager, props.theme, props.pluginHooks, props.dispatch, props.getCurrentData, props.emitter, props.calendarApi, this.registerInteractiveComponent, this.unregisterInteractiveComponent);
  9535. let viewLabelId = (toolbarConfig.header && toolbarConfig.header.hasTitle)
  9536. ? this.state.viewLabelId
  9537. : undefined;
  9538. return (y(ViewContextType.Provider, { value: viewContext },
  9539. y(NowTimer, { unit: "day" }, (nowDate) => {
  9540. let toolbarProps = this.buildToolbarProps(props.viewSpec, props.dateProfile, props.dateProfileGenerator, props.currentDate, nowDate, props.viewTitle);
  9541. return (y(_, null,
  9542. toolbarConfig.header && (y(Toolbar, Object.assign({ ref: this.headerRef, extraClassName: "fc-header-toolbar", model: toolbarConfig.header, titleId: viewLabelId }, toolbarProps))),
  9543. y(ViewHarness, { liquid: viewVGrow, height: viewHeight, aspectRatio: viewAspectRatio, labeledById: viewLabelId },
  9544. this.renderView(props),
  9545. this.buildAppendContent()),
  9546. toolbarConfig.footer && (y(Toolbar, Object.assign({ ref: this.footerRef, extraClassName: "fc-footer-toolbar", model: toolbarConfig.footer, titleId: "" }, toolbarProps)))));
  9547. })));
  9548. }
  9549. componentDidMount() {
  9550. let { props } = this;
  9551. this.calendarInteractions = props.pluginHooks.calendarInteractions
  9552. .map((CalendarInteractionClass) => new CalendarInteractionClass(props));
  9553. window.addEventListener('resize', this.handleWindowResize);
  9554. let { propSetHandlers } = props.pluginHooks;
  9555. for (let propName in propSetHandlers) {
  9556. propSetHandlers[propName](props[propName], props);
  9557. }
  9558. }
  9559. componentDidUpdate(prevProps) {
  9560. let { props } = this;
  9561. let { propSetHandlers } = props.pluginHooks;
  9562. for (let propName in propSetHandlers) {
  9563. if (props[propName] !== prevProps[propName]) {
  9564. propSetHandlers[propName](props[propName], props);
  9565. }
  9566. }
  9567. }
  9568. componentWillUnmount() {
  9569. window.removeEventListener('resize', this.handleWindowResize);
  9570. this.resizeRunner.clear();
  9571. for (let interaction of this.calendarInteractions) {
  9572. interaction.destroy();
  9573. }
  9574. this.props.emitter.trigger('_unmount');
  9575. }
  9576. buildAppendContent() {
  9577. let { props } = this;
  9578. let children = props.pluginHooks.viewContainerAppends.map((buildAppendContent) => buildAppendContent(props));
  9579. return y(_, {}, ...children);
  9580. }
  9581. renderView(props) {
  9582. let { pluginHooks } = props;
  9583. let { viewSpec } = props;
  9584. let viewProps = {
  9585. dateProfile: props.dateProfile,
  9586. businessHours: props.businessHours,
  9587. eventStore: props.renderableEventStore,
  9588. eventUiBases: props.eventUiBases,
  9589. dateSelection: props.dateSelection,
  9590. eventSelection: props.eventSelection,
  9591. eventDrag: props.eventDrag,
  9592. eventResize: props.eventResize,
  9593. isHeightAuto: props.isHeightAuto,
  9594. forPrint: props.forPrint,
  9595. };
  9596. let transformers = this.buildViewPropTransformers(pluginHooks.viewPropsTransformers);
  9597. for (let transformer of transformers) {
  9598. Object.assign(viewProps, transformer.transform(viewProps, props));
  9599. }
  9600. let ViewComponent = viewSpec.component;
  9601. return (y(ViewComponent, Object.assign({}, viewProps)));
  9602. }
  9603. }
  9604. function buildToolbarProps(viewSpec, dateProfile, dateProfileGenerator, currentDate, now, title) {
  9605. // don't force any date-profiles to valid date profiles (the `false`) so that we can tell if it's invalid
  9606. let todayInfo = dateProfileGenerator.build(now, undefined, false); // TODO: need `undefined` or else INFINITE LOOP for some reason
  9607. let prevInfo = dateProfileGenerator.buildPrev(dateProfile, currentDate, false);
  9608. let nextInfo = dateProfileGenerator.buildNext(dateProfile, currentDate, false);
  9609. return {
  9610. title,
  9611. activeButton: viewSpec.type,
  9612. navUnit: viewSpec.singleUnit,
  9613. isTodayEnabled: todayInfo.isValid && !rangeContainsMarker(dateProfile.currentRange, now),
  9614. isPrevEnabled: prevInfo.isValid,
  9615. isNextEnabled: nextInfo.isValid,
  9616. };
  9617. }
  9618. // Plugin
  9619. // -----------------------------------------------------------------------------------------------------------------
  9620. function buildViewPropTransformers(theClasses) {
  9621. return theClasses.map((TheClass) => new TheClass());
  9622. }
  9623. class Calendar extends CalendarImpl {
  9624. constructor(el, optionOverrides = {}) {
  9625. super();
  9626. this.isRendering = false;
  9627. this.isRendered = false;
  9628. this.currentClassNames = [];
  9629. this.customContentRenderId = 0;
  9630. this.handleAction = (action) => {
  9631. // actions we know we want to render immediately
  9632. switch (action.type) {
  9633. case 'SET_EVENT_DRAG':
  9634. case 'SET_EVENT_RESIZE':
  9635. this.renderRunner.tryDrain();
  9636. }
  9637. };
  9638. this.handleData = (data) => {
  9639. this.currentData = data;
  9640. this.renderRunner.request(data.calendarOptions.rerenderDelay);
  9641. };
  9642. this.handleRenderRequest = () => {
  9643. if (this.isRendering) {
  9644. this.isRendered = true;
  9645. let { currentData } = this;
  9646. flushSync(() => {
  9647. D$1(y(CalendarRoot, { options: currentData.calendarOptions, theme: currentData.theme, emitter: currentData.emitter }, (classNames, height, isHeightAuto, forPrint) => {
  9648. this.setClassNames(classNames);
  9649. this.setHeight(height);
  9650. return (y(RenderId.Provider, { value: this.customContentRenderId },
  9651. y(CalendarContent, Object.assign({ isHeightAuto: isHeightAuto, forPrint: forPrint }, currentData))));
  9652. }), this.el);
  9653. });
  9654. }
  9655. else if (this.isRendered) {
  9656. this.isRendered = false;
  9657. D$1(null, this.el);
  9658. this.setClassNames([]);
  9659. this.setHeight('');
  9660. }
  9661. };
  9662. ensureElHasStyles(el);
  9663. this.el = el;
  9664. this.renderRunner = new DelayedRunner(this.handleRenderRequest);
  9665. new CalendarDataManager({
  9666. optionOverrides,
  9667. calendarApi: this,
  9668. onAction: this.handleAction,
  9669. onData: this.handleData,
  9670. });
  9671. }
  9672. render() {
  9673. let wasRendering = this.isRendering;
  9674. if (!wasRendering) {
  9675. this.isRendering = true;
  9676. }
  9677. else {
  9678. this.customContentRenderId += 1;
  9679. }
  9680. this.renderRunner.request();
  9681. if (wasRendering) {
  9682. this.updateSize();
  9683. }
  9684. }
  9685. destroy() {
  9686. if (this.isRendering) {
  9687. this.isRendering = false;
  9688. this.renderRunner.request();
  9689. }
  9690. }
  9691. updateSize() {
  9692. flushSync(() => {
  9693. super.updateSize();
  9694. });
  9695. }
  9696. batchRendering(func) {
  9697. this.renderRunner.pause('batchRendering');
  9698. func();
  9699. this.renderRunner.resume('batchRendering');
  9700. }
  9701. pauseRendering() {
  9702. this.renderRunner.pause('pauseRendering');
  9703. }
  9704. resumeRendering() {
  9705. this.renderRunner.resume('pauseRendering', true);
  9706. }
  9707. resetOptions(optionOverrides, changedOptionNames) {
  9708. this.currentDataManager.resetOptions(optionOverrides, changedOptionNames);
  9709. }
  9710. setClassNames(classNames) {
  9711. if (!isArraysEqual(classNames, this.currentClassNames)) {
  9712. let { classList } = this.el;
  9713. for (let className of this.currentClassNames) {
  9714. classList.remove(className);
  9715. }
  9716. for (let className of classNames) {
  9717. classList.add(className);
  9718. }
  9719. this.currentClassNames = classNames;
  9720. }
  9721. }
  9722. setHeight(height) {
  9723. applyStyleProp(this.el, 'height', height);
  9724. }
  9725. }
  9726. function formatDate(dateInput, options = {}) {
  9727. let dateEnv = buildDateEnv(options);
  9728. let formatter = createFormatter(options);
  9729. let dateMeta = dateEnv.createMarkerMeta(dateInput);
  9730. if (!dateMeta) { // TODO: warning?
  9731. return '';
  9732. }
  9733. return dateEnv.format(dateMeta.marker, formatter, {
  9734. forcedTzo: dateMeta.forcedTzo,
  9735. });
  9736. }
  9737. function formatRange(startInput, endInput, options) {
  9738. let dateEnv = buildDateEnv(typeof options === 'object' && options ? options : {}); // pass in if non-null object
  9739. let formatter = createFormatter(options);
  9740. let startMeta = dateEnv.createMarkerMeta(startInput);
  9741. let endMeta = dateEnv.createMarkerMeta(endInput);
  9742. if (!startMeta || !endMeta) { // TODO: warning?
  9743. return '';
  9744. }
  9745. return dateEnv.formatRange(startMeta.marker, endMeta.marker, formatter, {
  9746. forcedStartTzo: startMeta.forcedTzo,
  9747. forcedEndTzo: endMeta.forcedTzo,
  9748. isEndExclusive: options.isEndExclusive,
  9749. defaultSeparator: BASE_OPTION_DEFAULTS.defaultRangeSeparator,
  9750. });
  9751. }
  9752. // TODO: more DRY and optimized
  9753. function buildDateEnv(settings) {
  9754. let locale = buildLocale(settings.locale || 'en', organizeRawLocales([]).map); // TODO: don't hardcode 'en' everywhere
  9755. return new DateEnv(Object.assign(Object.assign({ timeZone: BASE_OPTION_DEFAULTS.timeZone, calendarSystem: 'gregory' }, settings), { locale }));
  9756. }
  9757. // HELPERS
  9758. /*
  9759. if nextDayThreshold is specified, slicing is done in an all-day fashion.
  9760. you can get nextDayThreshold from context.nextDayThreshold
  9761. */
  9762. function sliceEvents(props, allDay) {
  9763. return sliceEventStore(props.eventStore, props.eventUiBases, props.dateProfile.activeRange, allDay ? props.nextDayThreshold : null).fg;
  9764. }
  9765. const version = '6.1.17';
  9766. config.touchMouseIgnoreWait = 500;
  9767. let ignoreMouseDepth = 0;
  9768. let listenerCnt = 0;
  9769. let isWindowTouchMoveCancelled = false;
  9770. /*
  9771. Uses a "pointer" abstraction, which monitors UI events for both mouse and touch.
  9772. Tracks when the pointer "drags" on a certain element, meaning down+move+up.
  9773. Also, tracks if there was touch-scrolling.
  9774. Also, can prevent touch-scrolling from happening.
  9775. Also, can fire pointermove events when scrolling happens underneath, even when no real pointer movement.
  9776. emits:
  9777. - pointerdown
  9778. - pointermove
  9779. - pointerup
  9780. */
  9781. class PointerDragging {
  9782. constructor(containerEl) {
  9783. this.subjectEl = null;
  9784. // options that can be directly assigned by caller
  9785. this.selector = ''; // will cause subjectEl in all emitted events to be this element
  9786. this.handleSelector = '';
  9787. this.shouldIgnoreMove = false;
  9788. this.shouldWatchScroll = true; // for simulating pointermove on scroll
  9789. // internal states
  9790. this.isDragging = false;
  9791. this.isTouchDragging = false;
  9792. this.wasTouchScroll = false;
  9793. // Mouse
  9794. // ----------------------------------------------------------------------------------------------------
  9795. this.handleMouseDown = (ev) => {
  9796. if (!this.shouldIgnoreMouse() &&
  9797. isPrimaryMouseButton(ev) &&
  9798. this.tryStart(ev)) {
  9799. let pev = this.createEventFromMouse(ev, true);
  9800. this.emitter.trigger('pointerdown', pev);
  9801. this.initScrollWatch(pev);
  9802. if (!this.shouldIgnoreMove) {
  9803. document.addEventListener('mousemove', this.handleMouseMove);
  9804. }
  9805. document.addEventListener('mouseup', this.handleMouseUp);
  9806. }
  9807. };
  9808. this.handleMouseMove = (ev) => {
  9809. let pev = this.createEventFromMouse(ev);
  9810. this.recordCoords(pev);
  9811. this.emitter.trigger('pointermove', pev);
  9812. };
  9813. this.handleMouseUp = (ev) => {
  9814. document.removeEventListener('mousemove', this.handleMouseMove);
  9815. document.removeEventListener('mouseup', this.handleMouseUp);
  9816. this.emitter.trigger('pointerup', this.createEventFromMouse(ev));
  9817. this.cleanup(); // call last so that pointerup has access to props
  9818. };
  9819. // Touch
  9820. // ----------------------------------------------------------------------------------------------------
  9821. this.handleTouchStart = (ev) => {
  9822. if (this.tryStart(ev)) {
  9823. this.isTouchDragging = true;
  9824. let pev = this.createEventFromTouch(ev, true);
  9825. this.emitter.trigger('pointerdown', pev);
  9826. this.initScrollWatch(pev);
  9827. // unlike mouse, need to attach to target, not document
  9828. // https://stackoverflow.com/a/45760014
  9829. let targetEl = ev.target;
  9830. if (!this.shouldIgnoreMove) {
  9831. targetEl.addEventListener('touchmove', this.handleTouchMove);
  9832. }
  9833. targetEl.addEventListener('touchend', this.handleTouchEnd);
  9834. targetEl.addEventListener('touchcancel', this.handleTouchEnd); // treat it as a touch end
  9835. // attach a handler to get called when ANY scroll action happens on the page.
  9836. // this was impossible to do with normal on/off because 'scroll' doesn't bubble.
  9837. // http://stackoverflow.com/a/32954565/96342
  9838. window.addEventListener('scroll', this.handleTouchScroll, true);
  9839. }
  9840. };
  9841. this.handleTouchMove = (ev) => {
  9842. let pev = this.createEventFromTouch(ev);
  9843. this.recordCoords(pev);
  9844. this.emitter.trigger('pointermove', pev);
  9845. };
  9846. this.handleTouchEnd = (ev) => {
  9847. if (this.isDragging) { // done to guard against touchend followed by touchcancel
  9848. let targetEl = ev.target;
  9849. targetEl.removeEventListener('touchmove', this.handleTouchMove);
  9850. targetEl.removeEventListener('touchend', this.handleTouchEnd);
  9851. targetEl.removeEventListener('touchcancel', this.handleTouchEnd);
  9852. window.removeEventListener('scroll', this.handleTouchScroll, true); // useCaptured=true
  9853. this.emitter.trigger('pointerup', this.createEventFromTouch(ev));
  9854. this.cleanup(); // call last so that pointerup has access to props
  9855. this.isTouchDragging = false;
  9856. startIgnoringMouse();
  9857. }
  9858. };
  9859. this.handleTouchScroll = () => {
  9860. this.wasTouchScroll = true;
  9861. };
  9862. this.handleScroll = (ev) => {
  9863. if (!this.shouldIgnoreMove) {
  9864. let pageX = (window.scrollX - this.prevScrollX) + this.prevPageX;
  9865. let pageY = (window.scrollY - this.prevScrollY) + this.prevPageY;
  9866. this.emitter.trigger('pointermove', {
  9867. origEvent: ev,
  9868. isTouch: this.isTouchDragging,
  9869. subjectEl: this.subjectEl,
  9870. pageX,
  9871. pageY,
  9872. deltaX: pageX - this.origPageX,
  9873. deltaY: pageY - this.origPageY,
  9874. });
  9875. }
  9876. };
  9877. this.containerEl = containerEl;
  9878. this.emitter = new Emitter();
  9879. containerEl.addEventListener('mousedown', this.handleMouseDown);
  9880. containerEl.addEventListener('touchstart', this.handleTouchStart, { passive: true });
  9881. listenerCreated();
  9882. }
  9883. destroy() {
  9884. this.containerEl.removeEventListener('mousedown', this.handleMouseDown);
  9885. this.containerEl.removeEventListener('touchstart', this.handleTouchStart, { passive: true });
  9886. listenerDestroyed();
  9887. }
  9888. tryStart(ev) {
  9889. let subjectEl = this.querySubjectEl(ev);
  9890. let downEl = ev.target;
  9891. if (subjectEl &&
  9892. (!this.handleSelector || elementClosest(downEl, this.handleSelector))) {
  9893. this.subjectEl = subjectEl;
  9894. this.isDragging = true; // do this first so cancelTouchScroll will work
  9895. this.wasTouchScroll = false;
  9896. return true;
  9897. }
  9898. return false;
  9899. }
  9900. cleanup() {
  9901. isWindowTouchMoveCancelled = false;
  9902. this.isDragging = false;
  9903. this.subjectEl = null;
  9904. // keep wasTouchScroll around for later access
  9905. this.destroyScrollWatch();
  9906. }
  9907. querySubjectEl(ev) {
  9908. if (this.selector) {
  9909. return elementClosest(ev.target, this.selector);
  9910. }
  9911. return this.containerEl;
  9912. }
  9913. shouldIgnoreMouse() {
  9914. return ignoreMouseDepth || this.isTouchDragging;
  9915. }
  9916. // can be called by user of this class, to cancel touch-based scrolling for the current drag
  9917. cancelTouchScroll() {
  9918. if (this.isDragging) {
  9919. isWindowTouchMoveCancelled = true;
  9920. }
  9921. }
  9922. // Scrolling that simulates pointermoves
  9923. // ----------------------------------------------------------------------------------------------------
  9924. initScrollWatch(ev) {
  9925. if (this.shouldWatchScroll) {
  9926. this.recordCoords(ev);
  9927. window.addEventListener('scroll', this.handleScroll, true); // useCapture=true
  9928. }
  9929. }
  9930. recordCoords(ev) {
  9931. if (this.shouldWatchScroll) {
  9932. this.prevPageX = ev.pageX;
  9933. this.prevPageY = ev.pageY;
  9934. this.prevScrollX = window.scrollX;
  9935. this.prevScrollY = window.scrollY;
  9936. }
  9937. }
  9938. destroyScrollWatch() {
  9939. if (this.shouldWatchScroll) {
  9940. window.removeEventListener('scroll', this.handleScroll, true); // useCaptured=true
  9941. }
  9942. }
  9943. // Event Normalization
  9944. // ----------------------------------------------------------------------------------------------------
  9945. createEventFromMouse(ev, isFirst) {
  9946. let deltaX = 0;
  9947. let deltaY = 0;
  9948. // TODO: repeat code
  9949. if (isFirst) {
  9950. this.origPageX = ev.pageX;
  9951. this.origPageY = ev.pageY;
  9952. }
  9953. else {
  9954. deltaX = ev.pageX - this.origPageX;
  9955. deltaY = ev.pageY - this.origPageY;
  9956. }
  9957. return {
  9958. origEvent: ev,
  9959. isTouch: false,
  9960. subjectEl: this.subjectEl,
  9961. pageX: ev.pageX,
  9962. pageY: ev.pageY,
  9963. deltaX,
  9964. deltaY,
  9965. };
  9966. }
  9967. createEventFromTouch(ev, isFirst) {
  9968. let touches = ev.touches;
  9969. let pageX;
  9970. let pageY;
  9971. let deltaX = 0;
  9972. let deltaY = 0;
  9973. // if touch coords available, prefer,
  9974. // because FF would give bad ev.pageX ev.pageY
  9975. if (touches && touches.length) {
  9976. pageX = touches[0].pageX;
  9977. pageY = touches[0].pageY;
  9978. }
  9979. else {
  9980. pageX = ev.pageX;
  9981. pageY = ev.pageY;
  9982. }
  9983. // TODO: repeat code
  9984. if (isFirst) {
  9985. this.origPageX = pageX;
  9986. this.origPageY = pageY;
  9987. }
  9988. else {
  9989. deltaX = pageX - this.origPageX;
  9990. deltaY = pageY - this.origPageY;
  9991. }
  9992. return {
  9993. origEvent: ev,
  9994. isTouch: true,
  9995. subjectEl: this.subjectEl,
  9996. pageX,
  9997. pageY,
  9998. deltaX,
  9999. deltaY,
  10000. };
  10001. }
  10002. }
  10003. // Returns a boolean whether this was a left mouse click and no ctrl key (which means right click on Mac)
  10004. function isPrimaryMouseButton(ev) {
  10005. return ev.button === 0 && !ev.ctrlKey;
  10006. }
  10007. // Ignoring fake mouse events generated by touch
  10008. // ----------------------------------------------------------------------------------------------------
  10009. function startIgnoringMouse() {
  10010. ignoreMouseDepth += 1;
  10011. setTimeout(() => {
  10012. ignoreMouseDepth -= 1;
  10013. }, config.touchMouseIgnoreWait);
  10014. }
  10015. // We want to attach touchmove as early as possible for Safari
  10016. // ----------------------------------------------------------------------------------------------------
  10017. function listenerCreated() {
  10018. listenerCnt += 1;
  10019. if (listenerCnt === 1) {
  10020. window.addEventListener('touchmove', onWindowTouchMove, { passive: false });
  10021. }
  10022. }
  10023. function listenerDestroyed() {
  10024. listenerCnt -= 1;
  10025. if (!listenerCnt) {
  10026. window.removeEventListener('touchmove', onWindowTouchMove, { passive: false });
  10027. }
  10028. }
  10029. function onWindowTouchMove(ev) {
  10030. if (isWindowTouchMoveCancelled) {
  10031. ev.preventDefault();
  10032. }
  10033. }
  10034. /*
  10035. An effect in which an element follows the movement of a pointer across the screen.
  10036. The moving element is a clone of some other element.
  10037. Must call start + handleMove + stop.
  10038. */
  10039. class ElementMirror {
  10040. constructor() {
  10041. this.isVisible = false; // must be explicitly enabled
  10042. this.sourceEl = null;
  10043. this.mirrorEl = null;
  10044. this.sourceElRect = null; // screen coords relative to viewport
  10045. // options that can be set directly by caller
  10046. this.parentNode = document.body; // HIGHLY SUGGESTED to set this to sidestep ShadowDOM issues
  10047. this.zIndex = 9999;
  10048. this.revertDuration = 0;
  10049. }
  10050. start(sourceEl, pageX, pageY) {
  10051. this.sourceEl = sourceEl;
  10052. this.sourceElRect = this.sourceEl.getBoundingClientRect();
  10053. this.origScreenX = pageX - window.scrollX;
  10054. this.origScreenY = pageY - window.scrollY;
  10055. this.deltaX = 0;
  10056. this.deltaY = 0;
  10057. this.updateElPosition();
  10058. }
  10059. handleMove(pageX, pageY) {
  10060. this.deltaX = (pageX - window.scrollX) - this.origScreenX;
  10061. this.deltaY = (pageY - window.scrollY) - this.origScreenY;
  10062. this.updateElPosition();
  10063. }
  10064. // can be called before start
  10065. setIsVisible(bool) {
  10066. if (bool) {
  10067. if (!this.isVisible) {
  10068. if (this.mirrorEl) {
  10069. this.mirrorEl.style.display = '';
  10070. }
  10071. this.isVisible = bool; // needs to happen before updateElPosition
  10072. this.updateElPosition(); // because was not updating the position while invisible
  10073. }
  10074. }
  10075. else if (this.isVisible) {
  10076. if (this.mirrorEl) {
  10077. this.mirrorEl.style.display = 'none';
  10078. }
  10079. this.isVisible = bool;
  10080. }
  10081. }
  10082. // always async
  10083. stop(needsRevertAnimation, callback) {
  10084. let done = () => {
  10085. this.cleanup();
  10086. callback();
  10087. };
  10088. if (needsRevertAnimation &&
  10089. this.mirrorEl &&
  10090. this.isVisible &&
  10091. this.revertDuration && // if 0, transition won't work
  10092. (this.deltaX || this.deltaY) // if same coords, transition won't work
  10093. ) {
  10094. this.doRevertAnimation(done, this.revertDuration);
  10095. }
  10096. else {
  10097. setTimeout(done, 0);
  10098. }
  10099. }
  10100. doRevertAnimation(callback, revertDuration) {
  10101. let mirrorEl = this.mirrorEl;
  10102. let finalSourceElRect = this.sourceEl.getBoundingClientRect(); // because autoscrolling might have happened
  10103. mirrorEl.style.transition =
  10104. 'top ' + revertDuration + 'ms,' +
  10105. 'left ' + revertDuration + 'ms';
  10106. applyStyle(mirrorEl, {
  10107. left: finalSourceElRect.left,
  10108. top: finalSourceElRect.top,
  10109. });
  10110. whenTransitionDone(mirrorEl, () => {
  10111. mirrorEl.style.transition = '';
  10112. callback();
  10113. });
  10114. }
  10115. cleanup() {
  10116. if (this.mirrorEl) {
  10117. removeElement(this.mirrorEl);
  10118. this.mirrorEl = null;
  10119. }
  10120. this.sourceEl = null;
  10121. }
  10122. updateElPosition() {
  10123. if (this.sourceEl && this.isVisible) {
  10124. applyStyle(this.getMirrorEl(), {
  10125. left: this.sourceElRect.left + this.deltaX,
  10126. top: this.sourceElRect.top + this.deltaY,
  10127. });
  10128. }
  10129. }
  10130. getMirrorEl() {
  10131. let sourceElRect = this.sourceElRect;
  10132. let mirrorEl = this.mirrorEl;
  10133. if (!mirrorEl) {
  10134. mirrorEl = this.mirrorEl = this.sourceEl.cloneNode(true); // cloneChildren=true
  10135. // we don't want long taps or any mouse interaction causing selection/menus.
  10136. // would use preventSelection(), but that prevents selectstart, causing problems.
  10137. mirrorEl.style.userSelect = 'none';
  10138. mirrorEl.style.webkitUserSelect = 'none';
  10139. mirrorEl.style.pointerEvents = 'none';
  10140. mirrorEl.classList.add('fc-event-dragging');
  10141. applyStyle(mirrorEl, {
  10142. position: 'fixed',
  10143. zIndex: this.zIndex,
  10144. visibility: '',
  10145. boxSizing: 'border-box',
  10146. width: sourceElRect.right - sourceElRect.left,
  10147. height: sourceElRect.bottom - sourceElRect.top,
  10148. right: 'auto',
  10149. bottom: 'auto',
  10150. margin: 0,
  10151. });
  10152. this.parentNode.appendChild(mirrorEl);
  10153. }
  10154. return mirrorEl;
  10155. }
  10156. }
  10157. /*
  10158. Is a cache for a given element's scroll information (all the info that ScrollController stores)
  10159. in addition the "client rectangle" of the element.. the area within the scrollbars.
  10160. The cache can be in one of two modes:
  10161. - doesListening:false - ignores when the container is scrolled by someone else
  10162. - doesListening:true - watch for scrolling and update the cache
  10163. */
  10164. class ScrollGeomCache extends ScrollController {
  10165. constructor(scrollController, doesListening) {
  10166. super();
  10167. this.handleScroll = () => {
  10168. this.scrollTop = this.scrollController.getScrollTop();
  10169. this.scrollLeft = this.scrollController.getScrollLeft();
  10170. this.handleScrollChange();
  10171. };
  10172. this.scrollController = scrollController;
  10173. this.doesListening = doesListening;
  10174. this.scrollTop = this.origScrollTop = scrollController.getScrollTop();
  10175. this.scrollLeft = this.origScrollLeft = scrollController.getScrollLeft();
  10176. this.scrollWidth = scrollController.getScrollWidth();
  10177. this.scrollHeight = scrollController.getScrollHeight();
  10178. this.clientWidth = scrollController.getClientWidth();
  10179. this.clientHeight = scrollController.getClientHeight();
  10180. this.clientRect = this.computeClientRect(); // do last in case it needs cached values
  10181. if (this.doesListening) {
  10182. this.getEventTarget().addEventListener('scroll', this.handleScroll);
  10183. }
  10184. }
  10185. destroy() {
  10186. if (this.doesListening) {
  10187. this.getEventTarget().removeEventListener('scroll', this.handleScroll);
  10188. }
  10189. }
  10190. getScrollTop() {
  10191. return this.scrollTop;
  10192. }
  10193. getScrollLeft() {
  10194. return this.scrollLeft;
  10195. }
  10196. setScrollTop(top) {
  10197. this.scrollController.setScrollTop(top);
  10198. if (!this.doesListening) {
  10199. // we are not relying on the element to normalize out-of-bounds scroll values
  10200. // so we need to sanitize ourselves
  10201. this.scrollTop = Math.max(Math.min(top, this.getMaxScrollTop()), 0);
  10202. this.handleScrollChange();
  10203. }
  10204. }
  10205. setScrollLeft(top) {
  10206. this.scrollController.setScrollLeft(top);
  10207. if (!this.doesListening) {
  10208. // we are not relying on the element to normalize out-of-bounds scroll values
  10209. // so we need to sanitize ourselves
  10210. this.scrollLeft = Math.max(Math.min(top, this.getMaxScrollLeft()), 0);
  10211. this.handleScrollChange();
  10212. }
  10213. }
  10214. getClientWidth() {
  10215. return this.clientWidth;
  10216. }
  10217. getClientHeight() {
  10218. return this.clientHeight;
  10219. }
  10220. getScrollWidth() {
  10221. return this.scrollWidth;
  10222. }
  10223. getScrollHeight() {
  10224. return this.scrollHeight;
  10225. }
  10226. handleScrollChange() {
  10227. }
  10228. }
  10229. class ElementScrollGeomCache extends ScrollGeomCache {
  10230. constructor(el, doesListening) {
  10231. super(new ElementScrollController(el), doesListening);
  10232. }
  10233. getEventTarget() {
  10234. return this.scrollController.el;
  10235. }
  10236. computeClientRect() {
  10237. return computeInnerRect(this.scrollController.el);
  10238. }
  10239. }
  10240. class WindowScrollGeomCache extends ScrollGeomCache {
  10241. constructor(doesListening) {
  10242. super(new WindowScrollController(), doesListening);
  10243. }
  10244. getEventTarget() {
  10245. return window;
  10246. }
  10247. computeClientRect() {
  10248. return {
  10249. left: this.scrollLeft,
  10250. right: this.scrollLeft + this.clientWidth,
  10251. top: this.scrollTop,
  10252. bottom: this.scrollTop + this.clientHeight,
  10253. };
  10254. }
  10255. // the window is the only scroll object that changes it's rectangle relative
  10256. // to the document's topleft as it scrolls
  10257. handleScrollChange() {
  10258. this.clientRect = this.computeClientRect();
  10259. }
  10260. }
  10261. // If available we are using native "performance" API instead of "Date"
  10262. // Read more about it on MDN:
  10263. // https://developer.mozilla.org/en-US/docs/Web/API/Performance
  10264. const getTime = typeof performance === 'function' ? performance.now : Date.now;
  10265. /*
  10266. For a pointer interaction, automatically scrolls certain scroll containers when the pointer
  10267. approaches the edge.
  10268. The caller must call start + handleMove + stop.
  10269. */
  10270. class AutoScroller {
  10271. constructor() {
  10272. // options that can be set by caller
  10273. this.isEnabled = true;
  10274. this.scrollQuery = [window, '.fc-scroller'];
  10275. this.edgeThreshold = 50; // pixels
  10276. this.maxVelocity = 300; // pixels per second
  10277. // internal state
  10278. this.pointerScreenX = null;
  10279. this.pointerScreenY = null;
  10280. this.isAnimating = false;
  10281. this.scrollCaches = null;
  10282. // protect against the initial pointerdown being too close to an edge and starting the scroll
  10283. this.everMovedUp = false;
  10284. this.everMovedDown = false;
  10285. this.everMovedLeft = false;
  10286. this.everMovedRight = false;
  10287. this.animate = () => {
  10288. if (this.isAnimating) { // wasn't cancelled between animation calls
  10289. let edge = this.computeBestEdge(this.pointerScreenX + window.scrollX, this.pointerScreenY + window.scrollY);
  10290. if (edge) {
  10291. let now = getTime();
  10292. this.handleSide(edge, (now - this.msSinceRequest) / 1000);
  10293. this.requestAnimation(now);
  10294. }
  10295. else {
  10296. this.isAnimating = false; // will stop animation
  10297. }
  10298. }
  10299. };
  10300. }
  10301. start(pageX, pageY, scrollStartEl) {
  10302. if (this.isEnabled) {
  10303. this.scrollCaches = this.buildCaches(scrollStartEl);
  10304. this.pointerScreenX = null;
  10305. this.pointerScreenY = null;
  10306. this.everMovedUp = false;
  10307. this.everMovedDown = false;
  10308. this.everMovedLeft = false;
  10309. this.everMovedRight = false;
  10310. this.handleMove(pageX, pageY);
  10311. }
  10312. }
  10313. handleMove(pageX, pageY) {
  10314. if (this.isEnabled) {
  10315. let pointerScreenX = pageX - window.scrollX;
  10316. let pointerScreenY = pageY - window.scrollY;
  10317. let yDelta = this.pointerScreenY === null ? 0 : pointerScreenY - this.pointerScreenY;
  10318. let xDelta = this.pointerScreenX === null ? 0 : pointerScreenX - this.pointerScreenX;
  10319. if (yDelta < 0) {
  10320. this.everMovedUp = true;
  10321. }
  10322. else if (yDelta > 0) {
  10323. this.everMovedDown = true;
  10324. }
  10325. if (xDelta < 0) {
  10326. this.everMovedLeft = true;
  10327. }
  10328. else if (xDelta > 0) {
  10329. this.everMovedRight = true;
  10330. }
  10331. this.pointerScreenX = pointerScreenX;
  10332. this.pointerScreenY = pointerScreenY;
  10333. if (!this.isAnimating) {
  10334. this.isAnimating = true;
  10335. this.requestAnimation(getTime());
  10336. }
  10337. }
  10338. }
  10339. stop() {
  10340. if (this.isEnabled) {
  10341. this.isAnimating = false; // will stop animation
  10342. for (let scrollCache of this.scrollCaches) {
  10343. scrollCache.destroy();
  10344. }
  10345. this.scrollCaches = null;
  10346. }
  10347. }
  10348. requestAnimation(now) {
  10349. this.msSinceRequest = now;
  10350. requestAnimationFrame(this.animate);
  10351. }
  10352. handleSide(edge, seconds) {
  10353. let { scrollCache } = edge;
  10354. let { edgeThreshold } = this;
  10355. let invDistance = edgeThreshold - edge.distance;
  10356. let velocity = // the closer to the edge, the faster we scroll
  10357. ((invDistance * invDistance) / (edgeThreshold * edgeThreshold)) * // quadratic
  10358. this.maxVelocity * seconds;
  10359. let sign = 1;
  10360. switch (edge.name) {
  10361. case 'left':
  10362. sign = -1;
  10363. // falls through
  10364. case 'right':
  10365. scrollCache.setScrollLeft(scrollCache.getScrollLeft() + velocity * sign);
  10366. break;
  10367. case 'top':
  10368. sign = -1;
  10369. // falls through
  10370. case 'bottom':
  10371. scrollCache.setScrollTop(scrollCache.getScrollTop() + velocity * sign);
  10372. break;
  10373. }
  10374. }
  10375. // left/top are relative to document topleft
  10376. computeBestEdge(left, top) {
  10377. let { edgeThreshold } = this;
  10378. let bestSide = null;
  10379. let scrollCaches = this.scrollCaches || [];
  10380. for (let scrollCache of scrollCaches) {
  10381. let rect = scrollCache.clientRect;
  10382. let leftDist = left - rect.left;
  10383. let rightDist = rect.right - left;
  10384. let topDist = top - rect.top;
  10385. let bottomDist = rect.bottom - top;
  10386. // completely within the rect?
  10387. if (leftDist >= 0 && rightDist >= 0 && topDist >= 0 && bottomDist >= 0) {
  10388. if (topDist <= edgeThreshold && this.everMovedUp && scrollCache.canScrollUp() &&
  10389. (!bestSide || bestSide.distance > topDist)) {
  10390. bestSide = { scrollCache, name: 'top', distance: topDist };
  10391. }
  10392. if (bottomDist <= edgeThreshold && this.everMovedDown && scrollCache.canScrollDown() &&
  10393. (!bestSide || bestSide.distance > bottomDist)) {
  10394. bestSide = { scrollCache, name: 'bottom', distance: bottomDist };
  10395. }
  10396. /*
  10397. TODO: fix broken RTL scrolling. canScrollLeft always returning false
  10398. https://github.com/fullcalendar/fullcalendar/issues/4837
  10399. */
  10400. if (leftDist <= edgeThreshold && this.everMovedLeft && scrollCache.canScrollLeft() &&
  10401. (!bestSide || bestSide.distance > leftDist)) {
  10402. bestSide = { scrollCache, name: 'left', distance: leftDist };
  10403. }
  10404. if (rightDist <= edgeThreshold && this.everMovedRight && scrollCache.canScrollRight() &&
  10405. (!bestSide || bestSide.distance > rightDist)) {
  10406. bestSide = { scrollCache, name: 'right', distance: rightDist };
  10407. }
  10408. }
  10409. }
  10410. return bestSide;
  10411. }
  10412. buildCaches(scrollStartEl) {
  10413. return this.queryScrollEls(scrollStartEl).map((el) => {
  10414. if (el === window) {
  10415. return new WindowScrollGeomCache(false); // false = don't listen to user-generated scrolls
  10416. }
  10417. return new ElementScrollGeomCache(el, false); // false = don't listen to user-generated scrolls
  10418. });
  10419. }
  10420. queryScrollEls(scrollStartEl) {
  10421. let els = [];
  10422. for (let query of this.scrollQuery) {
  10423. if (typeof query === 'object') {
  10424. els.push(query);
  10425. }
  10426. else {
  10427. /*
  10428. TODO: in the future, always have auto-scroll happen on element where current Hit came from
  10429. Ticket: https://github.com/fullcalendar/fullcalendar/issues/4593
  10430. */
  10431. els.push(...Array.prototype.slice.call(scrollStartEl.getRootNode().querySelectorAll(query)));
  10432. }
  10433. }
  10434. return els;
  10435. }
  10436. }
  10437. /*
  10438. Monitors dragging on an element. Has a number of high-level features:
  10439. - minimum distance required before dragging
  10440. - minimum wait time ("delay") before dragging
  10441. - a mirror element that follows the pointer
  10442. */
  10443. class FeaturefulElementDragging extends ElementDragging {
  10444. constructor(containerEl, selector) {
  10445. super(containerEl);
  10446. this.containerEl = containerEl;
  10447. // options that can be directly set by caller
  10448. // the caller can also set the PointerDragging's options as well
  10449. this.delay = null;
  10450. this.minDistance = 0;
  10451. this.touchScrollAllowed = true; // prevents drag from starting and blocks scrolling during drag
  10452. this.mirrorNeedsRevert = false;
  10453. this.isInteracting = false; // is the user validly moving the pointer? lasts until pointerup
  10454. this.isDragging = false; // is it INTENTFULLY dragging? lasts until after revert animation
  10455. this.isDelayEnded = false;
  10456. this.isDistanceSurpassed = false;
  10457. this.delayTimeoutId = null;
  10458. this.onPointerDown = (ev) => {
  10459. if (!this.isDragging) { // so new drag doesn't happen while revert animation is going
  10460. this.isInteracting = true;
  10461. this.isDelayEnded = false;
  10462. this.isDistanceSurpassed = false;
  10463. preventSelection(document.body);
  10464. preventContextMenu(document.body);
  10465. // prevent links from being visited if there's an eventual drag.
  10466. // also prevents selection in older browsers (maybe?).
  10467. // not necessary for touch, besides, browser would complain about passiveness.
  10468. if (!ev.isTouch) {
  10469. ev.origEvent.preventDefault();
  10470. }
  10471. this.emitter.trigger('pointerdown', ev);
  10472. if (this.isInteracting && // not destroyed via pointerdown handler
  10473. !this.pointer.shouldIgnoreMove) {
  10474. // actions related to initiating dragstart+dragmove+dragend...
  10475. this.mirror.setIsVisible(false); // reset. caller must set-visible
  10476. this.mirror.start(ev.subjectEl, ev.pageX, ev.pageY); // must happen on first pointer down
  10477. this.startDelay(ev);
  10478. if (!this.minDistance) {
  10479. this.handleDistanceSurpassed(ev);
  10480. }
  10481. }
  10482. }
  10483. };
  10484. this.onPointerMove = (ev) => {
  10485. if (this.isInteracting) {
  10486. this.emitter.trigger('pointermove', ev);
  10487. if (!this.isDistanceSurpassed) {
  10488. let minDistance = this.minDistance;
  10489. let distanceSq; // current distance from the origin, squared
  10490. let { deltaX, deltaY } = ev;
  10491. distanceSq = deltaX * deltaX + deltaY * deltaY;
  10492. if (distanceSq >= minDistance * minDistance) { // use pythagorean theorem
  10493. this.handleDistanceSurpassed(ev);
  10494. }
  10495. }
  10496. if (this.isDragging) {
  10497. // a real pointer move? (not one simulated by scrolling)
  10498. if (ev.origEvent.type !== 'scroll') {
  10499. this.mirror.handleMove(ev.pageX, ev.pageY);
  10500. this.autoScroller.handleMove(ev.pageX, ev.pageY);
  10501. }
  10502. this.emitter.trigger('dragmove', ev);
  10503. }
  10504. }
  10505. };
  10506. this.onPointerUp = (ev) => {
  10507. if (this.isInteracting) {
  10508. this.isInteracting = false;
  10509. allowSelection(document.body);
  10510. allowContextMenu(document.body);
  10511. this.emitter.trigger('pointerup', ev); // can potentially set mirrorNeedsRevert
  10512. if (this.isDragging) {
  10513. this.autoScroller.stop();
  10514. this.tryStopDrag(ev); // which will stop the mirror
  10515. }
  10516. if (this.delayTimeoutId) {
  10517. clearTimeout(this.delayTimeoutId);
  10518. this.delayTimeoutId = null;
  10519. }
  10520. }
  10521. };
  10522. let pointer = this.pointer = new PointerDragging(containerEl);
  10523. pointer.emitter.on('pointerdown', this.onPointerDown);
  10524. pointer.emitter.on('pointermove', this.onPointerMove);
  10525. pointer.emitter.on('pointerup', this.onPointerUp);
  10526. if (selector) {
  10527. pointer.selector = selector;
  10528. }
  10529. this.mirror = new ElementMirror();
  10530. this.autoScroller = new AutoScroller();
  10531. }
  10532. destroy() {
  10533. this.pointer.destroy();
  10534. // HACK: simulate a pointer-up to end the current drag
  10535. // TODO: fire 'dragend' directly and stop interaction. discourage use of pointerup event (b/c might not fire)
  10536. this.onPointerUp({});
  10537. }
  10538. startDelay(ev) {
  10539. if (typeof this.delay === 'number') {
  10540. this.delayTimeoutId = setTimeout(() => {
  10541. this.delayTimeoutId = null;
  10542. this.handleDelayEnd(ev);
  10543. }, this.delay); // not assignable to number!
  10544. }
  10545. else {
  10546. this.handleDelayEnd(ev);
  10547. }
  10548. }
  10549. handleDelayEnd(ev) {
  10550. this.isDelayEnded = true;
  10551. this.tryStartDrag(ev);
  10552. }
  10553. handleDistanceSurpassed(ev) {
  10554. this.isDistanceSurpassed = true;
  10555. this.tryStartDrag(ev);
  10556. }
  10557. tryStartDrag(ev) {
  10558. if (this.isDelayEnded && this.isDistanceSurpassed) {
  10559. if (!this.pointer.wasTouchScroll || this.touchScrollAllowed) {
  10560. this.isDragging = true;
  10561. this.mirrorNeedsRevert = false;
  10562. this.autoScroller.start(ev.pageX, ev.pageY, this.containerEl);
  10563. this.emitter.trigger('dragstart', ev);
  10564. if (this.touchScrollAllowed === false) {
  10565. this.pointer.cancelTouchScroll();
  10566. }
  10567. }
  10568. }
  10569. }
  10570. tryStopDrag(ev) {
  10571. // .stop() is ALWAYS asynchronous, which we NEED because we want all pointerup events
  10572. // that come from the document to fire beforehand. much more convenient this way.
  10573. this.mirror.stop(this.mirrorNeedsRevert, this.stopDrag.bind(this, ev));
  10574. }
  10575. stopDrag(ev) {
  10576. this.isDragging = false;
  10577. this.emitter.trigger('dragend', ev);
  10578. }
  10579. // fill in the implementations...
  10580. setIgnoreMove(bool) {
  10581. this.pointer.shouldIgnoreMove = bool;
  10582. }
  10583. setMirrorIsVisible(bool) {
  10584. this.mirror.setIsVisible(bool);
  10585. }
  10586. setMirrorNeedsRevert(bool) {
  10587. this.mirrorNeedsRevert = bool;
  10588. }
  10589. setAutoScrollEnabled(bool) {
  10590. this.autoScroller.isEnabled = bool;
  10591. }
  10592. }
  10593. /*
  10594. When this class is instantiated, it records the offset of an element (relative to the document topleft),
  10595. and continues to monitor scrolling, updating the cached coordinates if it needs to.
  10596. Does not access the DOM after instantiation, so highly performant.
  10597. Also keeps track of all scrolling/overflow:hidden containers that are parents of the given element
  10598. and an determine if a given point is inside the combined clipping rectangle.
  10599. */
  10600. class OffsetTracker {
  10601. constructor(el) {
  10602. this.el = el;
  10603. this.origRect = computeRect(el);
  10604. // will work fine for divs that have overflow:hidden
  10605. this.scrollCaches = getClippingParents(el).map((scrollEl) => new ElementScrollGeomCache(scrollEl, true));
  10606. }
  10607. destroy() {
  10608. for (let scrollCache of this.scrollCaches) {
  10609. scrollCache.destroy();
  10610. }
  10611. }
  10612. computeLeft() {
  10613. let left = this.origRect.left;
  10614. for (let scrollCache of this.scrollCaches) {
  10615. left += scrollCache.origScrollLeft - scrollCache.getScrollLeft();
  10616. }
  10617. return left;
  10618. }
  10619. computeTop() {
  10620. let top = this.origRect.top;
  10621. for (let scrollCache of this.scrollCaches) {
  10622. top += scrollCache.origScrollTop - scrollCache.getScrollTop();
  10623. }
  10624. return top;
  10625. }
  10626. isWithinClipping(pageX, pageY) {
  10627. let point = { left: pageX, top: pageY };
  10628. for (let scrollCache of this.scrollCaches) {
  10629. if (!isIgnoredClipping(scrollCache.getEventTarget()) &&
  10630. !pointInsideRect(point, scrollCache.clientRect)) {
  10631. return false;
  10632. }
  10633. }
  10634. return true;
  10635. }
  10636. }
  10637. // certain clipping containers should never constrain interactions, like <html> and <body>
  10638. // https://github.com/fullcalendar/fullcalendar/issues/3615
  10639. function isIgnoredClipping(node) {
  10640. let tagName = node.tagName;
  10641. return tagName === 'HTML' || tagName === 'BODY';
  10642. }
  10643. /*
  10644. Tracks movement over multiple droppable areas (aka "hits")
  10645. that exist in one or more DateComponents.
  10646. Relies on an existing draggable.
  10647. emits:
  10648. - pointerdown
  10649. - dragstart
  10650. - hitchange - fires initially, even if not over a hit
  10651. - pointerup
  10652. - (hitchange - again, to null, if ended over a hit)
  10653. - dragend
  10654. */
  10655. class HitDragging {
  10656. constructor(dragging, droppableStore) {
  10657. // options that can be set by caller
  10658. this.useSubjectCenter = false;
  10659. this.requireInitial = true; // if doesn't start out on a hit, won't emit any events
  10660. this.disablePointCheck = false;
  10661. this.initialHit = null;
  10662. this.movingHit = null;
  10663. this.finalHit = null; // won't ever be populated if shouldIgnoreMove
  10664. this.handlePointerDown = (ev) => {
  10665. let { dragging } = this;
  10666. this.initialHit = null;
  10667. this.movingHit = null;
  10668. this.finalHit = null;
  10669. this.prepareHits();
  10670. this.processFirstCoord(ev);
  10671. if (this.initialHit || !this.requireInitial) {
  10672. dragging.setIgnoreMove(false);
  10673. // TODO: fire this before computing processFirstCoord, so listeners can cancel. this gets fired by almost every handler :(
  10674. this.emitter.trigger('pointerdown', ev);
  10675. }
  10676. else {
  10677. dragging.setIgnoreMove(true);
  10678. }
  10679. };
  10680. this.handleDragStart = (ev) => {
  10681. this.emitter.trigger('dragstart', ev);
  10682. this.handleMove(ev, true); // force = fire even if initially null
  10683. };
  10684. this.handleDragMove = (ev) => {
  10685. this.emitter.trigger('dragmove', ev);
  10686. this.handleMove(ev);
  10687. };
  10688. this.handlePointerUp = (ev) => {
  10689. this.releaseHits();
  10690. this.emitter.trigger('pointerup', ev);
  10691. };
  10692. this.handleDragEnd = (ev) => {
  10693. if (this.movingHit) {
  10694. this.emitter.trigger('hitupdate', null, true, ev);
  10695. }
  10696. this.finalHit = this.movingHit;
  10697. this.movingHit = null;
  10698. this.emitter.trigger('dragend', ev);
  10699. };
  10700. this.droppableStore = droppableStore;
  10701. dragging.emitter.on('pointerdown', this.handlePointerDown);
  10702. dragging.emitter.on('dragstart', this.handleDragStart);
  10703. dragging.emitter.on('dragmove', this.handleDragMove);
  10704. dragging.emitter.on('pointerup', this.handlePointerUp);
  10705. dragging.emitter.on('dragend', this.handleDragEnd);
  10706. this.dragging = dragging;
  10707. this.emitter = new Emitter();
  10708. }
  10709. // sets initialHit
  10710. // sets coordAdjust
  10711. processFirstCoord(ev) {
  10712. let origPoint = { left: ev.pageX, top: ev.pageY };
  10713. let adjustedPoint = origPoint;
  10714. let subjectEl = ev.subjectEl;
  10715. let subjectRect;
  10716. if (subjectEl instanceof HTMLElement) { // i.e. not a Document/ShadowRoot
  10717. subjectRect = computeRect(subjectEl);
  10718. adjustedPoint = constrainPoint(adjustedPoint, subjectRect);
  10719. }
  10720. let initialHit = this.initialHit = this.queryHitForOffset(adjustedPoint.left, adjustedPoint.top);
  10721. if (initialHit) {
  10722. if (this.useSubjectCenter && subjectRect) {
  10723. let slicedSubjectRect = intersectRects(subjectRect, initialHit.rect);
  10724. if (slicedSubjectRect) {
  10725. adjustedPoint = getRectCenter(slicedSubjectRect);
  10726. }
  10727. }
  10728. this.coordAdjust = diffPoints(adjustedPoint, origPoint);
  10729. }
  10730. else {
  10731. this.coordAdjust = { left: 0, top: 0 };
  10732. }
  10733. }
  10734. handleMove(ev, forceHandle) {
  10735. let hit = this.queryHitForOffset(ev.pageX + this.coordAdjust.left, ev.pageY + this.coordAdjust.top);
  10736. if (forceHandle || !isHitsEqual(this.movingHit, hit)) {
  10737. this.movingHit = hit;
  10738. this.emitter.trigger('hitupdate', hit, false, ev);
  10739. }
  10740. }
  10741. prepareHits() {
  10742. this.offsetTrackers = mapHash(this.droppableStore, (interactionSettings) => {
  10743. interactionSettings.component.prepareHits();
  10744. return new OffsetTracker(interactionSettings.el);
  10745. });
  10746. }
  10747. releaseHits() {
  10748. let { offsetTrackers } = this;
  10749. for (let id in offsetTrackers) {
  10750. offsetTrackers[id].destroy();
  10751. }
  10752. this.offsetTrackers = {};
  10753. }
  10754. queryHitForOffset(offsetLeft, offsetTop) {
  10755. let { droppableStore, offsetTrackers } = this;
  10756. let bestHit = null;
  10757. for (let id in droppableStore) {
  10758. let component = droppableStore[id].component;
  10759. let offsetTracker = offsetTrackers[id];
  10760. if (offsetTracker && // wasn't destroyed mid-drag
  10761. offsetTracker.isWithinClipping(offsetLeft, offsetTop)) {
  10762. let originLeft = offsetTracker.computeLeft();
  10763. let originTop = offsetTracker.computeTop();
  10764. let positionLeft = offsetLeft - originLeft;
  10765. let positionTop = offsetTop - originTop;
  10766. let { origRect } = offsetTracker;
  10767. let width = origRect.right - origRect.left;
  10768. let height = origRect.bottom - origRect.top;
  10769. if (
  10770. // must be within the element's bounds
  10771. positionLeft >= 0 && positionLeft < width &&
  10772. positionTop >= 0 && positionTop < height) {
  10773. let hit = component.queryHit(positionLeft, positionTop, width, height);
  10774. if (hit && (
  10775. // make sure the hit is within activeRange, meaning it's not a dead cell
  10776. rangeContainsRange(hit.dateProfile.activeRange, hit.dateSpan.range)) &&
  10777. // Ensure the component we are querying for the hit is accessibly my the pointer
  10778. // Prevents obscured calendars (ex: under a modal dialog) from accepting hit
  10779. // https://github.com/fullcalendar/fullcalendar/issues/5026
  10780. (this.disablePointCheck ||
  10781. offsetTracker.el.contains(offsetTracker.el.getRootNode().elementFromPoint(
  10782. // add-back origins to get coordinate relative to top-left of window viewport
  10783. positionLeft + originLeft - window.scrollX, positionTop + originTop - window.scrollY))) &&
  10784. (!bestHit || hit.layer > bestHit.layer)) {
  10785. hit.componentId = id;
  10786. hit.context = component.context;
  10787. // TODO: better way to re-orient rectangle
  10788. hit.rect.left += originLeft;
  10789. hit.rect.right += originLeft;
  10790. hit.rect.top += originTop;
  10791. hit.rect.bottom += originTop;
  10792. bestHit = hit;
  10793. }
  10794. }
  10795. }
  10796. }
  10797. return bestHit;
  10798. }
  10799. }
  10800. function isHitsEqual(hit0, hit1) {
  10801. if (!hit0 && !hit1) {
  10802. return true;
  10803. }
  10804. if (Boolean(hit0) !== Boolean(hit1)) {
  10805. return false;
  10806. }
  10807. return isDateSpansEqual(hit0.dateSpan, hit1.dateSpan);
  10808. }
  10809. function buildDatePointApiWithContext(dateSpan, context) {
  10810. let props = {};
  10811. for (let transform of context.pluginHooks.datePointTransforms) {
  10812. Object.assign(props, transform(dateSpan, context));
  10813. }
  10814. Object.assign(props, buildDatePointApi(dateSpan, context.dateEnv));
  10815. return props;
  10816. }
  10817. function buildDatePointApi(span, dateEnv) {
  10818. return {
  10819. date: dateEnv.toDate(span.range.start),
  10820. dateStr: dateEnv.formatIso(span.range.start, { omitTime: span.allDay }),
  10821. allDay: span.allDay,
  10822. };
  10823. }
  10824. /*
  10825. Monitors when the user clicks on a specific date/time of a component.
  10826. A pointerdown+pointerup on the same "hit" constitutes a click.
  10827. */
  10828. class DateClicking extends Interaction {
  10829. constructor(settings) {
  10830. super(settings);
  10831. this.handlePointerDown = (pev) => {
  10832. let { dragging } = this;
  10833. let downEl = pev.origEvent.target;
  10834. // do this in pointerdown (not dragend) because DOM might be mutated by the time dragend is fired
  10835. dragging.setIgnoreMove(!this.component.isValidDateDownEl(downEl));
  10836. };
  10837. // won't even fire if moving was ignored
  10838. this.handleDragEnd = (ev) => {
  10839. let { component } = this;
  10840. let { pointer } = this.dragging;
  10841. if (!pointer.wasTouchScroll) {
  10842. let { initialHit, finalHit } = this.hitDragging;
  10843. if (initialHit && finalHit && isHitsEqual(initialHit, finalHit)) {
  10844. let { context } = component;
  10845. let arg = Object.assign(Object.assign({}, buildDatePointApiWithContext(initialHit.dateSpan, context)), { dayEl: initialHit.dayEl, jsEvent: ev.origEvent, view: context.viewApi || context.calendarApi.view });
  10846. context.emitter.trigger('dateClick', arg);
  10847. }
  10848. }
  10849. };
  10850. // we DO want to watch pointer moves because otherwise finalHit won't get populated
  10851. this.dragging = new FeaturefulElementDragging(settings.el);
  10852. this.dragging.autoScroller.isEnabled = false;
  10853. let hitDragging = this.hitDragging = new HitDragging(this.dragging, interactionSettingsToStore(settings));
  10854. hitDragging.emitter.on('pointerdown', this.handlePointerDown);
  10855. hitDragging.emitter.on('dragend', this.handleDragEnd);
  10856. }
  10857. destroy() {
  10858. this.dragging.destroy();
  10859. }
  10860. }
  10861. /*
  10862. Tracks when the user selects a portion of time of a component,
  10863. constituted by a drag over date cells, with a possible delay at the beginning of the drag.
  10864. */
  10865. class DateSelecting extends Interaction {
  10866. constructor(settings) {
  10867. super(settings);
  10868. this.dragSelection = null;
  10869. this.handlePointerDown = (ev) => {
  10870. let { component, dragging } = this;
  10871. let { options } = component.context;
  10872. let canSelect = options.selectable &&
  10873. component.isValidDateDownEl(ev.origEvent.target);
  10874. // don't bother to watch expensive moves if component won't do selection
  10875. dragging.setIgnoreMove(!canSelect);
  10876. // if touch, require user to hold down
  10877. dragging.delay = ev.isTouch ? getComponentTouchDelay$1(component) : null;
  10878. };
  10879. this.handleDragStart = (ev) => {
  10880. this.component.context.calendarApi.unselect(ev); // unselect previous selections
  10881. };
  10882. this.handleHitUpdate = (hit, isFinal) => {
  10883. let { context } = this.component;
  10884. let dragSelection = null;
  10885. let isInvalid = false;
  10886. if (hit) {
  10887. let initialHit = this.hitDragging.initialHit;
  10888. let disallowed = hit.componentId === initialHit.componentId
  10889. && this.isHitComboAllowed
  10890. && !this.isHitComboAllowed(initialHit, hit);
  10891. if (!disallowed) {
  10892. dragSelection = joinHitsIntoSelection(initialHit, hit, context.pluginHooks.dateSelectionTransformers);
  10893. }
  10894. if (!dragSelection || !isDateSelectionValid(dragSelection, hit.dateProfile, context)) {
  10895. isInvalid = true;
  10896. dragSelection = null;
  10897. }
  10898. }
  10899. if (dragSelection) {
  10900. context.dispatch({ type: 'SELECT_DATES', selection: dragSelection });
  10901. }
  10902. else if (!isFinal) { // only unselect if moved away while dragging
  10903. context.dispatch({ type: 'UNSELECT_DATES' });
  10904. }
  10905. if (!isInvalid) {
  10906. enableCursor();
  10907. }
  10908. else {
  10909. disableCursor();
  10910. }
  10911. if (!isFinal) {
  10912. this.dragSelection = dragSelection; // only clear if moved away from all hits while dragging
  10913. }
  10914. };
  10915. this.handlePointerUp = (pev) => {
  10916. if (this.dragSelection) {
  10917. // selection is already rendered, so just need to report selection
  10918. triggerDateSelect(this.dragSelection, pev, this.component.context);
  10919. this.dragSelection = null;
  10920. }
  10921. };
  10922. let { component } = settings;
  10923. let { options } = component.context;
  10924. let dragging = this.dragging = new FeaturefulElementDragging(settings.el);
  10925. dragging.touchScrollAllowed = false;
  10926. dragging.minDistance = options.selectMinDistance || 0;
  10927. dragging.autoScroller.isEnabled = options.dragScroll;
  10928. let hitDragging = this.hitDragging = new HitDragging(this.dragging, interactionSettingsToStore(settings));
  10929. hitDragging.emitter.on('pointerdown', this.handlePointerDown);
  10930. hitDragging.emitter.on('dragstart', this.handleDragStart);
  10931. hitDragging.emitter.on('hitupdate', this.handleHitUpdate);
  10932. hitDragging.emitter.on('pointerup', this.handlePointerUp);
  10933. }
  10934. destroy() {
  10935. this.dragging.destroy();
  10936. }
  10937. }
  10938. function getComponentTouchDelay$1(component) {
  10939. let { options } = component.context;
  10940. let delay = options.selectLongPressDelay;
  10941. if (delay == null) {
  10942. delay = options.longPressDelay;
  10943. }
  10944. return delay;
  10945. }
  10946. function joinHitsIntoSelection(hit0, hit1, dateSelectionTransformers) {
  10947. let dateSpan0 = hit0.dateSpan;
  10948. let dateSpan1 = hit1.dateSpan;
  10949. let ms = [
  10950. dateSpan0.range.start,
  10951. dateSpan0.range.end,
  10952. dateSpan1.range.start,
  10953. dateSpan1.range.end,
  10954. ];
  10955. ms.sort(compareNumbers);
  10956. let props = {};
  10957. for (let transformer of dateSelectionTransformers) {
  10958. let res = transformer(hit0, hit1);
  10959. if (res === false) {
  10960. return null;
  10961. }
  10962. if (res) {
  10963. Object.assign(props, res);
  10964. }
  10965. }
  10966. props.range = { start: ms[0], end: ms[3] };
  10967. props.allDay = dateSpan0.allDay;
  10968. return props;
  10969. }
  10970. class EventDragging extends Interaction {
  10971. constructor(settings) {
  10972. super(settings);
  10973. // internal state
  10974. this.subjectEl = null;
  10975. this.subjectSeg = null; // the seg being selected/dragged
  10976. this.isDragging = false;
  10977. this.eventRange = null;
  10978. this.relevantEvents = null; // the events being dragged
  10979. this.receivingContext = null;
  10980. this.validMutation = null;
  10981. this.mutatedRelevantEvents = null;
  10982. this.handlePointerDown = (ev) => {
  10983. let origTarget = ev.origEvent.target;
  10984. let { component, dragging } = this;
  10985. let { mirror } = dragging;
  10986. let { options } = component.context;
  10987. let initialContext = component.context;
  10988. this.subjectEl = ev.subjectEl;
  10989. let subjectSeg = this.subjectSeg = getElSeg(ev.subjectEl);
  10990. let eventRange = this.eventRange = subjectSeg.eventRange;
  10991. let eventInstanceId = eventRange.instance.instanceId;
  10992. this.relevantEvents = getRelevantEvents(initialContext.getCurrentData().eventStore, eventInstanceId);
  10993. dragging.minDistance = ev.isTouch ? 0 : options.eventDragMinDistance;
  10994. dragging.delay =
  10995. // only do a touch delay if touch and this event hasn't been selected yet
  10996. (ev.isTouch && eventInstanceId !== component.props.eventSelection) ?
  10997. getComponentTouchDelay(component) :
  10998. null;
  10999. if (options.fixedMirrorParent) {
  11000. mirror.parentNode = options.fixedMirrorParent;
  11001. }
  11002. else {
  11003. mirror.parentNode = elementClosest(origTarget, '.fc');
  11004. }
  11005. mirror.revertDuration = options.dragRevertDuration;
  11006. let isValid = component.isValidSegDownEl(origTarget) &&
  11007. !elementClosest(origTarget, '.fc-event-resizer'); // NOT on a resizer
  11008. dragging.setIgnoreMove(!isValid);
  11009. // disable dragging for elements that are resizable (ie, selectable)
  11010. // but are not draggable
  11011. this.isDragging = isValid &&
  11012. ev.subjectEl.classList.contains('fc-event-draggable');
  11013. };
  11014. this.handleDragStart = (ev) => {
  11015. let initialContext = this.component.context;
  11016. let eventRange = this.eventRange;
  11017. let eventInstanceId = eventRange.instance.instanceId;
  11018. if (ev.isTouch) {
  11019. // need to select a different event?
  11020. if (eventInstanceId !== this.component.props.eventSelection) {
  11021. initialContext.dispatch({ type: 'SELECT_EVENT', eventInstanceId });
  11022. }
  11023. }
  11024. else {
  11025. // if now using mouse, but was previous touch interaction, clear selected event
  11026. initialContext.dispatch({ type: 'UNSELECT_EVENT' });
  11027. }
  11028. if (this.isDragging) {
  11029. initialContext.calendarApi.unselect(ev); // unselect *date* selection
  11030. initialContext.emitter.trigger('eventDragStart', {
  11031. el: this.subjectEl,
  11032. event: new EventImpl(initialContext, eventRange.def, eventRange.instance),
  11033. jsEvent: ev.origEvent,
  11034. view: initialContext.viewApi,
  11035. });
  11036. }
  11037. };
  11038. this.handleHitUpdate = (hit, isFinal) => {
  11039. if (!this.isDragging) {
  11040. return;
  11041. }
  11042. let relevantEvents = this.relevantEvents;
  11043. let initialHit = this.hitDragging.initialHit;
  11044. let initialContext = this.component.context;
  11045. // states based on new hit
  11046. let receivingContext = null;
  11047. let mutation = null;
  11048. let mutatedRelevantEvents = null;
  11049. let isInvalid = false;
  11050. let interaction = {
  11051. affectedEvents: relevantEvents,
  11052. mutatedEvents: createEmptyEventStore(),
  11053. isEvent: true,
  11054. };
  11055. if (hit) {
  11056. receivingContext = hit.context;
  11057. let receivingOptions = receivingContext.options;
  11058. if (initialContext === receivingContext ||
  11059. (receivingOptions.editable && receivingOptions.droppable)) {
  11060. mutation = computeEventMutation(initialHit, hit, this.eventRange.instance.range.start, receivingContext.getCurrentData().pluginHooks.eventDragMutationMassagers);
  11061. if (mutation) {
  11062. mutatedRelevantEvents = applyMutationToEventStore(relevantEvents, receivingContext.getCurrentData().eventUiBases, mutation, receivingContext);
  11063. interaction.mutatedEvents = mutatedRelevantEvents;
  11064. if (!isInteractionValid(interaction, hit.dateProfile, receivingContext)) {
  11065. isInvalid = true;
  11066. mutation = null;
  11067. mutatedRelevantEvents = null;
  11068. interaction.mutatedEvents = createEmptyEventStore();
  11069. }
  11070. }
  11071. }
  11072. else {
  11073. receivingContext = null;
  11074. }
  11075. }
  11076. this.displayDrag(receivingContext, interaction);
  11077. if (!isInvalid) {
  11078. enableCursor();
  11079. }
  11080. else {
  11081. disableCursor();
  11082. }
  11083. if (!isFinal) {
  11084. if (initialContext === receivingContext && // TODO: write test for this
  11085. isHitsEqual(initialHit, hit)) {
  11086. mutation = null;
  11087. }
  11088. this.dragging.setMirrorNeedsRevert(!mutation);
  11089. // render the mirror if no already-rendered mirror
  11090. // TODO: wish we could somehow wait for dispatch to guarantee render
  11091. this.dragging.setMirrorIsVisible(!hit || !this.subjectEl.getRootNode().querySelector('.fc-event-mirror'));
  11092. // assign states based on new hit
  11093. this.receivingContext = receivingContext;
  11094. this.validMutation = mutation;
  11095. this.mutatedRelevantEvents = mutatedRelevantEvents;
  11096. }
  11097. };
  11098. this.handlePointerUp = () => {
  11099. if (!this.isDragging) {
  11100. this.cleanup(); // because handleDragEnd won't fire
  11101. }
  11102. };
  11103. this.handleDragEnd = (ev) => {
  11104. if (this.isDragging) {
  11105. let initialContext = this.component.context;
  11106. let initialView = initialContext.viewApi;
  11107. let { receivingContext, validMutation } = this;
  11108. let eventDef = this.eventRange.def;
  11109. let eventInstance = this.eventRange.instance;
  11110. let eventApi = new EventImpl(initialContext, eventDef, eventInstance);
  11111. let relevantEvents = this.relevantEvents;
  11112. let mutatedRelevantEvents = this.mutatedRelevantEvents;
  11113. let { finalHit } = this.hitDragging;
  11114. this.clearDrag(); // must happen after revert animation
  11115. initialContext.emitter.trigger('eventDragStop', {
  11116. el: this.subjectEl,
  11117. event: eventApi,
  11118. jsEvent: ev.origEvent,
  11119. view: initialView,
  11120. });
  11121. if (validMutation) {
  11122. // dropped within same calendar
  11123. if (receivingContext === initialContext) {
  11124. let updatedEventApi = new EventImpl(initialContext, mutatedRelevantEvents.defs[eventDef.defId], eventInstance ? mutatedRelevantEvents.instances[eventInstance.instanceId] : null);
  11125. initialContext.dispatch({
  11126. type: 'MERGE_EVENTS',
  11127. eventStore: mutatedRelevantEvents,
  11128. });
  11129. let eventChangeArg = {
  11130. oldEvent: eventApi,
  11131. event: updatedEventApi,
  11132. relatedEvents: buildEventApis(mutatedRelevantEvents, initialContext, eventInstance),
  11133. revert() {
  11134. initialContext.dispatch({
  11135. type: 'MERGE_EVENTS',
  11136. eventStore: relevantEvents, // the pre-change data
  11137. });
  11138. },
  11139. };
  11140. let transformed = {};
  11141. for (let transformer of initialContext.getCurrentData().pluginHooks.eventDropTransformers) {
  11142. Object.assign(transformed, transformer(validMutation, initialContext));
  11143. }
  11144. initialContext.emitter.trigger('eventDrop', Object.assign(Object.assign(Object.assign({}, eventChangeArg), transformed), { el: ev.subjectEl, delta: validMutation.datesDelta, jsEvent: ev.origEvent, view: initialView }));
  11145. initialContext.emitter.trigger('eventChange', eventChangeArg);
  11146. // dropped in different calendar
  11147. }
  11148. else if (receivingContext) {
  11149. let eventRemoveArg = {
  11150. event: eventApi,
  11151. relatedEvents: buildEventApis(relevantEvents, initialContext, eventInstance),
  11152. revert() {
  11153. initialContext.dispatch({
  11154. type: 'MERGE_EVENTS',
  11155. eventStore: relevantEvents,
  11156. });
  11157. },
  11158. };
  11159. initialContext.emitter.trigger('eventLeave', Object.assign(Object.assign({}, eventRemoveArg), { draggedEl: ev.subjectEl, view: initialView }));
  11160. initialContext.dispatch({
  11161. type: 'REMOVE_EVENTS',
  11162. eventStore: relevantEvents,
  11163. });
  11164. initialContext.emitter.trigger('eventRemove', eventRemoveArg);
  11165. let addedEventDef = mutatedRelevantEvents.defs[eventDef.defId];
  11166. let addedEventInstance = mutatedRelevantEvents.instances[eventInstance.instanceId];
  11167. let addedEventApi = new EventImpl(receivingContext, addedEventDef, addedEventInstance);
  11168. receivingContext.dispatch({
  11169. type: 'MERGE_EVENTS',
  11170. eventStore: mutatedRelevantEvents,
  11171. });
  11172. let eventAddArg = {
  11173. event: addedEventApi,
  11174. relatedEvents: buildEventApis(mutatedRelevantEvents, receivingContext, addedEventInstance),
  11175. revert() {
  11176. receivingContext.dispatch({
  11177. type: 'REMOVE_EVENTS',
  11178. eventStore: mutatedRelevantEvents,
  11179. });
  11180. },
  11181. };
  11182. receivingContext.emitter.trigger('eventAdd', eventAddArg);
  11183. if (ev.isTouch) {
  11184. receivingContext.dispatch({
  11185. type: 'SELECT_EVENT',
  11186. eventInstanceId: eventInstance.instanceId,
  11187. });
  11188. }
  11189. receivingContext.emitter.trigger('drop', Object.assign(Object.assign({}, buildDatePointApiWithContext(finalHit.dateSpan, receivingContext)), { draggedEl: ev.subjectEl, jsEvent: ev.origEvent, view: finalHit.context.viewApi }));
  11190. receivingContext.emitter.trigger('eventReceive', Object.assign(Object.assign({}, eventAddArg), { draggedEl: ev.subjectEl, view: finalHit.context.viewApi }));
  11191. }
  11192. }
  11193. else {
  11194. initialContext.emitter.trigger('_noEventDrop');
  11195. }
  11196. }
  11197. this.cleanup();
  11198. };
  11199. let { component } = this;
  11200. let { options } = component.context;
  11201. let dragging = this.dragging = new FeaturefulElementDragging(settings.el);
  11202. dragging.pointer.selector = EventDragging.SELECTOR;
  11203. dragging.touchScrollAllowed = false;
  11204. dragging.autoScroller.isEnabled = options.dragScroll;
  11205. let hitDragging = this.hitDragging = new HitDragging(this.dragging, interactionSettingsStore);
  11206. hitDragging.useSubjectCenter = settings.useEventCenter;
  11207. hitDragging.emitter.on('pointerdown', this.handlePointerDown);
  11208. hitDragging.emitter.on('dragstart', this.handleDragStart);
  11209. hitDragging.emitter.on('hitupdate', this.handleHitUpdate);
  11210. hitDragging.emitter.on('pointerup', this.handlePointerUp);
  11211. hitDragging.emitter.on('dragend', this.handleDragEnd);
  11212. }
  11213. destroy() {
  11214. this.dragging.destroy();
  11215. }
  11216. // render a drag state on the next receivingCalendar
  11217. displayDrag(nextContext, state) {
  11218. let initialContext = this.component.context;
  11219. let prevContext = this.receivingContext;
  11220. // does the previous calendar need to be cleared?
  11221. if (prevContext && prevContext !== nextContext) {
  11222. // does the initial calendar need to be cleared?
  11223. // if so, don't clear all the way. we still need to to hide the affectedEvents
  11224. if (prevContext === initialContext) {
  11225. prevContext.dispatch({
  11226. type: 'SET_EVENT_DRAG',
  11227. state: {
  11228. affectedEvents: state.affectedEvents,
  11229. mutatedEvents: createEmptyEventStore(),
  11230. isEvent: true,
  11231. },
  11232. });
  11233. // completely clear the old calendar if it wasn't the initial
  11234. }
  11235. else {
  11236. prevContext.dispatch({ type: 'UNSET_EVENT_DRAG' });
  11237. }
  11238. }
  11239. if (nextContext) {
  11240. nextContext.dispatch({ type: 'SET_EVENT_DRAG', state });
  11241. }
  11242. }
  11243. clearDrag() {
  11244. let initialCalendar = this.component.context;
  11245. let { receivingContext } = this;
  11246. if (receivingContext) {
  11247. receivingContext.dispatch({ type: 'UNSET_EVENT_DRAG' });
  11248. }
  11249. // the initial calendar might have an dummy drag state from displayDrag
  11250. if (initialCalendar !== receivingContext) {
  11251. initialCalendar.dispatch({ type: 'UNSET_EVENT_DRAG' });
  11252. }
  11253. }
  11254. cleanup() {
  11255. this.subjectSeg = null;
  11256. this.isDragging = false;
  11257. this.eventRange = null;
  11258. this.relevantEvents = null;
  11259. this.receivingContext = null;
  11260. this.validMutation = null;
  11261. this.mutatedRelevantEvents = null;
  11262. }
  11263. }
  11264. // TODO: test this in IE11
  11265. // QUESTION: why do we need it on the resizable???
  11266. EventDragging.SELECTOR = '.fc-event-draggable, .fc-event-resizable';
  11267. function computeEventMutation(hit0, hit1, eventInstanceStart, massagers) {
  11268. let dateSpan0 = hit0.dateSpan;
  11269. let dateSpan1 = hit1.dateSpan;
  11270. let date0 = dateSpan0.range.start;
  11271. let date1 = dateSpan1.range.start;
  11272. let standardProps = {};
  11273. if (dateSpan0.allDay !== dateSpan1.allDay) {
  11274. standardProps.allDay = dateSpan1.allDay;
  11275. standardProps.hasEnd = hit1.context.options.allDayMaintainDuration;
  11276. if (dateSpan1.allDay) {
  11277. // means date1 is already start-of-day,
  11278. // but date0 needs to be converted
  11279. date0 = startOfDay(eventInstanceStart);
  11280. }
  11281. else {
  11282. // Moving from allDate->timed
  11283. // Doesn't matter where on the event the drag began, mutate the event's start-date to date1
  11284. date0 = eventInstanceStart;
  11285. }
  11286. }
  11287. let delta = diffDates(date0, date1, hit0.context.dateEnv, hit0.componentId === hit1.componentId ?
  11288. hit0.largeUnit :
  11289. null);
  11290. if (delta.milliseconds) { // has hours/minutes/seconds
  11291. standardProps.allDay = false;
  11292. }
  11293. let mutation = {
  11294. datesDelta: delta,
  11295. standardProps,
  11296. };
  11297. for (let massager of massagers) {
  11298. massager(mutation, hit0, hit1);
  11299. }
  11300. return mutation;
  11301. }
  11302. function getComponentTouchDelay(component) {
  11303. let { options } = component.context;
  11304. let delay = options.eventLongPressDelay;
  11305. if (delay == null) {
  11306. delay = options.longPressDelay;
  11307. }
  11308. return delay;
  11309. }
  11310. class EventResizing extends Interaction {
  11311. constructor(settings) {
  11312. super(settings);
  11313. // internal state
  11314. this.draggingSegEl = null;
  11315. this.draggingSeg = null; // TODO: rename to resizingSeg? subjectSeg?
  11316. this.eventRange = null;
  11317. this.relevantEvents = null;
  11318. this.validMutation = null;
  11319. this.mutatedRelevantEvents = null;
  11320. this.handlePointerDown = (ev) => {
  11321. let { component } = this;
  11322. let segEl = this.querySegEl(ev);
  11323. let seg = getElSeg(segEl);
  11324. let eventRange = this.eventRange = seg.eventRange;
  11325. this.dragging.minDistance = component.context.options.eventDragMinDistance;
  11326. // if touch, need to be working with a selected event
  11327. this.dragging.setIgnoreMove(!this.component.isValidSegDownEl(ev.origEvent.target) ||
  11328. (ev.isTouch && this.component.props.eventSelection !== eventRange.instance.instanceId));
  11329. };
  11330. this.handleDragStart = (ev) => {
  11331. let { context } = this.component;
  11332. let eventRange = this.eventRange;
  11333. this.relevantEvents = getRelevantEvents(context.getCurrentData().eventStore, this.eventRange.instance.instanceId);
  11334. let segEl = this.querySegEl(ev);
  11335. this.draggingSegEl = segEl;
  11336. this.draggingSeg = getElSeg(segEl);
  11337. context.calendarApi.unselect();
  11338. context.emitter.trigger('eventResizeStart', {
  11339. el: segEl,
  11340. event: new EventImpl(context, eventRange.def, eventRange.instance),
  11341. jsEvent: ev.origEvent,
  11342. view: context.viewApi,
  11343. });
  11344. };
  11345. this.handleHitUpdate = (hit, isFinal, ev) => {
  11346. let { context } = this.component;
  11347. let relevantEvents = this.relevantEvents;
  11348. let initialHit = this.hitDragging.initialHit;
  11349. let eventInstance = this.eventRange.instance;
  11350. let mutation = null;
  11351. let mutatedRelevantEvents = null;
  11352. let isInvalid = false;
  11353. let interaction = {
  11354. affectedEvents: relevantEvents,
  11355. mutatedEvents: createEmptyEventStore(),
  11356. isEvent: true,
  11357. };
  11358. if (hit) {
  11359. let disallowed = hit.componentId === initialHit.componentId
  11360. && this.isHitComboAllowed
  11361. && !this.isHitComboAllowed(initialHit, hit);
  11362. if (!disallowed) {
  11363. mutation = computeMutation(initialHit, hit, ev.subjectEl.classList.contains('fc-event-resizer-start'), eventInstance.range);
  11364. }
  11365. }
  11366. if (mutation) {
  11367. mutatedRelevantEvents = applyMutationToEventStore(relevantEvents, context.getCurrentData().eventUiBases, mutation, context);
  11368. interaction.mutatedEvents = mutatedRelevantEvents;
  11369. if (!isInteractionValid(interaction, hit.dateProfile, context)) {
  11370. isInvalid = true;
  11371. mutation = null;
  11372. mutatedRelevantEvents = null;
  11373. interaction.mutatedEvents = null;
  11374. }
  11375. }
  11376. if (mutatedRelevantEvents) {
  11377. context.dispatch({
  11378. type: 'SET_EVENT_RESIZE',
  11379. state: interaction,
  11380. });
  11381. }
  11382. else {
  11383. context.dispatch({ type: 'UNSET_EVENT_RESIZE' });
  11384. }
  11385. if (!isInvalid) {
  11386. enableCursor();
  11387. }
  11388. else {
  11389. disableCursor();
  11390. }
  11391. if (!isFinal) {
  11392. if (mutation && isHitsEqual(initialHit, hit)) {
  11393. mutation = null;
  11394. }
  11395. this.validMutation = mutation;
  11396. this.mutatedRelevantEvents = mutatedRelevantEvents;
  11397. }
  11398. };
  11399. this.handleDragEnd = (ev) => {
  11400. let { context } = this.component;
  11401. let eventDef = this.eventRange.def;
  11402. let eventInstance = this.eventRange.instance;
  11403. let eventApi = new EventImpl(context, eventDef, eventInstance);
  11404. let relevantEvents = this.relevantEvents;
  11405. let mutatedRelevantEvents = this.mutatedRelevantEvents;
  11406. context.emitter.trigger('eventResizeStop', {
  11407. el: this.draggingSegEl,
  11408. event: eventApi,
  11409. jsEvent: ev.origEvent,
  11410. view: context.viewApi,
  11411. });
  11412. if (this.validMutation) {
  11413. let updatedEventApi = new EventImpl(context, mutatedRelevantEvents.defs[eventDef.defId], eventInstance ? mutatedRelevantEvents.instances[eventInstance.instanceId] : null);
  11414. context.dispatch({
  11415. type: 'MERGE_EVENTS',
  11416. eventStore: mutatedRelevantEvents,
  11417. });
  11418. let eventChangeArg = {
  11419. oldEvent: eventApi,
  11420. event: updatedEventApi,
  11421. relatedEvents: buildEventApis(mutatedRelevantEvents, context, eventInstance),
  11422. revert() {
  11423. context.dispatch({
  11424. type: 'MERGE_EVENTS',
  11425. eventStore: relevantEvents, // the pre-change events
  11426. });
  11427. },
  11428. };
  11429. context.emitter.trigger('eventResize', Object.assign(Object.assign({}, eventChangeArg), { el: this.draggingSegEl, startDelta: this.validMutation.startDelta || createDuration(0), endDelta: this.validMutation.endDelta || createDuration(0), jsEvent: ev.origEvent, view: context.viewApi }));
  11430. context.emitter.trigger('eventChange', eventChangeArg);
  11431. }
  11432. else {
  11433. context.emitter.trigger('_noEventResize');
  11434. }
  11435. // reset all internal state
  11436. this.draggingSeg = null;
  11437. this.relevantEvents = null;
  11438. this.validMutation = null;
  11439. // okay to keep eventInstance around. useful to set it in handlePointerDown
  11440. };
  11441. let { component } = settings;
  11442. let dragging = this.dragging = new FeaturefulElementDragging(settings.el);
  11443. dragging.pointer.selector = '.fc-event-resizer';
  11444. dragging.touchScrollAllowed = false;
  11445. dragging.autoScroller.isEnabled = component.context.options.dragScroll;
  11446. let hitDragging = this.hitDragging = new HitDragging(this.dragging, interactionSettingsToStore(settings));
  11447. hitDragging.emitter.on('pointerdown', this.handlePointerDown);
  11448. hitDragging.emitter.on('dragstart', this.handleDragStart);
  11449. hitDragging.emitter.on('hitupdate', this.handleHitUpdate);
  11450. hitDragging.emitter.on('dragend', this.handleDragEnd);
  11451. }
  11452. destroy() {
  11453. this.dragging.destroy();
  11454. }
  11455. querySegEl(ev) {
  11456. return elementClosest(ev.subjectEl, '.fc-event');
  11457. }
  11458. }
  11459. function computeMutation(hit0, hit1, isFromStart, instanceRange) {
  11460. let dateEnv = hit0.context.dateEnv;
  11461. let date0 = hit0.dateSpan.range.start;
  11462. let date1 = hit1.dateSpan.range.start;
  11463. let delta = diffDates(date0, date1, dateEnv, hit0.largeUnit);
  11464. if (isFromStart) {
  11465. if (dateEnv.add(instanceRange.start, delta) < instanceRange.end) {
  11466. return { startDelta: delta };
  11467. }
  11468. }
  11469. else if (dateEnv.add(instanceRange.end, delta) > instanceRange.start) {
  11470. return { endDelta: delta };
  11471. }
  11472. return null;
  11473. }
  11474. class UnselectAuto {
  11475. constructor(context) {
  11476. this.context = context;
  11477. this.isRecentPointerDateSelect = false; // wish we could use a selector to detect date selection, but uses hit system
  11478. this.matchesCancel = false;
  11479. this.matchesEvent = false;
  11480. this.onSelect = (selectInfo) => {
  11481. if (selectInfo.jsEvent) {
  11482. this.isRecentPointerDateSelect = true;
  11483. }
  11484. };
  11485. this.onDocumentPointerDown = (pev) => {
  11486. let unselectCancel = this.context.options.unselectCancel;
  11487. let downEl = getEventTargetViaRoot(pev.origEvent);
  11488. this.matchesCancel = !!elementClosest(downEl, unselectCancel);
  11489. this.matchesEvent = !!elementClosest(downEl, EventDragging.SELECTOR); // interaction started on an event?
  11490. };
  11491. this.onDocumentPointerUp = (pev) => {
  11492. let { context } = this;
  11493. let { documentPointer } = this;
  11494. let calendarState = context.getCurrentData();
  11495. // touch-scrolling should never unfocus any type of selection
  11496. if (!documentPointer.wasTouchScroll) {
  11497. if (calendarState.dateSelection && // an existing date selection?
  11498. !this.isRecentPointerDateSelect // a new pointer-initiated date selection since last onDocumentPointerUp?
  11499. ) {
  11500. let unselectAuto = context.options.unselectAuto;
  11501. if (unselectAuto && (!unselectAuto || !this.matchesCancel)) {
  11502. context.calendarApi.unselect(pev);
  11503. }
  11504. }
  11505. if (calendarState.eventSelection && // an existing event selected?
  11506. !this.matchesEvent // interaction DIDN'T start on an event
  11507. ) {
  11508. context.dispatch({ type: 'UNSELECT_EVENT' });
  11509. }
  11510. }
  11511. this.isRecentPointerDateSelect = false;
  11512. };
  11513. let documentPointer = this.documentPointer = new PointerDragging(document);
  11514. documentPointer.shouldIgnoreMove = true;
  11515. documentPointer.shouldWatchScroll = false;
  11516. documentPointer.emitter.on('pointerdown', this.onDocumentPointerDown);
  11517. documentPointer.emitter.on('pointerup', this.onDocumentPointerUp);
  11518. /*
  11519. TODO: better way to know about whether there was a selection with the pointer
  11520. */
  11521. context.emitter.on('select', this.onSelect);
  11522. }
  11523. destroy() {
  11524. this.context.emitter.off('select', this.onSelect);
  11525. this.documentPointer.destroy();
  11526. }
  11527. }
  11528. const OPTION_REFINERS$3 = {
  11529. fixedMirrorParent: identity,
  11530. };
  11531. const LISTENER_REFINERS = {
  11532. dateClick: identity,
  11533. eventDragStart: identity,
  11534. eventDragStop: identity,
  11535. eventDrop: identity,
  11536. eventResizeStart: identity,
  11537. eventResizeStop: identity,
  11538. eventResize: identity,
  11539. drop: identity,
  11540. eventReceive: identity,
  11541. eventLeave: identity,
  11542. };
  11543. /*
  11544. Given an already instantiated draggable object for one-or-more elements,
  11545. Interprets any dragging as an attempt to drag an events that lives outside
  11546. of a calendar onto a calendar.
  11547. */
  11548. class ExternalElementDragging {
  11549. constructor(dragging, suppliedDragMeta) {
  11550. this.receivingContext = null;
  11551. this.droppableEvent = null; // will exist for all drags, even if create:false
  11552. this.suppliedDragMeta = null;
  11553. this.dragMeta = null;
  11554. this.handleDragStart = (ev) => {
  11555. this.dragMeta = this.buildDragMeta(ev.subjectEl);
  11556. };
  11557. this.handleHitUpdate = (hit, isFinal, ev) => {
  11558. let { dragging } = this.hitDragging;
  11559. let receivingContext = null;
  11560. let droppableEvent = null;
  11561. let isInvalid = false;
  11562. let interaction = {
  11563. affectedEvents: createEmptyEventStore(),
  11564. mutatedEvents: createEmptyEventStore(),
  11565. isEvent: this.dragMeta.create,
  11566. };
  11567. if (hit) {
  11568. receivingContext = hit.context;
  11569. if (this.canDropElOnCalendar(ev.subjectEl, receivingContext)) {
  11570. droppableEvent = computeEventForDateSpan(hit.dateSpan, this.dragMeta, receivingContext);
  11571. interaction.mutatedEvents = eventTupleToStore(droppableEvent);
  11572. isInvalid = !isInteractionValid(interaction, hit.dateProfile, receivingContext);
  11573. if (isInvalid) {
  11574. interaction.mutatedEvents = createEmptyEventStore();
  11575. droppableEvent = null;
  11576. }
  11577. }
  11578. }
  11579. this.displayDrag(receivingContext, interaction);
  11580. // show mirror if no already-rendered mirror element OR if we are shutting down the mirror (?)
  11581. // TODO: wish we could somehow wait for dispatch to guarantee render
  11582. dragging.setMirrorIsVisible(isFinal || !droppableEvent || !document.querySelector('.fc-event-mirror'));
  11583. if (!isInvalid) {
  11584. enableCursor();
  11585. }
  11586. else {
  11587. disableCursor();
  11588. }
  11589. if (!isFinal) {
  11590. dragging.setMirrorNeedsRevert(!droppableEvent);
  11591. this.receivingContext = receivingContext;
  11592. this.droppableEvent = droppableEvent;
  11593. }
  11594. };
  11595. this.handleDragEnd = (pev) => {
  11596. let { receivingContext, droppableEvent } = this;
  11597. this.clearDrag();
  11598. if (receivingContext && droppableEvent) {
  11599. let finalHit = this.hitDragging.finalHit;
  11600. let finalView = finalHit.context.viewApi;
  11601. let dragMeta = this.dragMeta;
  11602. receivingContext.emitter.trigger('drop', Object.assign(Object.assign({}, buildDatePointApiWithContext(finalHit.dateSpan, receivingContext)), { draggedEl: pev.subjectEl, jsEvent: pev.origEvent, view: finalView }));
  11603. if (dragMeta.create) {
  11604. let addingEvents = eventTupleToStore(droppableEvent);
  11605. receivingContext.dispatch({
  11606. type: 'MERGE_EVENTS',
  11607. eventStore: addingEvents,
  11608. });
  11609. if (pev.isTouch) {
  11610. receivingContext.dispatch({
  11611. type: 'SELECT_EVENT',
  11612. eventInstanceId: droppableEvent.instance.instanceId,
  11613. });
  11614. }
  11615. // signal that an external event landed
  11616. receivingContext.emitter.trigger('eventReceive', {
  11617. event: new EventImpl(receivingContext, droppableEvent.def, droppableEvent.instance),
  11618. relatedEvents: [],
  11619. revert() {
  11620. receivingContext.dispatch({
  11621. type: 'REMOVE_EVENTS',
  11622. eventStore: addingEvents,
  11623. });
  11624. },
  11625. draggedEl: pev.subjectEl,
  11626. view: finalView,
  11627. });
  11628. }
  11629. }
  11630. this.receivingContext = null;
  11631. this.droppableEvent = null;
  11632. };
  11633. let hitDragging = this.hitDragging = new HitDragging(dragging, interactionSettingsStore);
  11634. hitDragging.requireInitial = false; // will start outside of a component
  11635. hitDragging.emitter.on('dragstart', this.handleDragStart);
  11636. hitDragging.emitter.on('hitupdate', this.handleHitUpdate);
  11637. hitDragging.emitter.on('dragend', this.handleDragEnd);
  11638. this.suppliedDragMeta = suppliedDragMeta;
  11639. }
  11640. buildDragMeta(subjectEl) {
  11641. if (typeof this.suppliedDragMeta === 'object') {
  11642. return parseDragMeta(this.suppliedDragMeta);
  11643. }
  11644. if (typeof this.suppliedDragMeta === 'function') {
  11645. return parseDragMeta(this.suppliedDragMeta(subjectEl));
  11646. }
  11647. return getDragMetaFromEl(subjectEl);
  11648. }
  11649. displayDrag(nextContext, state) {
  11650. let prevContext = this.receivingContext;
  11651. if (prevContext && prevContext !== nextContext) {
  11652. prevContext.dispatch({ type: 'UNSET_EVENT_DRAG' });
  11653. }
  11654. if (nextContext) {
  11655. nextContext.dispatch({ type: 'SET_EVENT_DRAG', state });
  11656. }
  11657. }
  11658. clearDrag() {
  11659. if (this.receivingContext) {
  11660. this.receivingContext.dispatch({ type: 'UNSET_EVENT_DRAG' });
  11661. }
  11662. }
  11663. canDropElOnCalendar(el, receivingContext) {
  11664. let dropAccept = receivingContext.options.dropAccept;
  11665. if (typeof dropAccept === 'function') {
  11666. return dropAccept.call(receivingContext.calendarApi, el);
  11667. }
  11668. if (typeof dropAccept === 'string' && dropAccept) {
  11669. return Boolean(elementMatches(el, dropAccept));
  11670. }
  11671. return true;
  11672. }
  11673. }
  11674. // Utils for computing event store from the DragMeta
  11675. // ----------------------------------------------------------------------------------------------------
  11676. function computeEventForDateSpan(dateSpan, dragMeta, context) {
  11677. let defProps = Object.assign({}, dragMeta.leftoverProps);
  11678. for (let transform of context.pluginHooks.externalDefTransforms) {
  11679. Object.assign(defProps, transform(dateSpan, dragMeta));
  11680. }
  11681. let { refined, extra } = refineEventDef(defProps, context);
  11682. let def = parseEventDef(refined, extra, dragMeta.sourceId, dateSpan.allDay, context.options.forceEventDuration || Boolean(dragMeta.duration), // hasEnd
  11683. context);
  11684. let start = dateSpan.range.start;
  11685. // only rely on time info if drop zone is all-day,
  11686. // otherwise, we already know the time
  11687. if (dateSpan.allDay && dragMeta.startTime) {
  11688. start = context.dateEnv.add(start, dragMeta.startTime);
  11689. }
  11690. let end = dragMeta.duration ?
  11691. context.dateEnv.add(start, dragMeta.duration) :
  11692. getDefaultEventEnd(dateSpan.allDay, start, context);
  11693. let instance = createEventInstance(def.defId, { start, end });
  11694. return { def, instance };
  11695. }
  11696. // Utils for extracting data from element
  11697. // ----------------------------------------------------------------------------------------------------
  11698. function getDragMetaFromEl(el) {
  11699. let str = getEmbeddedElData(el, 'event');
  11700. let obj = str ?
  11701. JSON.parse(str) :
  11702. { create: false }; // if no embedded data, assume no event creation
  11703. return parseDragMeta(obj);
  11704. }
  11705. config.dataAttrPrefix = '';
  11706. function getEmbeddedElData(el, name) {
  11707. let prefix = config.dataAttrPrefix;
  11708. let prefixedName = (prefix ? prefix + '-' : '') + name;
  11709. return el.getAttribute('data-' + prefixedName) || '';
  11710. }
  11711. /*
  11712. Makes an element (that is *external* to any calendar) draggable.
  11713. Can pass in data that determines how an event will be created when dropped onto a calendar.
  11714. Leverages FullCalendar's internal drag-n-drop functionality WITHOUT a third-party drag system.
  11715. */
  11716. class ExternalDraggable {
  11717. constructor(el, settings = {}) {
  11718. this.handlePointerDown = (ev) => {
  11719. let { dragging } = this;
  11720. let { minDistance, longPressDelay } = this.settings;
  11721. dragging.minDistance =
  11722. minDistance != null ?
  11723. minDistance :
  11724. (ev.isTouch ? 0 : BASE_OPTION_DEFAULTS.eventDragMinDistance);
  11725. dragging.delay =
  11726. ev.isTouch ? // TODO: eventually read eventLongPressDelay instead vvv
  11727. (longPressDelay != null ? longPressDelay : BASE_OPTION_DEFAULTS.longPressDelay) :
  11728. 0;
  11729. };
  11730. this.handleDragStart = (ev) => {
  11731. if (ev.isTouch &&
  11732. this.dragging.delay &&
  11733. ev.subjectEl.classList.contains('fc-event')) {
  11734. this.dragging.mirror.getMirrorEl().classList.add('fc-event-selected');
  11735. }
  11736. };
  11737. this.settings = settings;
  11738. let dragging = this.dragging = new FeaturefulElementDragging(el);
  11739. dragging.touchScrollAllowed = false;
  11740. if (settings.itemSelector != null) {
  11741. dragging.pointer.selector = settings.itemSelector;
  11742. }
  11743. if (settings.appendTo != null) {
  11744. dragging.mirror.parentNode = settings.appendTo; // TODO: write tests
  11745. }
  11746. dragging.emitter.on('pointerdown', this.handlePointerDown);
  11747. dragging.emitter.on('dragstart', this.handleDragStart);
  11748. new ExternalElementDragging(dragging, settings.eventData); // eslint-disable-line no-new
  11749. }
  11750. destroy() {
  11751. this.dragging.destroy();
  11752. }
  11753. }
  11754. /*
  11755. Detects when a *THIRD-PARTY* drag-n-drop system interacts with elements.
  11756. The third-party system is responsible for drawing the visuals effects of the drag.
  11757. This class simply monitors for pointer movements and fires events.
  11758. It also has the ability to hide the moving element (the "mirror") during the drag.
  11759. */
  11760. class InferredElementDragging extends ElementDragging {
  11761. constructor(containerEl) {
  11762. super(containerEl);
  11763. this.shouldIgnoreMove = false;
  11764. this.mirrorSelector = '';
  11765. this.currentMirrorEl = null;
  11766. this.handlePointerDown = (ev) => {
  11767. this.emitter.trigger('pointerdown', ev);
  11768. if (!this.shouldIgnoreMove) {
  11769. // fire dragstart right away. does not support delay or min-distance
  11770. this.emitter.trigger('dragstart', ev);
  11771. }
  11772. };
  11773. this.handlePointerMove = (ev) => {
  11774. if (!this.shouldIgnoreMove) {
  11775. this.emitter.trigger('dragmove', ev);
  11776. }
  11777. };
  11778. this.handlePointerUp = (ev) => {
  11779. this.emitter.trigger('pointerup', ev);
  11780. if (!this.shouldIgnoreMove) {
  11781. // fire dragend right away. does not support a revert animation
  11782. this.emitter.trigger('dragend', ev);
  11783. }
  11784. };
  11785. let pointer = this.pointer = new PointerDragging(containerEl);
  11786. pointer.emitter.on('pointerdown', this.handlePointerDown);
  11787. pointer.emitter.on('pointermove', this.handlePointerMove);
  11788. pointer.emitter.on('pointerup', this.handlePointerUp);
  11789. }
  11790. destroy() {
  11791. this.pointer.destroy();
  11792. }
  11793. setIgnoreMove(bool) {
  11794. this.shouldIgnoreMove = bool;
  11795. }
  11796. setMirrorIsVisible(bool) {
  11797. if (bool) {
  11798. // restore a previously hidden element.
  11799. // use the reference in case the selector class has already been removed.
  11800. if (this.currentMirrorEl) {
  11801. this.currentMirrorEl.style.visibility = '';
  11802. this.currentMirrorEl = null;
  11803. }
  11804. }
  11805. else {
  11806. let mirrorEl = this.mirrorSelector
  11807. // TODO: somehow query FullCalendars WITHIN shadow-roots
  11808. ? document.querySelector(this.mirrorSelector)
  11809. : null;
  11810. if (mirrorEl) {
  11811. this.currentMirrorEl = mirrorEl;
  11812. mirrorEl.style.visibility = 'hidden';
  11813. }
  11814. }
  11815. }
  11816. }
  11817. /*
  11818. Bridges third-party drag-n-drop systems with FullCalendar.
  11819. Must be instantiated and destroyed by caller.
  11820. */
  11821. class ThirdPartyDraggable {
  11822. constructor(containerOrSettings, settings) {
  11823. let containerEl = document;
  11824. if (
  11825. // wish we could just test instanceof EventTarget, but doesn't work in IE11
  11826. containerOrSettings === document ||
  11827. containerOrSettings instanceof Element) {
  11828. containerEl = containerOrSettings;
  11829. settings = settings || {};
  11830. }
  11831. else {
  11832. settings = (containerOrSettings || {});
  11833. }
  11834. let dragging = this.dragging = new InferredElementDragging(containerEl);
  11835. if (typeof settings.itemSelector === 'string') {
  11836. dragging.pointer.selector = settings.itemSelector;
  11837. }
  11838. else if (containerEl === document) {
  11839. dragging.pointer.selector = '[data-event]';
  11840. }
  11841. if (typeof settings.mirrorSelector === 'string') {
  11842. dragging.mirrorSelector = settings.mirrorSelector;
  11843. }
  11844. let externalDragging = new ExternalElementDragging(dragging, settings.eventData);
  11845. // The hit-detection system requires that the dnd-mirror-element be pointer-events:none,
  11846. // but this can't be guaranteed for third-party draggables, so disable
  11847. externalDragging.hitDragging.disablePointCheck = true;
  11848. }
  11849. destroy() {
  11850. this.dragging.destroy();
  11851. }
  11852. }
  11853. var index$4 = createPlugin({
  11854. name: '@fullcalendar/interaction',
  11855. componentInteractions: [DateClicking, DateSelecting, EventDragging, EventResizing],
  11856. calendarInteractions: [UnselectAuto],
  11857. elementDraggingImpl: FeaturefulElementDragging,
  11858. optionRefiners: OPTION_REFINERS$3,
  11859. listenerRefiners: LISTENER_REFINERS,
  11860. });
  11861. /* An abstract class for the daygrid views, as well as month view. Renders one or more rows of day cells.
  11862. ----------------------------------------------------------------------------------------------------------------------*/
  11863. // It is a manager for a Table subcomponent, which does most of the heavy lifting.
  11864. // It is responsible for managing width/height.
  11865. class TableView extends DateComponent {
  11866. constructor() {
  11867. super(...arguments);
  11868. this.headerElRef = d();
  11869. }
  11870. renderSimpleLayout(headerRowContent, bodyContent) {
  11871. let { props, context } = this;
  11872. let sections = [];
  11873. let stickyHeaderDates = getStickyHeaderDates(context.options);
  11874. if (headerRowContent) {
  11875. sections.push({
  11876. type: 'header',
  11877. key: 'header',
  11878. isSticky: stickyHeaderDates,
  11879. chunk: {
  11880. elRef: this.headerElRef,
  11881. tableClassName: 'fc-col-header',
  11882. rowContent: headerRowContent,
  11883. },
  11884. });
  11885. }
  11886. sections.push({
  11887. type: 'body',
  11888. key: 'body',
  11889. liquid: true,
  11890. chunk: { content: bodyContent },
  11891. });
  11892. return (y(ViewContainer, { elClasses: ['fc-daygrid'], viewSpec: context.viewSpec },
  11893. y(SimpleScrollGrid, { liquid: !props.isHeightAuto && !props.forPrint, collapsibleWidth: props.forPrint, cols: [] /* TODO: make optional? */, sections: sections })));
  11894. }
  11895. renderHScrollLayout(headerRowContent, bodyContent, colCnt, dayMinWidth) {
  11896. let ScrollGrid = this.context.pluginHooks.scrollGridImpl;
  11897. if (!ScrollGrid) {
  11898. throw new Error('No ScrollGrid implementation');
  11899. }
  11900. let { props, context } = this;
  11901. let stickyHeaderDates = !props.forPrint && getStickyHeaderDates(context.options);
  11902. let stickyFooterScrollbar = !props.forPrint && getStickyFooterScrollbar(context.options);
  11903. let sections = [];
  11904. if (headerRowContent) {
  11905. sections.push({
  11906. type: 'header',
  11907. key: 'header',
  11908. isSticky: stickyHeaderDates,
  11909. chunks: [{
  11910. key: 'main',
  11911. elRef: this.headerElRef,
  11912. tableClassName: 'fc-col-header',
  11913. rowContent: headerRowContent,
  11914. }],
  11915. });
  11916. }
  11917. sections.push({
  11918. type: 'body',
  11919. key: 'body',
  11920. liquid: true,
  11921. chunks: [{
  11922. key: 'main',
  11923. content: bodyContent,
  11924. }],
  11925. });
  11926. if (stickyFooterScrollbar) {
  11927. sections.push({
  11928. type: 'footer',
  11929. key: 'footer',
  11930. isSticky: true,
  11931. chunks: [{
  11932. key: 'main',
  11933. content: renderScrollShim,
  11934. }],
  11935. });
  11936. }
  11937. return (y(ViewContainer, { elClasses: ['fc-daygrid'], viewSpec: context.viewSpec },
  11938. y(ScrollGrid, { liquid: !props.isHeightAuto && !props.forPrint, forPrint: props.forPrint, collapsibleWidth: props.forPrint, colGroups: [{ cols: [{ span: colCnt, minWidth: dayMinWidth }] }], sections: sections })));
  11939. }
  11940. }
  11941. function splitSegsByRow(segs, rowCnt) {
  11942. let byRow = [];
  11943. for (let i = 0; i < rowCnt; i += 1) {
  11944. byRow[i] = [];
  11945. }
  11946. for (let seg of segs) {
  11947. byRow[seg.row].push(seg);
  11948. }
  11949. return byRow;
  11950. }
  11951. function splitSegsByFirstCol(segs, colCnt) {
  11952. let byCol = [];
  11953. for (let i = 0; i < colCnt; i += 1) {
  11954. byCol[i] = [];
  11955. }
  11956. for (let seg of segs) {
  11957. byCol[seg.firstCol].push(seg);
  11958. }
  11959. return byCol;
  11960. }
  11961. function splitInteractionByRow(ui, rowCnt) {
  11962. let byRow = [];
  11963. if (!ui) {
  11964. for (let i = 0; i < rowCnt; i += 1) {
  11965. byRow[i] = null;
  11966. }
  11967. }
  11968. else {
  11969. for (let i = 0; i < rowCnt; i += 1) {
  11970. byRow[i] = {
  11971. affectedInstances: ui.affectedInstances,
  11972. isEvent: ui.isEvent,
  11973. segs: [],
  11974. };
  11975. }
  11976. for (let seg of ui.segs) {
  11977. byRow[seg.row].segs.push(seg);
  11978. }
  11979. }
  11980. return byRow;
  11981. }
  11982. const DEFAULT_TABLE_EVENT_TIME_FORMAT = createFormatter({
  11983. hour: 'numeric',
  11984. minute: '2-digit',
  11985. omitZeroMinute: true,
  11986. meridiem: 'narrow',
  11987. });
  11988. function hasListItemDisplay(seg) {
  11989. let { display } = seg.eventRange.ui;
  11990. return display === 'list-item' || (display === 'auto' &&
  11991. !seg.eventRange.def.allDay &&
  11992. seg.firstCol === seg.lastCol && // can't be multi-day
  11993. seg.isStart && // "
  11994. seg.isEnd // "
  11995. );
  11996. }
  11997. class TableBlockEvent extends BaseComponent {
  11998. render() {
  11999. let { props } = this;
  12000. return (y(StandardEvent, Object.assign({}, props, { elClasses: ['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 })));
  12001. }
  12002. }
  12003. class TableListItemEvent extends BaseComponent {
  12004. render() {
  12005. let { props, context } = this;
  12006. let { options } = context;
  12007. let { seg } = props;
  12008. let timeFormat = options.eventTimeFormat || DEFAULT_TABLE_EVENT_TIME_FORMAT;
  12009. let timeText = buildSegTimeText(seg, timeFormat, context, true, props.defaultDisplayEventEnd);
  12010. return (y(EventContainer, Object.assign({}, props, { elTag: "a", elClasses: ['fc-daygrid-event', 'fc-daygrid-dot-event'], elAttrs: getSegAnchorAttrs(props.seg, context), defaultGenerator: renderInnerContent$2, timeText: timeText, isResizing: false, isDateSelecting: false })));
  12011. }
  12012. }
  12013. function renderInnerContent$2(renderProps) {
  12014. return (y(_, null,
  12015. y("div", { className: "fc-daygrid-event-dot", style: { borderColor: renderProps.borderColor || renderProps.backgroundColor } }),
  12016. renderProps.timeText && (y("div", { className: "fc-event-time" }, renderProps.timeText)),
  12017. y("div", { className: "fc-event-title" }, renderProps.event.title || y(_, null, "\u00A0"))));
  12018. }
  12019. class TableCellMoreLink extends BaseComponent {
  12020. constructor() {
  12021. super(...arguments);
  12022. this.compileSegs = memoize(compileSegs);
  12023. }
  12024. render() {
  12025. let { props } = this;
  12026. let { allSegs, invisibleSegs } = this.compileSegs(props.singlePlacements);
  12027. return (y(MoreLinkContainer, { elClasses: ['fc-daygrid-more-link'], 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: () => {
  12028. let isForcedInvisible = (props.eventDrag ? props.eventDrag.affectedInstances : null) ||
  12029. (props.eventResize ? props.eventResize.affectedInstances : null) ||
  12030. {};
  12031. return (y(_, null, allSegs.map((seg) => {
  12032. let instanceId = seg.eventRange.instance.instanceId;
  12033. return (y("div", { className: "fc-daygrid-event-harness", key: instanceId, style: {
  12034. visibility: isForcedInvisible[instanceId] ? 'hidden' : '',
  12035. } }, hasListItemDisplay(seg) ? (y(TableListItemEvent, Object.assign({ seg: seg, isDragging: false, isSelected: instanceId === props.eventSelection, defaultDisplayEventEnd: false }, getSegMeta(seg, props.todayRange)))) : (y(TableBlockEvent, Object.assign({ seg: seg, isDragging: false, isResizing: false, isDateSelecting: false, isSelected: instanceId === props.eventSelection, defaultDisplayEventEnd: false }, getSegMeta(seg, props.todayRange))))));
  12036. })));
  12037. } }));
  12038. }
  12039. }
  12040. function compileSegs(singlePlacements) {
  12041. let allSegs = [];
  12042. let invisibleSegs = [];
  12043. for (let placement of singlePlacements) {
  12044. allSegs.push(placement.seg);
  12045. if (!placement.isVisible) {
  12046. invisibleSegs.push(placement.seg);
  12047. }
  12048. }
  12049. return { allSegs, invisibleSegs };
  12050. }
  12051. const DEFAULT_WEEK_NUM_FORMAT$1 = createFormatter({ week: 'narrow' });
  12052. class TableCell extends DateComponent {
  12053. constructor() {
  12054. super(...arguments);
  12055. this.rootElRef = d();
  12056. this.state = {
  12057. dayNumberId: getUniqueDomId(),
  12058. };
  12059. this.handleRootEl = (el) => {
  12060. setRef(this.rootElRef, el);
  12061. setRef(this.props.elRef, el);
  12062. };
  12063. }
  12064. render() {
  12065. let { context, props, state, rootElRef } = this;
  12066. let { options, dateEnv } = context;
  12067. let { date, dateProfile } = props;
  12068. // TODO: memoize this?
  12069. const isMonthStart = props.showDayNumber &&
  12070. shouldDisplayMonthStart(date, dateProfile.currentRange, dateEnv);
  12071. return (y(DayCellContainer, { elTag: "td", elRef: this.handleRootEl, elClasses: [
  12072. 'fc-daygrid-day',
  12073. ...(props.extraClassNames || []),
  12074. ], elAttrs: Object.assign(Object.assign(Object.assign({}, props.extraDataAttrs), (props.showDayNumber ? { 'aria-labelledby': state.dayNumberId } : {})), { role: 'gridcell' }), defaultGenerator: renderTopInner, date: date, dateProfile: dateProfile, todayRange: props.todayRange, showDayNumber: props.showDayNumber, isMonthStart: isMonthStart, extraRenderProps: props.extraRenderProps }, (InnerContent, renderProps) => (y("div", { ref: props.innerElRef, className: "fc-daygrid-day-frame fc-scrollgrid-sync-inner", style: { minHeight: props.minHeight } },
  12075. props.showWeekNumber && (y(WeekNumberContainer, { elTag: "a", elClasses: ['fc-daygrid-week-number'], elAttrs: buildNavLinkAttrs(context, date, 'week'), date: date, defaultFormat: DEFAULT_WEEK_NUM_FORMAT$1 })),
  12076. !renderProps.isDisabled &&
  12077. (props.showDayNumber || hasCustomDayCellContent(options) || props.forceDayTop) ? (y("div", { className: "fc-daygrid-day-top" },
  12078. y(InnerContent, { elTag: "a", elClasses: [
  12079. 'fc-daygrid-day-number',
  12080. isMonthStart && 'fc-daygrid-month-start',
  12081. ], elAttrs: Object.assign(Object.assign({}, buildNavLinkAttrs(context, date)), { id: state.dayNumberId }) }))) : props.showDayNumber ? (
  12082. // for creating correct amount of space (see issue #7162)
  12083. y("div", { className: "fc-daygrid-day-top", style: { visibility: 'hidden' } },
  12084. y("a", { className: "fc-daygrid-day-number" }, "\u00A0"))) : undefined,
  12085. y("div", { className: "fc-daygrid-day-events", ref: props.fgContentElRef },
  12086. props.fgContent,
  12087. y("div", { className: "fc-daygrid-day-bottom", style: { marginTop: props.moreMarginTop } },
  12088. y(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 }))),
  12089. y("div", { className: "fc-daygrid-day-bg" }, props.bgContent)))));
  12090. }
  12091. }
  12092. function renderTopInner(props) {
  12093. return props.dayNumberText || y(_, null, "\u00A0");
  12094. }
  12095. function shouldDisplayMonthStart(date, currentRange, dateEnv) {
  12096. const { start: currentStart, end: currentEnd } = currentRange;
  12097. const currentEndIncl = addMs(currentEnd, -1);
  12098. const currentFirstYear = dateEnv.getYear(currentStart);
  12099. const currentFirstMonth = dateEnv.getMonth(currentStart);
  12100. const currentLastYear = dateEnv.getYear(currentEndIncl);
  12101. const currentLastMonth = dateEnv.getMonth(currentEndIncl);
  12102. // spans more than one month?
  12103. return !(currentFirstYear === currentLastYear && currentFirstMonth === currentLastMonth) &&
  12104. Boolean(
  12105. // first date in current view?
  12106. date.valueOf() === currentStart.valueOf() ||
  12107. // a month-start that's within the current range?
  12108. (dateEnv.getDay(date) === 1 && date.valueOf() < currentEnd.valueOf()));
  12109. }
  12110. function generateSegKey(seg) {
  12111. return seg.eventRange.instance.instanceId + ':' + seg.firstCol;
  12112. }
  12113. function generateSegUid(seg) {
  12114. return generateSegKey(seg) + ':' + seg.lastCol;
  12115. }
  12116. function computeFgSegPlacement(segs, // assumed already sorted
  12117. dayMaxEvents, dayMaxEventRows, strictOrder, segHeights, maxContentHeight, cells) {
  12118. let hierarchy = new DayGridSegHierarchy((segEntry) => {
  12119. // TODO: more DRY with generateSegUid
  12120. let segUid = segs[segEntry.index].eventRange.instance.instanceId +
  12121. ':' + segEntry.span.start +
  12122. ':' + (segEntry.span.end - 1);
  12123. // if no thickness known, assume 1 (if 0, so small it always fits)
  12124. return segHeights[segUid] || 1;
  12125. });
  12126. hierarchy.allowReslicing = true;
  12127. hierarchy.strictOrder = strictOrder;
  12128. if (dayMaxEvents === true || dayMaxEventRows === true) {
  12129. hierarchy.maxCoord = maxContentHeight;
  12130. hierarchy.hiddenConsumes = true;
  12131. }
  12132. else if (typeof dayMaxEvents === 'number') {
  12133. hierarchy.maxStackCnt = dayMaxEvents;
  12134. }
  12135. else if (typeof dayMaxEventRows === 'number') {
  12136. hierarchy.maxStackCnt = dayMaxEventRows;
  12137. hierarchy.hiddenConsumes = true;
  12138. }
  12139. // create segInputs only for segs with known heights
  12140. let segInputs = [];
  12141. let unknownHeightSegs = [];
  12142. for (let i = 0; i < segs.length; i += 1) {
  12143. let seg = segs[i];
  12144. let segUid = generateSegUid(seg);
  12145. let eventHeight = segHeights[segUid];
  12146. if (eventHeight != null) {
  12147. segInputs.push({
  12148. index: i,
  12149. span: {
  12150. start: seg.firstCol,
  12151. end: seg.lastCol + 1,
  12152. },
  12153. });
  12154. }
  12155. else {
  12156. unknownHeightSegs.push(seg);
  12157. }
  12158. }
  12159. let hiddenEntries = hierarchy.addSegs(segInputs);
  12160. let segRects = hierarchy.toRects();
  12161. let { singleColPlacements, multiColPlacements, leftoverMargins } = placeRects(segRects, segs, cells);
  12162. let moreCnts = [];
  12163. let moreMarginTops = [];
  12164. // add segs with unknown heights
  12165. for (let seg of unknownHeightSegs) {
  12166. multiColPlacements[seg.firstCol].push({
  12167. seg,
  12168. isVisible: false,
  12169. isAbsolute: true,
  12170. absoluteTop: 0,
  12171. marginTop: 0,
  12172. });
  12173. for (let col = seg.firstCol; col <= seg.lastCol; col += 1) {
  12174. singleColPlacements[col].push({
  12175. seg: resliceSeg(seg, col, col + 1, cells),
  12176. isVisible: false,
  12177. isAbsolute: false,
  12178. absoluteTop: 0,
  12179. marginTop: 0,
  12180. });
  12181. }
  12182. }
  12183. // add the hidden entries
  12184. for (let col = 0; col < cells.length; col += 1) {
  12185. moreCnts.push(0);
  12186. }
  12187. for (let hiddenEntry of hiddenEntries) {
  12188. let seg = segs[hiddenEntry.index];
  12189. let hiddenSpan = hiddenEntry.span;
  12190. multiColPlacements[hiddenSpan.start].push({
  12191. seg: resliceSeg(seg, hiddenSpan.start, hiddenSpan.end, cells),
  12192. isVisible: false,
  12193. isAbsolute: true,
  12194. absoluteTop: 0,
  12195. marginTop: 0,
  12196. });
  12197. for (let col = hiddenSpan.start; col < hiddenSpan.end; col += 1) {
  12198. moreCnts[col] += 1;
  12199. singleColPlacements[col].push({
  12200. seg: resliceSeg(seg, col, col + 1, cells),
  12201. isVisible: false,
  12202. isAbsolute: false,
  12203. absoluteTop: 0,
  12204. marginTop: 0,
  12205. });
  12206. }
  12207. }
  12208. // deal with leftover margins
  12209. for (let col = 0; col < cells.length; col += 1) {
  12210. moreMarginTops.push(leftoverMargins[col]);
  12211. }
  12212. return { singleColPlacements, multiColPlacements, moreCnts, moreMarginTops };
  12213. }
  12214. // rects ordered by top coord, then left
  12215. function placeRects(allRects, segs, cells) {
  12216. let rectsByEachCol = groupRectsByEachCol(allRects, cells.length);
  12217. let singleColPlacements = [];
  12218. let multiColPlacements = [];
  12219. let leftoverMargins = [];
  12220. for (let col = 0; col < cells.length; col += 1) {
  12221. let rects = rectsByEachCol[col];
  12222. // compute all static segs in singlePlacements
  12223. let singlePlacements = [];
  12224. let currentHeight = 0;
  12225. let currentMarginTop = 0;
  12226. for (let rect of rects) {
  12227. let seg = segs[rect.index];
  12228. singlePlacements.push({
  12229. seg: resliceSeg(seg, col, col + 1, cells),
  12230. isVisible: true,
  12231. isAbsolute: false,
  12232. absoluteTop: rect.levelCoord,
  12233. marginTop: rect.levelCoord - currentHeight,
  12234. });
  12235. currentHeight = rect.levelCoord + rect.thickness;
  12236. }
  12237. // compute mixed static/absolute segs in multiPlacements
  12238. let multiPlacements = [];
  12239. currentHeight = 0;
  12240. currentMarginTop = 0;
  12241. for (let rect of rects) {
  12242. let seg = segs[rect.index];
  12243. let isAbsolute = rect.span.end - rect.span.start > 1; // multi-column?
  12244. let isFirstCol = rect.span.start === col;
  12245. currentMarginTop += rect.levelCoord - currentHeight; // amount of space since bottom of previous seg
  12246. currentHeight = rect.levelCoord + rect.thickness; // height will now be bottom of current seg
  12247. if (isAbsolute) {
  12248. currentMarginTop += rect.thickness;
  12249. if (isFirstCol) {
  12250. multiPlacements.push({
  12251. seg: resliceSeg(seg, rect.span.start, rect.span.end, cells),
  12252. isVisible: true,
  12253. isAbsolute: true,
  12254. absoluteTop: rect.levelCoord,
  12255. marginTop: 0,
  12256. });
  12257. }
  12258. }
  12259. else if (isFirstCol) {
  12260. multiPlacements.push({
  12261. seg: resliceSeg(seg, rect.span.start, rect.span.end, cells),
  12262. isVisible: true,
  12263. isAbsolute: false,
  12264. absoluteTop: rect.levelCoord,
  12265. marginTop: currentMarginTop, // claim the margin
  12266. });
  12267. currentMarginTop = 0;
  12268. }
  12269. }
  12270. singleColPlacements.push(singlePlacements);
  12271. multiColPlacements.push(multiPlacements);
  12272. leftoverMargins.push(currentMarginTop);
  12273. }
  12274. return { singleColPlacements, multiColPlacements, leftoverMargins };
  12275. }
  12276. function groupRectsByEachCol(rects, colCnt) {
  12277. let rectsByEachCol = [];
  12278. for (let col = 0; col < colCnt; col += 1) {
  12279. rectsByEachCol.push([]);
  12280. }
  12281. for (let rect of rects) {
  12282. for (let col = rect.span.start; col < rect.span.end; col += 1) {
  12283. rectsByEachCol[col].push(rect);
  12284. }
  12285. }
  12286. return rectsByEachCol;
  12287. }
  12288. function resliceSeg(seg, spanStart, spanEnd, cells) {
  12289. if (seg.firstCol === spanStart && seg.lastCol === spanEnd - 1) {
  12290. return seg;
  12291. }
  12292. let eventRange = seg.eventRange;
  12293. let origRange = eventRange.range;
  12294. let slicedRange = intersectRanges(origRange, {
  12295. start: cells[spanStart].date,
  12296. end: addDays(cells[spanEnd - 1].date, 1),
  12297. });
  12298. return Object.assign(Object.assign({}, seg), { firstCol: spanStart, lastCol: spanEnd - 1, eventRange: {
  12299. def: eventRange.def,
  12300. ui: Object.assign(Object.assign({}, eventRange.ui), { durationEditable: false }),
  12301. instance: eventRange.instance,
  12302. range: slicedRange,
  12303. }, isStart: seg.isStart && slicedRange.start.valueOf() === origRange.start.valueOf(), isEnd: seg.isEnd && slicedRange.end.valueOf() === origRange.end.valueOf() });
  12304. }
  12305. class DayGridSegHierarchy extends SegHierarchy {
  12306. constructor() {
  12307. super(...arguments);
  12308. // config
  12309. this.hiddenConsumes = false;
  12310. // allows us to keep hidden entries in the hierarchy so they take up space
  12311. this.forceHidden = {};
  12312. }
  12313. addSegs(segInputs) {
  12314. const hiddenSegs = super.addSegs(segInputs);
  12315. const { entriesByLevel } = this;
  12316. const excludeHidden = (entry) => !this.forceHidden[buildEntryKey(entry)];
  12317. // remove the forced-hidden segs
  12318. for (let level = 0; level < entriesByLevel.length; level += 1) {
  12319. entriesByLevel[level] = entriesByLevel[level].filter(excludeHidden);
  12320. }
  12321. return hiddenSegs;
  12322. }
  12323. handleInvalidInsertion(insertion, entry, hiddenEntries) {
  12324. const { entriesByLevel, forceHidden } = this;
  12325. const { touchingEntry, touchingLevel, touchingLateral } = insertion;
  12326. // the entry that the new insertion is touching must be hidden
  12327. if (this.hiddenConsumes && touchingEntry) {
  12328. const touchingEntryId = buildEntryKey(touchingEntry);
  12329. if (!forceHidden[touchingEntryId]) {
  12330. if (this.allowReslicing) {
  12331. // split up the touchingEntry, reinsert it
  12332. const hiddenEntry = Object.assign(Object.assign({}, touchingEntry), { span: intersectSpans(touchingEntry.span, entry.span) });
  12333. // reinsert the area that turned into a "more" link (so no other entries try to
  12334. // occupy the space) but mark it forced-hidden
  12335. const hiddenEntryId = buildEntryKey(hiddenEntry);
  12336. forceHidden[hiddenEntryId] = true;
  12337. entriesByLevel[touchingLevel][touchingLateral] = hiddenEntry;
  12338. hiddenEntries.push(hiddenEntry);
  12339. this.splitEntry(touchingEntry, entry, hiddenEntries);
  12340. }
  12341. else {
  12342. forceHidden[touchingEntryId] = true;
  12343. hiddenEntries.push(touchingEntry);
  12344. }
  12345. }
  12346. }
  12347. // will try to reslice...
  12348. super.handleInvalidInsertion(insertion, entry, hiddenEntries);
  12349. }
  12350. }
  12351. class TableRow extends DateComponent {
  12352. constructor() {
  12353. super(...arguments);
  12354. this.cellElRefs = new RefMap(); // the <td>
  12355. this.frameElRefs = new RefMap(); // the fc-daygrid-day-frame
  12356. this.fgElRefs = new RefMap(); // the fc-daygrid-day-events
  12357. this.segHarnessRefs = new RefMap(); // indexed by "instanceId:firstCol"
  12358. this.rootElRef = d();
  12359. this.state = {
  12360. framePositions: null,
  12361. maxContentHeight: null,
  12362. segHeights: {},
  12363. };
  12364. this.handleResize = (isForced) => {
  12365. if (isForced) {
  12366. this.updateSizing(true); // isExternal=true
  12367. }
  12368. };
  12369. }
  12370. render() {
  12371. let { props, state, context } = this;
  12372. let { options } = context;
  12373. let colCnt = props.cells.length;
  12374. let businessHoursByCol = splitSegsByFirstCol(props.businessHourSegs, colCnt);
  12375. let bgEventSegsByCol = splitSegsByFirstCol(props.bgEventSegs, colCnt);
  12376. let highlightSegsByCol = splitSegsByFirstCol(this.getHighlightSegs(), colCnt);
  12377. let mirrorSegsByCol = splitSegsByFirstCol(this.getMirrorSegs(), colCnt);
  12378. let { singleColPlacements, multiColPlacements, moreCnts, moreMarginTops } = computeFgSegPlacement(sortEventSegs(props.fgEventSegs, options.eventOrder), props.dayMaxEvents, props.dayMaxEventRows, options.eventOrderStrict, state.segHeights, state.maxContentHeight, props.cells);
  12379. let isForcedInvisible = // TODO: messy way to compute this
  12380. (props.eventDrag && props.eventDrag.affectedInstances) ||
  12381. (props.eventResize && props.eventResize.affectedInstances) ||
  12382. {};
  12383. return (y("tr", { ref: this.rootElRef, role: "row" },
  12384. props.renderIntro && props.renderIntro(),
  12385. props.cells.map((cell, col) => {
  12386. let normalFgNodes = this.renderFgSegs(col, props.forPrint ? singleColPlacements[col] : multiColPlacements[col], props.todayRange, isForcedInvisible);
  12387. let mirrorFgNodes = this.renderFgSegs(col, buildMirrorPlacements(mirrorSegsByCol[col], multiColPlacements), props.todayRange, {}, Boolean(props.eventDrag), Boolean(props.eventResize), false);
  12388. return (y(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, extraRenderProps: cell.extraRenderProps, 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
  12389. y(_, null,
  12390. y(_, null, normalFgNodes),
  12391. y(_, null, mirrorFgNodes))), bgContent: ( // Fragment scopes the keys
  12392. y(_, null,
  12393. this.renderFillSegs(highlightSegsByCol[col], 'highlight'),
  12394. this.renderFillSegs(businessHoursByCol[col], 'non-business'),
  12395. this.renderFillSegs(bgEventSegsByCol[col], 'bg-event'))), minHeight: props.cellMinHeight }));
  12396. })));
  12397. }
  12398. componentDidMount() {
  12399. this.updateSizing(true);
  12400. this.context.addResizeHandler(this.handleResize);
  12401. }
  12402. componentDidUpdate(prevProps, prevState) {
  12403. let currentProps = this.props;
  12404. this.updateSizing(!isPropsEqual(prevProps, currentProps));
  12405. }
  12406. componentWillUnmount() {
  12407. this.context.removeResizeHandler(this.handleResize);
  12408. }
  12409. getHighlightSegs() {
  12410. let { props } = this;
  12411. if (props.eventDrag && props.eventDrag.segs.length) { // messy check
  12412. return props.eventDrag.segs;
  12413. }
  12414. if (props.eventResize && props.eventResize.segs.length) { // messy check
  12415. return props.eventResize.segs;
  12416. }
  12417. return props.dateSelectionSegs;
  12418. }
  12419. getMirrorSegs() {
  12420. let { props } = this;
  12421. if (props.eventResize && props.eventResize.segs.length) { // messy check
  12422. return props.eventResize.segs;
  12423. }
  12424. return [];
  12425. }
  12426. renderFgSegs(col, segPlacements, todayRange, isForcedInvisible, isDragging, isResizing, isDateSelecting) {
  12427. let { context } = this;
  12428. let { eventSelection } = this.props;
  12429. let { framePositions } = this.state;
  12430. let defaultDisplayEventEnd = this.props.cells.length === 1; // colCnt === 1
  12431. let isMirror = isDragging || isResizing || isDateSelecting;
  12432. let nodes = [];
  12433. if (framePositions) {
  12434. for (let placement of segPlacements) {
  12435. let { seg } = placement;
  12436. let { instanceId } = seg.eventRange.instance;
  12437. let isVisible = placement.isVisible && !isForcedInvisible[instanceId];
  12438. let isAbsolute = placement.isAbsolute;
  12439. let left = '';
  12440. let right = '';
  12441. if (isAbsolute) {
  12442. if (context.isRtl) {
  12443. right = 0;
  12444. left = framePositions.lefts[seg.lastCol] - framePositions.lefts[seg.firstCol];
  12445. }
  12446. else {
  12447. left = 0;
  12448. right = framePositions.rights[seg.firstCol] - framePositions.rights[seg.lastCol];
  12449. }
  12450. }
  12451. /*
  12452. known bug: events that are force to be list-item but span multiple days still take up space in later columns
  12453. todo: in print view, for multi-day events, don't display title within non-start/end segs
  12454. */
  12455. nodes.push(y("div", { className: 'fc-daygrid-event-harness' + (isAbsolute ? ' fc-daygrid-event-harness-abs' : ''), key: generateSegKey(seg), ref: isMirror ? null : this.segHarnessRefs.createRef(generateSegUid(seg)), style: {
  12456. visibility: isVisible ? '' : 'hidden',
  12457. marginTop: isAbsolute ? '' : placement.marginTop,
  12458. top: isAbsolute ? placement.absoluteTop : '',
  12459. left,
  12460. right,
  12461. } }, hasListItemDisplay(seg) ? (y(TableListItemEvent, Object.assign({ seg: seg, isDragging: isDragging, isSelected: instanceId === eventSelection, defaultDisplayEventEnd: defaultDisplayEventEnd }, getSegMeta(seg, todayRange)))) : (y(TableBlockEvent, Object.assign({ seg: seg, isDragging: isDragging, isResizing: isResizing, isDateSelecting: isDateSelecting, isSelected: instanceId === eventSelection, defaultDisplayEventEnd: defaultDisplayEventEnd }, getSegMeta(seg, todayRange))))));
  12462. }
  12463. }
  12464. return nodes;
  12465. }
  12466. renderFillSegs(segs, fillType) {
  12467. let { isRtl } = this.context;
  12468. let { todayRange } = this.props;
  12469. let { framePositions } = this.state;
  12470. let nodes = [];
  12471. if (framePositions) {
  12472. for (let seg of segs) {
  12473. let leftRightCss = isRtl ? {
  12474. right: 0,
  12475. left: framePositions.lefts[seg.lastCol] - framePositions.lefts[seg.firstCol],
  12476. } : {
  12477. left: 0,
  12478. right: framePositions.rights[seg.firstCol] - framePositions.rights[seg.lastCol],
  12479. };
  12480. nodes.push(y("div", { key: buildEventRangeKey(seg.eventRange), className: "fc-daygrid-bg-harness", style: leftRightCss }, fillType === 'bg-event' ?
  12481. y(BgEvent, Object.assign({ seg: seg }, getSegMeta(seg, todayRange))) :
  12482. renderFill(fillType)));
  12483. }
  12484. }
  12485. return y(_, {}, ...nodes);
  12486. }
  12487. updateSizing(isExternalSizingChange) {
  12488. let { props, state, frameElRefs } = this;
  12489. if (!props.forPrint &&
  12490. props.clientWidth !== null // positioning ready?
  12491. ) {
  12492. if (isExternalSizingChange) {
  12493. let frameEls = props.cells.map((cell) => frameElRefs.currentMap[cell.key]);
  12494. if (frameEls.length) {
  12495. let originEl = this.rootElRef.current;
  12496. let newPositionCache = new PositionCache(originEl, frameEls, true, // isHorizontal
  12497. false);
  12498. if (!state.framePositions || !state.framePositions.similarTo(newPositionCache)) {
  12499. this.setState({
  12500. framePositions: new PositionCache(originEl, frameEls, true, // isHorizontal
  12501. false),
  12502. });
  12503. }
  12504. }
  12505. }
  12506. const oldSegHeights = this.state.segHeights;
  12507. const newSegHeights = this.querySegHeights();
  12508. const limitByContentHeight = props.dayMaxEvents === true || props.dayMaxEventRows === true;
  12509. this.safeSetState({
  12510. // HACK to prevent oscillations of events being shown/hidden from max-event-rows
  12511. // Essentially, once you compute an element's height, never null-out.
  12512. // TODO: always display all events, as visibility:hidden?
  12513. segHeights: Object.assign(Object.assign({}, oldSegHeights), newSegHeights),
  12514. maxContentHeight: limitByContentHeight ? this.computeMaxContentHeight() : null,
  12515. });
  12516. }
  12517. }
  12518. querySegHeights() {
  12519. let segElMap = this.segHarnessRefs.currentMap;
  12520. let segHeights = {};
  12521. // get the max height amongst instance segs
  12522. for (let segUid in segElMap) {
  12523. let height = Math.round(segElMap[segUid].getBoundingClientRect().height);
  12524. segHeights[segUid] = Math.max(segHeights[segUid] || 0, height);
  12525. }
  12526. return segHeights;
  12527. }
  12528. computeMaxContentHeight() {
  12529. let firstKey = this.props.cells[0].key;
  12530. let cellEl = this.cellElRefs.currentMap[firstKey];
  12531. let fcContainerEl = this.fgElRefs.currentMap[firstKey];
  12532. return cellEl.getBoundingClientRect().bottom - fcContainerEl.getBoundingClientRect().top;
  12533. }
  12534. getCellEls() {
  12535. let elMap = this.cellElRefs.currentMap;
  12536. return this.props.cells.map((cell) => elMap[cell.key]);
  12537. }
  12538. }
  12539. TableRow.addStateEquality({
  12540. segHeights: isPropsEqual,
  12541. });
  12542. function buildMirrorPlacements(mirrorSegs, colPlacements) {
  12543. if (!mirrorSegs.length) {
  12544. return [];
  12545. }
  12546. let topsByInstanceId = buildAbsoluteTopHash(colPlacements); // TODO: cache this at first render?
  12547. return mirrorSegs.map((seg) => ({
  12548. seg,
  12549. isVisible: true,
  12550. isAbsolute: true,
  12551. absoluteTop: topsByInstanceId[seg.eventRange.instance.instanceId],
  12552. marginTop: 0,
  12553. }));
  12554. }
  12555. function buildAbsoluteTopHash(colPlacements) {
  12556. let topsByInstanceId = {};
  12557. for (let placements of colPlacements) {
  12558. for (let placement of placements) {
  12559. topsByInstanceId[placement.seg.eventRange.instance.instanceId] = placement.absoluteTop;
  12560. }
  12561. }
  12562. return topsByInstanceId;
  12563. }
  12564. class TableRows extends DateComponent {
  12565. constructor() {
  12566. super(...arguments);
  12567. this.splitBusinessHourSegs = memoize(splitSegsByRow);
  12568. this.splitBgEventSegs = memoize(splitSegsByRow);
  12569. this.splitFgEventSegs = memoize(splitSegsByRow);
  12570. this.splitDateSelectionSegs = memoize(splitSegsByRow);
  12571. this.splitEventDrag = memoize(splitInteractionByRow);
  12572. this.splitEventResize = memoize(splitInteractionByRow);
  12573. this.rowRefs = new RefMap();
  12574. }
  12575. render() {
  12576. let { props, context } = this;
  12577. let rowCnt = props.cells.length;
  12578. let businessHourSegsByRow = this.splitBusinessHourSegs(props.businessHourSegs, rowCnt);
  12579. let bgEventSegsByRow = this.splitBgEventSegs(props.bgEventSegs, rowCnt);
  12580. let fgEventSegsByRow = this.splitFgEventSegs(props.fgEventSegs, rowCnt);
  12581. let dateSelectionSegsByRow = this.splitDateSelectionSegs(props.dateSelectionSegs, rowCnt);
  12582. let eventDragByRow = this.splitEventDrag(props.eventDrag, rowCnt);
  12583. let eventResizeByRow = this.splitEventResize(props.eventResize, rowCnt);
  12584. // for DayGrid view with many rows, force a min-height on cells so doesn't appear squished
  12585. // choose 7 because a month view will have max 6 rows
  12586. let cellMinHeight = (rowCnt >= 7 && props.clientWidth) ?
  12587. props.clientWidth / context.options.aspectRatio / 6 :
  12588. null;
  12589. return (y(NowTimer, { unit: "day" }, (nowDate, todayRange) => (y(_, null, props.cells.map((cells, row) => (y(TableRow, { ref: this.rowRefs.createRef(row), key: cells.length
  12590. ? cells[0].date.toISOString() /* best? or put key on cell? or use diff formatter? */
  12591. : row // in case there are no cells (like when resource view is loading)
  12592. , showDayNumbers: rowCnt > 1, showWeekNumbers: props.showWeekNumbers, todayRange: todayRange, dateProfile: props.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: props.dayMaxEvents, dayMaxEventRows: props.dayMaxEventRows, clientWidth: props.clientWidth, clientHeight: props.clientHeight, cellMinHeight: cellMinHeight, forPrint: props.forPrint })))))));
  12593. }
  12594. componentDidMount() {
  12595. this.registerInteractiveComponent();
  12596. }
  12597. componentDidUpdate() {
  12598. // for if started with zero cells
  12599. this.registerInteractiveComponent();
  12600. }
  12601. registerInteractiveComponent() {
  12602. if (!this.rootEl) {
  12603. // HACK: need a daygrid wrapper parent to do positioning
  12604. // NOTE: a daygrid resource view w/o resources can have zero cells
  12605. const firstCellEl = this.rowRefs.currentMap[0].getCellEls()[0];
  12606. const rootEl = firstCellEl ? firstCellEl.closest('.fc-daygrid-body') : null;
  12607. if (rootEl) {
  12608. this.rootEl = rootEl;
  12609. this.context.registerInteractiveComponent(this, {
  12610. el: rootEl,
  12611. isHitComboAllowed: this.props.isHitComboAllowed,
  12612. });
  12613. }
  12614. }
  12615. }
  12616. componentWillUnmount() {
  12617. if (this.rootEl) {
  12618. this.context.unregisterInteractiveComponent(this);
  12619. this.rootEl = null;
  12620. }
  12621. }
  12622. // Hit System
  12623. // ----------------------------------------------------------------------------------------------------
  12624. prepareHits() {
  12625. this.rowPositions = new PositionCache(this.rootEl, this.rowRefs.collect().map((rowObj) => rowObj.getCellEls()[0]), // first cell el in each row. TODO: not optimal
  12626. false, true);
  12627. this.colPositions = new PositionCache(this.rootEl, this.rowRefs.currentMap[0].getCellEls(), // cell els in first row
  12628. true, // horizontal
  12629. false);
  12630. }
  12631. queryHit(positionLeft, positionTop) {
  12632. let { colPositions, rowPositions } = this;
  12633. let col = colPositions.leftToIndex(positionLeft);
  12634. let row = rowPositions.topToIndex(positionTop);
  12635. if (row != null && col != null) {
  12636. let cell = this.props.cells[row][col];
  12637. return {
  12638. dateProfile: this.props.dateProfile,
  12639. dateSpan: Object.assign({ range: this.getCellRange(row, col), allDay: true }, cell.extraDateSpan),
  12640. dayEl: this.getCellEl(row, col),
  12641. rect: {
  12642. left: colPositions.lefts[col],
  12643. right: colPositions.rights[col],
  12644. top: rowPositions.tops[row],
  12645. bottom: rowPositions.bottoms[row],
  12646. },
  12647. layer: 0,
  12648. };
  12649. }
  12650. return null;
  12651. }
  12652. getCellEl(row, col) {
  12653. return this.rowRefs.currentMap[row].getCellEls()[col]; // TODO: not optimal
  12654. }
  12655. getCellRange(row, col) {
  12656. let start = this.props.cells[row][col].date;
  12657. let end = addDays(start, 1);
  12658. return { start, end };
  12659. }
  12660. }
  12661. function isSegAllDay(seg) {
  12662. return seg.eventRange.def.allDay;
  12663. }
  12664. class Table extends DateComponent {
  12665. constructor() {
  12666. super(...arguments);
  12667. this.elRef = d();
  12668. this.needsScrollReset = false;
  12669. }
  12670. render() {
  12671. let { props } = this;
  12672. let { dayMaxEventRows, dayMaxEvents, expandRows } = props;
  12673. let limitViaBalanced = dayMaxEvents === true || dayMaxEventRows === true;
  12674. // if rows can't expand to fill fixed height, can't do balanced-height event limit
  12675. // TODO: best place to normalize these options?
  12676. if (limitViaBalanced && !expandRows) {
  12677. limitViaBalanced = false;
  12678. dayMaxEventRows = null;
  12679. dayMaxEvents = null;
  12680. }
  12681. let classNames = [
  12682. 'fc-daygrid-body',
  12683. limitViaBalanced ? 'fc-daygrid-body-balanced' : 'fc-daygrid-body-unbalanced',
  12684. expandRows ? '' : 'fc-daygrid-body-natural', // will height of one row depend on the others?
  12685. ];
  12686. return (y("div", { ref: this.elRef, className: classNames.join(' '), style: {
  12687. // these props are important to give this wrapper correct dimensions for interactions
  12688. // TODO: if we set it here, can we avoid giving to inner tables?
  12689. width: props.clientWidth,
  12690. minWidth: props.tableMinWidth,
  12691. } },
  12692. y("table", { role: "presentation", className: "fc-scrollgrid-sync-table", style: {
  12693. width: props.clientWidth,
  12694. minWidth: props.tableMinWidth,
  12695. height: expandRows ? props.clientHeight : '',
  12696. } },
  12697. props.colGroupNode,
  12698. y("tbody", { role: "presentation" },
  12699. y(TableRows, { dateProfile: props.dateProfile, cells: props.cells, renderRowIntro: props.renderRowIntro, showWeekNumbers: props.showWeekNumbers, clientWidth: props.clientWidth, clientHeight: props.clientHeight, businessHourSegs: props.businessHourSegs, bgEventSegs: props.bgEventSegs, fgEventSegs: props.fgEventSegs, dateSelectionSegs: props.dateSelectionSegs, eventSelection: props.eventSelection, eventDrag: props.eventDrag, eventResize: props.eventResize, dayMaxEvents: dayMaxEvents, dayMaxEventRows: dayMaxEventRows, forPrint: props.forPrint, isHitComboAllowed: props.isHitComboAllowed })))));
  12700. }
  12701. componentDidMount() {
  12702. this.requestScrollReset();
  12703. }
  12704. componentDidUpdate(prevProps) {
  12705. if (prevProps.dateProfile !== this.props.dateProfile) {
  12706. this.requestScrollReset();
  12707. }
  12708. else {
  12709. this.flushScrollReset();
  12710. }
  12711. }
  12712. requestScrollReset() {
  12713. this.needsScrollReset = true;
  12714. this.flushScrollReset();
  12715. }
  12716. flushScrollReset() {
  12717. if (this.needsScrollReset &&
  12718. this.props.clientWidth // sizes computed?
  12719. ) {
  12720. const subjectEl = getScrollSubjectEl(this.elRef.current, this.props.dateProfile);
  12721. if (subjectEl) {
  12722. const originEl = subjectEl.closest('.fc-daygrid-body');
  12723. const scrollEl = originEl.closest('.fc-scroller');
  12724. const scrollTop = subjectEl.getBoundingClientRect().top -
  12725. originEl.getBoundingClientRect().top;
  12726. scrollEl.scrollTop = scrollTop ? (scrollTop + 1) : 0; // overcome border
  12727. }
  12728. this.needsScrollReset = false;
  12729. }
  12730. }
  12731. }
  12732. function getScrollSubjectEl(containerEl, dateProfile) {
  12733. let el;
  12734. if (dateProfile.currentRangeUnit.match(/year|month/)) {
  12735. el = containerEl.querySelector(`[data-date="${formatIsoMonthStr(dateProfile.currentDate)}-01"]`);
  12736. // even if view is month-based, first-of-month might be hidden...
  12737. }
  12738. if (!el) {
  12739. el = containerEl.querySelector(`[data-date="${formatDayString(dateProfile.currentDate)}"]`);
  12740. // could still be hidden if an interior-view hidden day
  12741. }
  12742. return el;
  12743. }
  12744. class DayTableSlicer extends Slicer {
  12745. constructor() {
  12746. super(...arguments);
  12747. this.forceDayIfListItem = true;
  12748. }
  12749. sliceRange(dateRange, dayTableModel) {
  12750. return dayTableModel.sliceRange(dateRange);
  12751. }
  12752. }
  12753. class DayTable extends DateComponent {
  12754. constructor() {
  12755. super(...arguments);
  12756. this.slicer = new DayTableSlicer();
  12757. this.tableRef = d();
  12758. }
  12759. render() {
  12760. let { props, context } = this;
  12761. return (y(Table, Object.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 })));
  12762. }
  12763. }
  12764. class DayTableView extends TableView {
  12765. constructor() {
  12766. super(...arguments);
  12767. this.buildDayTableModel = memoize(buildDayTableModel);
  12768. this.headerRef = d();
  12769. this.tableRef = d();
  12770. // can't override any lifecycle methods from parent
  12771. }
  12772. render() {
  12773. let { options, dateProfileGenerator } = this.context;
  12774. let { props } = this;
  12775. let dayTableModel = this.buildDayTableModel(props.dateProfile, dateProfileGenerator);
  12776. let headerContent = options.dayHeaders && (y(DayHeader, { ref: this.headerRef, dateProfile: props.dateProfile, dates: dayTableModel.headerDates, datesRepDistinctDays: dayTableModel.rowCnt === 1 }));
  12777. let bodyContent = (contentArg) => (y(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 }));
  12778. return options.dayMinWidth
  12779. ? this.renderHScrollLayout(headerContent, bodyContent, dayTableModel.colCnt, options.dayMinWidth)
  12780. : this.renderSimpleLayout(headerContent, bodyContent);
  12781. }
  12782. }
  12783. function buildDayTableModel(dateProfile, dateProfileGenerator) {
  12784. let daySeries = new DaySeriesModel(dateProfile.renderRange, dateProfileGenerator);
  12785. return new DayTableModel(daySeries, /year|month|week/.test(dateProfile.currentRangeUnit));
  12786. }
  12787. class TableDateProfileGenerator extends DateProfileGenerator {
  12788. // Computes the date range that will be rendered
  12789. buildRenderRange(currentRange, currentRangeUnit, isRangeAllDay) {
  12790. let renderRange = super.buildRenderRange(currentRange, currentRangeUnit, isRangeAllDay);
  12791. let { props } = this;
  12792. return buildDayTableRenderRange({
  12793. currentRange: renderRange,
  12794. snapToWeek: /^(year|month)$/.test(currentRangeUnit),
  12795. fixedWeekCount: props.fixedWeekCount,
  12796. dateEnv: props.dateEnv,
  12797. });
  12798. }
  12799. }
  12800. function buildDayTableRenderRange(props) {
  12801. let { dateEnv, currentRange } = props;
  12802. let { start, end } = currentRange;
  12803. let endOfWeek;
  12804. // year and month views should be aligned with weeks. this is already done for week
  12805. if (props.snapToWeek) {
  12806. start = dateEnv.startOfWeek(start);
  12807. // make end-of-week if not already
  12808. endOfWeek = dateEnv.startOfWeek(end);
  12809. if (endOfWeek.valueOf() !== end.valueOf()) {
  12810. end = addWeeks(endOfWeek, 1);
  12811. }
  12812. }
  12813. // ensure 6 weeks
  12814. if (props.fixedWeekCount) {
  12815. // TODO: instead of these date-math gymnastics (for multimonth view),
  12816. // compute dateprofiles of all months, then use start of first and end of last.
  12817. let lastMonthRenderStart = dateEnv.startOfWeek(dateEnv.startOfMonth(addDays(currentRange.end, -1)));
  12818. let rowCnt = Math.ceil(// could be partial weeks due to hiddenDays
  12819. diffWeeks(lastMonthRenderStart, end));
  12820. end = addWeeks(end, 6 - rowCnt);
  12821. }
  12822. return { start, end };
  12823. }
  12824. var css_248z$3 = ":root{--fc-daygrid-event-dot-width:8px}.fc-daygrid-day-events:after,.fc-daygrid-day-events:before,.fc-daygrid-day-frame:after,.fc-daygrid-day-frame:before,.fc-daygrid-event-harness:after,.fc-daygrid-event-harness:before{clear:both;content:\"\";display:table}.fc .fc-daygrid-body{position:relative;z-index:1}.fc .fc-daygrid-day.fc-day-today{background-color:var(--fc-today-bg-color)}.fc .fc-daygrid-day-frame{min-height:100%;position:relative}.fc .fc-daygrid-day-top{display:flex;flex-direction:row-reverse}.fc .fc-day-other .fc-daygrid-day-top{opacity:.3}.fc .fc-daygrid-day-number{padding:4px;position:relative;z-index:4}.fc .fc-daygrid-month-start{font-size:1.1em;font-weight:700}.fc .fc-daygrid-day-events{margin-top:1px}.fc .fc-daygrid-body-balanced .fc-daygrid-day-events{left:0;position:absolute;right:0}.fc .fc-daygrid-body-unbalanced .fc-daygrid-day-events{min-height:2em;position:relative}.fc .fc-daygrid-body-natural .fc-daygrid-day-events{margin-bottom:1em}.fc .fc-daygrid-event-harness{position:relative}.fc .fc-daygrid-event-harness-abs{left:0;position:absolute;right:0;top:0}.fc .fc-daygrid-bg-harness{bottom:0;position:absolute;top:0}.fc .fc-daygrid-day-bg .fc-non-business{z-index:1}.fc .fc-daygrid-day-bg .fc-bg-event{z-index:2}.fc .fc-daygrid-day-bg .fc-highlight{z-index:3}.fc .fc-daygrid-event{margin-top:1px;z-index:6}.fc .fc-daygrid-event.fc-event-mirror{z-index:7}.fc .fc-daygrid-day-bottom{font-size:.85em;margin:0 2px}.fc .fc-daygrid-day-bottom:after,.fc .fc-daygrid-day-bottom:before{clear:both;content:\"\";display:table}.fc .fc-daygrid-more-link{border-radius:3px;cursor:pointer;line-height:1;margin-top:1px;max-width:100%;overflow:hidden;padding:2px;position:relative;white-space:nowrap;z-index:4}.fc .fc-daygrid-more-link:hover{background-color:rgba(0,0,0,.1)}.fc .fc-daygrid-week-number{background-color:var(--fc-neutral-bg-color);color:var(--fc-neutral-text-color);min-width:1.5em;padding:2px;position:absolute;text-align:center;top:0;z-index:5}.fc .fc-more-popover .fc-popover-body{min-width:220px;padding:10px}.fc-direction-ltr .fc-daygrid-event.fc-event-start,.fc-direction-rtl .fc-daygrid-event.fc-event-end{margin-left:2px}.fc-direction-ltr .fc-daygrid-event.fc-event-end,.fc-direction-rtl .fc-daygrid-event.fc-event-start{margin-right:2px}.fc-direction-ltr .fc-daygrid-more-link{float:left}.fc-direction-ltr .fc-daygrid-week-number{border-radius:0 0 3px 0;left:0}.fc-direction-rtl .fc-daygrid-more-link{float:right}.fc-direction-rtl .fc-daygrid-week-number{border-radius:0 0 0 3px;right:0}.fc-liquid-hack .fc-daygrid-day-frame{position:static}.fc-daygrid-event{border-radius:3px;font-size:var(--fc-small-font-size);position:relative;white-space:nowrap}.fc-daygrid-block-event .fc-event-time{font-weight:700}.fc-daygrid-block-event .fc-event-time,.fc-daygrid-block-event .fc-event-title{padding:1px}.fc-daygrid-dot-event{align-items:center;display:flex;padding:2px 0}.fc-daygrid-dot-event .fc-event-title{flex-grow:1;flex-shrink:1;font-weight:700;min-width:0;overflow:hidden}.fc-daygrid-dot-event.fc-event-mirror,.fc-daygrid-dot-event:hover{background:rgba(0,0,0,.1)}.fc-daygrid-dot-event.fc-event-selected:before{bottom:-10px;top:-10px}.fc-daygrid-event-dot{border:calc(var(--fc-daygrid-event-dot-width)/2) solid var(--fc-event-border-color);border-radius:calc(var(--fc-daygrid-event-dot-width)/2);box-sizing:content-box;height:0;margin:0 4px;width:0}.fc-direction-ltr .fc-daygrid-event .fc-event-time{margin-right:3px}.fc-direction-rtl .fc-daygrid-event .fc-event-time{margin-left:3px}";
  12825. injectStyles(css_248z$3);
  12826. var index$3 = createPlugin({
  12827. name: '@fullcalendar/daygrid',
  12828. initialView: 'dayGridMonth',
  12829. views: {
  12830. dayGrid: {
  12831. component: DayTableView,
  12832. dateProfileGeneratorClass: TableDateProfileGenerator,
  12833. },
  12834. dayGridDay: {
  12835. type: 'dayGrid',
  12836. duration: { days: 1 },
  12837. },
  12838. dayGridWeek: {
  12839. type: 'dayGrid',
  12840. duration: { weeks: 1 },
  12841. },
  12842. dayGridMonth: {
  12843. type: 'dayGrid',
  12844. duration: { months: 1 },
  12845. fixedWeekCount: true,
  12846. },
  12847. dayGridYear: {
  12848. type: 'dayGrid',
  12849. duration: { years: 1 },
  12850. },
  12851. },
  12852. });
  12853. class AllDaySplitter extends Splitter {
  12854. getKeyInfo() {
  12855. return {
  12856. allDay: {},
  12857. timed: {},
  12858. };
  12859. }
  12860. getKeysForDateSpan(dateSpan) {
  12861. if (dateSpan.allDay) {
  12862. return ['allDay'];
  12863. }
  12864. return ['timed'];
  12865. }
  12866. getKeysForEventDef(eventDef) {
  12867. if (!eventDef.allDay) {
  12868. return ['timed'];
  12869. }
  12870. if (hasBgRendering(eventDef)) {
  12871. return ['timed', 'allDay'];
  12872. }
  12873. return ['allDay'];
  12874. }
  12875. }
  12876. const DEFAULT_SLAT_LABEL_FORMAT = createFormatter({
  12877. hour: 'numeric',
  12878. minute: '2-digit',
  12879. omitZeroMinute: true,
  12880. meridiem: 'short',
  12881. });
  12882. function TimeColsAxisCell(props) {
  12883. let classNames = [
  12884. 'fc-timegrid-slot',
  12885. 'fc-timegrid-slot-label',
  12886. props.isLabeled ? 'fc-scrollgrid-shrink' : 'fc-timegrid-slot-minor',
  12887. ];
  12888. return (y(ViewContextType.Consumer, null, (context) => {
  12889. if (!props.isLabeled) {
  12890. return (y("td", { className: classNames.join(' '), "data-time": props.isoTimeStr }));
  12891. }
  12892. let { dateEnv, options, viewApi } = context;
  12893. let labelFormat = // TODO: fully pre-parse
  12894. options.slotLabelFormat == null ? DEFAULT_SLAT_LABEL_FORMAT :
  12895. Array.isArray(options.slotLabelFormat) ? createFormatter(options.slotLabelFormat[0]) :
  12896. createFormatter(options.slotLabelFormat);
  12897. let renderProps = {
  12898. level: 0,
  12899. time: props.time,
  12900. date: dateEnv.toDate(props.date),
  12901. view: viewApi,
  12902. text: dateEnv.format(props.date, labelFormat),
  12903. };
  12904. return (y(ContentContainer, { elTag: "td", elClasses: classNames, elAttrs: {
  12905. 'data-time': props.isoTimeStr,
  12906. }, renderProps: renderProps, generatorName: "slotLabelContent", customGenerator: options.slotLabelContent, defaultGenerator: renderInnerContent$1, classNameGenerator: options.slotLabelClassNames, didMount: options.slotLabelDidMount, willUnmount: options.slotLabelWillUnmount }, (InnerContent) => (y("div", { className: "fc-timegrid-slot-label-frame fc-scrollgrid-shrink-frame" },
  12907. y(InnerContent, { elTag: "div", elClasses: [
  12908. 'fc-timegrid-slot-label-cushion',
  12909. 'fc-scrollgrid-shrink-cushion',
  12910. ] })))));
  12911. }));
  12912. }
  12913. function renderInnerContent$1(props) {
  12914. return props.text;
  12915. }
  12916. class TimeBodyAxis extends BaseComponent {
  12917. render() {
  12918. return this.props.slatMetas.map((slatMeta) => (y("tr", { key: slatMeta.key },
  12919. y(TimeColsAxisCell, Object.assign({}, slatMeta)))));
  12920. }
  12921. }
  12922. const DEFAULT_WEEK_NUM_FORMAT = createFormatter({ week: 'short' });
  12923. const AUTO_ALL_DAY_MAX_EVENT_ROWS = 5;
  12924. class TimeColsView extends DateComponent {
  12925. constructor() {
  12926. super(...arguments);
  12927. this.allDaySplitter = new AllDaySplitter(); // for use by subclasses
  12928. this.headerElRef = d();
  12929. this.rootElRef = d();
  12930. this.scrollerElRef = d();
  12931. this.state = {
  12932. slatCoords: null,
  12933. };
  12934. this.handleScrollTopRequest = (scrollTop) => {
  12935. let scrollerEl = this.scrollerElRef.current;
  12936. if (scrollerEl) { // TODO: not sure how this could ever be null. weirdness with the reducer
  12937. scrollerEl.scrollTop = scrollTop;
  12938. }
  12939. };
  12940. /* Header Render Methods
  12941. ------------------------------------------------------------------------------------------------------------------*/
  12942. this.renderHeadAxis = (rowKey, frameHeight = '') => {
  12943. let { options } = this.context;
  12944. let { dateProfile } = this.props;
  12945. let range = dateProfile.renderRange;
  12946. let dayCnt = diffDays(range.start, range.end);
  12947. // only do in day views (to avoid doing in week views that dont need it)
  12948. let navLinkAttrs = (dayCnt === 1)
  12949. ? buildNavLinkAttrs(this.context, range.start, 'week')
  12950. : {};
  12951. if (options.weekNumbers && rowKey === 'day') {
  12952. return (y(WeekNumberContainer, { elTag: "th", elClasses: [
  12953. 'fc-timegrid-axis',
  12954. 'fc-scrollgrid-shrink',
  12955. ], elAttrs: {
  12956. 'aria-hidden': true,
  12957. }, date: range.start, defaultFormat: DEFAULT_WEEK_NUM_FORMAT }, (InnerContent) => (y("div", { className: [
  12958. 'fc-timegrid-axis-frame',
  12959. 'fc-scrollgrid-shrink-frame',
  12960. 'fc-timegrid-axis-frame-liquid',
  12961. ].join(' '), style: { height: frameHeight } },
  12962. y(InnerContent, { elTag: "a", elClasses: [
  12963. 'fc-timegrid-axis-cushion',
  12964. 'fc-scrollgrid-shrink-cushion',
  12965. 'fc-scrollgrid-sync-inner',
  12966. ], elAttrs: navLinkAttrs })))));
  12967. }
  12968. return (y("th", { "aria-hidden": true, className: "fc-timegrid-axis" },
  12969. y("div", { className: "fc-timegrid-axis-frame", style: { height: frameHeight } })));
  12970. };
  12971. /* Table Component Render Methods
  12972. ------------------------------------------------------------------------------------------------------------------*/
  12973. // only a one-way height sync. we don't send the axis inner-content height to the DayGrid,
  12974. // but DayGrid still needs to have classNames on inner elements in order to measure.
  12975. this.renderTableRowAxis = (rowHeight) => {
  12976. let { options, viewApi } = this.context;
  12977. let renderProps = {
  12978. text: options.allDayText,
  12979. view: viewApi,
  12980. };
  12981. return (
  12982. // TODO: make reusable hook. used in list view too
  12983. y(ContentContainer, { elTag: "td", elClasses: [
  12984. 'fc-timegrid-axis',
  12985. 'fc-scrollgrid-shrink',
  12986. ], elAttrs: {
  12987. 'aria-hidden': true,
  12988. }, renderProps: renderProps, generatorName: "allDayContent", customGenerator: options.allDayContent, defaultGenerator: renderAllDayInner$1, classNameGenerator: options.allDayClassNames, didMount: options.allDayDidMount, willUnmount: options.allDayWillUnmount }, (InnerContent) => (y("div", { className: [
  12989. 'fc-timegrid-axis-frame',
  12990. 'fc-scrollgrid-shrink-frame',
  12991. rowHeight == null ? ' fc-timegrid-axis-frame-liquid' : '',
  12992. ].join(' '), style: { height: rowHeight } },
  12993. y(InnerContent, { elTag: "span", elClasses: [
  12994. 'fc-timegrid-axis-cushion',
  12995. 'fc-scrollgrid-shrink-cushion',
  12996. 'fc-scrollgrid-sync-inner',
  12997. ] })))));
  12998. };
  12999. this.handleSlatCoords = (slatCoords) => {
  13000. this.setState({ slatCoords });
  13001. };
  13002. }
  13003. // rendering
  13004. // ----------------------------------------------------------------------------------------------------
  13005. renderSimpleLayout(headerRowContent, allDayContent, timeContent) {
  13006. let { context, props } = this;
  13007. let sections = [];
  13008. let stickyHeaderDates = getStickyHeaderDates(context.options);
  13009. if (headerRowContent) {
  13010. sections.push({
  13011. type: 'header',
  13012. key: 'header',
  13013. isSticky: stickyHeaderDates,
  13014. chunk: {
  13015. elRef: this.headerElRef,
  13016. tableClassName: 'fc-col-header',
  13017. rowContent: headerRowContent,
  13018. },
  13019. });
  13020. }
  13021. if (allDayContent) {
  13022. sections.push({
  13023. type: 'body',
  13024. key: 'all-day',
  13025. chunk: { content: allDayContent },
  13026. });
  13027. sections.push({
  13028. type: 'body',
  13029. key: 'all-day-divider',
  13030. outerContent: ( // TODO: rename to cellContent so don't need to define <tr>?
  13031. y("tr", { role: "presentation", className: "fc-scrollgrid-section" },
  13032. y("td", { className: 'fc-timegrid-divider ' + context.theme.getClass('tableCellShaded') }))),
  13033. });
  13034. }
  13035. sections.push({
  13036. type: 'body',
  13037. key: 'body',
  13038. liquid: true,
  13039. expandRows: Boolean(context.options.expandRows),
  13040. chunk: {
  13041. scrollerElRef: this.scrollerElRef,
  13042. content: timeContent,
  13043. },
  13044. });
  13045. return (y(ViewContainer, { elRef: this.rootElRef, elClasses: ['fc-timegrid'], viewSpec: context.viewSpec },
  13046. y(SimpleScrollGrid, { liquid: !props.isHeightAuto && !props.forPrint, collapsibleWidth: props.forPrint, cols: [{ width: 'shrink' }], sections: sections })));
  13047. }
  13048. renderHScrollLayout(headerRowContent, allDayContent, timeContent, colCnt, dayMinWidth, slatMetas, slatCoords) {
  13049. let ScrollGrid = this.context.pluginHooks.scrollGridImpl;
  13050. if (!ScrollGrid) {
  13051. throw new Error('No ScrollGrid implementation');
  13052. }
  13053. let { context, props } = this;
  13054. let stickyHeaderDates = !props.forPrint && getStickyHeaderDates(context.options);
  13055. let stickyFooterScrollbar = !props.forPrint && getStickyFooterScrollbar(context.options);
  13056. let sections = [];
  13057. if (headerRowContent) {
  13058. sections.push({
  13059. type: 'header',
  13060. key: 'header',
  13061. isSticky: stickyHeaderDates,
  13062. syncRowHeights: true,
  13063. chunks: [
  13064. {
  13065. key: 'axis',
  13066. rowContent: (arg) => (y("tr", { role: "presentation" }, this.renderHeadAxis('day', arg.rowSyncHeights[0]))),
  13067. },
  13068. {
  13069. key: 'cols',
  13070. elRef: this.headerElRef,
  13071. tableClassName: 'fc-col-header',
  13072. rowContent: headerRowContent,
  13073. },
  13074. ],
  13075. });
  13076. }
  13077. if (allDayContent) {
  13078. sections.push({
  13079. type: 'body',
  13080. key: 'all-day',
  13081. syncRowHeights: true,
  13082. chunks: [
  13083. {
  13084. key: 'axis',
  13085. rowContent: (contentArg) => (y("tr", { role: "presentation" }, this.renderTableRowAxis(contentArg.rowSyncHeights[0]))),
  13086. },
  13087. {
  13088. key: 'cols',
  13089. content: allDayContent,
  13090. },
  13091. ],
  13092. });
  13093. sections.push({
  13094. key: 'all-day-divider',
  13095. type: 'body',
  13096. outerContent: ( // TODO: rename to cellContent so don't need to define <tr>?
  13097. y("tr", { role: "presentation", className: "fc-scrollgrid-section" },
  13098. y("td", { colSpan: 2, className: 'fc-timegrid-divider ' + context.theme.getClass('tableCellShaded') }))),
  13099. });
  13100. }
  13101. let isNowIndicator = context.options.nowIndicator;
  13102. sections.push({
  13103. type: 'body',
  13104. key: 'body',
  13105. liquid: true,
  13106. expandRows: Boolean(context.options.expandRows),
  13107. chunks: [
  13108. {
  13109. key: 'axis',
  13110. content: (arg) => (
  13111. // TODO: make this now-indicator arrow more DRY with TimeColsContent
  13112. y("div", { className: "fc-timegrid-axis-chunk" },
  13113. y("table", { "aria-hidden": true, style: { height: arg.expandRows ? arg.clientHeight : '' } },
  13114. arg.tableColGroupNode,
  13115. y("tbody", null,
  13116. y(TimeBodyAxis, { slatMetas: slatMetas }))),
  13117. y("div", { className: "fc-timegrid-now-indicator-container" },
  13118. y(NowTimer, { unit: isNowIndicator ? 'minute' : 'day' /* hacky */ }, (nowDate) => {
  13119. let nowIndicatorTop = isNowIndicator &&
  13120. slatCoords &&
  13121. slatCoords.safeComputeTop(nowDate); // might return void
  13122. if (typeof nowIndicatorTop === 'number') {
  13123. return (y(NowIndicatorContainer, { elClasses: ['fc-timegrid-now-indicator-arrow'], elStyle: { top: nowIndicatorTop }, isAxis: true, date: nowDate }));
  13124. }
  13125. return null;
  13126. })))),
  13127. },
  13128. {
  13129. key: 'cols',
  13130. scrollerElRef: this.scrollerElRef,
  13131. content: timeContent,
  13132. },
  13133. ],
  13134. });
  13135. if (stickyFooterScrollbar) {
  13136. sections.push({
  13137. key: 'footer',
  13138. type: 'footer',
  13139. isSticky: true,
  13140. chunks: [
  13141. {
  13142. key: 'axis',
  13143. content: renderScrollShim,
  13144. },
  13145. {
  13146. key: 'cols',
  13147. content: renderScrollShim,
  13148. },
  13149. ],
  13150. });
  13151. }
  13152. return (y(ViewContainer, { elRef: this.rootElRef, elClasses: ['fc-timegrid'], viewSpec: context.viewSpec },
  13153. y(ScrollGrid, { liquid: !props.isHeightAuto && !props.forPrint, forPrint: props.forPrint, collapsibleWidth: false, colGroups: [
  13154. { width: 'shrink', cols: [{ width: 'shrink' }] },
  13155. { cols: [{ span: colCnt, minWidth: dayMinWidth }] },
  13156. ], sections: sections })));
  13157. }
  13158. /* Dimensions
  13159. ------------------------------------------------------------------------------------------------------------------*/
  13160. getAllDayMaxEventProps() {
  13161. let { dayMaxEvents, dayMaxEventRows } = this.context.options;
  13162. if (dayMaxEvents === true || dayMaxEventRows === true) { // is auto?
  13163. dayMaxEvents = undefined;
  13164. dayMaxEventRows = AUTO_ALL_DAY_MAX_EVENT_ROWS; // make sure "auto" goes to a real number
  13165. }
  13166. return { dayMaxEvents, dayMaxEventRows };
  13167. }
  13168. }
  13169. function renderAllDayInner$1(renderProps) {
  13170. return renderProps.text;
  13171. }
  13172. class TimeColsSlatsCoords {
  13173. constructor(positions, dateProfile, slotDuration) {
  13174. this.positions = positions;
  13175. this.dateProfile = dateProfile;
  13176. this.slotDuration = slotDuration;
  13177. }
  13178. safeComputeTop(date) {
  13179. let { dateProfile } = this;
  13180. if (rangeContainsMarker(dateProfile.currentRange, date)) {
  13181. let startOfDayDate = startOfDay(date);
  13182. let timeMs = date.valueOf() - startOfDayDate.valueOf();
  13183. if (timeMs >= asRoughMs(dateProfile.slotMinTime) &&
  13184. timeMs < asRoughMs(dateProfile.slotMaxTime)) {
  13185. return this.computeTimeTop(createDuration(timeMs));
  13186. }
  13187. }
  13188. return null;
  13189. }
  13190. // Computes the top coordinate, relative to the bounds of the grid, of the given date.
  13191. // A `startOfDayDate` must be given for avoiding ambiguity over how to treat midnight.
  13192. computeDateTop(when, startOfDayDate) {
  13193. if (!startOfDayDate) {
  13194. startOfDayDate = startOfDay(when);
  13195. }
  13196. return this.computeTimeTop(createDuration(when.valueOf() - startOfDayDate.valueOf()));
  13197. }
  13198. // Computes the top coordinate, relative to the bounds of the grid, of the given time (a Duration).
  13199. // This is a makeshify way to compute the time-top. Assumes all slatMetas dates are uniform.
  13200. // Eventually allow computation with arbirary slat dates.
  13201. computeTimeTop(duration) {
  13202. let { positions, dateProfile } = this;
  13203. let len = positions.els.length;
  13204. // floating-point value of # of slots covered
  13205. let slatCoverage = (duration.milliseconds - asRoughMs(dateProfile.slotMinTime)) / asRoughMs(this.slotDuration);
  13206. let slatIndex;
  13207. let slatRemainder;
  13208. // compute a floating-point number for how many slats should be progressed through.
  13209. // from 0 to number of slats (inclusive)
  13210. // constrained because slotMinTime/slotMaxTime might be customized.
  13211. slatCoverage = Math.max(0, slatCoverage);
  13212. slatCoverage = Math.min(len, slatCoverage);
  13213. // an integer index of the furthest whole slat
  13214. // from 0 to number slats (*exclusive*, so len-1)
  13215. slatIndex = Math.floor(slatCoverage);
  13216. slatIndex = Math.min(slatIndex, len - 1);
  13217. // how much further through the slatIndex slat (from 0.0-1.0) must be covered in addition.
  13218. // could be 1.0 if slatCoverage is covering *all* the slots
  13219. slatRemainder = slatCoverage - slatIndex;
  13220. return positions.tops[slatIndex] +
  13221. positions.getHeight(slatIndex) * slatRemainder;
  13222. }
  13223. }
  13224. class TimeColsSlatsBody extends BaseComponent {
  13225. render() {
  13226. let { props, context } = this;
  13227. let { options } = context;
  13228. let { slatElRefs } = props;
  13229. return (y("tbody", null, props.slatMetas.map((slatMeta, i) => {
  13230. let renderProps = {
  13231. time: slatMeta.time,
  13232. date: context.dateEnv.toDate(slatMeta.date),
  13233. view: context.viewApi,
  13234. };
  13235. return (y("tr", { key: slatMeta.key, ref: slatElRefs.createRef(slatMeta.key) },
  13236. props.axis && (y(TimeColsAxisCell, Object.assign({}, slatMeta))),
  13237. y(ContentContainer, { elTag: "td", elClasses: [
  13238. 'fc-timegrid-slot',
  13239. 'fc-timegrid-slot-lane',
  13240. !slatMeta.isLabeled && 'fc-timegrid-slot-minor',
  13241. ], elAttrs: {
  13242. 'data-time': slatMeta.isoTimeStr,
  13243. }, renderProps: renderProps, generatorName: "slotLaneContent", customGenerator: options.slotLaneContent, classNameGenerator: options.slotLaneClassNames, didMount: options.slotLaneDidMount, willUnmount: options.slotLaneWillUnmount })));
  13244. })));
  13245. }
  13246. }
  13247. /*
  13248. for the horizontal "slats" that run width-wise. Has a time axis on a side. Depends on RTL.
  13249. */
  13250. class TimeColsSlats extends BaseComponent {
  13251. constructor() {
  13252. super(...arguments);
  13253. this.rootElRef = d();
  13254. this.slatElRefs = new RefMap();
  13255. }
  13256. render() {
  13257. let { props, context } = this;
  13258. return (y("div", { ref: this.rootElRef, className: "fc-timegrid-slots" },
  13259. y("table", { "aria-hidden": true, className: context.theme.getClass('table'), style: {
  13260. minWidth: props.tableMinWidth,
  13261. width: props.clientWidth,
  13262. height: props.minHeight,
  13263. } },
  13264. props.tableColGroupNode /* relies on there only being a single <col> for the axis */,
  13265. y(TimeColsSlatsBody, { slatElRefs: this.slatElRefs, axis: props.axis, slatMetas: props.slatMetas }))));
  13266. }
  13267. componentDidMount() {
  13268. this.updateSizing();
  13269. }
  13270. componentDidUpdate() {
  13271. this.updateSizing();
  13272. }
  13273. componentWillUnmount() {
  13274. if (this.props.onCoords) {
  13275. this.props.onCoords(null);
  13276. }
  13277. }
  13278. updateSizing() {
  13279. let { context, props } = this;
  13280. if (props.onCoords &&
  13281. props.clientWidth !== null // means sizing has stabilized
  13282. ) {
  13283. let rootEl = this.rootElRef.current;
  13284. if (rootEl.offsetHeight) { // not hidden by css
  13285. props.onCoords(new TimeColsSlatsCoords(new PositionCache(this.rootElRef.current, collectSlatEls(this.slatElRefs.currentMap, props.slatMetas), false, true), this.props.dateProfile, context.options.slotDuration));
  13286. }
  13287. }
  13288. }
  13289. }
  13290. function collectSlatEls(elMap, slatMetas) {
  13291. return slatMetas.map((slatMeta) => elMap[slatMeta.key]);
  13292. }
  13293. function splitSegsByCol(segs, colCnt) {
  13294. let segsByCol = [];
  13295. let i;
  13296. for (i = 0; i < colCnt; i += 1) {
  13297. segsByCol.push([]);
  13298. }
  13299. if (segs) {
  13300. for (i = 0; i < segs.length; i += 1) {
  13301. segsByCol[segs[i].col].push(segs[i]);
  13302. }
  13303. }
  13304. return segsByCol;
  13305. }
  13306. function splitInteractionByCol(ui, colCnt) {
  13307. let byRow = [];
  13308. if (!ui) {
  13309. for (let i = 0; i < colCnt; i += 1) {
  13310. byRow[i] = null;
  13311. }
  13312. }
  13313. else {
  13314. for (let i = 0; i < colCnt; i += 1) {
  13315. byRow[i] = {
  13316. affectedInstances: ui.affectedInstances,
  13317. isEvent: ui.isEvent,
  13318. segs: [],
  13319. };
  13320. }
  13321. for (let seg of ui.segs) {
  13322. byRow[seg.col].segs.push(seg);
  13323. }
  13324. }
  13325. return byRow;
  13326. }
  13327. class TimeColMoreLink extends BaseComponent {
  13328. render() {
  13329. let { props } = this;
  13330. return (y(MoreLinkContainer, { elClasses: ['fc-timegrid-more-link'], elStyle: {
  13331. top: props.top,
  13332. bottom: props.bottom,
  13333. }, allDayDate: null, moreCnt: props.hiddenSegs.length, allSegs: props.hiddenSegs, hiddenSegs: props.hiddenSegs, extraDateSpan: props.extraDateSpan, dateProfile: props.dateProfile, todayRange: props.todayRange, popoverContent: () => renderPlainFgSegs(props.hiddenSegs, props), defaultGenerator: renderMoreLinkInner, forceTimed: true }, (InnerContent) => (y(InnerContent, { elTag: "div", elClasses: ['fc-timegrid-more-link-inner', 'fc-sticky'] }))));
  13334. }
  13335. }
  13336. function renderMoreLinkInner(props) {
  13337. return props.shortText;
  13338. }
  13339. // segInputs assumed sorted
  13340. function buildPositioning(segInputs, strictOrder, maxStackCnt) {
  13341. let hierarchy = new SegHierarchy();
  13342. if (strictOrder != null) {
  13343. hierarchy.strictOrder = strictOrder;
  13344. }
  13345. if (maxStackCnt != null) {
  13346. hierarchy.maxStackCnt = maxStackCnt;
  13347. }
  13348. let hiddenEntries = hierarchy.addSegs(segInputs);
  13349. let hiddenGroups = groupIntersectingEntries(hiddenEntries);
  13350. let web = buildWeb(hierarchy);
  13351. web = stretchWeb(web, 1); // all levelCoords/thickness will have 0.0-1.0
  13352. let segRects = webToRects(web);
  13353. return { segRects, hiddenGroups };
  13354. }
  13355. function buildWeb(hierarchy) {
  13356. const { entriesByLevel } = hierarchy;
  13357. const buildNode = cacheable((level, lateral) => level + ':' + lateral, (level, lateral) => {
  13358. let siblingRange = findNextLevelSegs(hierarchy, level, lateral);
  13359. let nextLevelRes = buildNodes(siblingRange, buildNode);
  13360. let entry = entriesByLevel[level][lateral];
  13361. return [
  13362. Object.assign(Object.assign({}, entry), { nextLevelNodes: nextLevelRes[0] }),
  13363. entry.thickness + nextLevelRes[1], // the pressure builds
  13364. ];
  13365. });
  13366. return buildNodes(entriesByLevel.length
  13367. ? { level: 0, lateralStart: 0, lateralEnd: entriesByLevel[0].length }
  13368. : null, buildNode)[0];
  13369. }
  13370. function buildNodes(siblingRange, buildNode) {
  13371. if (!siblingRange) {
  13372. return [[], 0];
  13373. }
  13374. let { level, lateralStart, lateralEnd } = siblingRange;
  13375. let lateral = lateralStart;
  13376. let pairs = [];
  13377. while (lateral < lateralEnd) {
  13378. pairs.push(buildNode(level, lateral));
  13379. lateral += 1;
  13380. }
  13381. pairs.sort(cmpDescPressures);
  13382. return [
  13383. pairs.map(extractNode),
  13384. pairs[0][1], // first item's pressure
  13385. ];
  13386. }
  13387. function cmpDescPressures(a, b) {
  13388. return b[1] - a[1];
  13389. }
  13390. function extractNode(a) {
  13391. return a[0];
  13392. }
  13393. function findNextLevelSegs(hierarchy, subjectLevel, subjectLateral) {
  13394. let { levelCoords, entriesByLevel } = hierarchy;
  13395. let subjectEntry = entriesByLevel[subjectLevel][subjectLateral];
  13396. let afterSubject = levelCoords[subjectLevel] + subjectEntry.thickness;
  13397. let levelCnt = levelCoords.length;
  13398. let level = subjectLevel;
  13399. // skip past levels that are too high up
  13400. for (; level < levelCnt && levelCoords[level] < afterSubject; level += 1)
  13401. ; // do nothing
  13402. for (; level < levelCnt; level += 1) {
  13403. let entries = entriesByLevel[level];
  13404. let entry;
  13405. let searchIndex = binarySearch(entries, subjectEntry.span.start, getEntrySpanEnd);
  13406. let lateralStart = searchIndex[0] + searchIndex[1]; // if exact match (which doesn't collide), go to next one
  13407. let lateralEnd = lateralStart;
  13408. while ( // loop through entries that horizontally intersect
  13409. (entry = entries[lateralEnd]) && // but not past the whole seg list
  13410. entry.span.start < subjectEntry.span.end) {
  13411. lateralEnd += 1;
  13412. }
  13413. if (lateralStart < lateralEnd) {
  13414. return { level, lateralStart, lateralEnd };
  13415. }
  13416. }
  13417. return null;
  13418. }
  13419. function stretchWeb(topLevelNodes, totalThickness) {
  13420. const stretchNode = cacheable((node, startCoord, prevThickness) => buildEntryKey(node), (node, startCoord, prevThickness) => {
  13421. let { nextLevelNodes, thickness } = node;
  13422. let allThickness = thickness + prevThickness;
  13423. let thicknessFraction = thickness / allThickness;
  13424. let endCoord;
  13425. let newChildren = [];
  13426. if (!nextLevelNodes.length) {
  13427. endCoord = totalThickness;
  13428. }
  13429. else {
  13430. for (let childNode of nextLevelNodes) {
  13431. if (endCoord === undefined) {
  13432. let res = stretchNode(childNode, startCoord, allThickness);
  13433. endCoord = res[0];
  13434. newChildren.push(res[1]);
  13435. }
  13436. else {
  13437. let res = stretchNode(childNode, endCoord, 0);
  13438. newChildren.push(res[1]);
  13439. }
  13440. }
  13441. }
  13442. let newThickness = (endCoord - startCoord) * thicknessFraction;
  13443. return [endCoord - newThickness, Object.assign(Object.assign({}, node), { thickness: newThickness, nextLevelNodes: newChildren })];
  13444. });
  13445. return topLevelNodes.map((node) => stretchNode(node, 0, 0)[1]);
  13446. }
  13447. // not sorted in any particular order
  13448. function webToRects(topLevelNodes) {
  13449. let rects = [];
  13450. const processNode = cacheable((node, levelCoord, stackDepth) => buildEntryKey(node), (node, levelCoord, stackDepth) => {
  13451. let rect = Object.assign(Object.assign({}, node), { levelCoord,
  13452. stackDepth, stackForward: 0 });
  13453. rects.push(rect);
  13454. return (rect.stackForward = processNodes(node.nextLevelNodes, levelCoord + node.thickness, stackDepth + 1) + 1);
  13455. });
  13456. function processNodes(nodes, levelCoord, stackDepth) {
  13457. let stackForward = 0;
  13458. for (let node of nodes) {
  13459. stackForward = Math.max(processNode(node, levelCoord, stackDepth), stackForward);
  13460. }
  13461. return stackForward;
  13462. }
  13463. processNodes(topLevelNodes, 0, 0);
  13464. return rects; // TODO: sort rects by levelCoord to be consistent with toRects?
  13465. }
  13466. // TODO: move to general util
  13467. function cacheable(keyFunc, workFunc) {
  13468. const cache = {};
  13469. return (...args) => {
  13470. let key = keyFunc(...args);
  13471. return (key in cache)
  13472. ? cache[key]
  13473. : (cache[key] = workFunc(...args));
  13474. };
  13475. }
  13476. function computeSegVCoords(segs, colDate, slatCoords = null, eventMinHeight = 0) {
  13477. let vcoords = [];
  13478. if (slatCoords) {
  13479. for (let i = 0; i < segs.length; i += 1) {
  13480. let seg = segs[i];
  13481. let spanStart = slatCoords.computeDateTop(seg.start, colDate);
  13482. let spanEnd = Math.max(spanStart + (eventMinHeight || 0), // :(
  13483. slatCoords.computeDateTop(seg.end, colDate));
  13484. vcoords.push({
  13485. start: Math.round(spanStart),
  13486. end: Math.round(spanEnd), //
  13487. });
  13488. }
  13489. }
  13490. return vcoords;
  13491. }
  13492. function computeFgSegPlacements(segs, segVCoords, // might not have for every seg
  13493. eventOrderStrict, eventMaxStack) {
  13494. let segInputs = [];
  13495. let dumbSegs = []; // segs without coords
  13496. for (let i = 0; i < segs.length; i += 1) {
  13497. let vcoords = segVCoords[i];
  13498. if (vcoords) {
  13499. segInputs.push({
  13500. index: i,
  13501. thickness: 1,
  13502. span: vcoords,
  13503. });
  13504. }
  13505. else {
  13506. dumbSegs.push(segs[i]);
  13507. }
  13508. }
  13509. let { segRects, hiddenGroups } = buildPositioning(segInputs, eventOrderStrict, eventMaxStack);
  13510. let segPlacements = [];
  13511. for (let segRect of segRects) {
  13512. segPlacements.push({
  13513. seg: segs[segRect.index],
  13514. rect: segRect,
  13515. });
  13516. }
  13517. for (let dumbSeg of dumbSegs) {
  13518. segPlacements.push({ seg: dumbSeg, rect: null });
  13519. }
  13520. return { segPlacements, hiddenGroups };
  13521. }
  13522. const DEFAULT_TIME_FORMAT$1 = createFormatter({
  13523. hour: 'numeric',
  13524. minute: '2-digit',
  13525. meridiem: false,
  13526. });
  13527. class TimeColEvent extends BaseComponent {
  13528. render() {
  13529. return (y(StandardEvent, Object.assign({}, this.props, { elClasses: [
  13530. 'fc-timegrid-event',
  13531. 'fc-v-event',
  13532. this.props.isShort && 'fc-timegrid-event-short',
  13533. ], defaultTimeFormat: DEFAULT_TIME_FORMAT$1 })));
  13534. }
  13535. }
  13536. class TimeCol extends BaseComponent {
  13537. constructor() {
  13538. super(...arguments);
  13539. this.sortEventSegs = memoize(sortEventSegs);
  13540. }
  13541. // TODO: memoize event-placement?
  13542. render() {
  13543. let { props, context } = this;
  13544. let { options } = context;
  13545. let isSelectMirror = options.selectMirror;
  13546. let mirrorSegs = // yuck
  13547. (props.eventDrag && props.eventDrag.segs) ||
  13548. (props.eventResize && props.eventResize.segs) ||
  13549. (isSelectMirror && props.dateSelectionSegs) ||
  13550. [];
  13551. let interactionAffectedInstances = // TODO: messy way to compute this
  13552. (props.eventDrag && props.eventDrag.affectedInstances) ||
  13553. (props.eventResize && props.eventResize.affectedInstances) ||
  13554. {};
  13555. let sortedFgSegs = this.sortEventSegs(props.fgEventSegs, options.eventOrder);
  13556. return (y(DayCellContainer, { elTag: "td", elRef: props.elRef, elClasses: [
  13557. 'fc-timegrid-col',
  13558. ...(props.extraClassNames || []),
  13559. ], elAttrs: Object.assign({ role: 'gridcell' }, props.extraDataAttrs), date: props.date, dateProfile: props.dateProfile, todayRange: props.todayRange, extraRenderProps: props.extraRenderProps }, (InnerContent) => (y("div", { className: "fc-timegrid-col-frame" },
  13560. y("div", { className: "fc-timegrid-col-bg" },
  13561. this.renderFillSegs(props.businessHourSegs, 'non-business'),
  13562. this.renderFillSegs(props.bgEventSegs, 'bg-event'),
  13563. this.renderFillSegs(props.dateSelectionSegs, 'highlight')),
  13564. y("div", { className: "fc-timegrid-col-events" }, this.renderFgSegs(sortedFgSegs, interactionAffectedInstances, false, false, false)),
  13565. y("div", { className: "fc-timegrid-col-events" }, this.renderFgSegs(mirrorSegs, {}, Boolean(props.eventDrag), Boolean(props.eventResize), Boolean(isSelectMirror), 'mirror')),
  13566. y("div", { className: "fc-timegrid-now-indicator-container" }, this.renderNowIndicator(props.nowIndicatorSegs)),
  13567. hasCustomDayCellContent(options) && (y(InnerContent, { elTag: "div", elClasses: ['fc-timegrid-col-misc'] }))))));
  13568. }
  13569. renderFgSegs(sortedFgSegs, segIsInvisible, isDragging, isResizing, isDateSelecting, forcedKey) {
  13570. let { props } = this;
  13571. if (props.forPrint) {
  13572. return renderPlainFgSegs(sortedFgSegs, props);
  13573. }
  13574. return this.renderPositionedFgSegs(sortedFgSegs, segIsInvisible, isDragging, isResizing, isDateSelecting, forcedKey);
  13575. }
  13576. renderPositionedFgSegs(segs, // if not mirror, needs to be sorted
  13577. segIsInvisible, isDragging, isResizing, isDateSelecting, forcedKey) {
  13578. let { eventMaxStack, eventShortHeight, eventOrderStrict, eventMinHeight } = this.context.options;
  13579. let { date, slatCoords, eventSelection, todayRange, nowDate } = this.props;
  13580. let isMirror = isDragging || isResizing || isDateSelecting;
  13581. let segVCoords = computeSegVCoords(segs, date, slatCoords, eventMinHeight);
  13582. let { segPlacements, hiddenGroups } = computeFgSegPlacements(segs, segVCoords, eventOrderStrict, eventMaxStack);
  13583. return (y(_, null,
  13584. this.renderHiddenGroups(hiddenGroups, segs),
  13585. segPlacements.map((segPlacement) => {
  13586. let { seg, rect } = segPlacement;
  13587. let instanceId = seg.eventRange.instance.instanceId;
  13588. let isVisible = isMirror || Boolean(!segIsInvisible[instanceId] && rect);
  13589. let vStyle = computeSegVStyle(rect && rect.span);
  13590. let hStyle = (!isMirror && rect) ? this.computeSegHStyle(rect) : { left: 0, right: 0 };
  13591. let isInset = Boolean(rect) && rect.stackForward > 0;
  13592. let isShort = Boolean(rect) && (rect.span.end - rect.span.start) < eventShortHeight; // look at other places for this problem
  13593. return (y("div", { className: 'fc-timegrid-event-harness' +
  13594. (isInset ? ' fc-timegrid-event-harness-inset' : ''), key: forcedKey || instanceId, style: Object.assign(Object.assign({ visibility: isVisible ? '' : 'hidden' }, vStyle), hStyle) },
  13595. y(TimeColEvent, Object.assign({ seg: seg, isDragging: isDragging, isResizing: isResizing, isDateSelecting: isDateSelecting, isSelected: instanceId === eventSelection, isShort: isShort }, getSegMeta(seg, todayRange, nowDate)))));
  13596. })));
  13597. }
  13598. // will already have eventMinHeight applied because segInputs already had it
  13599. renderHiddenGroups(hiddenGroups, segs) {
  13600. let { extraDateSpan, dateProfile, todayRange, nowDate, eventSelection, eventDrag, eventResize } = this.props;
  13601. return (y(_, null, hiddenGroups.map((hiddenGroup) => {
  13602. let positionCss = computeSegVStyle(hiddenGroup.span);
  13603. let hiddenSegs = compileSegsFromEntries(hiddenGroup.entries, segs);
  13604. return (y(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 }));
  13605. })));
  13606. }
  13607. renderFillSegs(segs, fillType) {
  13608. let { props, context } = this;
  13609. let segVCoords = computeSegVCoords(segs, props.date, props.slatCoords, context.options.eventMinHeight); // don't assume all populated
  13610. let children = segVCoords.map((vcoords, i) => {
  13611. let seg = segs[i];
  13612. return (y("div", { key: buildEventRangeKey(seg.eventRange), className: "fc-timegrid-bg-harness", style: computeSegVStyle(vcoords) }, fillType === 'bg-event' ?
  13613. y(BgEvent, Object.assign({ seg: seg }, getSegMeta(seg, props.todayRange, props.nowDate))) :
  13614. renderFill(fillType)));
  13615. });
  13616. return y(_, null, children);
  13617. }
  13618. renderNowIndicator(segs) {
  13619. let { slatCoords, date } = this.props;
  13620. if (!slatCoords) {
  13621. return null;
  13622. }
  13623. return segs.map((seg, i) => (y(NowIndicatorContainer
  13624. // key doesn't matter. will only ever be one
  13625. , {
  13626. // key doesn't matter. will only ever be one
  13627. key: i, elClasses: ['fc-timegrid-now-indicator-line'], elStyle: {
  13628. top: slatCoords.computeDateTop(seg.start, date),
  13629. }, isAxis: false, date: date })));
  13630. }
  13631. computeSegHStyle(segHCoords) {
  13632. let { isRtl, options } = this.context;
  13633. let shouldOverlap = options.slotEventOverlap;
  13634. let nearCoord = segHCoords.levelCoord; // the left side if LTR. the right side if RTL. floating-point
  13635. let farCoord = segHCoords.levelCoord + segHCoords.thickness; // the right side if LTR. the left side if RTL. floating-point
  13636. let left; // amount of space from left edge, a fraction of the total width
  13637. let right; // amount of space from right edge, a fraction of the total width
  13638. if (shouldOverlap) {
  13639. // double the width, but don't go beyond the maximum forward coordinate (1.0)
  13640. farCoord = Math.min(1, nearCoord + (farCoord - nearCoord) * 2);
  13641. }
  13642. if (isRtl) {
  13643. left = 1 - farCoord;
  13644. right = nearCoord;
  13645. }
  13646. else {
  13647. left = nearCoord;
  13648. right = 1 - farCoord;
  13649. }
  13650. let props = {
  13651. zIndex: segHCoords.stackDepth + 1,
  13652. left: left * 100 + '%',
  13653. right: right * 100 + '%',
  13654. };
  13655. if (shouldOverlap && !segHCoords.stackForward) {
  13656. // add padding to the edge so that forward stacked events don't cover the resizer's icon
  13657. props[isRtl ? 'marginLeft' : 'marginRight'] = 10 * 2; // 10 is a guesstimate of the icon's width
  13658. }
  13659. return props;
  13660. }
  13661. }
  13662. function renderPlainFgSegs(sortedFgSegs, { todayRange, nowDate, eventSelection, eventDrag, eventResize }) {
  13663. let hiddenInstances = (eventDrag ? eventDrag.affectedInstances : null) ||
  13664. (eventResize ? eventResize.affectedInstances : null) ||
  13665. {};
  13666. return (y(_, null, sortedFgSegs.map((seg) => {
  13667. let instanceId = seg.eventRange.instance.instanceId;
  13668. return (y("div", { key: instanceId, style: { visibility: hiddenInstances[instanceId] ? 'hidden' : '' } },
  13669. y(TimeColEvent, Object.assign({ seg: seg, isDragging: false, isResizing: false, isDateSelecting: false, isSelected: instanceId === eventSelection, isShort: false }, getSegMeta(seg, todayRange, nowDate)))));
  13670. })));
  13671. }
  13672. function computeSegVStyle(segVCoords) {
  13673. if (!segVCoords) {
  13674. return { top: '', bottom: '' };
  13675. }
  13676. return {
  13677. top: segVCoords.start,
  13678. bottom: -segVCoords.end,
  13679. };
  13680. }
  13681. function compileSegsFromEntries(segEntries, allSegs) {
  13682. return segEntries.map((segEntry) => allSegs[segEntry.index]);
  13683. }
  13684. class TimeColsContent extends BaseComponent {
  13685. constructor() {
  13686. super(...arguments);
  13687. this.splitFgEventSegs = memoize(splitSegsByCol);
  13688. this.splitBgEventSegs = memoize(splitSegsByCol);
  13689. this.splitBusinessHourSegs = memoize(splitSegsByCol);
  13690. this.splitNowIndicatorSegs = memoize(splitSegsByCol);
  13691. this.splitDateSelectionSegs = memoize(splitSegsByCol);
  13692. this.splitEventDrag = memoize(splitInteractionByCol);
  13693. this.splitEventResize = memoize(splitInteractionByCol);
  13694. this.rootElRef = d();
  13695. this.cellElRefs = new RefMap();
  13696. }
  13697. render() {
  13698. let { props, context } = this;
  13699. let nowIndicatorTop = context.options.nowIndicator &&
  13700. props.slatCoords &&
  13701. props.slatCoords.safeComputeTop(props.nowDate); // might return void
  13702. let colCnt = props.cells.length;
  13703. let fgEventSegsByRow = this.splitFgEventSegs(props.fgEventSegs, colCnt);
  13704. let bgEventSegsByRow = this.splitBgEventSegs(props.bgEventSegs, colCnt);
  13705. let businessHourSegsByRow = this.splitBusinessHourSegs(props.businessHourSegs, colCnt);
  13706. let nowIndicatorSegsByRow = this.splitNowIndicatorSegs(props.nowIndicatorSegs, colCnt);
  13707. let dateSelectionSegsByRow = this.splitDateSelectionSegs(props.dateSelectionSegs, colCnt);
  13708. let eventDragByRow = this.splitEventDrag(props.eventDrag, colCnt);
  13709. let eventResizeByRow = this.splitEventResize(props.eventResize, colCnt);
  13710. return (y("div", { className: "fc-timegrid-cols", ref: this.rootElRef },
  13711. y("table", { role: "presentation", style: {
  13712. minWidth: props.tableMinWidth,
  13713. width: props.clientWidth,
  13714. } },
  13715. props.tableColGroupNode,
  13716. y("tbody", { role: "presentation" },
  13717. y("tr", { role: "row" },
  13718. props.axis && (y("td", { "aria-hidden": true, className: "fc-timegrid-col fc-timegrid-axis" },
  13719. y("div", { className: "fc-timegrid-col-frame" },
  13720. y("div", { className: "fc-timegrid-now-indicator-container" }, typeof nowIndicatorTop === 'number' && (y(NowIndicatorContainer, { elClasses: ['fc-timegrid-now-indicator-arrow'], elStyle: { top: nowIndicatorTop }, isAxis: true, date: props.nowDate })))))),
  13721. props.cells.map((cell, i) => (y(TimeCol, { key: cell.key, elRef: this.cellElRefs.createRef(cell.key), dateProfile: props.dateProfile, date: cell.date, nowDate: props.nowDate, todayRange: props.todayRange, extraRenderProps: cell.extraRenderProps, 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 }))))))));
  13722. }
  13723. componentDidMount() {
  13724. this.updateCoords();
  13725. }
  13726. componentDidUpdate() {
  13727. this.updateCoords();
  13728. }
  13729. updateCoords() {
  13730. let { props } = this;
  13731. if (props.onColCoords &&
  13732. props.clientWidth !== null // means sizing has stabilized
  13733. ) {
  13734. props.onColCoords(new PositionCache(this.rootElRef.current, collectCellEls(this.cellElRefs.currentMap, props.cells), true, // horizontal
  13735. false));
  13736. }
  13737. }
  13738. }
  13739. function collectCellEls(elMap, cells) {
  13740. return cells.map((cell) => elMap[cell.key]);
  13741. }
  13742. /* A component that renders one or more columns of vertical time slots
  13743. ----------------------------------------------------------------------------------------------------------------------*/
  13744. class TimeCols extends DateComponent {
  13745. constructor() {
  13746. super(...arguments);
  13747. this.processSlotOptions = memoize(processSlotOptions);
  13748. this.state = {
  13749. slatCoords: null,
  13750. };
  13751. this.handleRootEl = (el) => {
  13752. if (el) {
  13753. this.context.registerInteractiveComponent(this, {
  13754. el,
  13755. isHitComboAllowed: this.props.isHitComboAllowed,
  13756. });
  13757. }
  13758. else {
  13759. this.context.unregisterInteractiveComponent(this);
  13760. }
  13761. };
  13762. this.handleScrollRequest = (request) => {
  13763. let { onScrollTopRequest } = this.props;
  13764. let { slatCoords } = this.state;
  13765. if (onScrollTopRequest && slatCoords) {
  13766. if (request.time) {
  13767. let top = slatCoords.computeTimeTop(request.time);
  13768. top = Math.ceil(top); // zoom can give weird floating-point values. rather scroll a little bit further
  13769. if (top) {
  13770. top += 1; // to overcome top border that slots beyond the first have. looks better
  13771. }
  13772. onScrollTopRequest(top);
  13773. }
  13774. return true;
  13775. }
  13776. return false;
  13777. };
  13778. this.handleColCoords = (colCoords) => {
  13779. this.colCoords = colCoords;
  13780. };
  13781. this.handleSlatCoords = (slatCoords) => {
  13782. this.setState({ slatCoords });
  13783. if (this.props.onSlatCoords) {
  13784. this.props.onSlatCoords(slatCoords);
  13785. }
  13786. };
  13787. }
  13788. render() {
  13789. let { props, state } = this;
  13790. return (y("div", { className: "fc-timegrid-body", ref: this.handleRootEl, style: {
  13791. // these props are important to give this wrapper correct dimensions for interactions
  13792. // TODO: if we set it here, can we avoid giving to inner tables?
  13793. width: props.clientWidth,
  13794. minWidth: props.tableMinWidth,
  13795. } },
  13796. y(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 }),
  13797. y(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 })));
  13798. }
  13799. componentDidMount() {
  13800. this.scrollResponder = this.context.createScrollResponder(this.handleScrollRequest);
  13801. }
  13802. componentDidUpdate(prevProps) {
  13803. this.scrollResponder.update(prevProps.dateProfile !== this.props.dateProfile);
  13804. }
  13805. componentWillUnmount() {
  13806. this.scrollResponder.detach();
  13807. }
  13808. queryHit(positionLeft, positionTop) {
  13809. let { dateEnv, options } = this.context;
  13810. let { colCoords } = this;
  13811. let { dateProfile } = this.props;
  13812. let { slatCoords } = this.state;
  13813. let { snapDuration, snapsPerSlot } = this.processSlotOptions(this.props.slotDuration, options.snapDuration);
  13814. let colIndex = colCoords.leftToIndex(positionLeft);
  13815. let slatIndex = slatCoords.positions.topToIndex(positionTop);
  13816. if (colIndex != null && slatIndex != null) {
  13817. let cell = this.props.cells[colIndex];
  13818. let slatTop = slatCoords.positions.tops[slatIndex];
  13819. let slatHeight = slatCoords.positions.getHeight(slatIndex);
  13820. let partial = (positionTop - slatTop) / slatHeight; // floating point number between 0 and 1
  13821. let localSnapIndex = Math.floor(partial * snapsPerSlot); // the snap # relative to start of slat
  13822. let snapIndex = slatIndex * snapsPerSlot + localSnapIndex;
  13823. let dayDate = this.props.cells[colIndex].date;
  13824. let time = addDurations(dateProfile.slotMinTime, multiplyDuration(snapDuration, snapIndex));
  13825. let start = dateEnv.add(dayDate, time);
  13826. let end = dateEnv.add(start, snapDuration);
  13827. return {
  13828. dateProfile,
  13829. dateSpan: Object.assign({ range: { start, end }, allDay: false }, cell.extraDateSpan),
  13830. dayEl: colCoords.els[colIndex],
  13831. rect: {
  13832. left: colCoords.lefts[colIndex],
  13833. right: colCoords.rights[colIndex],
  13834. top: slatTop,
  13835. bottom: slatTop + slatHeight,
  13836. },
  13837. layer: 0,
  13838. };
  13839. }
  13840. return null;
  13841. }
  13842. }
  13843. function processSlotOptions(slotDuration, snapDurationOverride) {
  13844. let snapDuration = snapDurationOverride || slotDuration;
  13845. let snapsPerSlot = wholeDivideDurations(slotDuration, snapDuration);
  13846. if (snapsPerSlot === null) {
  13847. snapDuration = slotDuration;
  13848. snapsPerSlot = 1;
  13849. // TODO: say warning?
  13850. }
  13851. return { snapDuration, snapsPerSlot };
  13852. }
  13853. class DayTimeColsSlicer extends Slicer {
  13854. sliceRange(range, dayRanges) {
  13855. let segs = [];
  13856. for (let col = 0; col < dayRanges.length; col += 1) {
  13857. let segRange = intersectRanges(range, dayRanges[col]);
  13858. if (segRange) {
  13859. segs.push({
  13860. start: segRange.start,
  13861. end: segRange.end,
  13862. isStart: segRange.start.valueOf() === range.start.valueOf(),
  13863. isEnd: segRange.end.valueOf() === range.end.valueOf(),
  13864. col,
  13865. });
  13866. }
  13867. }
  13868. return segs;
  13869. }
  13870. }
  13871. class DayTimeCols extends DateComponent {
  13872. constructor() {
  13873. super(...arguments);
  13874. this.buildDayRanges = memoize(buildDayRanges);
  13875. this.slicer = new DayTimeColsSlicer();
  13876. this.timeColsRef = d();
  13877. }
  13878. render() {
  13879. let { props, context } = this;
  13880. let { dateProfile, dayTableModel } = props;
  13881. let { nowIndicator, nextDayThreshold } = context.options;
  13882. let dayRanges = this.buildDayRanges(dayTableModel, dateProfile, context.dateEnv);
  13883. // give it the first row of cells
  13884. // TODO: would move this further down hierarchy, but sliceNowDate needs it
  13885. return (y(NowTimer, { unit: nowIndicator ? 'minute' : 'day' }, (nowDate, todayRange) => (y(TimeCols, Object.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: nowIndicator && this.slicer.sliceNowDate(nowDate, dateProfile, nextDayThreshold, context, dayRanges), todayRange: todayRange, onScrollTopRequest: props.onScrollTopRequest, onSlatCoords: props.onSlatCoords })))));
  13886. }
  13887. }
  13888. function buildDayRanges(dayTableModel, dateProfile, dateEnv) {
  13889. let ranges = [];
  13890. for (let date of dayTableModel.headerDates) {
  13891. ranges.push({
  13892. start: dateEnv.add(date, dateProfile.slotMinTime),
  13893. end: dateEnv.add(date, dateProfile.slotMaxTime),
  13894. });
  13895. }
  13896. return ranges;
  13897. }
  13898. // potential nice values for the slot-duration and interval-duration
  13899. // from largest to smallest
  13900. const STOCK_SUB_DURATIONS = [
  13901. { hours: 1 },
  13902. { minutes: 30 },
  13903. { minutes: 15 },
  13904. { seconds: 30 },
  13905. { seconds: 15 },
  13906. ];
  13907. function buildSlatMetas(slotMinTime, slotMaxTime, explicitLabelInterval, slotDuration, dateEnv) {
  13908. let dayStart = new Date(0);
  13909. let slatTime = slotMinTime;
  13910. let slatIterator = createDuration(0);
  13911. let labelInterval = explicitLabelInterval || computeLabelInterval(slotDuration);
  13912. let metas = [];
  13913. while (asRoughMs(slatTime) < asRoughMs(slotMaxTime)) {
  13914. let date = dateEnv.add(dayStart, slatTime);
  13915. let isLabeled = wholeDivideDurations(slatIterator, labelInterval) !== null;
  13916. metas.push({
  13917. date,
  13918. time: slatTime,
  13919. key: date.toISOString(),
  13920. isoTimeStr: formatIsoTimeString(date),
  13921. isLabeled,
  13922. });
  13923. slatTime = addDurations(slatTime, slotDuration);
  13924. slatIterator = addDurations(slatIterator, slotDuration);
  13925. }
  13926. return metas;
  13927. }
  13928. // Computes an automatic value for slotLabelInterval
  13929. function computeLabelInterval(slotDuration) {
  13930. let i;
  13931. let labelInterval;
  13932. let slotsPerLabel;
  13933. // find the smallest stock label interval that results in more than one slots-per-label
  13934. for (i = STOCK_SUB_DURATIONS.length - 1; i >= 0; i -= 1) {
  13935. labelInterval = createDuration(STOCK_SUB_DURATIONS[i]);
  13936. slotsPerLabel = wholeDivideDurations(labelInterval, slotDuration);
  13937. if (slotsPerLabel !== null && slotsPerLabel > 1) {
  13938. return labelInterval;
  13939. }
  13940. }
  13941. return slotDuration; // fall back
  13942. }
  13943. class DayTimeColsView extends TimeColsView {
  13944. constructor() {
  13945. super(...arguments);
  13946. this.buildTimeColsModel = memoize(buildTimeColsModel);
  13947. this.buildSlatMetas = memoize(buildSlatMetas);
  13948. }
  13949. render() {
  13950. let { options, dateEnv, dateProfileGenerator } = this.context;
  13951. let { props } = this;
  13952. let { dateProfile } = props;
  13953. let dayTableModel = this.buildTimeColsModel(dateProfile, dateProfileGenerator);
  13954. let splitProps = this.allDaySplitter.splitProps(props);
  13955. let slatMetas = this.buildSlatMetas(dateProfile.slotMinTime, dateProfile.slotMaxTime, options.slotLabelInterval, options.slotDuration, dateEnv);
  13956. let { dayMinWidth } = options;
  13957. let hasAttachedAxis = !dayMinWidth;
  13958. let hasDetachedAxis = dayMinWidth;
  13959. let headerContent = options.dayHeaders && (y(DayHeader, { dates: dayTableModel.headerDates, dateProfile: dateProfile, datesRepDistinctDays: true, renderIntro: hasAttachedAxis ? this.renderHeadAxis : null }));
  13960. let allDayContent = (options.allDaySlot !== false) && ((contentArg) => (y(DayTable, Object.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()))));
  13961. let timeGridContent = (contentArg) => (y(DayTimeCols, Object.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 })));
  13962. return hasDetachedAxis
  13963. ? this.renderHScrollLayout(headerContent, allDayContent, timeGridContent, dayTableModel.colCnt, dayMinWidth, slatMetas, this.state.slatCoords)
  13964. : this.renderSimpleLayout(headerContent, allDayContent, timeGridContent);
  13965. }
  13966. }
  13967. function buildTimeColsModel(dateProfile, dateProfileGenerator) {
  13968. let daySeries = new DaySeriesModel(dateProfile.renderRange, dateProfileGenerator);
  13969. return new DayTableModel(daySeries, false);
  13970. }
  13971. var css_248z$2 = ".fc-v-event{background-color:var(--fc-event-bg-color);border:1px solid var(--fc-event-border-color);display:block}.fc-v-event .fc-event-main{color:var(--fc-event-text-color);height:100%}.fc-v-event .fc-event-main-frame{display:flex;flex-direction:column;height:100%}.fc-v-event .fc-event-time{flex-grow:0;flex-shrink:0;max-height:100%;overflow:hidden}.fc-v-event .fc-event-title-container{flex-grow:1;flex-shrink:1;min-height:0}.fc-v-event .fc-event-title{bottom:0;max-height:100%;overflow:hidden;top:0}.fc-v-event:not(.fc-event-start){border-top-left-radius:0;border-top-right-radius:0;border-top-width:0}.fc-v-event:not(.fc-event-end){border-bottom-left-radius:0;border-bottom-right-radius:0;border-bottom-width:0}.fc-v-event.fc-event-selected:before{left:-10px;right:-10px}.fc-v-event .fc-event-resizer-start{cursor:n-resize}.fc-v-event .fc-event-resizer-end{cursor:s-resize}.fc-v-event:not(.fc-event-selected) .fc-event-resizer{height:var(--fc-event-resizer-thickness);left:0;right:0}.fc-v-event:not(.fc-event-selected) .fc-event-resizer-start{top:calc(var(--fc-event-resizer-thickness)/-2)}.fc-v-event:not(.fc-event-selected) .fc-event-resizer-end{bottom:calc(var(--fc-event-resizer-thickness)/-2)}.fc-v-event.fc-event-selected .fc-event-resizer{left:50%;margin-left:calc(var(--fc-event-resizer-dot-total-width)/-2)}.fc-v-event.fc-event-selected .fc-event-resizer-start{top:calc(var(--fc-event-resizer-dot-total-width)/-2)}.fc-v-event.fc-event-selected .fc-event-resizer-end{bottom:calc(var(--fc-event-resizer-dot-total-width)/-2)}.fc .fc-timegrid .fc-daygrid-body{z-index:2}.fc .fc-timegrid-divider{padding:0 0 2px}.fc .fc-timegrid-body{min-height:100%;position:relative;z-index:1}.fc .fc-timegrid-axis-chunk{position:relative}.fc .fc-timegrid-axis-chunk>table,.fc .fc-timegrid-slots{position:relative;z-index:1}.fc .fc-timegrid-slot{border-bottom:0;height:1.5em}.fc .fc-timegrid-slot:empty:before{content:\"\\00a0\"}.fc .fc-timegrid-slot-minor{border-top-style:dotted}.fc .fc-timegrid-slot-label-cushion{display:inline-block;white-space:nowrap}.fc .fc-timegrid-slot-label{vertical-align:middle}.fc .fc-timegrid-axis-cushion,.fc .fc-timegrid-slot-label-cushion{padding:0 4px}.fc .fc-timegrid-axis-frame-liquid{height:100%}.fc .fc-timegrid-axis-frame{align-items:center;display:flex;justify-content:flex-end;overflow:hidden}.fc .fc-timegrid-axis-cushion{flex-shrink:0;max-width:60px}.fc-direction-ltr .fc-timegrid-slot-label-frame{text-align:right}.fc-direction-rtl .fc-timegrid-slot-label-frame{text-align:left}.fc-liquid-hack .fc-timegrid-axis-frame-liquid{bottom:0;height:auto;left:0;position:absolute;right:0;top:0}.fc .fc-timegrid-col.fc-day-today{background-color:var(--fc-today-bg-color)}.fc .fc-timegrid-col-frame{min-height:100%;position:relative}.fc-media-screen.fc-liquid-hack .fc-timegrid-col-frame{bottom:0;height:auto;left:0;position:absolute;right:0;top:0}.fc-media-screen .fc-timegrid-cols{bottom:0;left:0;position:absolute;right:0;top:0}.fc-media-screen .fc-timegrid-cols>table{height:100%}.fc-media-screen .fc-timegrid-col-bg,.fc-media-screen .fc-timegrid-col-events,.fc-media-screen .fc-timegrid-now-indicator-container{left:0;position:absolute;right:0;top:0}.fc .fc-timegrid-col-bg{z-index:2}.fc .fc-timegrid-col-bg .fc-non-business{z-index:1}.fc .fc-timegrid-col-bg .fc-bg-event{z-index:2}.fc .fc-timegrid-col-bg .fc-highlight{z-index:3}.fc .fc-timegrid-bg-harness{left:0;position:absolute;right:0}.fc .fc-timegrid-col-events{z-index:3}.fc .fc-timegrid-now-indicator-container{bottom:0;overflow:hidden}.fc-direction-ltr .fc-timegrid-col-events{margin:0 2.5% 0 2px}.fc-direction-rtl .fc-timegrid-col-events{margin:0 2px 0 2.5%}.fc-timegrid-event-harness{position:absolute}.fc-timegrid-event-harness>.fc-timegrid-event{bottom:0;left:0;position:absolute;right:0;top:0}.fc-timegrid-event-harness-inset .fc-timegrid-event,.fc-timegrid-event.fc-event-mirror,.fc-timegrid-more-link{box-shadow:0 0 0 1px var(--fc-page-bg-color)}.fc-timegrid-event,.fc-timegrid-more-link{border-radius:3px;font-size:var(--fc-small-font-size)}.fc-timegrid-event{margin-bottom:1px}.fc-timegrid-event .fc-event-main{padding:1px 1px 0}.fc-timegrid-event .fc-event-time{font-size:var(--fc-small-font-size);margin-bottom:1px;white-space:nowrap}.fc-timegrid-event-short .fc-event-main-frame{flex-direction:row;overflow:hidden}.fc-timegrid-event-short .fc-event-time:after{content:\"\\00a0-\\00a0\"}.fc-timegrid-event-short .fc-event-title{font-size:var(--fc-small-font-size)}.fc-timegrid-more-link{background:var(--fc-more-link-bg-color);color:var(--fc-more-link-text-color);cursor:pointer;margin-bottom:1px;position:absolute;z-index:9999}.fc-timegrid-more-link-inner{padding:3px 2px;top:0}.fc-direction-ltr .fc-timegrid-more-link{right:0}.fc-direction-rtl .fc-timegrid-more-link{left:0}.fc .fc-timegrid-now-indicator-arrow,.fc .fc-timegrid-now-indicator-line{pointer-events:none}.fc .fc-timegrid-now-indicator-line{border-color:var(--fc-now-indicator-color);border-style:solid;border-width:1px 0 0;left:0;position:absolute;right:0;z-index:4}.fc .fc-timegrid-now-indicator-arrow{border-color:var(--fc-now-indicator-color);border-style:solid;margin-top:-5px;position:absolute;z-index:4}.fc-direction-ltr .fc-timegrid-now-indicator-arrow{border-bottom-color:transparent;border-top-color:transparent;border-width:5px 0 5px 6px;left:0}.fc-direction-rtl .fc-timegrid-now-indicator-arrow{border-bottom-color:transparent;border-top-color:transparent;border-width:5px 6px 5px 0;right:0}";
  13972. injectStyles(css_248z$2);
  13973. const OPTION_REFINERS$2 = {
  13974. allDaySlot: Boolean,
  13975. };
  13976. var index$2 = createPlugin({
  13977. name: '@fullcalendar/timegrid',
  13978. initialView: 'timeGridWeek',
  13979. optionRefiners: OPTION_REFINERS$2,
  13980. views: {
  13981. timeGrid: {
  13982. component: DayTimeColsView,
  13983. usesMinMaxTime: true,
  13984. allDaySlot: true,
  13985. slotDuration: '00:30:00',
  13986. slotEventOverlap: true, // a bad name. confused with overlap/constraint system
  13987. },
  13988. timeGridDay: {
  13989. type: 'timeGrid',
  13990. duration: { days: 1 },
  13991. },
  13992. timeGridWeek: {
  13993. type: 'timeGrid',
  13994. duration: { weeks: 1 },
  13995. },
  13996. },
  13997. });
  13998. class ListViewHeaderRow extends BaseComponent {
  13999. constructor() {
  14000. super(...arguments);
  14001. this.state = {
  14002. textId: getUniqueDomId(),
  14003. };
  14004. }
  14005. render() {
  14006. let { theme, dateEnv, options, viewApi } = this.context;
  14007. let { cellId, dayDate, todayRange } = this.props;
  14008. let { textId } = this.state;
  14009. let dayMeta = getDateMeta(dayDate, todayRange);
  14010. // will ever be falsy?
  14011. let text = options.listDayFormat ? dateEnv.format(dayDate, options.listDayFormat) : '';
  14012. // will ever be falsy? also, BAD NAME "alt"
  14013. let sideText = options.listDaySideFormat ? dateEnv.format(dayDate, options.listDaySideFormat) : '';
  14014. let renderProps = Object.assign({ date: dateEnv.toDate(dayDate), view: viewApi, textId,
  14015. text,
  14016. sideText, navLinkAttrs: buildNavLinkAttrs(this.context, dayDate), sideNavLinkAttrs: buildNavLinkAttrs(this.context, dayDate, 'day', false) }, dayMeta);
  14017. // TODO: make a reusable HOC for dayHeader (used in daygrid/timegrid too)
  14018. return (y(ContentContainer, { elTag: "tr", elClasses: [
  14019. 'fc-list-day',
  14020. ...getDayClassNames(dayMeta, theme),
  14021. ], elAttrs: {
  14022. 'data-date': formatDayString(dayDate),
  14023. }, renderProps: renderProps, generatorName: "dayHeaderContent", customGenerator: options.dayHeaderContent, defaultGenerator: renderInnerContent, classNameGenerator: options.dayHeaderClassNames, didMount: options.dayHeaderDidMount, willUnmount: options.dayHeaderWillUnmount }, (InnerContent) => ( // TODO: force-hide top border based on :first-child
  14024. y("th", { scope: "colgroup", colSpan: 3, id: cellId, "aria-labelledby": textId },
  14025. y(InnerContent, { elTag: "div", elClasses: [
  14026. 'fc-list-day-cushion',
  14027. theme.getClass('tableCellShaded'),
  14028. ] })))));
  14029. }
  14030. }
  14031. function renderInnerContent(props) {
  14032. return (y(_, null,
  14033. props.text && (y("a", Object.assign({ id: props.textId, className: "fc-list-day-text" }, props.navLinkAttrs), props.text)),
  14034. props.sideText && ( /* not keyboard tabbable */y("a", Object.assign({ "aria-hidden": true, className: "fc-list-day-side-text" }, props.sideNavLinkAttrs), props.sideText))));
  14035. }
  14036. const DEFAULT_TIME_FORMAT = createFormatter({
  14037. hour: 'numeric',
  14038. minute: '2-digit',
  14039. meridiem: 'short',
  14040. });
  14041. class ListViewEventRow extends BaseComponent {
  14042. render() {
  14043. let { props, context } = this;
  14044. let { options } = context;
  14045. let { seg, timeHeaderId, eventHeaderId, dateHeaderId } = props;
  14046. let timeFormat = options.eventTimeFormat || DEFAULT_TIME_FORMAT;
  14047. return (y(EventContainer, Object.assign({}, props, { elTag: "tr", elClasses: [
  14048. 'fc-list-event',
  14049. seg.eventRange.def.url && 'fc-event-forced-url',
  14050. ], defaultGenerator: () => renderEventInnerContent(seg, context) /* weird */, seg: seg, timeText: "", disableDragging: true, disableResizing: true }), (InnerContent, eventContentArg) => (y(_, null,
  14051. buildTimeContent(seg, timeFormat, context, timeHeaderId, dateHeaderId),
  14052. y("td", { "aria-hidden": true, className: "fc-list-event-graphic" },
  14053. y("span", { className: "fc-list-event-dot", style: {
  14054. borderColor: eventContentArg.borderColor || eventContentArg.backgroundColor,
  14055. } })),
  14056. y(InnerContent, { elTag: "td", elClasses: ['fc-list-event-title'], elAttrs: { headers: `${eventHeaderId} ${dateHeaderId}` } })))));
  14057. }
  14058. }
  14059. function renderEventInnerContent(seg, context) {
  14060. let interactiveAttrs = getSegAnchorAttrs(seg, context);
  14061. return (y("a", Object.assign({}, interactiveAttrs), seg.eventRange.def.title));
  14062. }
  14063. function buildTimeContent(seg, timeFormat, context, timeHeaderId, dateHeaderId) {
  14064. let { options } = context;
  14065. if (options.displayEventTime !== false) {
  14066. let eventDef = seg.eventRange.def;
  14067. let eventInstance = seg.eventRange.instance;
  14068. let doAllDay = false;
  14069. let timeText;
  14070. if (eventDef.allDay) {
  14071. doAllDay = true;
  14072. }
  14073. else if (isMultiDayRange(seg.eventRange.range)) { // TODO: use (!isStart || !isEnd) instead?
  14074. if (seg.isStart) {
  14075. timeText = buildSegTimeText(seg, timeFormat, context, null, null, eventInstance.range.start, seg.end);
  14076. }
  14077. else if (seg.isEnd) {
  14078. timeText = buildSegTimeText(seg, timeFormat, context, null, null, seg.start, eventInstance.range.end);
  14079. }
  14080. else {
  14081. doAllDay = true;
  14082. }
  14083. }
  14084. else {
  14085. timeText = buildSegTimeText(seg, timeFormat, context);
  14086. }
  14087. if (doAllDay) {
  14088. let renderProps = {
  14089. text: context.options.allDayText,
  14090. view: context.viewApi,
  14091. };
  14092. return (y(ContentContainer, { elTag: "td", elClasses: ['fc-list-event-time'], elAttrs: {
  14093. headers: `${timeHeaderId} ${dateHeaderId}`,
  14094. }, renderProps: renderProps, generatorName: "allDayContent", customGenerator: options.allDayContent, defaultGenerator: renderAllDayInner, classNameGenerator: options.allDayClassNames, didMount: options.allDayDidMount, willUnmount: options.allDayWillUnmount }));
  14095. }
  14096. return (y("td", { className: "fc-list-event-time" }, timeText));
  14097. }
  14098. return null;
  14099. }
  14100. function renderAllDayInner(renderProps) {
  14101. return renderProps.text;
  14102. }
  14103. /*
  14104. Responsible for the scroller, and forwarding event-related actions into the "grid".
  14105. */
  14106. class ListView extends DateComponent {
  14107. constructor() {
  14108. super(...arguments);
  14109. this.computeDateVars = memoize(computeDateVars);
  14110. this.eventStoreToSegs = memoize(this._eventStoreToSegs);
  14111. this.state = {
  14112. timeHeaderId: getUniqueDomId(),
  14113. eventHeaderId: getUniqueDomId(),
  14114. dateHeaderIdRoot: getUniqueDomId(),
  14115. };
  14116. this.setRootEl = (rootEl) => {
  14117. if (rootEl) {
  14118. this.context.registerInteractiveComponent(this, {
  14119. el: rootEl,
  14120. });
  14121. }
  14122. else {
  14123. this.context.unregisterInteractiveComponent(this);
  14124. }
  14125. };
  14126. }
  14127. render() {
  14128. let { props, context } = this;
  14129. let { dayDates, dayRanges } = this.computeDateVars(props.dateProfile);
  14130. let eventSegs = this.eventStoreToSegs(props.eventStore, props.eventUiBases, dayRanges);
  14131. return (y(ViewContainer, { elRef: this.setRootEl, elClasses: [
  14132. 'fc-list',
  14133. context.theme.getClass('table'),
  14134. context.options.stickyHeaderDates !== false ?
  14135. 'fc-list-sticky' :
  14136. '',
  14137. ], viewSpec: context.viewSpec },
  14138. y(Scroller, { liquid: !props.isHeightAuto, overflowX: props.isHeightAuto ? 'visible' : 'hidden', overflowY: props.isHeightAuto ? 'visible' : 'auto' }, eventSegs.length > 0 ?
  14139. this.renderSegList(eventSegs, dayDates) :
  14140. this.renderEmptyMessage())));
  14141. }
  14142. renderEmptyMessage() {
  14143. let { options, viewApi } = this.context;
  14144. let renderProps = {
  14145. text: options.noEventsText,
  14146. view: viewApi,
  14147. };
  14148. return (y(ContentContainer, { elTag: "div", elClasses: ['fc-list-empty'], renderProps: renderProps, generatorName: "noEventsContent", customGenerator: options.noEventsContent, defaultGenerator: renderNoEventsInner, classNameGenerator: options.noEventsClassNames, didMount: options.noEventsDidMount, willUnmount: options.noEventsWillUnmount }, (InnerContent) => (y(InnerContent, { elTag: "div", elClasses: ['fc-list-empty-cushion'] }))));
  14149. }
  14150. renderSegList(allSegs, dayDates) {
  14151. let { theme, options } = this.context;
  14152. let { timeHeaderId, eventHeaderId, dateHeaderIdRoot } = this.state;
  14153. let segsByDay = groupSegsByDay(allSegs); // sparse array
  14154. return (y(NowTimer, { unit: "day" }, (nowDate, todayRange) => {
  14155. let innerNodes = [];
  14156. for (let dayIndex = 0; dayIndex < segsByDay.length; dayIndex += 1) {
  14157. let daySegs = segsByDay[dayIndex];
  14158. if (daySegs) { // sparse array, so might be undefined
  14159. let dayStr = formatDayString(dayDates[dayIndex]);
  14160. let dateHeaderId = dateHeaderIdRoot + '-' + dayStr;
  14161. // append a day header
  14162. innerNodes.push(y(ListViewHeaderRow, { key: dayStr, cellId: dateHeaderId, dayDate: dayDates[dayIndex], todayRange: todayRange }));
  14163. daySegs = sortEventSegs(daySegs, options.eventOrder);
  14164. for (let seg of daySegs) {
  14165. innerNodes.push(y(ListViewEventRow, Object.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))));
  14166. }
  14167. }
  14168. }
  14169. return (y("table", { className: 'fc-list-table ' + theme.getClass('table') },
  14170. y("thead", null,
  14171. y("tr", null,
  14172. y("th", { scope: "col", id: timeHeaderId }, options.timeHint),
  14173. y("th", { scope: "col", "aria-hidden": true }),
  14174. y("th", { scope: "col", id: eventHeaderId }, options.eventHint))),
  14175. y("tbody", null, innerNodes)));
  14176. }));
  14177. }
  14178. _eventStoreToSegs(eventStore, eventUiBases, dayRanges) {
  14179. return this.eventRangesToSegs(sliceEventStore(eventStore, eventUiBases, this.props.dateProfile.activeRange, this.context.options.nextDayThreshold).fg, dayRanges);
  14180. }
  14181. eventRangesToSegs(eventRanges, dayRanges) {
  14182. let segs = [];
  14183. for (let eventRange of eventRanges) {
  14184. segs.push(...this.eventRangeToSegs(eventRange, dayRanges));
  14185. }
  14186. return segs;
  14187. }
  14188. eventRangeToSegs(eventRange, dayRanges) {
  14189. let { dateEnv } = this.context;
  14190. let { nextDayThreshold } = this.context.options;
  14191. let range = eventRange.range;
  14192. let allDay = eventRange.def.allDay;
  14193. let dayIndex;
  14194. let segRange;
  14195. let seg;
  14196. let segs = [];
  14197. for (dayIndex = 0; dayIndex < dayRanges.length; dayIndex += 1) {
  14198. segRange = intersectRanges(range, dayRanges[dayIndex]);
  14199. if (segRange) {
  14200. seg = {
  14201. component: this,
  14202. eventRange,
  14203. start: segRange.start,
  14204. end: segRange.end,
  14205. isStart: eventRange.isStart && segRange.start.valueOf() === range.start.valueOf(),
  14206. isEnd: eventRange.isEnd && segRange.end.valueOf() === range.end.valueOf(),
  14207. dayIndex,
  14208. };
  14209. segs.push(seg);
  14210. // detect when range won't go fully into the next day,
  14211. // and mutate the latest seg to the be the end.
  14212. if (!seg.isEnd && !allDay &&
  14213. dayIndex + 1 < dayRanges.length &&
  14214. range.end <
  14215. dateEnv.add(dayRanges[dayIndex + 1].start, nextDayThreshold)) {
  14216. seg.end = range.end;
  14217. seg.isEnd = true;
  14218. break;
  14219. }
  14220. }
  14221. }
  14222. return segs;
  14223. }
  14224. }
  14225. function renderNoEventsInner(renderProps) {
  14226. return renderProps.text;
  14227. }
  14228. function computeDateVars(dateProfile) {
  14229. let dayStart = startOfDay(dateProfile.renderRange.start);
  14230. let viewEnd = dateProfile.renderRange.end;
  14231. let dayDates = [];
  14232. let dayRanges = [];
  14233. while (dayStart < viewEnd) {
  14234. dayDates.push(dayStart);
  14235. dayRanges.push({
  14236. start: dayStart,
  14237. end: addDays(dayStart, 1),
  14238. });
  14239. dayStart = addDays(dayStart, 1);
  14240. }
  14241. return { dayDates, dayRanges };
  14242. }
  14243. // Returns a sparse array of arrays, segs grouped by their dayIndex
  14244. function groupSegsByDay(segs) {
  14245. let segsByDay = []; // sparse array
  14246. let i;
  14247. let seg;
  14248. for (i = 0; i < segs.length; i += 1) {
  14249. seg = segs[i];
  14250. (segsByDay[seg.dayIndex] || (segsByDay[seg.dayIndex] = []))
  14251. .push(seg);
  14252. }
  14253. return segsByDay;
  14254. }
  14255. var css_248z$1 = ":root{--fc-list-event-dot-width:10px;--fc-list-event-hover-bg-color:#f5f5f5}.fc-theme-standard .fc-list{border:1px solid var(--fc-border-color)}.fc .fc-list-empty{align-items:center;background-color:var(--fc-neutral-bg-color);display:flex;height:100%;justify-content:center}.fc .fc-list-empty-cushion{margin:5em 0}.fc .fc-list-table{border-style:hidden;width:100%}.fc .fc-list-table tr>*{border-left:0;border-right:0}.fc .fc-list-sticky .fc-list-day>*{background:var(--fc-page-bg-color);position:sticky;top:0}.fc .fc-list-table thead{left:-10000px;position:absolute}.fc .fc-list-table tbody>tr:first-child th{border-top:0}.fc .fc-list-table th{padding:0}.fc .fc-list-day-cushion,.fc .fc-list-table td{padding:8px 14px}.fc .fc-list-day-cushion:after{clear:both;content:\"\";display:table}.fc-theme-standard .fc-list-day-cushion{background-color:var(--fc-neutral-bg-color)}.fc-direction-ltr .fc-list-day-text,.fc-direction-rtl .fc-list-day-side-text{float:left}.fc-direction-ltr .fc-list-day-side-text,.fc-direction-rtl .fc-list-day-text{float:right}.fc-direction-ltr .fc-list-table .fc-list-event-graphic{padding-right:0}.fc-direction-rtl .fc-list-table .fc-list-event-graphic{padding-left:0}.fc .fc-list-event.fc-event-forced-url{cursor:pointer}.fc .fc-list-event:hover td{background-color:var(--fc-list-event-hover-bg-color)}.fc .fc-list-event-graphic,.fc .fc-list-event-time{white-space:nowrap;width:1px}.fc .fc-list-event-dot{border:calc(var(--fc-list-event-dot-width)/2) solid var(--fc-event-border-color);border-radius:calc(var(--fc-list-event-dot-width)/2);box-sizing:content-box;display:inline-block;height:0;width:0}.fc .fc-list-event-title a{color:inherit;text-decoration:none}.fc .fc-list-event.fc-event-forced-url:hover a{text-decoration:underline}";
  14256. injectStyles(css_248z$1);
  14257. const OPTION_REFINERS$1 = {
  14258. listDayFormat: createFalsableFormatter,
  14259. listDaySideFormat: createFalsableFormatter,
  14260. noEventsClassNames: identity,
  14261. noEventsContent: identity,
  14262. noEventsDidMount: identity,
  14263. noEventsWillUnmount: identity,
  14264. // noEventsText is defined in base options
  14265. };
  14266. function createFalsableFormatter(input) {
  14267. return input === false ? null : createFormatter(input);
  14268. }
  14269. var index$1 = createPlugin({
  14270. name: '@fullcalendar/list',
  14271. optionRefiners: OPTION_REFINERS$1,
  14272. views: {
  14273. list: {
  14274. component: ListView,
  14275. buttonTextKey: 'list',
  14276. listDayFormat: { month: 'long', day: 'numeric', year: 'numeric' }, // like "January 1, 2016"
  14277. },
  14278. listDay: {
  14279. type: 'list',
  14280. duration: { days: 1 },
  14281. listDayFormat: { weekday: 'long' }, // day-of-week is all we need. full date is probably in headerToolbar
  14282. },
  14283. listWeek: {
  14284. type: 'list',
  14285. duration: { weeks: 1 },
  14286. listDayFormat: { weekday: 'long' },
  14287. listDaySideFormat: { month: 'long', day: 'numeric', year: 'numeric' },
  14288. },
  14289. listMonth: {
  14290. type: 'list',
  14291. duration: { month: 1 },
  14292. listDaySideFormat: { weekday: 'long' }, // day-of-week is nice-to-have
  14293. },
  14294. listYear: {
  14295. type: 'list',
  14296. duration: { year: 1 },
  14297. listDaySideFormat: { weekday: 'long' }, // day-of-week is nice-to-have
  14298. },
  14299. },
  14300. });
  14301. class SingleMonth extends DateComponent {
  14302. constructor() {
  14303. super(...arguments);
  14304. this.buildDayTableModel = memoize(buildDayTableModel);
  14305. this.slicer = new DayTableSlicer();
  14306. this.state = {
  14307. labelId: getUniqueDomId(),
  14308. };
  14309. }
  14310. render() {
  14311. const { props, state, context } = this;
  14312. const { dateProfile, forPrint } = props;
  14313. const { options } = context;
  14314. const dayTableModel = this.buildDayTableModel(dateProfile, context.dateProfileGenerator);
  14315. const slicedProps = this.slicer.sliceProps(props, dateProfile, options.nextDayThreshold, context, dayTableModel);
  14316. // ensure single-month has aspect ratio
  14317. const tableHeight = props.tableWidth != null ? props.tableWidth / options.aspectRatio : null;
  14318. const rowCnt = dayTableModel.cells.length;
  14319. const rowHeight = tableHeight != null ? tableHeight / rowCnt : null;
  14320. return (y("div", { ref: props.elRef, "data-date": props.isoDateStr, className: "fc-multimonth-month", style: { width: props.width }, role: "grid", "aria-labelledby": state.labelId },
  14321. y("div", { className: "fc-multimonth-header", style: { marginBottom: rowHeight }, role: "presentation" },
  14322. y("div", { className: "fc-multimonth-title", id: state.labelId }, context.dateEnv.format(props.dateProfile.currentRange.start, props.titleFormat)),
  14323. y("table", { className: [
  14324. 'fc-multimonth-header-table',
  14325. context.theme.getClass('table'),
  14326. ].join(' '), role: "presentation" },
  14327. y("thead", { role: "rowgroup" },
  14328. y(DayHeader, { dateProfile: props.dateProfile, dates: dayTableModel.headerDates, datesRepDistinctDays: false })))),
  14329. y("div", { className: [
  14330. 'fc-multimonth-daygrid',
  14331. 'fc-daygrid',
  14332. 'fc-daygrid-body',
  14333. !forPrint && 'fc-daygrid-body-balanced',
  14334. forPrint && 'fc-daygrid-body-unbalanced',
  14335. forPrint && 'fc-daygrid-body-natural',
  14336. ].join(' '), style: { marginTop: -rowHeight } },
  14337. y("table", { className: [
  14338. 'fc-multimonth-daygrid-table',
  14339. context.theme.getClass('table'),
  14340. ].join(' '), style: { height: forPrint ? '' : tableHeight }, role: "presentation" },
  14341. y("tbody", { role: "rowgroup" },
  14342. y(TableRows, Object.assign({}, slicedProps, { dateProfile: dateProfile, cells: dayTableModel.cells, eventSelection: props.eventSelection, dayMaxEvents: !forPrint, dayMaxEventRows: !forPrint, showWeekNumbers: options.weekNumbers, clientWidth: props.clientWidth, clientHeight: props.clientHeight, forPrint: forPrint })))))));
  14343. }
  14344. }
  14345. class MultiMonthView extends DateComponent {
  14346. constructor() {
  14347. super(...arguments);
  14348. this.splitDateProfileByMonth = memoize(splitDateProfileByMonth);
  14349. this.buildMonthFormat = memoize(buildMonthFormat);
  14350. this.scrollElRef = d();
  14351. this.firstMonthElRef = d();
  14352. this.needsScrollReset = false;
  14353. this.handleSizing = (isForced) => {
  14354. if (isForced) {
  14355. this.updateSize();
  14356. }
  14357. };
  14358. }
  14359. render() {
  14360. const { context, props, state } = this;
  14361. const { options } = context;
  14362. const { clientWidth, clientHeight } = state;
  14363. const monthHPadding = state.monthHPadding || 0;
  14364. const colCount = Math.min(clientWidth != null ?
  14365. Math.floor(clientWidth / (options.multiMonthMinWidth + monthHPadding)) :
  14366. 1, options.multiMonthMaxColumns) || 1;
  14367. const monthWidthPct = (100 / colCount) + '%';
  14368. const monthTableWidth = clientWidth == null ? null :
  14369. (clientWidth / colCount) - monthHPadding;
  14370. const isLegitSingleCol = clientWidth != null && colCount === 1;
  14371. const monthDateProfiles = this.splitDateProfileByMonth(context.dateProfileGenerator, props.dateProfile, context.dateEnv, isLegitSingleCol ? false : options.fixedWeekCount, options.showNonCurrentDates);
  14372. const monthTitleFormat = this.buildMonthFormat(options.multiMonthTitleFormat, monthDateProfiles);
  14373. const rootClassNames = [
  14374. 'fc-multimonth',
  14375. isLegitSingleCol ?
  14376. 'fc-multimonth-singlecol' :
  14377. 'fc-multimonth-multicol',
  14378. (monthTableWidth != null && monthTableWidth < 400) ?
  14379. 'fc-multimonth-compact' :
  14380. '',
  14381. props.isHeightAuto ?
  14382. '' :
  14383. 'fc-scroller', // for AutoScroller
  14384. ];
  14385. return (y(ViewContainer, { elRef: this.scrollElRef, elClasses: rootClassNames, viewSpec: context.viewSpec }, monthDateProfiles.map((monthDateProfile, i) => {
  14386. const monthStr = formatIsoMonthStr(monthDateProfile.currentRange.start);
  14387. return (y(SingleMonth, Object.assign({}, props, { key: monthStr, isoDateStr: monthStr, elRef: i === 0 ? this.firstMonthElRef : undefined, titleFormat: monthTitleFormat, dateProfile: monthDateProfile, width: monthWidthPct, tableWidth: monthTableWidth, clientWidth: clientWidth, clientHeight: clientHeight })));
  14388. })));
  14389. }
  14390. componentDidMount() {
  14391. this.updateSize();
  14392. this.context.addResizeHandler(this.handleSizing);
  14393. this.requestScrollReset();
  14394. }
  14395. componentDidUpdate(prevProps) {
  14396. if (!isPropsEqual(prevProps, this.props)) { // an external change?
  14397. this.handleSizing(false);
  14398. }
  14399. if (prevProps.dateProfile !== this.props.dateProfile) {
  14400. this.requestScrollReset();
  14401. }
  14402. else {
  14403. this.flushScrollReset();
  14404. }
  14405. }
  14406. componentWillUnmount() {
  14407. this.context.removeResizeHandler(this.handleSizing);
  14408. }
  14409. updateSize() {
  14410. const scrollEl = this.scrollElRef.current;
  14411. const firstMonthEl = this.firstMonthElRef.current;
  14412. if (scrollEl) {
  14413. this.setState({
  14414. clientWidth: scrollEl.clientWidth,
  14415. clientHeight: scrollEl.clientHeight,
  14416. });
  14417. }
  14418. if (firstMonthEl && scrollEl) {
  14419. if (this.state.monthHPadding == null) { // always remember initial non-zero value
  14420. this.setState({
  14421. monthHPadding: scrollEl.clientWidth - // go within padding
  14422. firstMonthEl.firstChild.offsetWidth,
  14423. });
  14424. }
  14425. }
  14426. }
  14427. requestScrollReset() {
  14428. this.needsScrollReset = true;
  14429. this.flushScrollReset();
  14430. }
  14431. flushScrollReset() {
  14432. if (this.needsScrollReset &&
  14433. this.state.monthHPadding != null // indicates sizing already happened
  14434. ) {
  14435. const { currentDate } = this.props.dateProfile;
  14436. const scrollEl = this.scrollElRef.current;
  14437. const monthEl = scrollEl.querySelector(`[data-date="${formatIsoMonthStr(currentDate)}"]`);
  14438. scrollEl.scrollTop = monthEl.getBoundingClientRect().top -
  14439. this.firstMonthElRef.current.getBoundingClientRect().top;
  14440. this.needsScrollReset = false;
  14441. }
  14442. }
  14443. // workaround for when queued setState render (w/ clientWidth) gets cancelled because
  14444. // subsequent update and shouldComponentUpdate says not to render :(
  14445. shouldComponentUpdate() {
  14446. return true;
  14447. }
  14448. }
  14449. // date profile
  14450. // -------------------------------------------------------------------------------------------------
  14451. const oneMonthDuration = createDuration(1, 'month');
  14452. function splitDateProfileByMonth(dateProfileGenerator, dateProfile, dateEnv, fixedWeekCount, showNonCurrentDates) {
  14453. const { start, end } = dateProfile.currentRange;
  14454. let monthStart = start;
  14455. const monthDateProfiles = [];
  14456. while (monthStart.valueOf() < end.valueOf()) {
  14457. const monthEnd = dateEnv.add(monthStart, oneMonthDuration);
  14458. const currentRange = {
  14459. // yuck
  14460. start: dateProfileGenerator.skipHiddenDays(monthStart),
  14461. end: dateProfileGenerator.skipHiddenDays(monthEnd, -1, true),
  14462. };
  14463. let renderRange = buildDayTableRenderRange({
  14464. currentRange,
  14465. snapToWeek: true,
  14466. fixedWeekCount,
  14467. dateEnv,
  14468. });
  14469. renderRange = {
  14470. // yuck
  14471. start: dateProfileGenerator.skipHiddenDays(renderRange.start),
  14472. end: dateProfileGenerator.skipHiddenDays(renderRange.end, -1, true),
  14473. };
  14474. const activeRange = dateProfile.activeRange ?
  14475. intersectRanges(dateProfile.activeRange, showNonCurrentDates ? renderRange : currentRange) :
  14476. null;
  14477. monthDateProfiles.push({
  14478. currentDate: dateProfile.currentDate,
  14479. isValid: dateProfile.isValid,
  14480. validRange: dateProfile.validRange,
  14481. renderRange,
  14482. activeRange,
  14483. currentRange,
  14484. currentRangeUnit: 'month',
  14485. isRangeAllDay: true,
  14486. dateIncrement: dateProfile.dateIncrement,
  14487. slotMinTime: dateProfile.slotMaxTime,
  14488. slotMaxTime: dateProfile.slotMinTime,
  14489. });
  14490. monthStart = monthEnd;
  14491. }
  14492. return monthDateProfiles;
  14493. }
  14494. // date formatting
  14495. // -------------------------------------------------------------------------------------------------
  14496. const YEAR_MONTH_FORMATTER = createFormatter({ year: 'numeric', month: 'long' });
  14497. const YEAR_FORMATTER = createFormatter({ month: 'long' });
  14498. function buildMonthFormat(formatOverride, monthDateProfiles) {
  14499. return formatOverride ||
  14500. ((monthDateProfiles[0].currentRange.start.getUTCFullYear() !==
  14501. monthDateProfiles[monthDateProfiles.length - 1].currentRange.start.getUTCFullYear())
  14502. ? YEAR_MONTH_FORMATTER
  14503. : YEAR_FORMATTER);
  14504. }
  14505. const OPTION_REFINERS = {
  14506. multiMonthTitleFormat: createFormatter,
  14507. multiMonthMaxColumns: Number,
  14508. multiMonthMinWidth: Number,
  14509. };
  14510. var css_248z = ".fc .fc-multimonth{border:1px solid var(--fc-border-color);display:flex;flex-wrap:wrap;overflow-x:hidden;overflow-y:auto}.fc .fc-multimonth-title{font-size:1.2em;font-weight:700;padding:1em 0;text-align:center}.fc .fc-multimonth-daygrid{background:var(--fc-page-bg-color)}.fc .fc-multimonth-daygrid-table,.fc .fc-multimonth-header-table{table-layout:fixed;width:100%}.fc .fc-multimonth-daygrid-table{border-top-style:hidden!important}.fc .fc-multimonth-singlecol .fc-multimonth{position:relative}.fc .fc-multimonth-singlecol .fc-multimonth-header{background:var(--fc-page-bg-color);position:relative;top:0;z-index:2}.fc .fc-multimonth-singlecol .fc-multimonth-daygrid{position:relative;z-index:1}.fc .fc-multimonth-singlecol .fc-multimonth-daygrid-table,.fc .fc-multimonth-singlecol .fc-multimonth-header-table{border-left-style:hidden;border-right-style:hidden}.fc .fc-multimonth-singlecol .fc-multimonth-month:last-child .fc-multimonth-daygrid-table{border-bottom-style:hidden}.fc .fc-multimonth-multicol{line-height:1}.fc .fc-multimonth-multicol .fc-multimonth-month{padding:0 1.2em 1.2em}.fc .fc-multimonth-multicol .fc-daygrid-more-link{border:1px solid var(--fc-event-border-color);display:block;float:none;padding:1px}.fc .fc-multimonth-compact{line-height:1}.fc .fc-multimonth-compact .fc-multimonth-daygrid-table,.fc .fc-multimonth-compact .fc-multimonth-header-table{font-size:.9em}.fc-media-screen .fc-multimonth-singlecol .fc-multimonth-header{position:sticky}.fc-media-print .fc-multimonth{overflow:visible}";
  14511. injectStyles(css_248z);
  14512. var index = createPlugin({
  14513. name: '@fullcalendar/multimonth',
  14514. initialView: 'multiMonthYear',
  14515. optionRefiners: OPTION_REFINERS,
  14516. views: {
  14517. multiMonth: {
  14518. component: MultiMonthView,
  14519. dateProfileGeneratorClass: TableDateProfileGenerator,
  14520. multiMonthMinWidth: 350,
  14521. multiMonthMaxColumns: 3,
  14522. },
  14523. multiMonthYear: {
  14524. type: 'multiMonth',
  14525. duration: { years: 1 },
  14526. fixedWeekCount: true,
  14527. showNonCurrentDates: false,
  14528. },
  14529. },
  14530. });
  14531. globalPlugins.push(index$4, index$3, index$2, index$1, index);
  14532. exports.Calendar = Calendar;
  14533. exports.Draggable = ExternalDraggable;
  14534. exports.Internal = internal;
  14535. exports.JsonRequestError = JsonRequestError;
  14536. exports.Preact = preact;
  14537. exports.ThirdPartyDraggable = ThirdPartyDraggable;
  14538. exports.createPlugin = createPlugin;
  14539. exports.formatDate = formatDate;
  14540. exports.formatRange = formatRange;
  14541. exports.globalLocales = globalLocales;
  14542. exports.globalPlugins = globalPlugins;
  14543. exports.sliceEvents = sliceEvents;
  14544. exports.version = version;
  14545. Object.defineProperty(exports, '__esModule', { value: true });
  14546. return exports;
  14547. })({});