main.js 656 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357
  1. /*!
  2. FullCalendar v5.1.0
  3. Docs & License: https://fullcalendar.io/
  4. (c) 2020 Adam Shaw
  5. */
  6. var FullCalendar = (function (exports) {
  7. 'use strict';
  8. /*! *****************************************************************************
  9. Copyright (c) Microsoft Corporation.
  10. Permission to use, copy, modify, and/or distribute this software for any
  11. purpose with or without fee is hereby granted.
  12. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
  13. REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
  14. AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
  15. INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  16. LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
  17. OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  18. PERFORMANCE OF THIS SOFTWARE.
  19. ***************************************************************************** */
  20. /* global Reflect, Promise */
  21. var extendStatics = function(d, b) {
  22. extendStatics = Object.setPrototypeOf ||
  23. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  24. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  25. return extendStatics(d, b);
  26. };
  27. function __extends(d, b) {
  28. extendStatics(d, b);
  29. function __() { this.constructor = d; }
  30. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  31. }
  32. var __assign = function() {
  33. __assign = Object.assign || function __assign(t) {
  34. for (var s, i = 1, n = arguments.length; i < n; i++) {
  35. s = arguments[i];
  36. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  37. }
  38. return t;
  39. };
  40. return __assign.apply(this, arguments);
  41. };
  42. function __spreadArrays() {
  43. for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
  44. for (var r = Array(s), k = 0, i = 0; i < il; i++)
  45. for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
  46. r[k] = a[j];
  47. return r;
  48. }
  49. var n,u,i,t,r,o,f,e={},c=[],s=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord/i;function a(n,l){for(var u in l)n[u]=l[u];return n}function v(n){var l=n.parentNode;l&&l.removeChild(n);}function h(n,l,u){var i,t=arguments,r={};for(i in l)"key"!==i&&"ref"!==i&&(r[i]=l[i]);if(arguments.length>3)for(u=[u],i=3;i<arguments.length;i++)u.push(t[i]);if(null!=u&&(r.children=u),"function"==typeof n&&null!=n.defaultProps)for(i in n.defaultProps)void 0===r[i]&&(r[i]=n.defaultProps[i]);return p(n,r,l&&l.key,l&&l.ref,null)}function p(l,u,i,t,r){var o={type:l,props:u,key:i,ref:t,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,constructor:void 0,__v:r};return null==r&&(o.__v=o),n.vnode&&n.vnode(o),o}function y(){return {}}function d(n){return n.children}function m(n,l){this.props=n,this.context=l;}function w(n,l){if(null==l)return n.__?w(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?w(n):null}function k(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 k(n)}}function g(l){(!l.__d&&(l.__d=!0)&&u.push(l)&&!i++||r!==n.debounceRendering)&&((r=n.debounceRendering)||t)(_);}function _(){for(var n;i=u.length;)n=u.sort(function(n,l){return n.__v.__b-l.__v.__b}),u=[],n.some(function(n){var l,u,i,t,r,o,f;n.__d&&(o=(r=(l=n).__v).__e,(f=l.__P)&&(u=[],(i=a({},r)).__v=i,t=A(f,r,i,l.__n,void 0!==f.ownerSVGElement,null,u,null==o?w(r):o),T(u,r),t!=o&&k(r)));});}function b(n,l,u,i,t,r,o,f,s){var a,h,p,y,d,m,k,g=u&&u.__k||c,_=g.length;if(f==e&&(f=null!=r?r[0]:_?w(u,0):null),a=0,l.__k=x(l.__k,function(u){if(null!=u){if(u.__=l,u.__b=l.__b+1,null===(p=g[a])||p&&u.key==p.key&&u.type===p.type)g[a]=void 0;else for(h=0;h<_;h++){if((p=g[h])&&u.key==p.key&&u.type===p.type){g[h]=void 0;break}p=null;}if(y=A(n,u,p=p||e,i,t,r,o,f,s),(h=u.ref)&&p.ref!=h&&(k||(k=[]),p.ref&&k.push(p.ref,null,u),k.push(h,u.__c||y,u)),null!=y){var c;if(null==m&&(m=y),void 0!==u.__d)c=u.__d,u.__d=void 0;else if(r==p||y!=f||null==y.parentNode){n:if(null==f||f.parentNode!==n)n.appendChild(y),c=null;else {for(d=f,h=0;(d=d.nextSibling)&&h<_;h+=2)if(d==y)break n;n.insertBefore(y,f),c=f;}"option"==l.type&&(n.value="");}f=void 0!==c?c:y.nextSibling,"function"==typeof l.type&&(l.__d=f);}else f&&p.__e==f&&f.parentNode!=n&&(f=w(p));}return a++,u}),l.__e=m,null!=r&&"function"!=typeof l.type)for(a=r.length;a--;)null!=r[a]&&v(r[a]);for(a=_;a--;)null!=g[a]&&D(g[a],g[a]);if(k)for(a=0;a<k.length;a++)j(k[a],k[++a],k[++a]);}function x(n,l,u){if(null==u&&(u=[]),null==n||"boolean"==typeof n)l&&u.push(l(null));else if(Array.isArray(n))for(var i=0;i<n.length;i++)x(n[i],l,u);else u.push(l?l("string"==typeof n||"number"==typeof n?p(null,n,null,null,n):null!=n.__e||null!=n.__c?p(n.type,n.props,n.key,null,n.__v):n):n);return u}function P(n,l,u,i,t){var r;for(r in u)"children"===r||"key"===r||r in l||N(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]||N(n,r,l[r],u[r],i);}function C(n,l,u){"-"===l[0]?n.setProperty(l,u):n[l]="number"==typeof u&&!1===s.test(l)?u+"px":null==u?"":u;}function N(n,l,u,i,t){var r,o,f,e,c;if(t?"className"===l&&(l="class"):"class"===l&&(l="className"),"style"===l)if(r=n.style,"string"==typeof u)r.cssText=u;else {if("string"==typeof i&&(r.cssText="",i=null),i)for(e in i)u&&e in u||C(r,e,"");if(u)for(c in u)i&&u[c]===i[c]||C(r,c,u[c]);}else "o"===l[0]&&"n"===l[1]?(o=l!==(l=l.replace(/Capture$/,"")),f=l.toLowerCase(),l=(f in n?f:l).slice(2),u?(i||n.addEventListener(l,z,o),(n.l||(n.l={}))[l]=u):n.removeEventListener(l,z,o)):"list"!==l&&"tagName"!==l&&"form"!==l&&"type"!==l&&"size"!==l&&!t&&l in n?n[l]=null==u?"":u:"function"!=typeof u&&"dangerouslySetInnerHTML"!==l&&(l!==(l=l.replace(/^xlink:?/,""))?null==u||!1===u?n.removeAttributeNS("http://www.w3.org/1999/xlink",l.toLowerCase()):n.setAttributeNS("http://www.w3.org/1999/xlink",l.toLowerCase(),u):null==u||!1===u&&!/^ar/.test(l)?n.removeAttribute(l):n.setAttribute(l,u));}function z(l){this.l[l.type](n.event?n.event(l):l);}function A(l,u,i,t,r,o,f,e,c){var s,v,h,p,y,w,k,g,_,x,P=u.type;if(void 0!==u.constructor)return null;(s=n.__b)&&s(u);try{n:if("function"==typeof P){if(g=u.props,_=(s=P.contextType)&&t[s.__c],x=s?_?_.props.value:s.__:t,i.__c?k=(v=u.__c=i.__c).__=v.__E:("prototype"in P&&P.prototype.render?u.__c=v=new P(g,x):(u.__c=v=new m(g,x),v.constructor=P,v.render=E),_&&_.sub(v),v.props=g,v.state||(v.state={}),v.context=x,v.__n=t,h=v.__d=!0,v.__h=[]),null==v.__s&&(v.__s=v.state),null!=P.getDerivedStateFromProps&&(v.__s==v.state&&(v.__s=a({},v.__s)),a(v.__s,P.getDerivedStateFromProps(g,v.__s))),p=v.props,y=v.state,h)null==P.getDerivedStateFromProps&&null!=v.componentWillMount&&v.componentWillMount(),null!=v.componentDidMount&&v.__h.push(v.componentDidMount);else {if(null==P.getDerivedStateFromProps&&g!==p&&null!=v.componentWillReceiveProps&&v.componentWillReceiveProps(g,x),!v.__e&&null!=v.shouldComponentUpdate&&!1===v.shouldComponentUpdate(g,v.__s,x)||u.__v===i.__v&&!v.__){for(v.props=g,v.state=v.__s,u.__v!==i.__v&&(v.__d=!1),v.__v=u,u.__e=i.__e,u.__k=i.__k,v.__h.length&&f.push(v),s=0;s<u.__k.length;s++)u.__k[s]&&(u.__k[s].__=u);break n}null!=v.componentWillUpdate&&v.componentWillUpdate(g,v.__s,x),null!=v.componentDidUpdate&&v.__h.push(function(){v.componentDidUpdate(p,y,w);});}v.context=x,v.props=g,v.state=v.__s,(s=n.__r)&&s(u),v.__d=!1,v.__v=u,v.__P=l,s=v.render(v.props,v.state,v.context),u.__k=null!=s&&s.type==d&&null==s.key?s.props.children:Array.isArray(s)?s:[s],null!=v.getChildContext&&(t=a(a({},t),v.getChildContext())),h||null==v.getSnapshotBeforeUpdate||(w=v.getSnapshotBeforeUpdate(p,y)),b(l,u,i,t,r,o,f,e,c),v.base=u.__e,v.__h.length&&f.push(v),k&&(v.__E=v.__=null),v.__e=!1;}else null==o&&u.__v===i.__v?(u.__k=i.__k,u.__e=i.__e):u.__e=$(i.__e,u,i,t,r,o,f,c);(s=n.diffed)&&s(u);}catch(l){u.__v=null,n.__e(l,u,i);}return u.__e}function T(l,u){n.__c&&n.__c(u,l),l.some(function(u){try{l=u.__h,u.__h=[],l.some(function(n){n.call(u);});}catch(l){n.__e(l,u.__v);}});}function $(n,l,u,i,t,r,o,f){var s,a,v,h,p,y=u.props,d=l.props;if(t="svg"===l.type||t,null!=r)for(s=0;s<r.length;s++)if(null!=(a=r[s])&&((null===l.type?3===a.nodeType:a.localName===l.type)||n==a)){n=a,r[s]=null;break}if(null==n){if(null===l.type)return document.createTextNode(d);n=t?document.createElementNS("http://www.w3.org/2000/svg",l.type):document.createElement(l.type,d.is&&{is:d.is}),r=null,f=!1;}if(null===l.type)y!==d&&n.data!=d&&(n.data=d);else {if(null!=r&&(r=c.slice.call(n.childNodes)),v=(y=u.props||e).dangerouslySetInnerHTML,h=d.dangerouslySetInnerHTML,!f){if(y===e)for(y={},p=0;p<n.attributes.length;p++)y[n.attributes[p].name]=n.attributes[p].value;(h||v)&&(h&&v&&h.__html==v.__html||(n.innerHTML=h&&h.__html||""));}P(n,d,y,t,f),h?l.__k=[]:(l.__k=l.props.children,b(n,l,u,i,"foreignObject"!==l.type&&t,r,o,e,f)),f||("value"in d&&void 0!==(s=d.value)&&s!==n.value&&N(n,"value",s,y.value,!1),"checked"in d&&void 0!==(s=d.checked)&&s!==n.checked&&N(n,"checked",s,y.checked,!1));}return n}function j(l,u,i){try{"function"==typeof l?l(u):l.current=u;}catch(l){n.__e(l,i);}}function D(l,u,i){var t,r,o;if(n.unmount&&n.unmount(l),(t=l.ref)&&(t.current&&t.current!==l.__e||j(t,null,u)),i||"function"==typeof l.type||(i=null!=(r=l.__e)),l.__e=l.__d=void 0,null!=(t=l.__c)){if(t.componentWillUnmount)try{t.componentWillUnmount();}catch(l){n.__e(l,u);}t.base=t.__P=null;}if(t=l.__k)for(o=0;o<t.length;o++)t[o]&&D(t[o],u,i);null!=r&&v(r);}function E(n,l,u){return this.constructor(n,u)}function H(l,u,i){var t,r,f;n.__&&n.__(l,u),r=(t=i===o)?null:i&&i.__k||u.__k,l=h(d,null,[l]),f=[],A(u,(t?u:i||u).__k=l,r||e,e,void 0!==u.ownerSVGElement,i&&!t?[i]:r?null:c.slice.call(u.childNodes),f,i||e,t),T(f,l);}function M(n){var l={},u={__c:"__cC"+f++,__:n,Consumer:function(n,l){return n.children(l)},Provider:function(n){var i,t=this;return this.getChildContext||(i=[],this.getChildContext=function(){return l[u.__c]=t,l},this.shouldComponentUpdate=function(n){t.props.value!==n.value&&i.some(function(l){l.context=n.value,g(l);});},this.sub=function(n){i.push(n);var l=n.componentWillUnmount;n.componentWillUnmount=function(){i.splice(i.indexOf(n),1),l&&l.call(n);};}),n.children}};return u.Consumer.contextType=u,u.Provider.__=u,u}n={__e:function(n,l){for(var u,i;l=l.__;)if((u=l.__c)&&!u.__)try{if(u.constructor&&null!=u.constructor.getDerivedStateFromError&&(i=!0,u.setState(u.constructor.getDerivedStateFromError(n))),null!=u.componentDidCatch&&(i=!0,u.componentDidCatch(n)),i)return g(u.__E=u)}catch(l){n=l;}throw n}},m.prototype.setState=function(n,l){var u;u=this.__s!==this.state?this.__s:this.__s=a({},this.state),"function"==typeof n&&(n=n(u,this.props)),n&&a(u,n),null!=n&&this.__v&&(l&&this.__h.push(l),g(this));},m.prototype.forceUpdate=function(n){this.__v&&(this.__e=!0,n&&this.__h.push(n),g(this));},m.prototype.render=d,u=[],i=0,t="function"==typeof Promise?Promise.prototype.then.bind(Promise.resolve()):setTimeout,o=e,f=0;
  50. window.FullCalendarVDom = {
  51. Component: m,
  52. createElement: h,
  53. render: H,
  54. createRef: y,
  55. Fragment: d,
  56. createContext: createContext,
  57. flushToDom: flushToDom
  58. };
  59. // HACKS...
  60. // TODO: lock version
  61. // TODO: link gh issues
  62. function flushToDom() {
  63. var oldDebounceRendering = n.debounceRendering; // orig
  64. var callbackQ = [];
  65. function execCallbackSync(callback) {
  66. callbackQ.push(callback);
  67. }
  68. n.debounceRendering = execCallbackSync;
  69. H(h(FakeComponent, {}), document.createElement('div'));
  70. while (callbackQ.length) {
  71. callbackQ.shift()();
  72. }
  73. n.debounceRendering = oldDebounceRendering;
  74. }
  75. var FakeComponent = /** @class */ (function (_super) {
  76. __extends(FakeComponent, _super);
  77. function FakeComponent() {
  78. return _super !== null && _super.apply(this, arguments) || this;
  79. }
  80. FakeComponent.prototype.render = function () { return h('div', {}); };
  81. FakeComponent.prototype.componentDidMount = function () { this.setState({}); };
  82. return FakeComponent;
  83. }(m));
  84. function createContext(defaultValue) {
  85. var ContextType = M(defaultValue);
  86. var origProvider = ContextType.Provider;
  87. ContextType.Provider = function () {
  88. var _this = this;
  89. var isNew = !this.getChildContext;
  90. var children = origProvider.apply(this, arguments);
  91. if (isNew) {
  92. var subs_1 = [];
  93. this.shouldComponentUpdate = function (_props) {
  94. if (_this.props.value !== _props.value) {
  95. subs_1.some(function (c) {
  96. c.context = _props.value;
  97. c.forceUpdate();
  98. });
  99. }
  100. };
  101. this.sub = function (c) {
  102. subs_1.push(c);
  103. var old = c.componentWillUnmount;
  104. c.componentWillUnmount = function () {
  105. subs_1.splice(subs_1.indexOf(c), 1);
  106. old && old.call(c);
  107. };
  108. };
  109. }
  110. return children;
  111. };
  112. return ContextType;
  113. }
  114. // no public types yet. when there are, export from:
  115. // import {} from './api-type-deps'
  116. var EventSourceApi = /** @class */ (function () {
  117. function EventSourceApi(context, internalEventSource // rename?
  118. ) {
  119. this.context = context;
  120. this.internalEventSource = internalEventSource;
  121. }
  122. EventSourceApi.prototype.remove = function () {
  123. this.context.dispatch({
  124. type: 'REMOVE_EVENT_SOURCE',
  125. sourceId: this.internalEventSource.sourceId
  126. });
  127. };
  128. EventSourceApi.prototype.refetch = function () {
  129. this.context.dispatch({
  130. type: 'FETCH_EVENT_SOURCES',
  131. sourceIds: [this.internalEventSource.sourceId]
  132. });
  133. };
  134. Object.defineProperty(EventSourceApi.prototype, "id", {
  135. get: function () {
  136. return this.internalEventSource.publicId;
  137. },
  138. enumerable: false,
  139. configurable: true
  140. });
  141. Object.defineProperty(EventSourceApi.prototype, "url", {
  142. // only relevant to json-feed event sources
  143. get: function () {
  144. return this.internalEventSource.meta.url;
  145. },
  146. enumerable: false,
  147. configurable: true
  148. });
  149. return EventSourceApi;
  150. }());
  151. // TODO: new util arrayify?
  152. function removeExact(array, exactVal) {
  153. var removeCnt = 0;
  154. var i = 0;
  155. while (i < array.length) {
  156. if (array[i] === exactVal) {
  157. array.splice(i, 1);
  158. removeCnt++;
  159. }
  160. else {
  161. i++;
  162. }
  163. }
  164. return removeCnt;
  165. }
  166. function isArraysEqual(a0, a1, equalityFunc) {
  167. if (a0 === a1) {
  168. return true;
  169. }
  170. var len = a0.length;
  171. var i;
  172. if (len !== a1.length) { // not array? or not same length?
  173. return false;
  174. }
  175. for (i = 0; i < len; i++) {
  176. if (!(equalityFunc ? equalityFunc(a0[i], a1[i]) : a0[i] === a1[i])) {
  177. return false;
  178. }
  179. }
  180. return true;
  181. }
  182. function htmlToElement(html) {
  183. html = html.trim();
  184. var container = document.createElement('div');
  185. container.innerHTML = html;
  186. return container.firstChild;
  187. }
  188. function removeElement(el) {
  189. if (el.parentNode) {
  190. el.parentNode.removeChild(el);
  191. }
  192. }
  193. function injectHtml(el, html) {
  194. el.innerHTML = html;
  195. }
  196. function injectDomNodes(el, domNodes) {
  197. var oldNodes = Array.prototype.slice.call(el.childNodes); // TODO: use array util
  198. var newNodes = Array.prototype.slice.call(domNodes); // TODO: use array util
  199. if (!isArraysEqual(oldNodes, newNodes)) {
  200. for (var _i = 0, newNodes_1 = newNodes; _i < newNodes_1.length; _i++) {
  201. var newNode = newNodes_1[_i];
  202. el.appendChild(newNode);
  203. }
  204. oldNodes.forEach(removeElement);
  205. }
  206. }
  207. // Querying
  208. // ----------------------------------------------------------------------------------------------------------------
  209. // from https://developer.mozilla.org/en-US/docs/Web/API/Element/closest
  210. var matchesMethod = Element.prototype.matches ||
  211. Element.prototype.matchesSelector ||
  212. Element.prototype.msMatchesSelector;
  213. var closestMethod = Element.prototype.closest || function (selector) {
  214. // polyfill
  215. var el = this;
  216. if (!document.documentElement.contains(el)) {
  217. return null;
  218. }
  219. do {
  220. if (elementMatches(el, selector)) {
  221. return el;
  222. }
  223. el = el.parentElement || el.parentNode;
  224. } while (el !== null && el.nodeType === 1);
  225. return null;
  226. };
  227. function elementClosest(el, selector) {
  228. return closestMethod.call(el, selector);
  229. }
  230. function elementMatches(el, selector) {
  231. return matchesMethod.call(el, selector);
  232. }
  233. // accepts multiple subject els
  234. // returns a real array. good for methods like forEach
  235. // TODO: accept the document
  236. function findElements(container, selector) {
  237. var containers = container instanceof HTMLElement ? [container] : container;
  238. var allMatches = [];
  239. for (var i = 0; i < containers.length; i++) {
  240. var matches = containers[i].querySelectorAll(selector);
  241. for (var j = 0; j < matches.length; j++) {
  242. allMatches.push(matches[j]);
  243. }
  244. }
  245. return allMatches;
  246. }
  247. // accepts multiple subject els
  248. // only queries direct child elements // TODO: rename to findDirectChildren!
  249. function findDirectChildren(parent, selector) {
  250. var parents = parent instanceof HTMLElement ? [parent] : parent;
  251. var allMatches = [];
  252. for (var i = 0; i < parents.length; i++) {
  253. var childNodes = parents[i].children; // only ever elements
  254. for (var j = 0; j < childNodes.length; j++) {
  255. var childNode = childNodes[j];
  256. if (!selector || elementMatches(childNode, selector)) {
  257. allMatches.push(childNode);
  258. }
  259. }
  260. }
  261. return allMatches;
  262. }
  263. // Style
  264. // ----------------------------------------------------------------------------------------------------------------
  265. var PIXEL_PROP_RE = /(top|left|right|bottom|width|height)$/i;
  266. function applyStyle(el, props) {
  267. for (var propName in props) {
  268. applyStyleProp(el, propName, props[propName]);
  269. }
  270. }
  271. function applyStyleProp(el, name, val) {
  272. if (val == null) {
  273. el.style[name] = '';
  274. }
  275. else if (typeof val === 'number' && PIXEL_PROP_RE.test(name)) {
  276. el.style[name] = val + 'px';
  277. }
  278. else {
  279. el.style[name] = val;
  280. }
  281. }
  282. // Stops a mouse/touch event from doing it's native browser action
  283. function preventDefault(ev) {
  284. ev.preventDefault();
  285. }
  286. // Event Delegation
  287. // ----------------------------------------------------------------------------------------------------------------
  288. function buildDelegationHandler(selector, handler) {
  289. return function (ev) {
  290. var matchedChild = elementClosest(ev.target, selector);
  291. if (matchedChild) {
  292. handler.call(matchedChild, ev, matchedChild);
  293. }
  294. };
  295. }
  296. function listenBySelector(container, eventType, selector, handler) {
  297. var attachedHandler = buildDelegationHandler(selector, handler);
  298. container.addEventListener(eventType, attachedHandler);
  299. return function () {
  300. container.removeEventListener(eventType, attachedHandler);
  301. };
  302. }
  303. function listenToHoverBySelector(container, selector, onMouseEnter, onMouseLeave) {
  304. var currentMatchedChild;
  305. return listenBySelector(container, 'mouseover', selector, function (ev, matchedChild) {
  306. if (matchedChild !== currentMatchedChild) {
  307. currentMatchedChild = matchedChild;
  308. onMouseEnter(ev, matchedChild);
  309. var realOnMouseLeave_1 = function (ev) {
  310. currentMatchedChild = null;
  311. onMouseLeave(ev, matchedChild);
  312. matchedChild.removeEventListener('mouseleave', realOnMouseLeave_1);
  313. };
  314. // listen to the next mouseleave, and then unattach
  315. matchedChild.addEventListener('mouseleave', realOnMouseLeave_1);
  316. }
  317. });
  318. }
  319. // Animation
  320. // ----------------------------------------------------------------------------------------------------------------
  321. var transitionEventNames = [
  322. 'webkitTransitionEnd',
  323. 'otransitionend',
  324. 'oTransitionEnd',
  325. 'msTransitionEnd',
  326. 'transitionend'
  327. ];
  328. // triggered only when the next single subsequent transition finishes
  329. function whenTransitionDone(el, callback) {
  330. var realCallback = function (ev) {
  331. callback(ev);
  332. transitionEventNames.forEach(function (eventName) {
  333. el.removeEventListener(eventName, realCallback);
  334. });
  335. };
  336. transitionEventNames.forEach(function (eventName) {
  337. el.addEventListener(eventName, realCallback); // cross-browser way to determine when the transition finishes
  338. });
  339. }
  340. var guidNumber = 0;
  341. function guid() {
  342. return String(guidNumber++);
  343. }
  344. /* FullCalendar-specific DOM Utilities
  345. ----------------------------------------------------------------------------------------------------------------------*/
  346. // Make the mouse cursor express that an event is not allowed in the current area
  347. function disableCursor() {
  348. document.body.classList.add('fc-not-allowed');
  349. }
  350. // Returns the mouse cursor to its original look
  351. function enableCursor() {
  352. document.body.classList.remove('fc-not-allowed');
  353. }
  354. /* Selection
  355. ----------------------------------------------------------------------------------------------------------------------*/
  356. function preventSelection(el) {
  357. el.classList.add('fc-unselectable');
  358. el.addEventListener('selectstart', preventDefault);
  359. }
  360. function allowSelection(el) {
  361. el.classList.remove('fc-unselectable');
  362. el.removeEventListener('selectstart', preventDefault);
  363. }
  364. /* Context Menu
  365. ----------------------------------------------------------------------------------------------------------------------*/
  366. function preventContextMenu(el) {
  367. el.addEventListener('contextmenu', preventDefault);
  368. }
  369. function allowContextMenu(el) {
  370. el.removeEventListener('contextmenu', preventDefault);
  371. }
  372. function parseFieldSpecs(input) {
  373. var specs = [];
  374. var tokens = [];
  375. var i;
  376. var token;
  377. if (typeof input === 'string') {
  378. tokens = input.split(/\s*,\s*/);
  379. }
  380. else if (typeof input === 'function') {
  381. tokens = [input];
  382. }
  383. else if (Array.isArray(input)) {
  384. tokens = input;
  385. }
  386. for (i = 0; i < tokens.length; i++) {
  387. token = tokens[i];
  388. if (typeof token === 'string') {
  389. specs.push(token.charAt(0) === '-' ?
  390. { field: token.substring(1), order: -1 } :
  391. { field: token, order: 1 });
  392. }
  393. else if (typeof token === 'function') {
  394. specs.push({ func: token });
  395. }
  396. }
  397. return specs;
  398. }
  399. function compareByFieldSpecs(obj0, obj1, fieldSpecs) {
  400. var i;
  401. var cmp;
  402. for (i = 0; i < fieldSpecs.length; i++) {
  403. cmp = compareByFieldSpec(obj0, obj1, fieldSpecs[i]);
  404. if (cmp) {
  405. return cmp;
  406. }
  407. }
  408. return 0;
  409. }
  410. function compareByFieldSpec(obj0, obj1, fieldSpec) {
  411. if (fieldSpec.func) {
  412. return fieldSpec.func(obj0, obj1);
  413. }
  414. return flexibleCompare(obj0[fieldSpec.field], obj1[fieldSpec.field])
  415. * (fieldSpec.order || 1);
  416. }
  417. function flexibleCompare(a, b) {
  418. if (!a && !b) {
  419. return 0;
  420. }
  421. if (b == null) {
  422. return -1;
  423. }
  424. if (a == null) {
  425. return 1;
  426. }
  427. if (typeof a === 'string' || typeof b === 'string') {
  428. return String(a).localeCompare(String(b));
  429. }
  430. return a - b;
  431. }
  432. /* String Utilities
  433. ----------------------------------------------------------------------------------------------------------------------*/
  434. function padStart(val, len) {
  435. var s = String(val);
  436. return '000'.substr(0, len - s.length) + s;
  437. }
  438. /* Number Utilities
  439. ----------------------------------------------------------------------------------------------------------------------*/
  440. function compareNumbers(a, b) {
  441. return a - b;
  442. }
  443. function isInt(n) {
  444. return n % 1 === 0;
  445. }
  446. /* FC-specific DOM dimension stuff
  447. ----------------------------------------------------------------------------------------------------------------------*/
  448. function computeSmallestCellWidth(cellEl) {
  449. var allWidthEl = cellEl.querySelector('.fc-scrollgrid-shrink-frame');
  450. var contentWidthEl = cellEl.querySelector('.fc-scrollgrid-shrink-cushion');
  451. if (!allWidthEl) {
  452. throw new Error('needs fc-scrollgrid-shrink-frame className'); // TODO: use const
  453. }
  454. if (!contentWidthEl) {
  455. throw new Error('needs fc-scrollgrid-shrink-cushion className');
  456. }
  457. return cellEl.getBoundingClientRect().width - allWidthEl.getBoundingClientRect().width + // the cell padding+border
  458. contentWidthEl.getBoundingClientRect().width;
  459. }
  460. var DAY_IDS = ['sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat'];
  461. // Adding
  462. function addWeeks(m, n) {
  463. var a = dateToUtcArray(m);
  464. a[2] += n * 7;
  465. return arrayToUtcDate(a);
  466. }
  467. function addDays(m, n) {
  468. var a = dateToUtcArray(m);
  469. a[2] += n;
  470. return arrayToUtcDate(a);
  471. }
  472. function addMs(m, n) {
  473. var a = dateToUtcArray(m);
  474. a[6] += n;
  475. return arrayToUtcDate(a);
  476. }
  477. // Diffing (all return floats)
  478. // TODO: why not use ranges?
  479. function diffWeeks(m0, m1) {
  480. return diffDays(m0, m1) / 7;
  481. }
  482. function diffDays(m0, m1) {
  483. return (m1.valueOf() - m0.valueOf()) / (1000 * 60 * 60 * 24);
  484. }
  485. function diffHours(m0, m1) {
  486. return (m1.valueOf() - m0.valueOf()) / (1000 * 60 * 60);
  487. }
  488. function diffMinutes(m0, m1) {
  489. return (m1.valueOf() - m0.valueOf()) / (1000 * 60);
  490. }
  491. function diffSeconds(m0, m1) {
  492. return (m1.valueOf() - m0.valueOf()) / 1000;
  493. }
  494. function diffDayAndTime(m0, m1) {
  495. var m0day = startOfDay(m0);
  496. var m1day = startOfDay(m1);
  497. return {
  498. years: 0,
  499. months: 0,
  500. days: Math.round(diffDays(m0day, m1day)),
  501. milliseconds: (m1.valueOf() - m1day.valueOf()) - (m0.valueOf() - m0day.valueOf())
  502. };
  503. }
  504. // Diffing Whole Units
  505. function diffWholeWeeks(m0, m1) {
  506. var d = diffWholeDays(m0, m1);
  507. if (d !== null && d % 7 === 0) {
  508. return d / 7;
  509. }
  510. return null;
  511. }
  512. function diffWholeDays(m0, m1) {
  513. if (timeAsMs(m0) === timeAsMs(m1)) {
  514. return Math.round(diffDays(m0, m1));
  515. }
  516. return null;
  517. }
  518. // Start-Of
  519. function startOfDay(m) {
  520. return arrayToUtcDate([
  521. m.getUTCFullYear(),
  522. m.getUTCMonth(),
  523. m.getUTCDate()
  524. ]);
  525. }
  526. function startOfHour(m) {
  527. return arrayToUtcDate([
  528. m.getUTCFullYear(),
  529. m.getUTCMonth(),
  530. m.getUTCDate(),
  531. m.getUTCHours()
  532. ]);
  533. }
  534. function startOfMinute(m) {
  535. return arrayToUtcDate([
  536. m.getUTCFullYear(),
  537. m.getUTCMonth(),
  538. m.getUTCDate(),
  539. m.getUTCHours(),
  540. m.getUTCMinutes()
  541. ]);
  542. }
  543. function startOfSecond(m) {
  544. return arrayToUtcDate([
  545. m.getUTCFullYear(),
  546. m.getUTCMonth(),
  547. m.getUTCDate(),
  548. m.getUTCHours(),
  549. m.getUTCMinutes(),
  550. m.getUTCSeconds()
  551. ]);
  552. }
  553. // Week Computation
  554. function weekOfYear(marker, dow, doy) {
  555. var y = marker.getUTCFullYear();
  556. var w = weekOfGivenYear(marker, y, dow, doy);
  557. if (w < 1) {
  558. return weekOfGivenYear(marker, y - 1, dow, doy);
  559. }
  560. var nextW = weekOfGivenYear(marker, y + 1, dow, doy);
  561. if (nextW >= 1) {
  562. return Math.min(w, nextW);
  563. }
  564. return w;
  565. }
  566. function weekOfGivenYear(marker, year, dow, doy) {
  567. var firstWeekStart = arrayToUtcDate([year, 0, 1 + firstWeekOffset(year, dow, doy)]);
  568. var dayStart = startOfDay(marker);
  569. var days = Math.round(diffDays(firstWeekStart, dayStart));
  570. return Math.floor(days / 7) + 1; // zero-indexed
  571. }
  572. // start-of-first-week - start-of-year
  573. function firstWeekOffset(year, dow, doy) {
  574. // first-week day -- which january is always in the first week (4 for iso, 1 for other)
  575. var fwd = 7 + dow - doy;
  576. // first-week day local weekday -- which local weekday is fwd
  577. var fwdlw = (7 + arrayToUtcDate([year, 0, fwd]).getUTCDay() - dow) % 7;
  578. return -fwdlw + fwd - 1;
  579. }
  580. // Array Conversion
  581. function dateToLocalArray(date) {
  582. return [
  583. date.getFullYear(),
  584. date.getMonth(),
  585. date.getDate(),
  586. date.getHours(),
  587. date.getMinutes(),
  588. date.getSeconds(),
  589. date.getMilliseconds()
  590. ];
  591. }
  592. function arrayToLocalDate(a) {
  593. return new Date(a[0], a[1] || 0, a[2] == null ? 1 : a[2], // day of month
  594. a[3] || 0, a[4] || 0, a[5] || 0);
  595. }
  596. function dateToUtcArray(date) {
  597. return [
  598. date.getUTCFullYear(),
  599. date.getUTCMonth(),
  600. date.getUTCDate(),
  601. date.getUTCHours(),
  602. date.getUTCMinutes(),
  603. date.getUTCSeconds(),
  604. date.getUTCMilliseconds()
  605. ];
  606. }
  607. function arrayToUtcDate(a) {
  608. // according to web standards (and Safari), a month index is required.
  609. // massage if only given a year.
  610. if (a.length === 1) {
  611. a = a.concat([0]);
  612. }
  613. return new Date(Date.UTC.apply(Date, a));
  614. }
  615. // Other Utils
  616. function isValidDate(m) {
  617. return !isNaN(m.valueOf());
  618. }
  619. function timeAsMs(m) {
  620. return m.getUTCHours() * 1000 * 60 * 60 +
  621. m.getUTCMinutes() * 1000 * 60 +
  622. m.getUTCSeconds() * 1000 +
  623. m.getUTCMilliseconds();
  624. }
  625. function createEventInstance(defId, range, forcedStartTzo, forcedEndTzo) {
  626. return {
  627. instanceId: guid(),
  628. defId: defId,
  629. range: range,
  630. forcedStartTzo: forcedStartTzo == null ? null : forcedStartTzo,
  631. forcedEndTzo: forcedEndTzo == null ? null : forcedEndTzo
  632. };
  633. }
  634. var hasOwnProperty = Object.prototype.hasOwnProperty;
  635. // Merges an array of objects into a single object.
  636. // The second argument allows for an array of property names who's object values will be merged together.
  637. function mergeProps(propObjs, complexPropsMap) {
  638. var dest = {};
  639. if (complexPropsMap) {
  640. for (var name_1 in complexPropsMap) {
  641. var complexObjs = [];
  642. // collect the trailing object values, stopping when a non-object is discovered
  643. for (var i = propObjs.length - 1; i >= 0; i--) {
  644. var val = propObjs[i][name_1];
  645. if (typeof val === 'object' && val) { // non-null object
  646. complexObjs.unshift(val);
  647. }
  648. else if (val !== undefined) {
  649. dest[name_1] = val; // if there were no objects, this value will be used
  650. break;
  651. }
  652. }
  653. // if the trailing values were objects, use the merged value
  654. if (complexObjs.length) {
  655. dest[name_1] = mergeProps(complexObjs);
  656. }
  657. }
  658. }
  659. // copy values into the destination, going from last to first
  660. for (var i = propObjs.length - 1; i >= 0; i--) {
  661. var props = propObjs[i];
  662. for (var name_2 in props) {
  663. if (!(name_2 in dest)) { // if already assigned by previous props or complex props, don't reassign
  664. dest[name_2] = props[name_2];
  665. }
  666. }
  667. }
  668. return dest;
  669. }
  670. function filterHash(hash, func) {
  671. var filtered = {};
  672. for (var key in hash) {
  673. if (func(hash[key], key)) {
  674. filtered[key] = hash[key];
  675. }
  676. }
  677. return filtered;
  678. }
  679. function mapHash(hash, func) {
  680. var newHash = {};
  681. for (var key in hash) {
  682. newHash[key] = func(hash[key], key);
  683. }
  684. return newHash;
  685. }
  686. function arrayToHash(a) {
  687. var hash = {};
  688. for (var _i = 0, a_1 = a; _i < a_1.length; _i++) {
  689. var item = a_1[_i];
  690. hash[item] = true;
  691. }
  692. return hash;
  693. }
  694. function buildHashFromArray(a, func) {
  695. var hash = {};
  696. for (var i = 0; i < a.length; i++) {
  697. var tuple = func(a[i], i);
  698. hash[tuple[0]] = tuple[1];
  699. }
  700. return hash;
  701. }
  702. function hashValuesToArray(obj) {
  703. var a = [];
  704. for (var key in obj) {
  705. a.push(obj[key]);
  706. }
  707. return a;
  708. }
  709. function isPropsEqual(obj0, obj1) {
  710. if (obj0 === obj1) {
  711. return true;
  712. }
  713. for (var key in obj0) {
  714. if (hasOwnProperty.call(obj0, key)) {
  715. if (!(key in obj1)) {
  716. return false;
  717. }
  718. }
  719. }
  720. for (var key in obj1) {
  721. if (hasOwnProperty.call(obj1, key)) {
  722. if (obj0[key] !== obj1[key]) {
  723. return false;
  724. }
  725. }
  726. }
  727. return true;
  728. }
  729. function getUnequalProps(obj0, obj1) {
  730. var keys = [];
  731. for (var key in obj0) {
  732. if (hasOwnProperty.call(obj0, key)) {
  733. if (!(key in obj1)) {
  734. keys.push(key);
  735. }
  736. }
  737. }
  738. for (var key in obj1) {
  739. if (hasOwnProperty.call(obj1, key)) {
  740. if (obj0[key] !== obj1[key]) {
  741. keys.push(key);
  742. }
  743. }
  744. }
  745. return keys;
  746. }
  747. function compareObjs(oldProps, newProps, equalityFuncs) {
  748. if (equalityFuncs === void 0) { equalityFuncs = {}; }
  749. if (oldProps === newProps) {
  750. return true;
  751. }
  752. for (var key in newProps) {
  753. if (key in oldProps && isObjValsEqual(oldProps[key], newProps[key], equalityFuncs[key])) ;
  754. else {
  755. return false;
  756. }
  757. }
  758. // check for props that were omitted in the new
  759. for (var key in oldProps) {
  760. if (!(key in newProps)) {
  761. return false;
  762. }
  763. }
  764. return true;
  765. }
  766. /*
  767. assumed "true" equality for handler names like "onReceiveSomething"
  768. */
  769. function isObjValsEqual(val0, val1, comparator) {
  770. if (val0 === val1 || comparator === true) {
  771. return true;
  772. }
  773. if (comparator) {
  774. return comparator(val0, val1);
  775. }
  776. return false;
  777. }
  778. function collectFromHash(hash, startIndex, endIndex, step) {
  779. if (startIndex === void 0) { startIndex = 0; }
  780. if (step === void 0) { step = 1; }
  781. var res = [];
  782. if (endIndex == null) {
  783. endIndex = Object.keys(hash).length;
  784. }
  785. for (var i = startIndex; i < endIndex; i += step) {
  786. var val = hash[i];
  787. if (val !== undefined) { // will disregard undefined for sparse arrays
  788. res.push(val);
  789. }
  790. }
  791. return res;
  792. }
  793. function parseRecurring(refined, defaultAllDay, dateEnv, recurringTypes) {
  794. for (var i = 0; i < recurringTypes.length; i++) {
  795. var parsed = recurringTypes[i].parse(refined, dateEnv);
  796. if (parsed) {
  797. var allDay = refined.allDay;
  798. if (allDay == null) {
  799. allDay = defaultAllDay;
  800. if (allDay == null) {
  801. allDay = parsed.allDayGuess;
  802. if (allDay == null) {
  803. allDay = false;
  804. }
  805. }
  806. }
  807. return {
  808. allDay: allDay,
  809. duration: parsed.duration,
  810. typeData: parsed.typeData,
  811. typeId: i
  812. };
  813. }
  814. }
  815. return null;
  816. }
  817. function expandRecurring(eventStore, framingRange, context) {
  818. var dateEnv = context.dateEnv, pluginHooks = context.pluginHooks, options = context.options;
  819. var defs = eventStore.defs, instances = eventStore.instances;
  820. // remove existing recurring instances
  821. // TODO: bad. always expand events as a second step
  822. instances = filterHash(instances, function (instance) {
  823. return !defs[instance.defId].recurringDef;
  824. });
  825. for (var defId in defs) {
  826. var def = defs[defId];
  827. if (def.recurringDef) {
  828. var duration = def.recurringDef.duration;
  829. if (!duration) {
  830. duration = def.allDay ?
  831. options.defaultAllDayEventDuration :
  832. options.defaultTimedEventDuration;
  833. }
  834. var starts = expandRecurringRanges(def, duration, framingRange, dateEnv, pluginHooks.recurringTypes);
  835. for (var _i = 0, starts_1 = starts; _i < starts_1.length; _i++) {
  836. var start = starts_1[_i];
  837. var instance = createEventInstance(defId, {
  838. start: start,
  839. end: dateEnv.add(start, duration)
  840. });
  841. instances[instance.instanceId] = instance;
  842. }
  843. }
  844. }
  845. return { defs: defs, instances: instances };
  846. }
  847. /*
  848. Event MUST have a recurringDef
  849. */
  850. function expandRecurringRanges(eventDef, duration, framingRange, dateEnv, recurringTypes) {
  851. var typeDef = recurringTypes[eventDef.recurringDef.typeId];
  852. var markers = typeDef.expand(eventDef.recurringDef.typeData, {
  853. start: dateEnv.subtract(framingRange.start, duration),
  854. end: framingRange.end
  855. }, dateEnv);
  856. // the recurrence plugins don't guarantee that all-day events are start-of-day, so we have to
  857. if (eventDef.allDay) {
  858. markers = markers.map(startOfDay);
  859. }
  860. return markers;
  861. }
  862. var INTERNAL_UNITS = ['years', 'months', 'days', 'milliseconds'];
  863. var PARSE_RE = /^(-?)(?:(\d+)\.)?(\d+):(\d\d)(?::(\d\d)(?:\.(\d\d\d))?)?/;
  864. // Parsing and Creation
  865. function createDuration(input, unit) {
  866. var _a;
  867. if (typeof input === 'string') {
  868. return parseString(input);
  869. }
  870. else if (typeof input === 'object' && input) { // non-null object
  871. return parseObject(input);
  872. }
  873. else if (typeof input === 'number') {
  874. return parseObject((_a = {}, _a[unit || 'milliseconds'] = input, _a));
  875. }
  876. else {
  877. return null;
  878. }
  879. }
  880. function parseString(s) {
  881. var m = PARSE_RE.exec(s);
  882. if (m) {
  883. var sign = m[1] ? -1 : 1;
  884. return {
  885. years: 0,
  886. months: 0,
  887. days: sign * (m[2] ? parseInt(m[2], 10) : 0),
  888. milliseconds: sign * ((m[3] ? parseInt(m[3], 10) : 0) * 60 * 60 * 1000 + // hours
  889. (m[4] ? parseInt(m[4], 10) : 0) * 60 * 1000 + // minutes
  890. (m[5] ? parseInt(m[5], 10) : 0) * 1000 + // seconds
  891. (m[6] ? parseInt(m[6], 10) : 0) // ms
  892. )
  893. };
  894. }
  895. return null;
  896. }
  897. function parseObject(obj) {
  898. var duration = {
  899. years: obj.years || obj.year || 0,
  900. months: obj.months || obj.month || 0,
  901. days: obj.days || obj.day || 0,
  902. milliseconds: (obj.hours || obj.hour || 0) * 60 * 60 * 1000 + // hours
  903. (obj.minutes || obj.minute || 0) * 60 * 1000 + // minutes
  904. (obj.seconds || obj.second || 0) * 1000 + // seconds
  905. (obj.milliseconds || obj.millisecond || obj.ms || 0) // ms
  906. };
  907. var weeks = obj.weeks || obj.week;
  908. if (weeks) {
  909. duration.days += weeks * 7;
  910. duration.specifiedWeeks = true;
  911. }
  912. return duration;
  913. }
  914. // Equality
  915. function durationsEqual(d0, d1) {
  916. return d0.years === d1.years &&
  917. d0.months === d1.months &&
  918. d0.days === d1.days &&
  919. d0.milliseconds === d1.milliseconds;
  920. }
  921. function isSingleDay(dur) {
  922. return dur.years === 0 && dur.months === 0 && dur.days === 1 && dur.milliseconds === 0;
  923. }
  924. // Simple Math
  925. function addDurations(d0, d1) {
  926. return {
  927. years: d0.years + d1.years,
  928. months: d0.months + d1.months,
  929. days: d0.days + d1.days,
  930. milliseconds: d0.milliseconds + d1.milliseconds
  931. };
  932. }
  933. function subtractDurations(d1, d0) {
  934. return {
  935. years: d1.years - d0.years,
  936. months: d1.months - d0.months,
  937. days: d1.days - d0.days,
  938. milliseconds: d1.milliseconds - d0.milliseconds
  939. };
  940. }
  941. function multiplyDuration(d, n) {
  942. return {
  943. years: d.years * n,
  944. months: d.months * n,
  945. days: d.days * n,
  946. milliseconds: d.milliseconds * n
  947. };
  948. }
  949. // Conversions
  950. // "Rough" because they are based on average-case Gregorian months/years
  951. function asRoughYears(dur) {
  952. return asRoughDays(dur) / 365;
  953. }
  954. function asRoughMonths(dur) {
  955. return asRoughDays(dur) / 30;
  956. }
  957. function asRoughDays(dur) {
  958. return asRoughMs(dur) / 864e5;
  959. }
  960. function asRoughMinutes(dur) {
  961. return asRoughMs(dur) / (1000 * 60);
  962. }
  963. function asRoughSeconds(dur) {
  964. return asRoughMs(dur) / 1000;
  965. }
  966. function asRoughMs(dur) {
  967. return dur.years * (365 * 864e5) +
  968. dur.months * (30 * 864e5) +
  969. dur.days * 864e5 +
  970. dur.milliseconds;
  971. }
  972. // Advanced Math
  973. function wholeDivideDurations(numerator, denominator) {
  974. var res = null;
  975. for (var i = 0; i < INTERNAL_UNITS.length; i++) {
  976. var unit = INTERNAL_UNITS[i];
  977. if (denominator[unit]) {
  978. var localRes = numerator[unit] / denominator[unit];
  979. if (!isInt(localRes) || (res !== null && res !== localRes)) {
  980. return null;
  981. }
  982. res = localRes;
  983. }
  984. else if (numerator[unit]) {
  985. // needs to divide by something but can't!
  986. return null;
  987. }
  988. }
  989. return res;
  990. }
  991. function greatestDurationDenominator(dur) {
  992. var ms = dur.milliseconds;
  993. if (ms) {
  994. if (ms % 1000 !== 0) {
  995. return { unit: 'millisecond', value: ms };
  996. }
  997. if (ms % (1000 * 60) !== 0) {
  998. return { unit: 'second', value: ms / 1000 };
  999. }
  1000. if (ms % (1000 * 60 * 60) !== 0) {
  1001. return { unit: 'minute', value: ms / (1000 * 60) };
  1002. }
  1003. if (ms) {
  1004. return { unit: 'hour', value: ms / (1000 * 60 * 60) };
  1005. }
  1006. }
  1007. if (dur.days) {
  1008. if (dur.specifiedWeeks && dur.days % 7 === 0) {
  1009. return { unit: 'week', value: dur.days / 7 };
  1010. }
  1011. return { unit: 'day', value: dur.days };
  1012. }
  1013. if (dur.months) {
  1014. return { unit: 'month', value: dur.months };
  1015. }
  1016. if (dur.years) {
  1017. return { unit: 'year', value: dur.years };
  1018. }
  1019. return { unit: 'millisecond', value: 0 };
  1020. }
  1021. // timeZoneOffset is in minutes
  1022. function buildIsoString(marker, timeZoneOffset, stripZeroTime) {
  1023. if (stripZeroTime === void 0) { stripZeroTime = false; }
  1024. var s = marker.toISOString();
  1025. s = s.replace('.000', '');
  1026. if (stripZeroTime) {
  1027. s = s.replace('T00:00:00Z', '');
  1028. }
  1029. if (s.length > 10) { // time part wasn't stripped, can add timezone info
  1030. if (timeZoneOffset == null) {
  1031. s = s.replace('Z', '');
  1032. }
  1033. else if (timeZoneOffset !== 0) {
  1034. s = s.replace('Z', formatTimeZoneOffset(timeZoneOffset, true));
  1035. }
  1036. // otherwise, its UTC-0 and we want to keep the Z
  1037. }
  1038. return s;
  1039. }
  1040. // formats the date, but with no time part
  1041. // TODO: somehow merge with buildIsoString and stripZeroTime
  1042. // TODO: rename. omit "string"
  1043. function formatDayString(marker) {
  1044. return marker.toISOString().replace(/T.*$/, '');
  1045. }
  1046. // TODO: use Date::toISOString and use everything after the T?
  1047. function formatIsoTimeString(marker) {
  1048. return padStart(marker.getUTCHours(), 2) + ':' +
  1049. padStart(marker.getUTCMinutes(), 2) + ':' +
  1050. padStart(marker.getUTCSeconds(), 2);
  1051. }
  1052. function formatTimeZoneOffset(minutes, doIso) {
  1053. if (doIso === void 0) { doIso = false; }
  1054. var sign = minutes < 0 ? '-' : '+';
  1055. var abs = Math.abs(minutes);
  1056. var hours = Math.floor(abs / 60);
  1057. var mins = Math.round(abs % 60);
  1058. if (doIso) {
  1059. return sign + padStart(hours, 2) + ':' + padStart(mins, 2);
  1060. }
  1061. else {
  1062. return 'GMT' + sign + hours + (mins ? ':' + padStart(mins, 2) : '');
  1063. }
  1064. }
  1065. function memoize(workerFunc, resEquality, teardownFunc) {
  1066. var currentArgs;
  1067. var currentRes;
  1068. return function () {
  1069. var newArgs = [];
  1070. for (var _i = 0; _i < arguments.length; _i++) {
  1071. newArgs[_i] = arguments[_i];
  1072. }
  1073. if (!currentArgs) {
  1074. currentRes = workerFunc.apply(this, newArgs);
  1075. }
  1076. else if (!isArraysEqual(currentArgs, newArgs)) {
  1077. if (teardownFunc) {
  1078. teardownFunc(currentRes);
  1079. }
  1080. var res = workerFunc.apply(this, newArgs);
  1081. if (!resEquality || !resEquality(res, currentRes)) {
  1082. currentRes = res;
  1083. }
  1084. }
  1085. currentArgs = newArgs;
  1086. return currentRes;
  1087. };
  1088. }
  1089. function memoizeObjArg(workerFunc, resEquality, teardownFunc) {
  1090. var currentArg;
  1091. var currentRes;
  1092. return function (newArg) {
  1093. if (!currentArg) {
  1094. currentRes = workerFunc.call(this, newArg);
  1095. }
  1096. else if (!isPropsEqual(currentArg, newArg)) {
  1097. if (teardownFunc) {
  1098. teardownFunc(currentRes);
  1099. }
  1100. var res = workerFunc.call(this, newArg);
  1101. if (!resEquality || !resEquality(res, currentRes)) {
  1102. currentRes = res;
  1103. }
  1104. }
  1105. currentArg = newArg;
  1106. return currentRes;
  1107. };
  1108. }
  1109. function memoizeArraylike(// used at all?
  1110. workerFunc, resEquality, teardownFunc) {
  1111. var currentArgSets = [];
  1112. var currentResults = [];
  1113. return function (newArgSets) {
  1114. var currentLen = currentArgSets.length;
  1115. var newLen = newArgSets.length;
  1116. var i = 0;
  1117. for (; i < currentLen; i++) {
  1118. if (!newArgSets[i]) { // one of the old sets no longer exists
  1119. if (teardownFunc) {
  1120. teardownFunc(currentResults[i]);
  1121. }
  1122. }
  1123. else if (!isArraysEqual(currentArgSets[i], newArgSets[i])) {
  1124. if (teardownFunc) {
  1125. teardownFunc(currentResults[i]);
  1126. }
  1127. var res = workerFunc.apply(this, newArgSets[i]);
  1128. if (!resEquality || !resEquality(res, currentResults[i])) {
  1129. currentResults[i] = res;
  1130. }
  1131. }
  1132. }
  1133. for (; i < newLen; i++) {
  1134. currentResults[i] = workerFunc.apply(this, newArgSets[i]);
  1135. }
  1136. currentArgSets = newArgSets;
  1137. currentResults.splice(newLen); // remove excess
  1138. return currentResults;
  1139. };
  1140. }
  1141. function memoizeHashlike(// used?
  1142. workerFunc, resEquality, teardownFunc // TODO: change arg order
  1143. ) {
  1144. var currentArgHash = {};
  1145. var currentResHash = {};
  1146. return function (newArgHash) {
  1147. var newResHash = {};
  1148. for (var key in newArgHash) {
  1149. if (!currentResHash[key]) {
  1150. newResHash[key] = workerFunc.apply(this, newArgHash[key]);
  1151. }
  1152. else if (!isArraysEqual(currentArgHash[key], newArgHash[key])) {
  1153. if (teardownFunc) {
  1154. teardownFunc(currentResHash[key]);
  1155. }
  1156. var res = workerFunc.apply(this, newArgHash[key]);
  1157. newResHash[key] = (resEquality && resEquality(res, currentResHash[key]))
  1158. ? currentResHash[key]
  1159. : res;
  1160. }
  1161. else {
  1162. newResHash[key] = currentResHash[key];
  1163. }
  1164. }
  1165. currentArgHash = newArgHash;
  1166. currentResHash = newResHash;
  1167. return newResHash;
  1168. };
  1169. }
  1170. var EXTENDED_SETTINGS_AND_SEVERITIES = {
  1171. week: 3,
  1172. separator: 0,
  1173. omitZeroMinute: 0,
  1174. meridiem: 0,
  1175. omitCommas: 0
  1176. };
  1177. var STANDARD_DATE_PROP_SEVERITIES = {
  1178. timeZoneName: 7,
  1179. era: 6,
  1180. year: 5,
  1181. month: 4,
  1182. day: 2,
  1183. weekday: 2,
  1184. hour: 1,
  1185. minute: 1,
  1186. second: 1
  1187. };
  1188. var MERIDIEM_RE = /\s*([ap])\.?m\.?/i; // eats up leading spaces too
  1189. var COMMA_RE = /,/g; // we need re for globalness
  1190. var MULTI_SPACE_RE = /\s+/g;
  1191. var LTR_RE = /\u200e/g; // control character
  1192. var UTC_RE = /UTC|GMT/;
  1193. var NativeFormatter = /** @class */ (function () {
  1194. function NativeFormatter(formatSettings) {
  1195. var standardDateProps = {};
  1196. var extendedSettings = {};
  1197. var severity = 0;
  1198. for (var name_1 in formatSettings) {
  1199. if (name_1 in EXTENDED_SETTINGS_AND_SEVERITIES) {
  1200. extendedSettings[name_1] = formatSettings[name_1];
  1201. severity = Math.max(EXTENDED_SETTINGS_AND_SEVERITIES[name_1], severity);
  1202. }
  1203. else {
  1204. standardDateProps[name_1] = formatSettings[name_1];
  1205. if (name_1 in STANDARD_DATE_PROP_SEVERITIES) { // TODO: what about hour12? no severity
  1206. severity = Math.max(STANDARD_DATE_PROP_SEVERITIES[name_1], severity);
  1207. }
  1208. }
  1209. }
  1210. this.standardDateProps = standardDateProps;
  1211. this.extendedSettings = extendedSettings;
  1212. this.severity = severity;
  1213. this.buildFormattingFunc = memoize(buildFormattingFunc);
  1214. }
  1215. NativeFormatter.prototype.format = function (date, context) {
  1216. return this.buildFormattingFunc(this.standardDateProps, this.extendedSettings, context)(date);
  1217. };
  1218. NativeFormatter.prototype.formatRange = function (start, end, context, betterDefaultSeparator) {
  1219. var _a = this, standardDateProps = _a.standardDateProps, extendedSettings = _a.extendedSettings;
  1220. var diffSeverity = computeMarkerDiffSeverity(start.marker, end.marker, context.calendarSystem);
  1221. if (!diffSeverity) {
  1222. return this.format(start, context);
  1223. }
  1224. var biggestUnitForPartial = diffSeverity;
  1225. if (biggestUnitForPartial > 1 && // the two dates are different in a way that's larger scale than time
  1226. (standardDateProps.year === 'numeric' || standardDateProps.year === '2-digit') &&
  1227. (standardDateProps.month === 'numeric' || standardDateProps.month === '2-digit') &&
  1228. (standardDateProps.day === 'numeric' || standardDateProps.day === '2-digit')) {
  1229. biggestUnitForPartial = 1; // make it look like the dates are only different in terms of time
  1230. }
  1231. var full0 = this.format(start, context);
  1232. var full1 = this.format(end, context);
  1233. if (full0 === full1) {
  1234. return full0;
  1235. }
  1236. var partialDateProps = computePartialFormattingOptions(standardDateProps, biggestUnitForPartial);
  1237. var partialFormattingFunc = buildFormattingFunc(partialDateProps, extendedSettings, context);
  1238. var partial0 = partialFormattingFunc(start);
  1239. var partial1 = partialFormattingFunc(end);
  1240. var insertion = findCommonInsertion(full0, partial0, full1, partial1);
  1241. var separator = extendedSettings.separator || betterDefaultSeparator || context.defaultSeparator || '';
  1242. if (insertion) {
  1243. return insertion.before + partial0 + separator + partial1 + insertion.after;
  1244. }
  1245. return full0 + separator + full1;
  1246. };
  1247. NativeFormatter.prototype.getLargestUnit = function () {
  1248. switch (this.severity) {
  1249. case 7:
  1250. case 6:
  1251. case 5:
  1252. return 'year';
  1253. case 4:
  1254. return 'month';
  1255. case 3:
  1256. return 'week';
  1257. case 2:
  1258. return 'day';
  1259. default:
  1260. return 'time'; // really?
  1261. }
  1262. };
  1263. return NativeFormatter;
  1264. }());
  1265. function buildFormattingFunc(standardDateProps, extendedSettings, context) {
  1266. var standardDatePropCnt = Object.keys(standardDateProps).length;
  1267. if (standardDatePropCnt === 1 && standardDateProps.timeZoneName === 'short') {
  1268. return function (date) {
  1269. return formatTimeZoneOffset(date.timeZoneOffset);
  1270. };
  1271. }
  1272. if (standardDatePropCnt === 0 && extendedSettings.week) {
  1273. return function (date) {
  1274. return formatWeekNumber(context.computeWeekNumber(date.marker), context.weekText, context.locale, extendedSettings.week);
  1275. };
  1276. }
  1277. return buildNativeFormattingFunc(standardDateProps, extendedSettings, context);
  1278. }
  1279. function buildNativeFormattingFunc(standardDateProps, extendedSettings, context) {
  1280. standardDateProps = __assign({}, standardDateProps); // copy
  1281. extendedSettings = __assign({}, extendedSettings); // copy
  1282. sanitizeSettings(standardDateProps, extendedSettings);
  1283. standardDateProps.timeZone = 'UTC'; // we leverage the only guaranteed timeZone for our UTC markers
  1284. var normalFormat = new Intl.DateTimeFormat(context.locale.codes, standardDateProps);
  1285. var zeroFormat; // needed?
  1286. if (extendedSettings.omitZeroMinute) {
  1287. var zeroProps = __assign({}, standardDateProps);
  1288. delete zeroProps.minute; // seconds and ms were already considered in sanitizeSettings
  1289. zeroFormat = new Intl.DateTimeFormat(context.locale.codes, zeroProps);
  1290. }
  1291. return function (date) {
  1292. var marker = date.marker;
  1293. var format;
  1294. if (zeroFormat && !marker.getUTCMinutes()) {
  1295. format = zeroFormat;
  1296. }
  1297. else {
  1298. format = normalFormat;
  1299. }
  1300. var s = format.format(marker);
  1301. return postProcess(s, date, standardDateProps, extendedSettings, context);
  1302. };
  1303. }
  1304. function sanitizeSettings(standardDateProps, extendedSettings) {
  1305. // deal with a browser inconsistency where formatting the timezone
  1306. // requires that the hour/minute be present.
  1307. if (standardDateProps.timeZoneName) {
  1308. if (!standardDateProps.hour) {
  1309. standardDateProps.hour = '2-digit';
  1310. }
  1311. if (!standardDateProps.minute) {
  1312. standardDateProps.minute = '2-digit';
  1313. }
  1314. }
  1315. // only support short timezone names
  1316. if (standardDateProps.timeZoneName === 'long') {
  1317. standardDateProps.timeZoneName = 'short';
  1318. }
  1319. // if requesting to display seconds, MUST display minutes
  1320. if (extendedSettings.omitZeroMinute && (standardDateProps.second || standardDateProps.millisecond)) {
  1321. delete extendedSettings.omitZeroMinute;
  1322. }
  1323. }
  1324. function postProcess(s, date, standardDateProps, extendedSettings, context) {
  1325. s = s.replace(LTR_RE, ''); // remove left-to-right control chars. do first. good for other regexes
  1326. if (standardDateProps.timeZoneName === 'short') {
  1327. s = injectTzoStr(s, (context.timeZone === 'UTC' || date.timeZoneOffset == null) ?
  1328. 'UTC' : // important to normalize for IE, which does "GMT"
  1329. formatTimeZoneOffset(date.timeZoneOffset));
  1330. }
  1331. if (extendedSettings.omitCommas) {
  1332. s = s.replace(COMMA_RE, '').trim();
  1333. }
  1334. if (extendedSettings.omitZeroMinute) {
  1335. s = s.replace(':00', ''); // zeroFormat doesn't always achieve this
  1336. }
  1337. // ^ do anything that might create adjacent spaces before this point,
  1338. // because MERIDIEM_RE likes to eat up loading spaces
  1339. if (extendedSettings.meridiem === false) {
  1340. s = s.replace(MERIDIEM_RE, '').trim();
  1341. }
  1342. else if (extendedSettings.meridiem === 'narrow') { // a/p
  1343. s = s.replace(MERIDIEM_RE, function (m0, m1) {
  1344. return m1.toLocaleLowerCase();
  1345. });
  1346. }
  1347. else if (extendedSettings.meridiem === 'short') { // am/pm
  1348. s = s.replace(MERIDIEM_RE, function (m0, m1) {
  1349. return m1.toLocaleLowerCase() + 'm';
  1350. });
  1351. }
  1352. else if (extendedSettings.meridiem === 'lowercase') { // other meridiem transformers already converted to lowercase
  1353. s = s.replace(MERIDIEM_RE, function (m0) {
  1354. return m0.toLocaleLowerCase();
  1355. });
  1356. }
  1357. s = s.replace(MULTI_SPACE_RE, ' ');
  1358. s = s.trim();
  1359. return s;
  1360. }
  1361. function injectTzoStr(s, tzoStr) {
  1362. var replaced = false;
  1363. s = s.replace(UTC_RE, function () {
  1364. replaced = true;
  1365. return tzoStr;
  1366. });
  1367. // IE11 doesn't include UTC/GMT in the original string, so append to end
  1368. if (!replaced) {
  1369. s += ' ' + tzoStr;
  1370. }
  1371. return s;
  1372. }
  1373. function formatWeekNumber(num, weekText, locale, display) {
  1374. var parts = [];
  1375. if (display === 'narrow') {
  1376. parts.push(weekText);
  1377. }
  1378. else if (display === 'short') {
  1379. parts.push(weekText, ' ');
  1380. }
  1381. // otherwise, considered 'numeric'
  1382. parts.push(locale.simpleNumberFormat.format(num));
  1383. if (locale.options.direction === 'rtl') { // TODO: use control characters instead?
  1384. parts.reverse();
  1385. }
  1386. return parts.join('');
  1387. }
  1388. // Range Formatting Utils
  1389. // 0 = exactly the same
  1390. // 1 = different by time
  1391. // and bigger
  1392. function computeMarkerDiffSeverity(d0, d1, ca) {
  1393. if (ca.getMarkerYear(d0) !== ca.getMarkerYear(d1)) {
  1394. return 5;
  1395. }
  1396. if (ca.getMarkerMonth(d0) !== ca.getMarkerMonth(d1)) {
  1397. return 4;
  1398. }
  1399. if (ca.getMarkerDay(d0) !== ca.getMarkerDay(d1)) {
  1400. return 2;
  1401. }
  1402. if (timeAsMs(d0) !== timeAsMs(d1)) {
  1403. return 1;
  1404. }
  1405. return 0;
  1406. }
  1407. function computePartialFormattingOptions(options, biggestUnit) {
  1408. var partialOptions = {};
  1409. for (var name_2 in options) {
  1410. if (!(name_2 in STANDARD_DATE_PROP_SEVERITIES) || // not a date part prop (like timeZone)
  1411. STANDARD_DATE_PROP_SEVERITIES[name_2] <= biggestUnit) {
  1412. partialOptions[name_2] = options[name_2];
  1413. }
  1414. }
  1415. return partialOptions;
  1416. }
  1417. function findCommonInsertion(full0, partial0, full1, partial1) {
  1418. var i0 = 0;
  1419. while (i0 < full0.length) {
  1420. var found0 = full0.indexOf(partial0, i0);
  1421. if (found0 === -1) {
  1422. break;
  1423. }
  1424. var before0 = full0.substr(0, found0);
  1425. i0 = found0 + partial0.length;
  1426. var after0 = full0.substr(i0);
  1427. var i1 = 0;
  1428. while (i1 < full1.length) {
  1429. var found1 = full1.indexOf(partial1, i1);
  1430. if (found1 === -1) {
  1431. break;
  1432. }
  1433. var before1 = full1.substr(0, found1);
  1434. i1 = found1 + partial1.length;
  1435. var after1 = full1.substr(i1);
  1436. if (before0 === before1 && after0 === after1) {
  1437. return {
  1438. before: before0,
  1439. after: after0
  1440. };
  1441. }
  1442. }
  1443. }
  1444. return null;
  1445. }
  1446. function expandZonedMarker(dateInfo, calendarSystem) {
  1447. var a = calendarSystem.markerToArray(dateInfo.marker);
  1448. return {
  1449. marker: dateInfo.marker,
  1450. timeZoneOffset: dateInfo.timeZoneOffset,
  1451. array: a,
  1452. year: a[0],
  1453. month: a[1],
  1454. day: a[2],
  1455. hour: a[3],
  1456. minute: a[4],
  1457. second: a[5],
  1458. millisecond: a[6]
  1459. };
  1460. }
  1461. function createVerboseFormattingArg(start, end, context, betterDefaultSeparator) {
  1462. var startInfo = expandZonedMarker(start, context.calendarSystem);
  1463. var endInfo = end ? expandZonedMarker(end, context.calendarSystem) : null;
  1464. return {
  1465. date: startInfo,
  1466. start: startInfo,
  1467. end: endInfo,
  1468. timeZone: context.timeZone,
  1469. localeCodes: context.locale.codes,
  1470. defaultSeparator: betterDefaultSeparator || context.defaultSeparator
  1471. };
  1472. }
  1473. /*
  1474. TODO: fix the terminology of "formatter" vs "formatting func"
  1475. */
  1476. /*
  1477. At the time of instantiation, this object does not know which cmd-formatting system it will use.
  1478. It receives this at the time of formatting, as a setting.
  1479. */
  1480. var CmdFormatter = /** @class */ (function () {
  1481. function CmdFormatter(cmdStr) {
  1482. this.cmdStr = cmdStr;
  1483. }
  1484. CmdFormatter.prototype.format = function (date, context, betterDefaultSeparator) {
  1485. return context.cmdFormatter(this.cmdStr, createVerboseFormattingArg(date, null, context, betterDefaultSeparator));
  1486. };
  1487. CmdFormatter.prototype.formatRange = function (start, end, context, betterDefaultSeparator) {
  1488. return context.cmdFormatter(this.cmdStr, createVerboseFormattingArg(start, end, context, betterDefaultSeparator));
  1489. };
  1490. return CmdFormatter;
  1491. }());
  1492. var FuncFormatter = /** @class */ (function () {
  1493. function FuncFormatter(func) {
  1494. this.func = func;
  1495. }
  1496. FuncFormatter.prototype.format = function (date, context, betterDefaultSeparator) {
  1497. return this.func(createVerboseFormattingArg(date, null, context, betterDefaultSeparator));
  1498. };
  1499. FuncFormatter.prototype.formatRange = function (start, end, context, betterDefaultSeparator) {
  1500. return this.func(createVerboseFormattingArg(start, end, context, betterDefaultSeparator));
  1501. };
  1502. return FuncFormatter;
  1503. }());
  1504. function createFormatter(input) {
  1505. if (typeof input === 'object' && input) { // non-null object
  1506. return new NativeFormatter(input);
  1507. }
  1508. else if (typeof input === 'string') {
  1509. return new CmdFormatter(input);
  1510. }
  1511. else if (typeof input === 'function') {
  1512. return new FuncFormatter(input);
  1513. }
  1514. }
  1515. // base options
  1516. // ------------
  1517. var BASE_OPTION_REFINERS = {
  1518. navLinkDayClick: identity,
  1519. navLinkWeekClick: identity,
  1520. duration: createDuration,
  1521. bootstrapFontAwesome: identity,
  1522. buttonIcons: identity,
  1523. customButtons: identity,
  1524. defaultAllDayEventDuration: createDuration,
  1525. defaultTimedEventDuration: createDuration,
  1526. nextDayThreshold: createDuration,
  1527. scrollTime: createDuration,
  1528. slotMinTime: createDuration,
  1529. slotMaxTime: createDuration,
  1530. dayPopoverFormat: createFormatter,
  1531. slotDuration: createDuration,
  1532. snapDuration: createDuration,
  1533. headerToolbar: identity,
  1534. footerToolbar: identity,
  1535. defaultRangeSeparator: String,
  1536. titleRangeSeparator: String,
  1537. forceEventDuration: Boolean,
  1538. dayHeaders: Boolean,
  1539. dayHeaderFormat: createFormatter,
  1540. dayHeaderClassNames: identity,
  1541. dayHeaderContent: identity,
  1542. dayHeaderDidMount: identity,
  1543. dayHeaderWillUnmount: identity,
  1544. dayCellClassNames: identity,
  1545. dayCellContent: identity,
  1546. dayCellDidMount: identity,
  1547. dayCellWillUnmount: identity,
  1548. initialView: String,
  1549. aspectRatio: Number,
  1550. weekends: Boolean,
  1551. weekNumberCalculation: identity,
  1552. weekNumbers: Boolean,
  1553. weekNumberClassNames: identity,
  1554. weekNumberContent: identity,
  1555. weekNumberDidMount: identity,
  1556. weekNumberWillUnmount: identity,
  1557. editable: Boolean,
  1558. viewClassNames: identity,
  1559. viewDidMount: identity,
  1560. viewWillUnmount: identity,
  1561. nowIndicator: Boolean,
  1562. nowIndicatorClassNames: identity,
  1563. nowIndicatorContent: identity,
  1564. nowIndicatorDidMount: identity,
  1565. nowIndicatorWillUnmount: identity,
  1566. showNonCurrentDates: Boolean,
  1567. lazyFetching: Boolean,
  1568. startParam: String,
  1569. endParam: String,
  1570. timeZoneParam: String,
  1571. timeZone: String,
  1572. locales: identity,
  1573. locale: identity,
  1574. themeSystem: String,
  1575. dragRevertDuration: Number,
  1576. dragScroll: Boolean,
  1577. allDayMaintainDuration: Boolean,
  1578. unselectAuto: Boolean,
  1579. dropAccept: identity,
  1580. eventOrder: parseFieldSpecs,
  1581. handleWindowResize: Boolean,
  1582. windowResizeDelay: Number,
  1583. longPressDelay: Number,
  1584. eventDragMinDistance: Number,
  1585. expandRows: Boolean,
  1586. height: identity,
  1587. contentHeight: identity,
  1588. direction: String,
  1589. weekNumberFormat: createFormatter,
  1590. eventResizableFromStart: Boolean,
  1591. displayEventTime: Boolean,
  1592. displayEventEnd: Boolean,
  1593. weekText: String,
  1594. progressiveEventRendering: Boolean,
  1595. businessHours: identity,
  1596. initialDate: identity,
  1597. now: identity,
  1598. eventDataTransform: identity,
  1599. stickyHeaderDates: identity,
  1600. stickyFooterScrollbar: identity,
  1601. viewHeight: identity,
  1602. defaultAllDay: Boolean,
  1603. eventSourceFailure: identity,
  1604. eventSourceSuccess: identity,
  1605. eventDisplay: String,
  1606. eventStartEditable: Boolean,
  1607. eventDurationEditable: Boolean,
  1608. eventOverlap: identity,
  1609. eventConstraint: identity,
  1610. eventAllow: identity,
  1611. eventBackgroundColor: String,
  1612. eventBorderColor: String,
  1613. eventTextColor: String,
  1614. eventColor: String,
  1615. eventClassNames: identity,
  1616. eventContent: identity,
  1617. eventDidMount: identity,
  1618. eventWillUnmount: identity,
  1619. selectConstraint: identity,
  1620. selectOverlap: identity,
  1621. selectAllow: identity,
  1622. droppable: Boolean,
  1623. unselectCancel: String,
  1624. slotLabelFormat: identity,
  1625. slotLaneClassNames: identity,
  1626. slotLaneContent: identity,
  1627. slotLaneDidMount: identity,
  1628. slotLaneWillUnmount: identity,
  1629. slotLabelClassNames: identity,
  1630. slotLabelContent: identity,
  1631. slotLabelDidMount: identity,
  1632. slotLabelWillUnmount: identity,
  1633. dayMaxEvents: identity,
  1634. dayMaxEventRows: identity,
  1635. dayMinWidth: Number,
  1636. slotLabelInterval: createDuration,
  1637. allDayText: String,
  1638. allDayClassNames: identity,
  1639. allDayContent: identity,
  1640. allDayDidMount: identity,
  1641. allDayWillUnmount: identity,
  1642. slotMinWidth: Number,
  1643. navLinks: Boolean,
  1644. eventTimeFormat: createFormatter,
  1645. rerenderDelay: Number,
  1646. moreLinkText: identity,
  1647. selectMinDistance: Number,
  1648. selectable: Boolean,
  1649. selectLongPressDelay: Number,
  1650. eventLongPressDelay: Number,
  1651. selectMirror: Boolean,
  1652. eventMinHeight: Number,
  1653. slotEventOverlap: Boolean,
  1654. plugins: identity,
  1655. firstDay: Number,
  1656. dayCount: Number,
  1657. dateAlignment: String,
  1658. dateIncrement: createDuration,
  1659. hiddenDays: identity,
  1660. monthMode: Boolean,
  1661. fixedWeekCount: Boolean,
  1662. validRange: identity,
  1663. visibleRange: identity,
  1664. titleFormat: identity,
  1665. // only used by list-view, but languages define the value, so we need it in base options
  1666. noEventsText: String
  1667. };
  1668. // do NOT give a type here. need `typeof BASE_OPTION_DEFAULTS` to give real results.
  1669. // raw values.
  1670. var BASE_OPTION_DEFAULTS = {
  1671. eventDisplay: 'auto',
  1672. defaultRangeSeparator: ' - ',
  1673. titleRangeSeparator: ' \u2013 ',
  1674. defaultTimedEventDuration: '01:00:00',
  1675. defaultAllDayEventDuration: { day: 1 },
  1676. forceEventDuration: false,
  1677. nextDayThreshold: '00:00:00',
  1678. dayHeaders: true,
  1679. initialView: '',
  1680. aspectRatio: 1.35,
  1681. headerToolbar: {
  1682. start: 'title',
  1683. center: '',
  1684. end: 'today prev,next'
  1685. },
  1686. weekends: true,
  1687. weekNumbers: false,
  1688. weekNumberCalculation: 'local',
  1689. editable: false,
  1690. nowIndicator: false,
  1691. scrollTime: '06:00:00',
  1692. slotMinTime: '00:00:00',
  1693. slotMaxTime: '24:00:00',
  1694. showNonCurrentDates: true,
  1695. lazyFetching: true,
  1696. startParam: 'start',
  1697. endParam: 'end',
  1698. timeZoneParam: 'timeZone',
  1699. timeZone: 'local',
  1700. locales: [],
  1701. locale: '',
  1702. themeSystem: 'standard',
  1703. dragRevertDuration: 500,
  1704. dragScroll: true,
  1705. allDayMaintainDuration: false,
  1706. unselectAuto: true,
  1707. dropAccept: '*',
  1708. eventOrder: 'start,-duration,allDay,title',
  1709. dayPopoverFormat: { month: 'long', day: 'numeric', year: 'numeric' },
  1710. handleWindowResize: true,
  1711. windowResizeDelay: 100,
  1712. longPressDelay: 1000,
  1713. eventDragMinDistance: 5,
  1714. expandRows: false,
  1715. navLinks: false,
  1716. selectable: false
  1717. };
  1718. // calendar listeners
  1719. // ------------------
  1720. var CALENDAR_LISTENER_REFINERS = {
  1721. datesSet: identity,
  1722. eventsSet: identity,
  1723. eventAdd: identity,
  1724. eventChange: identity,
  1725. eventRemove: identity,
  1726. windowResize: identity,
  1727. eventClick: identity,
  1728. eventMouseEnter: identity,
  1729. eventMouseLeave: identity,
  1730. select: identity,
  1731. unselect: identity,
  1732. loading: identity,
  1733. // internal
  1734. _unmount: identity,
  1735. _beforeprint: identity,
  1736. _afterprint: identity,
  1737. _noEventDrop: identity,
  1738. _noEventResize: identity,
  1739. _resize: identity,
  1740. _scrollRequest: identity
  1741. };
  1742. // calendar-specific options
  1743. // -------------------------
  1744. var CALENDAR_OPTION_REFINERS = {
  1745. buttonText: identity,
  1746. views: identity,
  1747. plugins: identity,
  1748. initialEvents: identity,
  1749. events: identity,
  1750. eventSources: identity
  1751. };
  1752. var COMPLEX_OPTION_COMPARATORS = {
  1753. headerToolbar: isBoolComplexEqual,
  1754. footerToolbar: isBoolComplexEqual,
  1755. buttonText: isBoolComplexEqual,
  1756. buttonIcons: isBoolComplexEqual
  1757. };
  1758. function isBoolComplexEqual(a, b) {
  1759. if (typeof a === 'object' && typeof b === 'object' && a && b) { // both non-null objects
  1760. return isPropsEqual(a, b);
  1761. }
  1762. else {
  1763. return a === b;
  1764. }
  1765. }
  1766. // view-specific options
  1767. // ---------------------
  1768. var VIEW_OPTION_REFINERS = {
  1769. type: String,
  1770. component: identity,
  1771. buttonText: String,
  1772. buttonTextKey: String,
  1773. dateProfileGeneratorClass: identity,
  1774. usesMinMaxTime: Boolean,
  1775. classNames: identity,
  1776. content: identity,
  1777. didMount: identity,
  1778. willUnmount: identity
  1779. };
  1780. // util funcs
  1781. // ----------------------------------------------------------------------------------------------------
  1782. function mergeRawOptions(optionSets) {
  1783. return mergeProps(optionSets, COMPLEX_OPTION_COMPARATORS);
  1784. }
  1785. function refineProps(input, refiners) {
  1786. var refined = {};
  1787. var extra = {};
  1788. for (var propName in refiners) {
  1789. if (propName in input) {
  1790. refined[propName] = refiners[propName](input[propName]);
  1791. }
  1792. }
  1793. for (var propName in input) {
  1794. if (!(propName in refiners)) {
  1795. extra[propName] = input[propName];
  1796. }
  1797. }
  1798. return { refined: refined, extra: extra };
  1799. }
  1800. function identity(raw) {
  1801. return raw;
  1802. }
  1803. function parseEvents(rawEvents, eventSource, context, allowOpenRange) {
  1804. var eventStore = createEmptyEventStore();
  1805. var eventRefiners = buildEventRefiners(context);
  1806. for (var _i = 0, rawEvents_1 = rawEvents; _i < rawEvents_1.length; _i++) {
  1807. var rawEvent = rawEvents_1[_i];
  1808. var tuple = parseEvent(rawEvent, eventSource, context, allowOpenRange, eventRefiners);
  1809. if (tuple) {
  1810. eventTupleToStore(tuple, eventStore);
  1811. }
  1812. }
  1813. return eventStore;
  1814. }
  1815. function eventTupleToStore(tuple, eventStore) {
  1816. if (eventStore === void 0) { eventStore = createEmptyEventStore(); }
  1817. eventStore.defs[tuple.def.defId] = tuple.def;
  1818. if (tuple.instance) {
  1819. eventStore.instances[tuple.instance.instanceId] = tuple.instance;
  1820. }
  1821. return eventStore;
  1822. }
  1823. // retrieves events that have the same groupId as the instance specified by `instanceId`
  1824. // or they are the same as the instance.
  1825. // why might instanceId not be in the store? an event from another calendar?
  1826. function getRelevantEvents(eventStore, instanceId) {
  1827. var instance = eventStore.instances[instanceId];
  1828. if (instance) {
  1829. var def_1 = eventStore.defs[instance.defId];
  1830. // get events/instances with same group
  1831. var newStore = filterEventStoreDefs(eventStore, function (lookDef) {
  1832. return isEventDefsGrouped(def_1, lookDef);
  1833. });
  1834. // add the original
  1835. // TODO: wish we could use eventTupleToStore or something like it
  1836. newStore.defs[def_1.defId] = def_1;
  1837. newStore.instances[instance.instanceId] = instance;
  1838. return newStore;
  1839. }
  1840. return createEmptyEventStore();
  1841. }
  1842. function isEventDefsGrouped(def0, def1) {
  1843. return Boolean(def0.groupId && def0.groupId === def1.groupId);
  1844. }
  1845. function createEmptyEventStore() {
  1846. return { defs: {}, instances: {} };
  1847. }
  1848. function mergeEventStores(store0, store1) {
  1849. return {
  1850. defs: __assign(__assign({}, store0.defs), store1.defs),
  1851. instances: __assign(__assign({}, store0.instances), store1.instances)
  1852. };
  1853. }
  1854. function filterEventStoreDefs(eventStore, filterFunc) {
  1855. var defs = filterHash(eventStore.defs, filterFunc);
  1856. var instances = filterHash(eventStore.instances, function (instance) {
  1857. return defs[instance.defId]; // still exists?
  1858. });
  1859. return { defs: defs, instances: instances };
  1860. }
  1861. function excludeSubEventStore(master, sub) {
  1862. var defs = master.defs, instances = master.instances;
  1863. var filteredDefs = {};
  1864. var filteredInstances = {};
  1865. for (var defId in defs) {
  1866. if (!sub.defs[defId]) { // not explicitly excluded
  1867. filteredDefs[defId] = defs[defId];
  1868. }
  1869. }
  1870. for (var instanceId in instances) {
  1871. if (!sub.instances[instanceId] && // not explicitly excluded
  1872. filteredDefs[instances[instanceId].defId] // def wasn't filtered away
  1873. ) {
  1874. filteredInstances[instanceId] = instances[instanceId];
  1875. }
  1876. }
  1877. return {
  1878. defs: filteredDefs,
  1879. instances: filteredInstances
  1880. };
  1881. }
  1882. function normalizeConstraint(input, context) {
  1883. if (Array.isArray(input)) {
  1884. return parseEvents(input, null, context, true); // allowOpenRange=true
  1885. }
  1886. else if (typeof input === 'object' && input) { // non-null object
  1887. return parseEvents([input], null, context, true); // allowOpenRange=true
  1888. }
  1889. else if (input != null) {
  1890. return String(input);
  1891. }
  1892. else {
  1893. return null;
  1894. }
  1895. }
  1896. function parseClassNames(raw) {
  1897. if (Array.isArray(raw)) {
  1898. return raw;
  1899. }
  1900. else if (typeof raw === 'string') {
  1901. return raw.split(/\s+/);
  1902. }
  1903. else {
  1904. return [];
  1905. }
  1906. }
  1907. // TODO: better called "EventSettings" or "EventConfig"
  1908. // TODO: move this file into structs
  1909. // TODO: separate constraint/overlap/allow, because selection uses only that, not other props
  1910. var EVENT_UI_REFINERS = {
  1911. display: String,
  1912. editable: Boolean,
  1913. startEditable: Boolean,
  1914. durationEditable: Boolean,
  1915. constraint: identity,
  1916. overlap: identity,
  1917. allow: identity,
  1918. className: parseClassNames,
  1919. classNames: parseClassNames,
  1920. color: String,
  1921. backgroundColor: String,
  1922. borderColor: String,
  1923. textColor: String
  1924. };
  1925. function createEventUi(refined, context) {
  1926. var constraint = normalizeConstraint(refined.constraint, context);
  1927. return {
  1928. display: refined.display || null,
  1929. startEditable: refined.startEditable != null ? refined.startEditable : refined.editable,
  1930. durationEditable: refined.durationEditable != null ? refined.durationEditable : refined.editable,
  1931. constraints: constraint != null ? [constraint] : [],
  1932. overlap: refined.overlap != null ? refined.overlap : null,
  1933. allows: refined.allow != null ? [refined.allow] : [],
  1934. backgroundColor: refined.backgroundColor || refined.color || '',
  1935. borderColor: refined.borderColor || refined.color || '',
  1936. textColor: refined.textColor || '',
  1937. classNames: (refined.className || []).concat(refined.classNames || []) // join singular and plural
  1938. };
  1939. }
  1940. // TODO: prevent against problems with <2 args!
  1941. function combineEventUis(uis) {
  1942. return uis.reduce(combineTwoEventUis, EMPTY_EVENT_UI);
  1943. }
  1944. function combineTwoEventUis(item0, item1) {
  1945. return {
  1946. display: item1.display != null ? item1.display : item0.display,
  1947. startEditable: item1.startEditable != null ? item1.startEditable : item0.startEditable,
  1948. durationEditable: item1.durationEditable != null ? item1.durationEditable : item0.durationEditable,
  1949. constraints: item0.constraints.concat(item1.constraints),
  1950. overlap: typeof item1.overlap === 'boolean' ? item1.overlap : item0.overlap,
  1951. allows: item0.allows.concat(item1.allows),
  1952. backgroundColor: item1.backgroundColor || item0.backgroundColor,
  1953. borderColor: item1.borderColor || item0.borderColor,
  1954. textColor: item1.textColor || item0.textColor,
  1955. classNames: item0.classNames.concat(item1.classNames)
  1956. };
  1957. }
  1958. var EMPTY_EVENT_UI = {
  1959. display: null,
  1960. startEditable: null,
  1961. durationEditable: null,
  1962. constraints: [],
  1963. overlap: null,
  1964. allows: [],
  1965. backgroundColor: '',
  1966. borderColor: '',
  1967. textColor: '',
  1968. classNames: []
  1969. };
  1970. var EVENT_NON_DATE_REFINERS = {
  1971. id: String,
  1972. groupId: String,
  1973. title: String,
  1974. url: String
  1975. };
  1976. var EVENT_DATE_REFINERS = {
  1977. start: identity,
  1978. end: identity,
  1979. date: identity,
  1980. allDay: Boolean
  1981. };
  1982. var EVENT_REFINERS = __assign(__assign(__assign({}, EVENT_NON_DATE_REFINERS), EVENT_DATE_REFINERS), { extendedProps: identity });
  1983. function parseEvent(raw, eventSource, context, allowOpenRange, refiners) {
  1984. if (refiners === void 0) { refiners = buildEventRefiners(context); }
  1985. var _a = refineEventDef(raw, context, refiners), refined = _a.refined, extra = _a.extra;
  1986. var defaultAllDay = computeIsDefaultAllDay(eventSource, context);
  1987. var recurringRes = parseRecurring(refined, defaultAllDay, context.dateEnv, context.pluginHooks.recurringTypes);
  1988. if (recurringRes) {
  1989. var def = parseEventDef(refined, extra, eventSource ? eventSource.sourceId : '', recurringRes.allDay, Boolean(recurringRes.duration), context);
  1990. def.recurringDef = {
  1991. typeId: recurringRes.typeId,
  1992. typeData: recurringRes.typeData,
  1993. duration: recurringRes.duration
  1994. };
  1995. return { def: def, instance: null };
  1996. }
  1997. else {
  1998. var singleRes = parseSingle(refined, defaultAllDay, context, allowOpenRange);
  1999. if (singleRes) {
  2000. var def = parseEventDef(refined, extra, eventSource ? eventSource.sourceId : '', singleRes.allDay, singleRes.hasEnd, context);
  2001. var instance = createEventInstance(def.defId, singleRes.range, singleRes.forcedStartTzo, singleRes.forcedEndTzo);
  2002. return { def: def, instance: instance };
  2003. }
  2004. }
  2005. return null;
  2006. }
  2007. function refineEventDef(raw, context, refiners) {
  2008. if (refiners === void 0) { refiners = buildEventRefiners(context); }
  2009. return refineProps(raw, refiners);
  2010. }
  2011. function buildEventRefiners(context) {
  2012. return __assign(__assign(__assign({}, EVENT_UI_REFINERS), EVENT_REFINERS), context.pluginHooks.eventRefiners);
  2013. }
  2014. /*
  2015. Will NOT populate extendedProps with the leftover properties.
  2016. Will NOT populate date-related props.
  2017. */
  2018. function parseEventDef(refined, extra, sourceId, allDay, hasEnd, context) {
  2019. var def = {
  2020. title: refined.title || '',
  2021. groupId: refined.groupId || '',
  2022. publicId: refined.id || '',
  2023. url: refined.url || '',
  2024. recurringDef: null,
  2025. defId: guid(),
  2026. sourceId: sourceId,
  2027. allDay: allDay,
  2028. hasEnd: hasEnd,
  2029. ui: createEventUi(refined, context),
  2030. extendedProps: __assign(__assign({}, (refined.extendedProps || {})), extra)
  2031. };
  2032. for (var _i = 0, _a = context.pluginHooks.eventDefMemberAdders; _i < _a.length; _i++) {
  2033. var memberAdder = _a[_i];
  2034. __assign(def, memberAdder(refined));
  2035. }
  2036. // help out EventApi from having user modify props
  2037. Object.freeze(def.ui.classNames);
  2038. Object.freeze(def.extendedProps);
  2039. return def;
  2040. }
  2041. function parseSingle(refined, defaultAllDay, context, allowOpenRange) {
  2042. var allDay = refined.allDay;
  2043. var startMeta;
  2044. var startMarker = null;
  2045. var hasEnd = false;
  2046. var endMeta;
  2047. var endMarker = null;
  2048. var startInput = refined.start != null ? refined.start : refined.date;
  2049. startMeta = context.dateEnv.createMarkerMeta(startInput);
  2050. if (startMeta) {
  2051. startMarker = startMeta.marker;
  2052. }
  2053. else if (!allowOpenRange) {
  2054. return null;
  2055. }
  2056. if (refined.end != null) {
  2057. endMeta = context.dateEnv.createMarkerMeta(refined.end);
  2058. }
  2059. if (allDay == null) {
  2060. if (defaultAllDay != null) {
  2061. allDay = defaultAllDay;
  2062. }
  2063. else {
  2064. // fall back to the date props LAST
  2065. allDay = (!startMeta || startMeta.isTimeUnspecified) &&
  2066. (!endMeta || endMeta.isTimeUnspecified);
  2067. }
  2068. }
  2069. if (allDay && startMarker) {
  2070. startMarker = startOfDay(startMarker);
  2071. }
  2072. if (endMeta) {
  2073. endMarker = endMeta.marker;
  2074. if (allDay) {
  2075. endMarker = startOfDay(endMarker);
  2076. }
  2077. if (startMarker && endMarker <= startMarker) {
  2078. endMarker = null;
  2079. }
  2080. }
  2081. if (endMarker) {
  2082. hasEnd = true;
  2083. }
  2084. else if (!allowOpenRange) {
  2085. hasEnd = context.options.forceEventDuration || false;
  2086. endMarker = context.dateEnv.add(startMarker, allDay ?
  2087. context.options.defaultAllDayEventDuration :
  2088. context.options.defaultTimedEventDuration);
  2089. }
  2090. return {
  2091. allDay: allDay,
  2092. hasEnd: hasEnd,
  2093. range: { start: startMarker, end: endMarker },
  2094. forcedStartTzo: startMeta ? startMeta.forcedTzo : null,
  2095. forcedEndTzo: endMeta ? endMeta.forcedTzo : null
  2096. };
  2097. }
  2098. function computeIsDefaultAllDay(eventSource, context) {
  2099. var res = null;
  2100. if (eventSource) {
  2101. res = eventSource.defaultAllDay;
  2102. }
  2103. if (res == null) {
  2104. res = context.options.defaultAllDay;
  2105. }
  2106. return res;
  2107. }
  2108. /* Date stuff that doesn't belong in datelib core
  2109. ----------------------------------------------------------------------------------------------------------------------*/
  2110. // given a timed range, computes an all-day range that has the same exact duration,
  2111. // but whose start time is aligned with the start of the day.
  2112. function computeAlignedDayRange(timedRange) {
  2113. var dayCnt = Math.floor(diffDays(timedRange.start, timedRange.end)) || 1;
  2114. var start = startOfDay(timedRange.start);
  2115. var end = addDays(start, dayCnt);
  2116. return { start: start, end: end };
  2117. }
  2118. // given a timed range, computes an all-day range based on how for the end date bleeds into the next day
  2119. // TODO: give nextDayThreshold a default arg
  2120. function computeVisibleDayRange(timedRange, nextDayThreshold) {
  2121. if (nextDayThreshold === void 0) { nextDayThreshold = createDuration(0); }
  2122. var startDay = null;
  2123. var endDay = null;
  2124. if (timedRange.end) {
  2125. endDay = startOfDay(timedRange.end);
  2126. var endTimeMS = timedRange.end.valueOf() - endDay.valueOf(); // # of milliseconds into `endDay`
  2127. // If the end time is actually inclusively part of the next day and is equal to or
  2128. // beyond the next day threshold, adjust the end to be the exclusive end of `endDay`.
  2129. // Otherwise, leaving it as inclusive will cause it to exclude `endDay`.
  2130. if (endTimeMS && endTimeMS >= asRoughMs(nextDayThreshold)) {
  2131. endDay = addDays(endDay, 1);
  2132. }
  2133. }
  2134. if (timedRange.start) {
  2135. startDay = startOfDay(timedRange.start); // the beginning of the day the range starts
  2136. // If end is within `startDay` but not past nextDayThreshold, assign the default duration of one day.
  2137. if (endDay && endDay <= startDay) {
  2138. endDay = addDays(startDay, 1);
  2139. }
  2140. }
  2141. return { start: startDay, end: endDay };
  2142. }
  2143. // spans from one day into another?
  2144. function isMultiDayRange(range) {
  2145. var visibleRange = computeVisibleDayRange(range);
  2146. return diffDays(visibleRange.start, visibleRange.end) > 1;
  2147. }
  2148. function diffDates(date0, date1, dateEnv, largeUnit) {
  2149. if (largeUnit === 'year') {
  2150. return createDuration(dateEnv.diffWholeYears(date0, date1), 'year');
  2151. }
  2152. else if (largeUnit === 'month') {
  2153. return createDuration(dateEnv.diffWholeMonths(date0, date1), 'month');
  2154. }
  2155. else {
  2156. return diffDayAndTime(date0, date1); // returns a duration
  2157. }
  2158. }
  2159. function parseRange(input, dateEnv) {
  2160. var start = null;
  2161. var end = null;
  2162. if (input.start) {
  2163. start = dateEnv.createMarker(input.start);
  2164. }
  2165. if (input.end) {
  2166. end = dateEnv.createMarker(input.end);
  2167. }
  2168. if (!start && !end) {
  2169. return null;
  2170. }
  2171. if (start && end && end < start) {
  2172. return null;
  2173. }
  2174. return { start: start, end: end };
  2175. }
  2176. // SIDE-EFFECT: will mutate ranges.
  2177. // Will return a new array result.
  2178. function invertRanges(ranges, constraintRange) {
  2179. var invertedRanges = [];
  2180. var start = constraintRange.start; // the end of the previous range. the start of the new range
  2181. var i;
  2182. var dateRange;
  2183. // ranges need to be in order. required for our date-walking algorithm
  2184. ranges.sort(compareRanges);
  2185. for (i = 0; i < ranges.length; i++) {
  2186. dateRange = ranges[i];
  2187. // add the span of time before the event (if there is any)
  2188. if (dateRange.start > start) { // compare millisecond time (skip any ambig logic)
  2189. invertedRanges.push({ start: start, end: dateRange.start });
  2190. }
  2191. if (dateRange.end > start) {
  2192. start = dateRange.end;
  2193. }
  2194. }
  2195. // add the span of time after the last event (if there is any)
  2196. if (start < constraintRange.end) { // compare millisecond time (skip any ambig logic)
  2197. invertedRanges.push({ start: start, end: constraintRange.end });
  2198. }
  2199. return invertedRanges;
  2200. }
  2201. function compareRanges(range0, range1) {
  2202. return range0.start.valueOf() - range1.start.valueOf(); // earlier ranges go first
  2203. }
  2204. function intersectRanges(range0, range1) {
  2205. var start = range0.start;
  2206. var end = range0.end;
  2207. var newRange = null;
  2208. if (range1.start !== null) {
  2209. if (start === null) {
  2210. start = range1.start;
  2211. }
  2212. else {
  2213. start = new Date(Math.max(start.valueOf(), range1.start.valueOf()));
  2214. }
  2215. }
  2216. if (range1.end != null) {
  2217. if (end === null) {
  2218. end = range1.end;
  2219. }
  2220. else {
  2221. end = new Date(Math.min(end.valueOf(), range1.end.valueOf()));
  2222. }
  2223. }
  2224. if (start === null || end === null || start < end) {
  2225. newRange = { start: start, end: end };
  2226. }
  2227. return newRange;
  2228. }
  2229. function rangesEqual(range0, range1) {
  2230. return (range0.start === null ? null : range0.start.valueOf()) === (range1.start === null ? null : range1.start.valueOf()) &&
  2231. (range0.end === null ? null : range0.end.valueOf()) === (range1.end === null ? null : range1.end.valueOf());
  2232. }
  2233. function rangesIntersect(range0, range1) {
  2234. return (range0.end === null || range1.start === null || range0.end > range1.start) &&
  2235. (range0.start === null || range1.end === null || range0.start < range1.end);
  2236. }
  2237. function rangeContainsRange(outerRange, innerRange) {
  2238. return (outerRange.start === null || (innerRange.start !== null && innerRange.start >= outerRange.start)) &&
  2239. (outerRange.end === null || (innerRange.end !== null && innerRange.end <= outerRange.end));
  2240. }
  2241. function rangeContainsMarker(range, date) {
  2242. return (range.start === null || date >= range.start) &&
  2243. (range.end === null || date < range.end);
  2244. }
  2245. // If the given date is not within the given range, move it inside.
  2246. // (If it's past the end, make it one millisecond before the end).
  2247. function constrainMarkerToRange(date, range) {
  2248. if (range.start != null && date < range.start) {
  2249. return range.start;
  2250. }
  2251. if (range.end != null && date >= range.end) {
  2252. return new Date(range.end.valueOf() - 1);
  2253. }
  2254. return date;
  2255. }
  2256. /*
  2257. Specifying nextDayThreshold signals that all-day ranges should be sliced.
  2258. */
  2259. function sliceEventStore(eventStore, eventUiBases, framingRange, nextDayThreshold) {
  2260. var inverseBgByGroupId = {};
  2261. var inverseBgByDefId = {};
  2262. var defByGroupId = {};
  2263. var bgRanges = [];
  2264. var fgRanges = [];
  2265. var eventUis = compileEventUis(eventStore.defs, eventUiBases);
  2266. for (var defId in eventStore.defs) {
  2267. var def = eventStore.defs[defId];
  2268. var ui = eventUis[def.defId];
  2269. if (ui.display === 'inverse-background') {
  2270. if (def.groupId) {
  2271. inverseBgByGroupId[def.groupId] = [];
  2272. if (!defByGroupId[def.groupId]) {
  2273. defByGroupId[def.groupId] = def;
  2274. }
  2275. }
  2276. else {
  2277. inverseBgByDefId[defId] = [];
  2278. }
  2279. }
  2280. }
  2281. for (var instanceId in eventStore.instances) {
  2282. var instance = eventStore.instances[instanceId];
  2283. var def = eventStore.defs[instance.defId];
  2284. var ui = eventUis[def.defId];
  2285. var origRange = instance.range;
  2286. var normalRange = (!def.allDay && nextDayThreshold) ?
  2287. computeVisibleDayRange(origRange, nextDayThreshold) :
  2288. origRange;
  2289. var slicedRange = intersectRanges(normalRange, framingRange);
  2290. if (slicedRange) {
  2291. if (ui.display === 'inverse-background') {
  2292. if (def.groupId) {
  2293. inverseBgByGroupId[def.groupId].push(slicedRange);
  2294. }
  2295. else {
  2296. inverseBgByDefId[instance.defId].push(slicedRange);
  2297. }
  2298. }
  2299. else if (ui.display !== 'none') {
  2300. (ui.display === 'background' ? bgRanges : fgRanges).push({
  2301. def: def,
  2302. ui: ui,
  2303. instance: instance,
  2304. range: slicedRange,
  2305. isStart: normalRange.start && normalRange.start.valueOf() === slicedRange.start.valueOf(),
  2306. isEnd: normalRange.end && normalRange.end.valueOf() === slicedRange.end.valueOf()
  2307. });
  2308. }
  2309. }
  2310. }
  2311. for (var groupId in inverseBgByGroupId) { // BY GROUP
  2312. var ranges = inverseBgByGroupId[groupId];
  2313. var invertedRanges = invertRanges(ranges, framingRange);
  2314. for (var _i = 0, invertedRanges_1 = invertedRanges; _i < invertedRanges_1.length; _i++) {
  2315. var invertedRange = invertedRanges_1[_i];
  2316. var def = defByGroupId[groupId];
  2317. var ui = eventUis[def.defId];
  2318. bgRanges.push({
  2319. def: def,
  2320. ui: ui,
  2321. instance: null,
  2322. range: invertedRange,
  2323. isStart: false,
  2324. isEnd: false
  2325. });
  2326. }
  2327. }
  2328. for (var defId in inverseBgByDefId) {
  2329. var ranges = inverseBgByDefId[defId];
  2330. var invertedRanges = invertRanges(ranges, framingRange);
  2331. for (var _a = 0, invertedRanges_2 = invertedRanges; _a < invertedRanges_2.length; _a++) {
  2332. var invertedRange = invertedRanges_2[_a];
  2333. bgRanges.push({
  2334. def: eventStore.defs[defId],
  2335. ui: eventUis[defId],
  2336. instance: null,
  2337. range: invertedRange,
  2338. isStart: false,
  2339. isEnd: false
  2340. });
  2341. }
  2342. }
  2343. return { bg: bgRanges, fg: fgRanges };
  2344. }
  2345. function hasBgRendering(def) {
  2346. return def.ui.display === 'background' || def.ui.display === 'inverse-background';
  2347. }
  2348. function setElSeg(el, seg) {
  2349. el.fcSeg = seg;
  2350. }
  2351. function getElSeg(el) {
  2352. return el.fcSeg ||
  2353. el.parentNode.fcSeg || // for the harness
  2354. null;
  2355. }
  2356. // event ui computation
  2357. function compileEventUis(eventDefs, eventUiBases) {
  2358. return mapHash(eventDefs, function (eventDef) {
  2359. return compileEventUi(eventDef, eventUiBases);
  2360. });
  2361. }
  2362. function compileEventUi(eventDef, eventUiBases) {
  2363. var uis = [];
  2364. if (eventUiBases['']) {
  2365. uis.push(eventUiBases['']);
  2366. }
  2367. if (eventUiBases[eventDef.defId]) {
  2368. uis.push(eventUiBases[eventDef.defId]);
  2369. }
  2370. uis.push(eventDef.ui);
  2371. return combineEventUis(uis);
  2372. }
  2373. function sortEventSegs(segs, eventOrderSpecs) {
  2374. var objs = segs.map(buildSegCompareObj);
  2375. objs.sort(function (obj0, obj1) {
  2376. return compareByFieldSpecs(obj0, obj1, eventOrderSpecs);
  2377. });
  2378. return objs.map(function (c) {
  2379. return c._seg;
  2380. });
  2381. }
  2382. // returns a object with all primitive props that can be compared
  2383. function buildSegCompareObj(seg) {
  2384. var eventRange = seg.eventRange;
  2385. var eventDef = eventRange.def;
  2386. var range = eventRange.instance ? eventRange.instance.range : eventRange.range;
  2387. var start = range.start ? range.start.valueOf() : 0; // TODO: better support for open-range events
  2388. var end = range.end ? range.end.valueOf() : 0; // "
  2389. return __assign(__assign(__assign({}, eventDef.extendedProps), eventDef), { id: eventDef.publicId, start: start,
  2390. end: end, duration: end - start, allDay: Number(eventDef.allDay), _seg: seg // for later retrieval
  2391. });
  2392. }
  2393. function computeSegDraggable(seg, context) {
  2394. var pluginHooks = context.pluginHooks;
  2395. var transformers = pluginHooks.isDraggableTransformers;
  2396. var _a = seg.eventRange, def = _a.def, ui = _a.ui;
  2397. var val = ui.startEditable;
  2398. for (var _i = 0, transformers_1 = transformers; _i < transformers_1.length; _i++) {
  2399. var transformer = transformers_1[_i];
  2400. val = transformer(val, def, ui, context);
  2401. }
  2402. return val;
  2403. }
  2404. function computeSegStartResizable(seg, context) {
  2405. return seg.isStart && seg.eventRange.ui.durationEditable && context.options.eventResizableFromStart;
  2406. }
  2407. function computeSegEndResizable(seg, context) {
  2408. return seg.isEnd && seg.eventRange.ui.durationEditable;
  2409. }
  2410. function buildSegTimeText(seg, timeFormat, context, defaultDisplayEventTime, // defaults to true
  2411. defaultDisplayEventEnd, // defaults to true
  2412. startOverride, endOverride) {
  2413. var dateEnv = context.dateEnv, options = context.options;
  2414. var displayEventTime = options.displayEventTime, displayEventEnd = options.displayEventEnd;
  2415. var eventDef = seg.eventRange.def;
  2416. var eventInstance = seg.eventRange.instance;
  2417. if (displayEventTime == null) {
  2418. displayEventTime = defaultDisplayEventTime !== false;
  2419. }
  2420. if (displayEventEnd == null) {
  2421. displayEventEnd = defaultDisplayEventEnd !== false;
  2422. }
  2423. if (displayEventTime && !eventDef.allDay && (seg.isStart || seg.isEnd)) {
  2424. var segStart = startOverride || (seg.isStart ? eventInstance.range.start : (seg.start || seg.eventRange.range.start));
  2425. var segEnd = endOverride || (seg.isEnd ? eventInstance.range.end : (seg.end || seg.eventRange.range.end));
  2426. if (displayEventEnd && eventDef.hasEnd) {
  2427. return dateEnv.formatRange(segStart, segEnd, timeFormat, {
  2428. forcedStartTzo: startOverride ? null : eventInstance.forcedStartTzo,
  2429. forcedEndTzo: endOverride ? null : eventInstance.forcedEndTzo
  2430. });
  2431. }
  2432. else {
  2433. return dateEnv.format(segStart, timeFormat, {
  2434. forcedTzo: startOverride ? null : eventInstance.forcedStartTzo // nooooo, same
  2435. });
  2436. }
  2437. }
  2438. return '';
  2439. }
  2440. function getSegMeta(seg, todayRange, nowDate) {
  2441. var segRange = seg.eventRange.range;
  2442. return {
  2443. isPast: segRange.end < (nowDate || todayRange.start),
  2444. isFuture: segRange.start >= (nowDate || todayRange.end),
  2445. isToday: todayRange && rangeContainsMarker(todayRange, segRange.start)
  2446. };
  2447. }
  2448. function getEventClassNames(props) {
  2449. var classNames = ['fc-event'];
  2450. if (props.isMirror) {
  2451. classNames.push('fc-event-mirror');
  2452. }
  2453. if (props.isDraggable) {
  2454. classNames.push('fc-event-draggable');
  2455. }
  2456. if (props.isStartResizable || props.isEndResizable) {
  2457. classNames.push('fc-event-resizable');
  2458. }
  2459. if (props.isDragging) {
  2460. classNames.push('fc-event-dragging');
  2461. }
  2462. if (props.isResizing) {
  2463. classNames.push('fc-event-resizing');
  2464. }
  2465. if (props.isSelected) {
  2466. classNames.push('fc-event-selected');
  2467. }
  2468. if (props.isStart) {
  2469. classNames.push('fc-event-start');
  2470. }
  2471. if (props.isEnd) {
  2472. classNames.push('fc-event-end');
  2473. }
  2474. if (props.isPast) {
  2475. classNames.push('fc-event-past');
  2476. }
  2477. if (props.isToday) {
  2478. classNames.push('fc-event-today');
  2479. }
  2480. if (props.isFuture) {
  2481. classNames.push('fc-event-future');
  2482. }
  2483. return classNames;
  2484. }
  2485. function buildEventRangeKey(eventRange) {
  2486. return eventRange.instance
  2487. ? eventRange.instance.instanceId
  2488. : eventRange.def.defId + ':' + eventRange.range.start.toISOString();
  2489. // inverse-background events don't have specific instances. TODO: better solution
  2490. }
  2491. var STANDARD_PROPS = {
  2492. start: identity,
  2493. end: identity,
  2494. allDay: Boolean
  2495. };
  2496. function parseDateSpan(raw, dateEnv, defaultDuration) {
  2497. var span = parseOpenDateSpan(raw, dateEnv);
  2498. var range = span.range;
  2499. if (!range.start) {
  2500. return null;
  2501. }
  2502. if (!range.end) {
  2503. if (defaultDuration == null) {
  2504. return null;
  2505. }
  2506. else {
  2507. range.end = dateEnv.add(range.start, defaultDuration);
  2508. }
  2509. }
  2510. return span;
  2511. }
  2512. /*
  2513. TODO: somehow combine with parseRange?
  2514. Will return null if the start/end props were present but parsed invalidly.
  2515. */
  2516. function parseOpenDateSpan(raw, dateEnv) {
  2517. var _a = refineProps(raw, STANDARD_PROPS), standardProps = _a.refined, extra = _a.extra;
  2518. var startMeta = standardProps.start ? dateEnv.createMarkerMeta(standardProps.start) : null;
  2519. var endMeta = standardProps.end ? dateEnv.createMarkerMeta(standardProps.end) : null;
  2520. var allDay = standardProps.allDay;
  2521. if (allDay == null) {
  2522. allDay = (startMeta && startMeta.isTimeUnspecified) &&
  2523. (!endMeta || endMeta.isTimeUnspecified);
  2524. }
  2525. return __assign({ range: {
  2526. start: startMeta ? startMeta.marker : null,
  2527. end: endMeta ? endMeta.marker : null,
  2528. }, allDay: allDay }, extra);
  2529. }
  2530. function isDateSpansEqual(span0, span1) {
  2531. return rangesEqual(span0.range, span1.range) &&
  2532. span0.allDay === span1.allDay &&
  2533. isSpanPropsEqual(span0, span1);
  2534. }
  2535. // the NON-DATE-RELATED props
  2536. function isSpanPropsEqual(span0, span1) {
  2537. for (var propName in span1) {
  2538. if (propName !== 'range' && propName !== 'allDay') {
  2539. if (span0[propName] !== span1[propName]) {
  2540. return false;
  2541. }
  2542. }
  2543. }
  2544. // are there any props that span0 has that span1 DOESN'T have?
  2545. // both have range/allDay, so no need to special-case.
  2546. for (var propName in span0) {
  2547. if (!(propName in span1)) {
  2548. return false;
  2549. }
  2550. }
  2551. return true;
  2552. }
  2553. function buildDateSpanApi(span, dateEnv) {
  2554. return __assign(__assign({}, buildRangeApi(span.range, dateEnv, span.allDay)), { allDay: span.allDay });
  2555. }
  2556. function buildRangeApiWithTimeZone(range, dateEnv, omitTime) {
  2557. return __assign(__assign({}, buildRangeApi(range, dateEnv, omitTime)), { timeZone: dateEnv.timeZone });
  2558. }
  2559. function buildRangeApi(range, dateEnv, omitTime) {
  2560. return {
  2561. start: dateEnv.toDate(range.start),
  2562. end: dateEnv.toDate(range.end),
  2563. startStr: dateEnv.formatIso(range.start, { omitTime: omitTime }),
  2564. endStr: dateEnv.formatIso(range.end, { omitTime: omitTime })
  2565. };
  2566. }
  2567. function fabricateEventRange(dateSpan, eventUiBases, context) {
  2568. var res = refineEventDef({ editable: false }, context);
  2569. var def = parseEventDef(res.refined, res.extra, '', // sourceId
  2570. dateSpan.allDay, true, // hasEnd
  2571. context);
  2572. return {
  2573. def: def,
  2574. ui: compileEventUi(def, eventUiBases),
  2575. instance: createEventInstance(def.defId, dateSpan.range),
  2576. range: dateSpan.range,
  2577. isStart: true,
  2578. isEnd: true
  2579. };
  2580. }
  2581. function triggerDateSelect(selection, pev, context) {
  2582. context.emitter.trigger('select', __assign(__assign({}, buildDateSpanApiWithContext(selection, context)), { jsEvent: pev ? pev.origEvent : null, view: context.viewApi || context.calendarApi.view }));
  2583. }
  2584. function triggerDateUnselect(pev, context) {
  2585. context.emitter.trigger('unselect', {
  2586. jsEvent: pev ? pev.origEvent : null,
  2587. view: context.viewApi || context.calendarApi.view
  2588. });
  2589. }
  2590. function buildDateSpanApiWithContext(dateSpan, context) {
  2591. var props = {};
  2592. for (var _i = 0, _a = context.pluginHooks.dateSpanTransforms; _i < _a.length; _i++) {
  2593. var transform = _a[_i];
  2594. __assign(props, transform(dateSpan, context));
  2595. }
  2596. __assign(props, buildDateSpanApi(dateSpan, context.dateEnv));
  2597. return props;
  2598. }
  2599. // Given an event's allDay status and start date, return what its fallback end date should be.
  2600. // TODO: rename to computeDefaultEventEnd
  2601. function getDefaultEventEnd(allDay, marker, context) {
  2602. var dateEnv = context.dateEnv, options = context.options;
  2603. var end = marker;
  2604. if (allDay) {
  2605. end = startOfDay(end);
  2606. end = dateEnv.add(end, options.defaultAllDayEventDuration);
  2607. }
  2608. else {
  2609. end = dateEnv.add(end, options.defaultTimedEventDuration);
  2610. }
  2611. return end;
  2612. }
  2613. // applies the mutation to ALL defs/instances within the event store
  2614. function applyMutationToEventStore(eventStore, eventConfigBase, mutation, context) {
  2615. var eventConfigs = compileEventUis(eventStore.defs, eventConfigBase);
  2616. var dest = createEmptyEventStore();
  2617. for (var defId in eventStore.defs) {
  2618. var def = eventStore.defs[defId];
  2619. dest.defs[defId] = applyMutationToEventDef(def, eventConfigs[defId], mutation, context);
  2620. }
  2621. for (var instanceId in eventStore.instances) {
  2622. var instance = eventStore.instances[instanceId];
  2623. var def = dest.defs[instance.defId]; // important to grab the newly modified def
  2624. dest.instances[instanceId] = applyMutationToEventInstance(instance, def, eventConfigs[instance.defId], mutation, context);
  2625. }
  2626. return dest;
  2627. }
  2628. function applyMutationToEventDef(eventDef, eventConfig, mutation, context) {
  2629. var standardProps = mutation.standardProps || {};
  2630. // if hasEnd has not been specified, guess a good value based on deltas.
  2631. // if duration will change, there's no way the default duration will persist,
  2632. // and thus, we need to mark the event as having a real end
  2633. if (standardProps.hasEnd == null &&
  2634. eventConfig.durationEditable &&
  2635. (mutation.startDelta || mutation.endDelta)) {
  2636. standardProps.hasEnd = true; // TODO: is this mutation okay?
  2637. }
  2638. var copy = __assign(__assign(__assign({}, eventDef), standardProps), { ui: __assign(__assign({}, eventDef.ui), standardProps.ui) });
  2639. if (mutation.extendedProps) {
  2640. copy.extendedProps = __assign(__assign({}, copy.extendedProps), mutation.extendedProps);
  2641. }
  2642. for (var _i = 0, _a = context.pluginHooks.eventDefMutationAppliers; _i < _a.length; _i++) {
  2643. var applier = _a[_i];
  2644. applier(copy, mutation, context);
  2645. }
  2646. if (!copy.hasEnd && context.options.forceEventDuration) {
  2647. copy.hasEnd = true;
  2648. }
  2649. return copy;
  2650. }
  2651. function applyMutationToEventInstance(eventInstance, eventDef, // must first be modified by applyMutationToEventDef
  2652. eventConfig, mutation, context) {
  2653. var dateEnv = context.dateEnv;
  2654. var forceAllDay = mutation.standardProps && mutation.standardProps.allDay === true;
  2655. var clearEnd = mutation.standardProps && mutation.standardProps.hasEnd === false;
  2656. var copy = __assign({}, eventInstance);
  2657. if (forceAllDay) {
  2658. copy.range = computeAlignedDayRange(copy.range);
  2659. }
  2660. if (mutation.datesDelta && eventConfig.startEditable) {
  2661. copy.range = {
  2662. start: dateEnv.add(copy.range.start, mutation.datesDelta),
  2663. end: dateEnv.add(copy.range.end, mutation.datesDelta)
  2664. };
  2665. }
  2666. if (mutation.startDelta && eventConfig.durationEditable) {
  2667. copy.range = {
  2668. start: dateEnv.add(copy.range.start, mutation.startDelta),
  2669. end: copy.range.end
  2670. };
  2671. }
  2672. if (mutation.endDelta && eventConfig.durationEditable) {
  2673. copy.range = {
  2674. start: copy.range.start,
  2675. end: dateEnv.add(copy.range.end, mutation.endDelta)
  2676. };
  2677. }
  2678. if (clearEnd) {
  2679. copy.range = {
  2680. start: copy.range.start,
  2681. end: getDefaultEventEnd(eventDef.allDay, copy.range.start, context)
  2682. };
  2683. }
  2684. // in case event was all-day but the supplied deltas were not
  2685. // better util for this?
  2686. if (eventDef.allDay) {
  2687. copy.range = {
  2688. start: startOfDay(copy.range.start),
  2689. end: startOfDay(copy.range.end)
  2690. };
  2691. }
  2692. // handle invalid durations
  2693. if (copy.range.end < copy.range.start) {
  2694. copy.range.end = getDefaultEventEnd(eventDef.allDay, copy.range.start, context);
  2695. }
  2696. return copy;
  2697. }
  2698. // no public types yet. when there are, export from:
  2699. // import {} from './api-type-deps'
  2700. var ViewApi = /** @class */ (function () {
  2701. function ViewApi(type, getCurrentData, dateEnv) {
  2702. this.type = type;
  2703. this.getCurrentData = getCurrentData;
  2704. this.dateEnv = dateEnv;
  2705. }
  2706. Object.defineProperty(ViewApi.prototype, "calendar", {
  2707. get: function () {
  2708. return this.getCurrentData().calendarApi;
  2709. },
  2710. enumerable: false,
  2711. configurable: true
  2712. });
  2713. Object.defineProperty(ViewApi.prototype, "title", {
  2714. get: function () {
  2715. return this.getCurrentData().viewTitle;
  2716. },
  2717. enumerable: false,
  2718. configurable: true
  2719. });
  2720. Object.defineProperty(ViewApi.prototype, "activeStart", {
  2721. get: function () {
  2722. return this.dateEnv.toDate(this.getCurrentData().dateProfile.activeRange.start);
  2723. },
  2724. enumerable: false,
  2725. configurable: true
  2726. });
  2727. Object.defineProperty(ViewApi.prototype, "activeEnd", {
  2728. get: function () {
  2729. return this.dateEnv.toDate(this.getCurrentData().dateProfile.activeRange.end);
  2730. },
  2731. enumerable: false,
  2732. configurable: true
  2733. });
  2734. Object.defineProperty(ViewApi.prototype, "currentStart", {
  2735. get: function () {
  2736. return this.dateEnv.toDate(this.getCurrentData().dateProfile.currentRange.start);
  2737. },
  2738. enumerable: false,
  2739. configurable: true
  2740. });
  2741. Object.defineProperty(ViewApi.prototype, "currentEnd", {
  2742. get: function () {
  2743. return this.dateEnv.toDate(this.getCurrentData().dateProfile.currentRange.end);
  2744. },
  2745. enumerable: false,
  2746. configurable: true
  2747. });
  2748. ViewApi.prototype.getOption = function (name) {
  2749. return this.getCurrentData().options[name]; // are the view-specific options
  2750. };
  2751. return ViewApi;
  2752. }());
  2753. var EVENT_SOURCE_REFINERS = {
  2754. id: String,
  2755. defaultAllDay: Boolean,
  2756. url: String,
  2757. events: identity,
  2758. eventDataTransform: identity,
  2759. // for any network-related sources
  2760. success: identity,
  2761. failure: identity,
  2762. };
  2763. function parseEventSource(raw, context, refiners) {
  2764. if (refiners === void 0) { refiners = buildEventSourceRefiners(context); }
  2765. var rawObj;
  2766. if (typeof raw === 'string') {
  2767. rawObj = { url: raw };
  2768. }
  2769. else if (typeof raw === 'function' || Array.isArray(raw)) {
  2770. rawObj = { events: raw };
  2771. }
  2772. else if (typeof raw === 'object' && raw) { // not null
  2773. rawObj = raw;
  2774. }
  2775. if (rawObj) {
  2776. var _a = refineProps(rawObj, refiners), refined = _a.refined, extra = _a.extra;
  2777. var metaRes = buildEventSourceMeta(refined, context);
  2778. if (metaRes) {
  2779. return {
  2780. _raw: raw,
  2781. isFetching: false,
  2782. latestFetchId: '',
  2783. fetchRange: null,
  2784. defaultAllDay: refined.defaultAllDay,
  2785. eventDataTransform: refined.eventDataTransform,
  2786. success: refined.success,
  2787. failure: refined.failure,
  2788. publicId: refined.id || '',
  2789. sourceId: guid(),
  2790. sourceDefId: metaRes.sourceDefId,
  2791. meta: metaRes.meta,
  2792. ui: createEventUi(refined, context),
  2793. extendedProps: extra
  2794. };
  2795. }
  2796. }
  2797. return null;
  2798. }
  2799. function buildEventSourceRefiners(context) {
  2800. return __assign(__assign(__assign({}, EVENT_UI_REFINERS), EVENT_SOURCE_REFINERS), context.pluginHooks.eventSourceRefiners);
  2801. }
  2802. function buildEventSourceMeta(raw, context) {
  2803. var defs = context.pluginHooks.eventSourceDefs;
  2804. for (var i = defs.length - 1; i >= 0; i--) { // later-added plugins take precedence
  2805. var def = defs[i];
  2806. var meta = def.parseMeta(raw);
  2807. if (meta) {
  2808. return { sourceDefId: i, meta: meta };
  2809. }
  2810. }
  2811. return null;
  2812. }
  2813. function reduceCurrentDate(currentDate, action) {
  2814. switch (action.type) {
  2815. case 'CHANGE_DATE':
  2816. return action.dateMarker;
  2817. default:
  2818. return currentDate;
  2819. }
  2820. }
  2821. function getInitialDate(options, dateEnv) {
  2822. var initialDateInput = options.initialDate;
  2823. // compute the initial ambig-timezone date
  2824. if (initialDateInput != null) {
  2825. return dateEnv.createMarker(initialDateInput);
  2826. }
  2827. else {
  2828. return getNow(options.now, dateEnv); // getNow already returns unzoned
  2829. }
  2830. }
  2831. function getNow(nowInput, dateEnv) {
  2832. if (typeof nowInput === 'function') {
  2833. nowInput = nowInput();
  2834. }
  2835. if (nowInput == null) {
  2836. return dateEnv.createNowMarker();
  2837. }
  2838. return dateEnv.createMarker(nowInput);
  2839. }
  2840. var CalendarApi = /** @class */ (function () {
  2841. function CalendarApi() {
  2842. }
  2843. CalendarApi.prototype.getCurrentData = function () {
  2844. return this.currentDataManager.getCurrentData();
  2845. };
  2846. CalendarApi.prototype.dispatch = function (action) {
  2847. return this.currentDataManager.dispatch(action);
  2848. };
  2849. Object.defineProperty(CalendarApi.prototype, "view", {
  2850. get: function () { return this.getCurrentData().viewApi; } // for public API
  2851. ,
  2852. enumerable: false,
  2853. configurable: true
  2854. });
  2855. CalendarApi.prototype.batchRendering = function (callback) {
  2856. callback();
  2857. };
  2858. CalendarApi.prototype.updateSize = function () {
  2859. this.trigger('_resize', true);
  2860. };
  2861. // Options
  2862. // -----------------------------------------------------------------------------------------------------------------
  2863. CalendarApi.prototype.setOption = function (name, val) {
  2864. this.dispatch({
  2865. type: 'SET_OPTION',
  2866. optionName: name,
  2867. rawOptionValue: val
  2868. });
  2869. };
  2870. CalendarApi.prototype.getOption = function (name) {
  2871. return this.currentDataManager.currentCalendarOptionsInput[name];
  2872. };
  2873. CalendarApi.prototype.getAvailableLocaleCodes = function () {
  2874. return Object.keys(this.getCurrentData().availableRawLocales);
  2875. };
  2876. // Trigger
  2877. // -----------------------------------------------------------------------------------------------------------------
  2878. CalendarApi.prototype.on = function (handlerName, handler) {
  2879. var currentDataManager = this.currentDataManager;
  2880. if (currentDataManager.currentCalendarOptionsRefiners[handlerName]) {
  2881. currentDataManager.emitter.on(handlerName, handler);
  2882. }
  2883. else {
  2884. console.warn("Unknown listener name '" + handlerName + "'");
  2885. }
  2886. };
  2887. CalendarApi.prototype.off = function (handlerName, handler) {
  2888. this.currentDataManager.emitter.off(handlerName, handler);
  2889. };
  2890. CalendarApi.prototype.trigger = function (handlerName) {
  2891. var _a;
  2892. var args = [];
  2893. for (var _i = 1; _i < arguments.length; _i++) {
  2894. args[_i - 1] = arguments[_i];
  2895. }
  2896. (_a = this.currentDataManager.emitter).trigger.apply(_a, __spreadArrays([handlerName], args));
  2897. };
  2898. // View
  2899. // -----------------------------------------------------------------------------------------------------------------
  2900. CalendarApi.prototype.changeView = function (viewType, dateOrRange) {
  2901. var _this = this;
  2902. this.batchRendering(function () {
  2903. _this.unselect();
  2904. if (dateOrRange) {
  2905. if (dateOrRange.start && dateOrRange.end) { // a range
  2906. _this.dispatch({
  2907. type: 'CHANGE_VIEW_TYPE',
  2908. viewType: viewType,
  2909. });
  2910. _this.dispatch({
  2911. type: 'SET_OPTION',
  2912. optionName: 'visibleRange',
  2913. rawOptionValue: dateOrRange
  2914. });
  2915. }
  2916. else {
  2917. var dateEnv = _this.getCurrentData().dateEnv;
  2918. _this.dispatch({
  2919. type: 'CHANGE_VIEW_TYPE',
  2920. viewType: viewType,
  2921. dateMarker: dateEnv.createMarker(dateOrRange)
  2922. });
  2923. }
  2924. }
  2925. else {
  2926. _this.dispatch({
  2927. type: 'CHANGE_VIEW_TYPE',
  2928. viewType: viewType
  2929. });
  2930. }
  2931. });
  2932. };
  2933. // Forces navigation to a view for the given date.
  2934. // `viewType` can be a specific view name or a generic one like "week" or "day".
  2935. // needs to change
  2936. CalendarApi.prototype.zoomTo = function (dateMarker, viewType) {
  2937. var state = this.getCurrentData();
  2938. var spec;
  2939. viewType = viewType || 'day'; // day is default zoom
  2940. spec = state.viewSpecs[viewType] || this.getUnitViewSpec(viewType);
  2941. this.unselect();
  2942. if (spec) {
  2943. this.dispatch({
  2944. type: 'CHANGE_VIEW_TYPE',
  2945. viewType: spec.type,
  2946. dateMarker: dateMarker
  2947. });
  2948. }
  2949. else {
  2950. this.dispatch({
  2951. type: 'CHANGE_DATE',
  2952. dateMarker: dateMarker
  2953. });
  2954. }
  2955. };
  2956. // Given a duration singular unit, like "week" or "day", finds a matching view spec.
  2957. // Preference is given to views that have corresponding buttons.
  2958. CalendarApi.prototype.getUnitViewSpec = function (unit) {
  2959. var _a = this.getCurrentData(), viewSpecs = _a.viewSpecs, toolbarConfig = _a.toolbarConfig;
  2960. var viewTypes = [].concat(toolbarConfig.viewsWithButtons);
  2961. var i;
  2962. var spec;
  2963. for (var viewType in viewSpecs) {
  2964. viewTypes.push(viewType);
  2965. }
  2966. for (i = 0; i < viewTypes.length; i++) {
  2967. spec = viewSpecs[viewTypes[i]];
  2968. if (spec) {
  2969. if (spec.singleUnit === unit) {
  2970. return spec;
  2971. }
  2972. }
  2973. }
  2974. };
  2975. // Current Date
  2976. // -----------------------------------------------------------------------------------------------------------------
  2977. CalendarApi.prototype.prev = function () {
  2978. this.unselect();
  2979. this.dispatch({ type: 'PREV' });
  2980. };
  2981. CalendarApi.prototype.next = function () {
  2982. this.unselect();
  2983. this.dispatch({ type: 'NEXT' });
  2984. };
  2985. CalendarApi.prototype.prevYear = function () {
  2986. var state = this.getCurrentData();
  2987. this.unselect();
  2988. this.dispatch({
  2989. type: 'CHANGE_DATE',
  2990. dateMarker: state.dateEnv.addYears(state.currentDate, -1)
  2991. });
  2992. };
  2993. CalendarApi.prototype.nextYear = function () {
  2994. var state = this.getCurrentData();
  2995. this.unselect();
  2996. this.dispatch({
  2997. type: 'CHANGE_DATE',
  2998. dateMarker: state.dateEnv.addYears(state.currentDate, 1)
  2999. });
  3000. };
  3001. CalendarApi.prototype.today = function () {
  3002. var state = this.getCurrentData();
  3003. this.unselect();
  3004. this.dispatch({
  3005. type: 'CHANGE_DATE',
  3006. dateMarker: getNow(state.calendarOptions.now, state.dateEnv)
  3007. });
  3008. };
  3009. CalendarApi.prototype.gotoDate = function (zonedDateInput) {
  3010. var state = this.getCurrentData();
  3011. this.unselect();
  3012. this.dispatch({
  3013. type: 'CHANGE_DATE',
  3014. dateMarker: state.dateEnv.createMarker(zonedDateInput)
  3015. });
  3016. };
  3017. CalendarApi.prototype.incrementDate = function (deltaInput) {
  3018. var state = this.getCurrentData();
  3019. var delta = createDuration(deltaInput);
  3020. if (delta) { // else, warn about invalid input?
  3021. this.unselect();
  3022. this.dispatch({
  3023. type: 'CHANGE_DATE',
  3024. dateMarker: state.dateEnv.add(state.currentDate, delta)
  3025. });
  3026. }
  3027. };
  3028. // for external API
  3029. CalendarApi.prototype.getDate = function () {
  3030. var state = this.getCurrentData();
  3031. return state.dateEnv.toDate(state.currentDate);
  3032. };
  3033. // Date Formatting Utils
  3034. // -----------------------------------------------------------------------------------------------------------------
  3035. CalendarApi.prototype.formatDate = function (d, formatter) {
  3036. var dateEnv = this.getCurrentData().dateEnv;
  3037. return dateEnv.format(dateEnv.createMarker(d), createFormatter(formatter));
  3038. };
  3039. // `settings` is for formatter AND isEndExclusive
  3040. CalendarApi.prototype.formatRange = function (d0, d1, settings) {
  3041. var dateEnv = this.getCurrentData().dateEnv;
  3042. return dateEnv.formatRange(dateEnv.createMarker(d0), dateEnv.createMarker(d1), createFormatter(settings), settings);
  3043. };
  3044. CalendarApi.prototype.formatIso = function (d, omitTime) {
  3045. var dateEnv = this.getCurrentData().dateEnv;
  3046. return dateEnv.formatIso(dateEnv.createMarker(d), { omitTime: omitTime });
  3047. };
  3048. // Date Selection / Event Selection / DayClick
  3049. // -----------------------------------------------------------------------------------------------------------------
  3050. // this public method receives start/end dates in any format, with any timezone
  3051. // NOTE: args were changed from v3
  3052. CalendarApi.prototype.select = function (dateOrObj, endDate) {
  3053. var selectionInput;
  3054. if (endDate == null) {
  3055. if (dateOrObj.start != null) {
  3056. selectionInput = dateOrObj;
  3057. }
  3058. else {
  3059. selectionInput = {
  3060. start: dateOrObj,
  3061. end: null
  3062. };
  3063. }
  3064. }
  3065. else {
  3066. selectionInput = {
  3067. start: dateOrObj,
  3068. end: endDate
  3069. };
  3070. }
  3071. var state = this.getCurrentData();
  3072. var selection = parseDateSpan(selectionInput, state.dateEnv, createDuration({ days: 1 }) // TODO: cache this?
  3073. );
  3074. if (selection) { // throw parse error otherwise?
  3075. this.dispatch({ type: 'SELECT_DATES', selection: selection });
  3076. triggerDateSelect(selection, null, state);
  3077. }
  3078. };
  3079. // public method
  3080. CalendarApi.prototype.unselect = function (pev) {
  3081. var state = this.getCurrentData();
  3082. if (state.dateSelection) {
  3083. this.dispatch({ type: 'UNSELECT_DATES' });
  3084. triggerDateUnselect(pev, state);
  3085. }
  3086. };
  3087. // Public Events API
  3088. // -----------------------------------------------------------------------------------------------------------------
  3089. CalendarApi.prototype.addEvent = function (eventInput, sourceInput) {
  3090. if (eventInput instanceof EventApi) {
  3091. var def = eventInput._def;
  3092. var instance = eventInput._instance;
  3093. var currentData = this.getCurrentData();
  3094. // not already present? don't want to add an old snapshot
  3095. if (!currentData.eventStore.defs[def.defId]) {
  3096. this.dispatch({
  3097. type: 'ADD_EVENTS',
  3098. eventStore: eventTupleToStore({ def: def, instance: instance }) // TODO: better util for two args?
  3099. });
  3100. this.triggerEventAdd(eventInput);
  3101. }
  3102. return eventInput;
  3103. }
  3104. var state = this.getCurrentData();
  3105. var eventSource;
  3106. if (sourceInput instanceof EventSourceApi) {
  3107. eventSource = sourceInput.internalEventSource;
  3108. }
  3109. else if (typeof sourceInput === 'boolean') {
  3110. if (sourceInput) { // true. part of the first event source
  3111. eventSource = hashValuesToArray(state.eventSources)[0];
  3112. }
  3113. }
  3114. else if (sourceInput != null) { // an ID. accepts a number too
  3115. var sourceApi = this.getEventSourceById(sourceInput); // TODO: use an internal function
  3116. if (!sourceApi) {
  3117. console.warn('Could not find an event source with ID "' + sourceInput + '"'); // TODO: test
  3118. return null;
  3119. }
  3120. else {
  3121. eventSource = sourceApi.internalEventSource;
  3122. }
  3123. }
  3124. var tuple = parseEvent(eventInput, eventSource, state, false);
  3125. if (tuple) {
  3126. var newEventApi = new EventApi(state, tuple.def, tuple.def.recurringDef ? null : tuple.instance);
  3127. this.dispatch({
  3128. type: 'ADD_EVENTS',
  3129. eventStore: eventTupleToStore(tuple)
  3130. });
  3131. this.triggerEventAdd(newEventApi);
  3132. return newEventApi;
  3133. }
  3134. return null;
  3135. };
  3136. CalendarApi.prototype.triggerEventAdd = function (eventApi) {
  3137. var _this = this;
  3138. var emitter = this.getCurrentData().emitter;
  3139. emitter.trigger('eventAdd', {
  3140. event: eventApi,
  3141. relatedEvents: [],
  3142. revert: function () {
  3143. _this.dispatch({
  3144. type: 'REMOVE_EVENTS',
  3145. eventStore: eventApiToStore(eventApi)
  3146. });
  3147. }
  3148. });
  3149. };
  3150. // TODO: optimize
  3151. CalendarApi.prototype.getEventById = function (id) {
  3152. var state = this.getCurrentData();
  3153. var _a = state.eventStore, defs = _a.defs, instances = _a.instances;
  3154. id = String(id);
  3155. for (var defId in defs) {
  3156. var def = defs[defId];
  3157. if (def.publicId === id) {
  3158. if (def.recurringDef) {
  3159. return new EventApi(state, def, null);
  3160. }
  3161. else {
  3162. for (var instanceId in instances) {
  3163. var instance = instances[instanceId];
  3164. if (instance.defId === def.defId) {
  3165. return new EventApi(state, def, instance);
  3166. }
  3167. }
  3168. }
  3169. }
  3170. }
  3171. return null;
  3172. };
  3173. CalendarApi.prototype.getEvents = function () {
  3174. var currentData = this.getCurrentData();
  3175. return buildEventApis(currentData.eventStore, currentData);
  3176. };
  3177. CalendarApi.prototype.removeAllEvents = function () {
  3178. this.dispatch({ type: 'REMOVE_ALL_EVENTS' });
  3179. };
  3180. // Public Event Sources API
  3181. // -----------------------------------------------------------------------------------------------------------------
  3182. CalendarApi.prototype.getEventSources = function () {
  3183. var state = this.getCurrentData();
  3184. var sourceHash = state.eventSources;
  3185. var sourceApis = [];
  3186. for (var internalId in sourceHash) {
  3187. sourceApis.push(new EventSourceApi(state, sourceHash[internalId]));
  3188. }
  3189. return sourceApis;
  3190. };
  3191. CalendarApi.prototype.getEventSourceById = function (id) {
  3192. var state = this.getCurrentData();
  3193. var sourceHash = state.eventSources;
  3194. id = String(id);
  3195. for (var sourceId in sourceHash) {
  3196. if (sourceHash[sourceId].publicId === id) {
  3197. return new EventSourceApi(state, sourceHash[sourceId]);
  3198. }
  3199. }
  3200. return null;
  3201. };
  3202. CalendarApi.prototype.addEventSource = function (sourceInput) {
  3203. var state = this.getCurrentData();
  3204. if (sourceInput instanceof EventSourceApi) {
  3205. // not already present? don't want to add an old snapshot
  3206. if (!state.eventSources[sourceInput.internalEventSource.sourceId]) {
  3207. this.dispatch({
  3208. type: 'ADD_EVENT_SOURCES',
  3209. sources: [sourceInput.internalEventSource]
  3210. });
  3211. }
  3212. return sourceInput;
  3213. }
  3214. var eventSource = parseEventSource(sourceInput, state);
  3215. if (eventSource) { // TODO: error otherwise?
  3216. this.dispatch({ type: 'ADD_EVENT_SOURCES', sources: [eventSource] });
  3217. return new EventSourceApi(state, eventSource);
  3218. }
  3219. return null;
  3220. };
  3221. CalendarApi.prototype.removeAllEventSources = function () {
  3222. this.dispatch({ type: 'REMOVE_ALL_EVENT_SOURCES' });
  3223. };
  3224. CalendarApi.prototype.refetchEvents = function () {
  3225. this.dispatch({ type: 'FETCH_EVENT_SOURCES' });
  3226. };
  3227. // Scroll
  3228. // -----------------------------------------------------------------------------------------------------------------
  3229. CalendarApi.prototype.scrollToTime = function (timeInput) {
  3230. var time = createDuration(timeInput);
  3231. if (time) {
  3232. this.trigger('_scrollRequest', { time: time });
  3233. }
  3234. };
  3235. return CalendarApi;
  3236. }());
  3237. var EventApi = /** @class */ (function () {
  3238. // instance will be null if expressing a recurring event that has no current instances,
  3239. // OR if trying to validate an incoming external event that has no dates assigned
  3240. function EventApi(context, def, instance) {
  3241. this._context = context;
  3242. this._def = def;
  3243. this._instance = instance || null;
  3244. }
  3245. /*
  3246. TODO: make event struct more responsible for this
  3247. */
  3248. EventApi.prototype.setProp = function (name, val) {
  3249. var _a, _b;
  3250. if (name in EVENT_DATE_REFINERS) {
  3251. console.warn("Could not set date-related prop 'name'. Use one of the date-related methods instead.");
  3252. }
  3253. else if (name in EVENT_NON_DATE_REFINERS) {
  3254. val = EVENT_NON_DATE_REFINERS[name](val);
  3255. this.mutate({
  3256. standardProps: (_a = {}, _a[name] = val, _a)
  3257. });
  3258. }
  3259. else if (name in EVENT_UI_REFINERS) {
  3260. var ui = EVENT_UI_REFINERS[name](val);
  3261. if (name === 'color') {
  3262. ui = { backgroundColor: val, borderColor: val };
  3263. }
  3264. else if (name === 'editable') {
  3265. ui = { startEditable: val, durationEditable: val };
  3266. }
  3267. else {
  3268. ui = (_b = {}, _b[name] = val, _b);
  3269. }
  3270. this.mutate({
  3271. standardProps: { ui: ui }
  3272. });
  3273. }
  3274. else {
  3275. console.warn("Could not set prop '" + name + "'. Use setExtendedProp instead.");
  3276. }
  3277. };
  3278. EventApi.prototype.setExtendedProp = function (name, val) {
  3279. var _a;
  3280. this.mutate({
  3281. extendedProps: (_a = {}, _a[name] = val, _a)
  3282. });
  3283. };
  3284. EventApi.prototype.setStart = function (startInput, options) {
  3285. if (options === void 0) { options = {}; }
  3286. var dateEnv = this._context.dateEnv;
  3287. var start = dateEnv.createMarker(startInput);
  3288. if (start && this._instance) { // TODO: warning if parsed bad
  3289. var instanceRange = this._instance.range;
  3290. var startDelta = diffDates(instanceRange.start, start, dateEnv, options.granularity); // what if parsed bad!?
  3291. if (options.maintainDuration) {
  3292. this.mutate({ datesDelta: startDelta });
  3293. }
  3294. else {
  3295. this.mutate({ startDelta: startDelta });
  3296. }
  3297. }
  3298. };
  3299. EventApi.prototype.setEnd = function (endInput, options) {
  3300. if (options === void 0) { options = {}; }
  3301. var dateEnv = this._context.dateEnv;
  3302. var end;
  3303. if (endInput != null) {
  3304. end = dateEnv.createMarker(endInput);
  3305. if (!end) {
  3306. return; // TODO: warning if parsed bad
  3307. }
  3308. }
  3309. if (this._instance) {
  3310. if (end) {
  3311. var endDelta = diffDates(this._instance.range.end, end, dateEnv, options.granularity);
  3312. this.mutate({ endDelta: endDelta });
  3313. }
  3314. else {
  3315. this.mutate({ standardProps: { hasEnd: false } });
  3316. }
  3317. }
  3318. };
  3319. EventApi.prototype.setDates = function (startInput, endInput, options) {
  3320. if (options === void 0) { options = {}; }
  3321. var dateEnv = this._context.dateEnv;
  3322. var standardProps = { allDay: options.allDay };
  3323. var start = dateEnv.createMarker(startInput);
  3324. var end;
  3325. if (!start) {
  3326. return; // TODO: warning if parsed bad
  3327. }
  3328. if (endInput != null) {
  3329. end = dateEnv.createMarker(endInput);
  3330. if (!end) { // TODO: warning if parsed bad
  3331. return;
  3332. }
  3333. }
  3334. if (this._instance) {
  3335. var instanceRange = this._instance.range;
  3336. // when computing the diff for an event being converted to all-day,
  3337. // compute diff off of the all-day values the way event-mutation does.
  3338. if (options.allDay === true) {
  3339. instanceRange = computeAlignedDayRange(instanceRange);
  3340. }
  3341. var startDelta = diffDates(instanceRange.start, start, dateEnv, options.granularity);
  3342. if (end) {
  3343. var endDelta = diffDates(instanceRange.end, end, dateEnv, options.granularity);
  3344. if (durationsEqual(startDelta, endDelta)) {
  3345. this.mutate({ datesDelta: startDelta, standardProps: standardProps });
  3346. }
  3347. else {
  3348. this.mutate({ startDelta: startDelta, endDelta: endDelta, standardProps: standardProps });
  3349. }
  3350. }
  3351. else { // means "clear the end"
  3352. standardProps.hasEnd = false;
  3353. this.mutate({ datesDelta: startDelta, standardProps: standardProps });
  3354. }
  3355. }
  3356. };
  3357. EventApi.prototype.moveStart = function (deltaInput) {
  3358. var delta = createDuration(deltaInput);
  3359. if (delta) { // TODO: warning if parsed bad
  3360. this.mutate({ startDelta: delta });
  3361. }
  3362. };
  3363. EventApi.prototype.moveEnd = function (deltaInput) {
  3364. var delta = createDuration(deltaInput);
  3365. if (delta) { // TODO: warning if parsed bad
  3366. this.mutate({ endDelta: delta });
  3367. }
  3368. };
  3369. EventApi.prototype.moveDates = function (deltaInput) {
  3370. var delta = createDuration(deltaInput);
  3371. if (delta) { // TODO: warning if parsed bad
  3372. this.mutate({ datesDelta: delta });
  3373. }
  3374. };
  3375. EventApi.prototype.setAllDay = function (allDay, options) {
  3376. if (options === void 0) { options = {}; }
  3377. var standardProps = { allDay: allDay };
  3378. var maintainDuration = options.maintainDuration;
  3379. if (maintainDuration == null) {
  3380. maintainDuration = this._context.options.allDayMaintainDuration;
  3381. }
  3382. if (this._def.allDay !== allDay) {
  3383. standardProps.hasEnd = maintainDuration;
  3384. }
  3385. this.mutate({ standardProps: standardProps });
  3386. };
  3387. EventApi.prototype.formatRange = function (formatInput) {
  3388. var dateEnv = this._context.dateEnv;
  3389. var instance = this._instance;
  3390. var formatter = createFormatter(formatInput);
  3391. if (this._def.hasEnd) {
  3392. return dateEnv.formatRange(instance.range.start, instance.range.end, formatter, {
  3393. forcedStartTzo: instance.forcedStartTzo,
  3394. forcedEndTzo: instance.forcedEndTzo
  3395. });
  3396. }
  3397. else {
  3398. return dateEnv.format(instance.range.start, formatter, {
  3399. forcedTzo: instance.forcedStartTzo
  3400. });
  3401. }
  3402. };
  3403. EventApi.prototype.mutate = function (mutation) {
  3404. var instance = this._instance;
  3405. if (instance) {
  3406. var def = this._def;
  3407. var context_1 = this._context;
  3408. var eventStore = context_1.getCurrentData().eventStore;
  3409. var relevantEvents_1 = getRelevantEvents(eventStore, instance.instanceId);
  3410. var eventConfigBase = {
  3411. '': {
  3412. display: '',
  3413. startEditable: true,
  3414. durationEditable: true,
  3415. constraints: [],
  3416. overlap: null,
  3417. allows: [],
  3418. backgroundColor: '',
  3419. borderColor: '',
  3420. textColor: '',
  3421. classNames: []
  3422. }
  3423. };
  3424. relevantEvents_1 = applyMutationToEventStore(relevantEvents_1, eventConfigBase, mutation, context_1);
  3425. var oldEvent = new EventApi(context_1, def, instance); // snapshot
  3426. this._def = relevantEvents_1.defs[def.defId];
  3427. this._instance = relevantEvents_1.instances[instance.instanceId];
  3428. context_1.dispatch({
  3429. type: 'MERGE_EVENTS',
  3430. eventStore: relevantEvents_1
  3431. });
  3432. context_1.emitter.trigger('eventChange', {
  3433. oldEvent: oldEvent,
  3434. event: this,
  3435. relatedEvents: buildEventApis(relevantEvents_1, context_1, instance),
  3436. revert: function () {
  3437. context_1.dispatch({
  3438. type: 'REMOVE_EVENTS',
  3439. eventStore: relevantEvents_1
  3440. });
  3441. }
  3442. });
  3443. }
  3444. };
  3445. EventApi.prototype.remove = function () {
  3446. var context = this._context;
  3447. var asStore = eventApiToStore(this);
  3448. context.dispatch({
  3449. type: 'REMOVE_EVENTS',
  3450. eventStore: asStore
  3451. });
  3452. context.emitter.trigger('eventRemove', {
  3453. event: this,
  3454. relatedEvents: [],
  3455. revert: function () {
  3456. context.dispatch({
  3457. type: 'MERGE_EVENTS',
  3458. eventStore: asStore
  3459. });
  3460. }
  3461. });
  3462. };
  3463. Object.defineProperty(EventApi.prototype, "source", {
  3464. get: function () {
  3465. var sourceId = this._def.sourceId;
  3466. if (sourceId) {
  3467. return new EventSourceApi(this._context, this._context.getCurrentData().eventSources[sourceId]);
  3468. }
  3469. return null;
  3470. },
  3471. enumerable: false,
  3472. configurable: true
  3473. });
  3474. Object.defineProperty(EventApi.prototype, "start", {
  3475. get: function () {
  3476. return this._instance ?
  3477. this._context.dateEnv.toDate(this._instance.range.start) :
  3478. null;
  3479. },
  3480. enumerable: false,
  3481. configurable: true
  3482. });
  3483. Object.defineProperty(EventApi.prototype, "end", {
  3484. get: function () {
  3485. return (this._instance && this._def.hasEnd) ?
  3486. this._context.dateEnv.toDate(this._instance.range.end) :
  3487. null;
  3488. },
  3489. enumerable: false,
  3490. configurable: true
  3491. });
  3492. Object.defineProperty(EventApi.prototype, "startStr", {
  3493. get: function () {
  3494. var instance = this._instance;
  3495. if (instance) {
  3496. return this._context.dateEnv.formatIso(instance.range.start, {
  3497. omitTime: this._def.allDay,
  3498. forcedTzo: instance.forcedStartTzo
  3499. });
  3500. }
  3501. return '';
  3502. },
  3503. enumerable: false,
  3504. configurable: true
  3505. });
  3506. Object.defineProperty(EventApi.prototype, "endStr", {
  3507. get: function () {
  3508. var instance = this._instance;
  3509. if (instance && this._def.hasEnd) {
  3510. return this._context.dateEnv.formatIso(instance.range.end, {
  3511. omitTime: this._def.allDay,
  3512. forcedTzo: instance.forcedEndTzo
  3513. });
  3514. }
  3515. return '';
  3516. },
  3517. enumerable: false,
  3518. configurable: true
  3519. });
  3520. Object.defineProperty(EventApi.prototype, "id", {
  3521. // computable props that all access the def
  3522. // TODO: find a TypeScript-compatible way to do this at scale
  3523. get: function () { return this._def.publicId; },
  3524. enumerable: false,
  3525. configurable: true
  3526. });
  3527. Object.defineProperty(EventApi.prototype, "groupId", {
  3528. get: function () { return this._def.groupId; },
  3529. enumerable: false,
  3530. configurable: true
  3531. });
  3532. Object.defineProperty(EventApi.prototype, "allDay", {
  3533. get: function () { return this._def.allDay; },
  3534. enumerable: false,
  3535. configurable: true
  3536. });
  3537. Object.defineProperty(EventApi.prototype, "title", {
  3538. get: function () { return this._def.title; },
  3539. enumerable: false,
  3540. configurable: true
  3541. });
  3542. Object.defineProperty(EventApi.prototype, "url", {
  3543. get: function () { return this._def.url; },
  3544. enumerable: false,
  3545. configurable: true
  3546. });
  3547. Object.defineProperty(EventApi.prototype, "display", {
  3548. get: function () { return this._def.ui.display || 'auto'; } // bad. just normalize the type earlier
  3549. ,
  3550. enumerable: false,
  3551. configurable: true
  3552. });
  3553. Object.defineProperty(EventApi.prototype, "startEditable", {
  3554. get: function () { return this._def.ui.startEditable; },
  3555. enumerable: false,
  3556. configurable: true
  3557. });
  3558. Object.defineProperty(EventApi.prototype, "durationEditable", {
  3559. get: function () { return this._def.ui.durationEditable; },
  3560. enumerable: false,
  3561. configurable: true
  3562. });
  3563. Object.defineProperty(EventApi.prototype, "constraint", {
  3564. get: function () { return this._def.ui.constraints[0] || null; },
  3565. enumerable: false,
  3566. configurable: true
  3567. });
  3568. Object.defineProperty(EventApi.prototype, "overlap", {
  3569. get: function () { return this._def.ui.overlap; },
  3570. enumerable: false,
  3571. configurable: true
  3572. });
  3573. Object.defineProperty(EventApi.prototype, "allow", {
  3574. get: function () { return this._def.ui.allows[0] || null; },
  3575. enumerable: false,
  3576. configurable: true
  3577. });
  3578. Object.defineProperty(EventApi.prototype, "backgroundColor", {
  3579. get: function () { return this._def.ui.backgroundColor; },
  3580. enumerable: false,
  3581. configurable: true
  3582. });
  3583. Object.defineProperty(EventApi.prototype, "borderColor", {
  3584. get: function () { return this._def.ui.borderColor; },
  3585. enumerable: false,
  3586. configurable: true
  3587. });
  3588. Object.defineProperty(EventApi.prototype, "textColor", {
  3589. get: function () { return this._def.ui.textColor; },
  3590. enumerable: false,
  3591. configurable: true
  3592. });
  3593. Object.defineProperty(EventApi.prototype, "classNames", {
  3594. // NOTE: user can't modify these because Object.freeze was called in event-def parsing
  3595. get: function () { return this._def.ui.classNames; },
  3596. enumerable: false,
  3597. configurable: true
  3598. });
  3599. Object.defineProperty(EventApi.prototype, "extendedProps", {
  3600. get: function () { return this._def.extendedProps; },
  3601. enumerable: false,
  3602. configurable: true
  3603. });
  3604. EventApi.prototype.toPlainObject = function (settings) {
  3605. if (settings === void 0) { settings = {}; }
  3606. var def = this._def;
  3607. var ui = def.ui;
  3608. var _a = this, startStr = _a.startStr, endStr = _a.endStr;
  3609. var res = {};
  3610. if (def.title) {
  3611. res.title = def.title;
  3612. }
  3613. if (startStr) {
  3614. res.start = startStr;
  3615. }
  3616. if (endStr) {
  3617. res.end = endStr;
  3618. }
  3619. if (def.publicId) {
  3620. res.id = def.publicId;
  3621. }
  3622. if (def.groupId) {
  3623. res.groupId = def.groupId;
  3624. }
  3625. if (def.url) {
  3626. res.url = def.url;
  3627. }
  3628. if (ui.display && ui.display !== 'auto') {
  3629. res.display = ui.display;
  3630. }
  3631. // TODO: what about recurring-event properties???
  3632. // TODO: include startEditable/durationEditable/constraint/overlap/allow
  3633. if (settings.collapseColor && ui.backgroundColor && ui.backgroundColor === ui.borderColor) {
  3634. res.color = ui.backgroundColor;
  3635. }
  3636. else {
  3637. if (ui.backgroundColor) {
  3638. res.backgroundColor = ui.backgroundColor;
  3639. }
  3640. if (ui.borderColor) {
  3641. res.borderColor = ui.borderColor;
  3642. }
  3643. }
  3644. if (ui.textColor) {
  3645. res.textColor = ui.textColor;
  3646. }
  3647. if (ui.classNames.length) {
  3648. res.classNames = ui.classNames;
  3649. }
  3650. if (Object.keys(def.extendedProps).length) {
  3651. if (settings.collapseExtendedProps) {
  3652. __assign(res, def.extendedProps);
  3653. }
  3654. else {
  3655. res.extendedProps = def.extendedProps;
  3656. }
  3657. }
  3658. return res;
  3659. };
  3660. EventApi.prototype.toJSON = function () {
  3661. return this.toPlainObject();
  3662. };
  3663. return EventApi;
  3664. }());
  3665. function eventApiToStore(eventApi) {
  3666. var _a, _b;
  3667. var def = eventApi._def;
  3668. var instance = eventApi._instance;
  3669. return {
  3670. defs: (_a = {}, _a[def.defId] = def, _a),
  3671. instances: instance
  3672. ? (_b = {}, _b[instance.instanceId] = instance, _b) : {}
  3673. };
  3674. }
  3675. function buildEventApis(eventStore, context, excludeInstance) {
  3676. var defs = eventStore.defs, instances = eventStore.instances;
  3677. var eventApis = [];
  3678. var excludeInstanceId = excludeInstance ? excludeInstance.instanceId : '';
  3679. for (var id in instances) {
  3680. var instance = instances[id];
  3681. var def = defs[instance.defId];
  3682. if (instance.instanceId !== excludeInstanceId) {
  3683. eventApis.push(new EventApi(context, def, instance));
  3684. }
  3685. }
  3686. return eventApis;
  3687. }
  3688. var calendarSystemClassMap = {};
  3689. function registerCalendarSystem(name, theClass) {
  3690. calendarSystemClassMap[name] = theClass;
  3691. }
  3692. function createCalendarSystem(name) {
  3693. return new calendarSystemClassMap[name]();
  3694. }
  3695. var GregorianCalendarSystem = /** @class */ (function () {
  3696. function GregorianCalendarSystem() {
  3697. }
  3698. GregorianCalendarSystem.prototype.getMarkerYear = function (d) {
  3699. return d.getUTCFullYear();
  3700. };
  3701. GregorianCalendarSystem.prototype.getMarkerMonth = function (d) {
  3702. return d.getUTCMonth();
  3703. };
  3704. GregorianCalendarSystem.prototype.getMarkerDay = function (d) {
  3705. return d.getUTCDate();
  3706. };
  3707. GregorianCalendarSystem.prototype.arrayToMarker = function (arr) {
  3708. return arrayToUtcDate(arr);
  3709. };
  3710. GregorianCalendarSystem.prototype.markerToArray = function (marker) {
  3711. return dateToUtcArray(marker);
  3712. };
  3713. return GregorianCalendarSystem;
  3714. }());
  3715. registerCalendarSystem('gregory', GregorianCalendarSystem);
  3716. var ISO_RE = /^\s*(\d{4})(-(\d{2})(-(\d{2})([T ](\d{2}):(\d{2})(:(\d{2})(\.(\d+))?)?(Z|(([-+])(\d{2})(:?(\d{2}))?))?)?)?)?$/;
  3717. function parse(str) {
  3718. var m = ISO_RE.exec(str);
  3719. if (m) {
  3720. var marker = new Date(Date.UTC(Number(m[1]), m[3] ? Number(m[3]) - 1 : 0, Number(m[5] || 1), Number(m[7] || 0), Number(m[8] || 0), Number(m[10] || 0), m[12] ? Number('0.' + m[12]) * 1000 : 0));
  3721. if (isValidDate(marker)) {
  3722. var timeZoneOffset = null;
  3723. if (m[13]) {
  3724. timeZoneOffset = (m[15] === '-' ? -1 : 1) * (Number(m[16] || 0) * 60 +
  3725. Number(m[18] || 0));
  3726. }
  3727. return {
  3728. marker: marker,
  3729. isTimeUnspecified: !m[6],
  3730. timeZoneOffset: timeZoneOffset
  3731. };
  3732. }
  3733. }
  3734. return null;
  3735. }
  3736. var DateEnv = /** @class */ (function () {
  3737. function DateEnv(settings) {
  3738. var timeZone = this.timeZone = settings.timeZone;
  3739. var isNamedTimeZone = timeZone !== 'local' && timeZone !== 'UTC';
  3740. if (settings.namedTimeZoneImpl && isNamedTimeZone) {
  3741. this.namedTimeZoneImpl = new settings.namedTimeZoneImpl(timeZone);
  3742. }
  3743. this.canComputeOffset = Boolean(!isNamedTimeZone || this.namedTimeZoneImpl);
  3744. this.calendarSystem = createCalendarSystem(settings.calendarSystem);
  3745. this.locale = settings.locale;
  3746. this.weekDow = settings.locale.week.dow;
  3747. this.weekDoy = settings.locale.week.doy;
  3748. if (settings.weekNumberCalculation === 'ISO') {
  3749. this.weekDow = 1;
  3750. this.weekDoy = 4;
  3751. }
  3752. if (typeof settings.firstDay === 'number') {
  3753. this.weekDow = settings.firstDay;
  3754. }
  3755. if (typeof settings.weekNumberCalculation === 'function') {
  3756. this.weekNumberFunc = settings.weekNumberCalculation;
  3757. }
  3758. this.weekText = settings.weekText != null ? settings.weekText : settings.locale.options.weekText;
  3759. this.cmdFormatter = settings.cmdFormatter;
  3760. this.defaultSeparator = settings.defaultSeparator;
  3761. }
  3762. // Creating / Parsing
  3763. DateEnv.prototype.createMarker = function (input) {
  3764. var meta = this.createMarkerMeta(input);
  3765. if (meta === null) {
  3766. return null;
  3767. }
  3768. return meta.marker;
  3769. };
  3770. DateEnv.prototype.createNowMarker = function () {
  3771. if (this.canComputeOffset) {
  3772. return this.timestampToMarker(new Date().valueOf());
  3773. }
  3774. else {
  3775. // if we can't compute the current date val for a timezone,
  3776. // better to give the current local date vals than UTC
  3777. return arrayToUtcDate(dateToLocalArray(new Date()));
  3778. }
  3779. };
  3780. DateEnv.prototype.createMarkerMeta = function (input) {
  3781. if (typeof input === 'string') {
  3782. return this.parse(input);
  3783. }
  3784. var marker = null;
  3785. if (typeof input === 'number') {
  3786. marker = this.timestampToMarker(input);
  3787. }
  3788. else if (input instanceof Date) {
  3789. input = input.valueOf();
  3790. if (!isNaN(input)) {
  3791. marker = this.timestampToMarker(input);
  3792. }
  3793. }
  3794. else if (Array.isArray(input)) {
  3795. marker = arrayToUtcDate(input);
  3796. }
  3797. if (marker === null || !isValidDate(marker)) {
  3798. return null;
  3799. }
  3800. return { marker: marker, isTimeUnspecified: false, forcedTzo: null };
  3801. };
  3802. DateEnv.prototype.parse = function (s) {
  3803. var parts = parse(s);
  3804. if (parts === null) {
  3805. return null;
  3806. }
  3807. var marker = parts.marker;
  3808. var forcedTzo = null;
  3809. if (parts.timeZoneOffset !== null) {
  3810. if (this.canComputeOffset) {
  3811. marker = this.timestampToMarker(marker.valueOf() - parts.timeZoneOffset * 60 * 1000);
  3812. }
  3813. else {
  3814. forcedTzo = parts.timeZoneOffset;
  3815. }
  3816. }
  3817. return { marker: marker, isTimeUnspecified: parts.isTimeUnspecified, forcedTzo: forcedTzo };
  3818. };
  3819. // Accessors
  3820. DateEnv.prototype.getYear = function (marker) {
  3821. return this.calendarSystem.getMarkerYear(marker);
  3822. };
  3823. DateEnv.prototype.getMonth = function (marker) {
  3824. return this.calendarSystem.getMarkerMonth(marker);
  3825. };
  3826. // Adding / Subtracting
  3827. DateEnv.prototype.add = function (marker, dur) {
  3828. var a = this.calendarSystem.markerToArray(marker);
  3829. a[0] += dur.years;
  3830. a[1] += dur.months;
  3831. a[2] += dur.days;
  3832. a[6] += dur.milliseconds;
  3833. return this.calendarSystem.arrayToMarker(a);
  3834. };
  3835. DateEnv.prototype.subtract = function (marker, dur) {
  3836. var a = this.calendarSystem.markerToArray(marker);
  3837. a[0] -= dur.years;
  3838. a[1] -= dur.months;
  3839. a[2] -= dur.days;
  3840. a[6] -= dur.milliseconds;
  3841. return this.calendarSystem.arrayToMarker(a);
  3842. };
  3843. DateEnv.prototype.addYears = function (marker, n) {
  3844. var a = this.calendarSystem.markerToArray(marker);
  3845. a[0] += n;
  3846. return this.calendarSystem.arrayToMarker(a);
  3847. };
  3848. DateEnv.prototype.addMonths = function (marker, n) {
  3849. var a = this.calendarSystem.markerToArray(marker);
  3850. a[1] += n;
  3851. return this.calendarSystem.arrayToMarker(a);
  3852. };
  3853. // Diffing Whole Units
  3854. DateEnv.prototype.diffWholeYears = function (m0, m1) {
  3855. var calendarSystem = this.calendarSystem;
  3856. if (timeAsMs(m0) === timeAsMs(m1) &&
  3857. calendarSystem.getMarkerDay(m0) === calendarSystem.getMarkerDay(m1) &&
  3858. calendarSystem.getMarkerMonth(m0) === calendarSystem.getMarkerMonth(m1)) {
  3859. return calendarSystem.getMarkerYear(m1) - calendarSystem.getMarkerYear(m0);
  3860. }
  3861. return null;
  3862. };
  3863. DateEnv.prototype.diffWholeMonths = function (m0, m1) {
  3864. var calendarSystem = this.calendarSystem;
  3865. if (timeAsMs(m0) === timeAsMs(m1) &&
  3866. calendarSystem.getMarkerDay(m0) === calendarSystem.getMarkerDay(m1)) {
  3867. return (calendarSystem.getMarkerMonth(m1) - calendarSystem.getMarkerMonth(m0)) +
  3868. (calendarSystem.getMarkerYear(m1) - calendarSystem.getMarkerYear(m0)) * 12;
  3869. }
  3870. return null;
  3871. };
  3872. // Range / Duration
  3873. DateEnv.prototype.greatestWholeUnit = function (m0, m1) {
  3874. var n = this.diffWholeYears(m0, m1);
  3875. if (n !== null) {
  3876. return { unit: 'year', value: n };
  3877. }
  3878. n = this.diffWholeMonths(m0, m1);
  3879. if (n !== null) {
  3880. return { unit: 'month', value: n };
  3881. }
  3882. n = diffWholeWeeks(m0, m1);
  3883. if (n !== null) {
  3884. return { unit: 'week', value: n };
  3885. }
  3886. n = diffWholeDays(m0, m1);
  3887. if (n !== null) {
  3888. return { unit: 'day', value: n };
  3889. }
  3890. n = diffHours(m0, m1);
  3891. if (isInt(n)) {
  3892. return { unit: 'hour', value: n };
  3893. }
  3894. n = diffMinutes(m0, m1);
  3895. if (isInt(n)) {
  3896. return { unit: 'minute', value: n };
  3897. }
  3898. n = diffSeconds(m0, m1);
  3899. if (isInt(n)) {
  3900. return { unit: 'second', value: n };
  3901. }
  3902. return { unit: 'millisecond', value: m1.valueOf() - m0.valueOf() };
  3903. };
  3904. DateEnv.prototype.countDurationsBetween = function (m0, m1, d) {
  3905. // TODO: can use greatestWholeUnit
  3906. var diff;
  3907. if (d.years) {
  3908. diff = this.diffWholeYears(m0, m1);
  3909. if (diff !== null) {
  3910. return diff / asRoughYears(d);
  3911. }
  3912. }
  3913. if (d.months) {
  3914. diff = this.diffWholeMonths(m0, m1);
  3915. if (diff !== null) {
  3916. return diff / asRoughMonths(d);
  3917. }
  3918. }
  3919. if (d.days) {
  3920. diff = diffWholeDays(m0, m1);
  3921. if (diff !== null) {
  3922. return diff / asRoughDays(d);
  3923. }
  3924. }
  3925. return (m1.valueOf() - m0.valueOf()) / asRoughMs(d);
  3926. };
  3927. // Start-Of
  3928. // these DON'T return zoned-dates. only UTC start-of dates
  3929. DateEnv.prototype.startOf = function (m, unit) {
  3930. if (unit === 'year') {
  3931. return this.startOfYear(m);
  3932. }
  3933. else if (unit === 'month') {
  3934. return this.startOfMonth(m);
  3935. }
  3936. else if (unit === 'week') {
  3937. return this.startOfWeek(m);
  3938. }
  3939. else if (unit === 'day') {
  3940. return startOfDay(m);
  3941. }
  3942. else if (unit === 'hour') {
  3943. return startOfHour(m);
  3944. }
  3945. else if (unit === 'minute') {
  3946. return startOfMinute(m);
  3947. }
  3948. else if (unit === 'second') {
  3949. return startOfSecond(m);
  3950. }
  3951. };
  3952. DateEnv.prototype.startOfYear = function (m) {
  3953. return this.calendarSystem.arrayToMarker([
  3954. this.calendarSystem.getMarkerYear(m)
  3955. ]);
  3956. };
  3957. DateEnv.prototype.startOfMonth = function (m) {
  3958. return this.calendarSystem.arrayToMarker([
  3959. this.calendarSystem.getMarkerYear(m),
  3960. this.calendarSystem.getMarkerMonth(m)
  3961. ]);
  3962. };
  3963. DateEnv.prototype.startOfWeek = function (m) {
  3964. return this.calendarSystem.arrayToMarker([
  3965. this.calendarSystem.getMarkerYear(m),
  3966. this.calendarSystem.getMarkerMonth(m),
  3967. m.getUTCDate() - ((m.getUTCDay() - this.weekDow + 7) % 7)
  3968. ]);
  3969. };
  3970. // Week Number
  3971. DateEnv.prototype.computeWeekNumber = function (marker) {
  3972. if (this.weekNumberFunc) {
  3973. return this.weekNumberFunc(this.toDate(marker));
  3974. }
  3975. else {
  3976. return weekOfYear(marker, this.weekDow, this.weekDoy);
  3977. }
  3978. };
  3979. // TODO: choke on timeZoneName: long
  3980. DateEnv.prototype.format = function (marker, formatter, dateOptions) {
  3981. if (dateOptions === void 0) { dateOptions = {}; }
  3982. return formatter.format({
  3983. marker: marker,
  3984. timeZoneOffset: dateOptions.forcedTzo != null ?
  3985. dateOptions.forcedTzo :
  3986. this.offsetForMarker(marker)
  3987. }, this);
  3988. };
  3989. DateEnv.prototype.formatRange = function (start, end, formatter, dateOptions) {
  3990. if (dateOptions === void 0) { dateOptions = {}; }
  3991. if (dateOptions.isEndExclusive) {
  3992. end = addMs(end, -1);
  3993. }
  3994. return formatter.formatRange({
  3995. marker: start,
  3996. timeZoneOffset: dateOptions.forcedStartTzo != null ?
  3997. dateOptions.forcedStartTzo :
  3998. this.offsetForMarker(start)
  3999. }, {
  4000. marker: end,
  4001. timeZoneOffset: dateOptions.forcedEndTzo != null ?
  4002. dateOptions.forcedEndTzo :
  4003. this.offsetForMarker(end)
  4004. }, this, dateOptions.defaultSeparator);
  4005. };
  4006. /*
  4007. DUMB: the omitTime arg is dumb. if we omit the time, we want to omit the timezone offset. and if we do that,
  4008. might as well use buildIsoString or some other util directly
  4009. */
  4010. DateEnv.prototype.formatIso = function (marker, extraOptions) {
  4011. if (extraOptions === void 0) { extraOptions = {}; }
  4012. var timeZoneOffset = null;
  4013. if (!extraOptions.omitTimeZoneOffset) {
  4014. if (extraOptions.forcedTzo != null) {
  4015. timeZoneOffset = extraOptions.forcedTzo;
  4016. }
  4017. else {
  4018. timeZoneOffset = this.offsetForMarker(marker);
  4019. }
  4020. }
  4021. return buildIsoString(marker, timeZoneOffset, extraOptions.omitTime);
  4022. };
  4023. // TimeZone
  4024. DateEnv.prototype.timestampToMarker = function (ms) {
  4025. if (this.timeZone === 'local') {
  4026. return arrayToUtcDate(dateToLocalArray(new Date(ms)));
  4027. }
  4028. else if (this.timeZone === 'UTC' || !this.namedTimeZoneImpl) {
  4029. return new Date(ms);
  4030. }
  4031. else {
  4032. return arrayToUtcDate(this.namedTimeZoneImpl.timestampToArray(ms));
  4033. }
  4034. };
  4035. DateEnv.prototype.offsetForMarker = function (m) {
  4036. if (this.timeZone === 'local') {
  4037. return -arrayToLocalDate(dateToUtcArray(m)).getTimezoneOffset(); // convert "inverse" offset to "normal" offset
  4038. }
  4039. else if (this.timeZone === 'UTC') {
  4040. return 0;
  4041. }
  4042. else if (this.namedTimeZoneImpl) {
  4043. return this.namedTimeZoneImpl.offsetForArray(dateToUtcArray(m));
  4044. }
  4045. return null;
  4046. };
  4047. // Conversion
  4048. DateEnv.prototype.toDate = function (m, forcedTzo) {
  4049. if (this.timeZone === 'local') {
  4050. return arrayToLocalDate(dateToUtcArray(m));
  4051. }
  4052. else if (this.timeZone === 'UTC') {
  4053. return new Date(m.valueOf()); // make sure it's a copy
  4054. }
  4055. else if (!this.namedTimeZoneImpl) {
  4056. return new Date(m.valueOf() - (forcedTzo || 0));
  4057. }
  4058. else {
  4059. return new Date(m.valueOf() -
  4060. this.namedTimeZoneImpl.offsetForArray(dateToUtcArray(m)) * 1000 * 60 // convert minutes -> ms
  4061. );
  4062. }
  4063. };
  4064. return DateEnv;
  4065. }());
  4066. var globalLocales = [];
  4067. var RAW_EN_LOCALE = {
  4068. code: 'en',
  4069. week: {
  4070. dow: 0,
  4071. doy: 4 // 4 days need to be within the year to be considered the first week
  4072. },
  4073. direction: 'ltr',
  4074. buttonText: {
  4075. prev: 'prev',
  4076. next: 'next',
  4077. prevYear: 'prev year',
  4078. nextYear: 'next year',
  4079. year: 'year',
  4080. today: 'today',
  4081. month: 'month',
  4082. week: 'week',
  4083. day: 'day',
  4084. list: 'list'
  4085. },
  4086. weekText: 'W',
  4087. allDayText: 'all-day',
  4088. moreLinkText: 'more',
  4089. noEventsText: 'No events to display'
  4090. };
  4091. function organizeRawLocales(explicitRawLocales) {
  4092. var defaultCode = explicitRawLocales.length > 0 ? explicitRawLocales[0].code : 'en';
  4093. var allRawLocales = globalLocales.concat(explicitRawLocales);
  4094. var rawLocaleMap = {
  4095. en: RAW_EN_LOCALE // necessary?
  4096. };
  4097. for (var _i = 0, allRawLocales_1 = allRawLocales; _i < allRawLocales_1.length; _i++) {
  4098. var rawLocale = allRawLocales_1[_i];
  4099. rawLocaleMap[rawLocale.code] = rawLocale;
  4100. }
  4101. return {
  4102. map: rawLocaleMap,
  4103. defaultCode: defaultCode
  4104. };
  4105. }
  4106. function buildLocale(inputSingular, available) {
  4107. if (typeof inputSingular === 'object' && !Array.isArray(inputSingular)) {
  4108. return parseLocale(inputSingular.code, [inputSingular.code], inputSingular);
  4109. }
  4110. else {
  4111. return queryLocale(inputSingular, available);
  4112. }
  4113. }
  4114. function queryLocale(codeArg, available) {
  4115. var codes = [].concat(codeArg || []); // will convert to array
  4116. var raw = queryRawLocale(codes, available) || RAW_EN_LOCALE;
  4117. return parseLocale(codeArg, codes, raw);
  4118. }
  4119. function queryRawLocale(codes, available) {
  4120. for (var i = 0; i < codes.length; i++) {
  4121. var parts = codes[i].toLocaleLowerCase().split('-');
  4122. for (var j = parts.length; j > 0; j--) {
  4123. var simpleId = parts.slice(0, j).join('-');
  4124. if (available[simpleId]) {
  4125. return available[simpleId];
  4126. }
  4127. }
  4128. }
  4129. return null;
  4130. }
  4131. function parseLocale(codeArg, codes, raw) {
  4132. var merged = mergeProps([RAW_EN_LOCALE, raw], ['buttonText']);
  4133. delete merged.code; // don't want this part of the options
  4134. var week = merged.week;
  4135. delete merged.week;
  4136. return {
  4137. codeArg: codeArg,
  4138. codes: codes,
  4139. week: week,
  4140. simpleNumberFormat: new Intl.NumberFormat(codeArg),
  4141. options: merged
  4142. };
  4143. }
  4144. function formatDate(dateInput, options) {
  4145. if (options === void 0) { options = {}; }
  4146. var dateEnv = buildDateEnv(options);
  4147. var formatter = createFormatter(options);
  4148. var dateMeta = dateEnv.createMarkerMeta(dateInput);
  4149. if (!dateMeta) { // TODO: warning?
  4150. return '';
  4151. }
  4152. return dateEnv.format(dateMeta.marker, formatter, {
  4153. forcedTzo: dateMeta.forcedTzo
  4154. });
  4155. }
  4156. function formatRange(startInput, endInput, options // mixture of env and formatter settings
  4157. ) {
  4158. var dateEnv = buildDateEnv(typeof options === 'object' && options ? options : {}); // pass in if non-null object
  4159. var formatter = createFormatter(options);
  4160. var startMeta = dateEnv.createMarkerMeta(startInput);
  4161. var endMeta = dateEnv.createMarkerMeta(endInput);
  4162. if (!startMeta || !endMeta) { // TODO: warning?
  4163. return '';
  4164. }
  4165. return dateEnv.formatRange(startMeta.marker, endMeta.marker, formatter, {
  4166. forcedStartTzo: startMeta.forcedTzo,
  4167. forcedEndTzo: endMeta.forcedTzo,
  4168. isEndExclusive: options.isEndExclusive,
  4169. defaultSeparator: BASE_OPTION_DEFAULTS.defaultRangeSeparator
  4170. });
  4171. }
  4172. // TODO: more DRY and optimized
  4173. function buildDateEnv(settings) {
  4174. var locale = buildLocale(settings.locale || 'en', organizeRawLocales([]).map); // TODO: don't hardcode 'en' everywhere
  4175. return new DateEnv(__assign(__assign({ timeZone: BASE_OPTION_DEFAULTS.timeZone, calendarSystem: 'gregory' }, settings), { locale: locale }));
  4176. }
  4177. var DEF_DEFAULTS = {
  4178. startTime: '09:00',
  4179. endTime: '17:00',
  4180. daysOfWeek: [1, 2, 3, 4, 5],
  4181. display: 'inverse-background',
  4182. classNames: 'fc-non-business',
  4183. groupId: '_businessHours' // so multiple defs get grouped
  4184. };
  4185. /*
  4186. TODO: pass around as EventDefHash!!!
  4187. */
  4188. function parseBusinessHours(input, context) {
  4189. return parseEvents(refineInputs(input), null, context);
  4190. }
  4191. function refineInputs(input) {
  4192. var rawDefs;
  4193. if (input === true) {
  4194. rawDefs = [{}]; // will get DEF_DEFAULTS verbatim
  4195. }
  4196. else if (Array.isArray(input)) {
  4197. // if specifying an array, every sub-definition NEEDS a day-of-week
  4198. rawDefs = input.filter(function (rawDef) {
  4199. return rawDef.daysOfWeek;
  4200. });
  4201. }
  4202. else if (typeof input === 'object' && input) { // non-null object
  4203. rawDefs = [input];
  4204. }
  4205. else { // is probably false
  4206. rawDefs = [];
  4207. }
  4208. rawDefs = rawDefs.map(function (rawDef) {
  4209. return __assign(__assign({}, DEF_DEFAULTS), rawDef);
  4210. });
  4211. return rawDefs;
  4212. }
  4213. function pointInsideRect(point, rect) {
  4214. return point.left >= rect.left &&
  4215. point.left < rect.right &&
  4216. point.top >= rect.top &&
  4217. point.top < rect.bottom;
  4218. }
  4219. // Returns a new rectangle that is the intersection of the two rectangles. If they don't intersect, returns false
  4220. function intersectRects(rect1, rect2) {
  4221. var res = {
  4222. left: Math.max(rect1.left, rect2.left),
  4223. right: Math.min(rect1.right, rect2.right),
  4224. top: Math.max(rect1.top, rect2.top),
  4225. bottom: Math.min(rect1.bottom, rect2.bottom)
  4226. };
  4227. if (res.left < res.right && res.top < res.bottom) {
  4228. return res;
  4229. }
  4230. return false;
  4231. }
  4232. function translateRect(rect, deltaX, deltaY) {
  4233. return {
  4234. left: rect.left + deltaX,
  4235. right: rect.right + deltaX,
  4236. top: rect.top + deltaY,
  4237. bottom: rect.bottom + deltaY
  4238. };
  4239. }
  4240. // Returns a new point that will have been moved to reside within the given rectangle
  4241. function constrainPoint(point, rect) {
  4242. return {
  4243. left: Math.min(Math.max(point.left, rect.left), rect.right),
  4244. top: Math.min(Math.max(point.top, rect.top), rect.bottom)
  4245. };
  4246. }
  4247. // Returns a point that is the center of the given rectangle
  4248. function getRectCenter(rect) {
  4249. return {
  4250. left: (rect.left + rect.right) / 2,
  4251. top: (rect.top + rect.bottom) / 2
  4252. };
  4253. }
  4254. // Subtracts point2's coordinates from point1's coordinates, returning a delta
  4255. function diffPoints(point1, point2) {
  4256. return {
  4257. left: point1.left - point2.left,
  4258. top: point1.top - point2.top
  4259. };
  4260. }
  4261. var EMPTY_EVENT_STORE = createEmptyEventStore(); // for purecomponents. TODO: keep elsewhere
  4262. var Splitter = /** @class */ (function () {
  4263. function Splitter() {
  4264. this.getKeysForEventDefs = memoize(this._getKeysForEventDefs);
  4265. this.splitDateSelection = memoize(this._splitDateSpan);
  4266. this.splitEventStore = memoize(this._splitEventStore);
  4267. this.splitIndividualUi = memoize(this._splitIndividualUi);
  4268. this.splitEventDrag = memoize(this._splitInteraction);
  4269. this.splitEventResize = memoize(this._splitInteraction);
  4270. this.eventUiBuilders = {}; // TODO: typescript protection
  4271. }
  4272. Splitter.prototype.splitProps = function (props) {
  4273. var _this = this;
  4274. var keyInfos = this.getKeyInfo(props);
  4275. var defKeys = this.getKeysForEventDefs(props.eventStore);
  4276. var dateSelections = this.splitDateSelection(props.dateSelection);
  4277. var individualUi = this.splitIndividualUi(props.eventUiBases, defKeys); // the individual *bases*
  4278. var eventStores = this.splitEventStore(props.eventStore, defKeys);
  4279. var eventDrags = this.splitEventDrag(props.eventDrag);
  4280. var eventResizes = this.splitEventResize(props.eventResize);
  4281. var splitProps = {};
  4282. this.eventUiBuilders = mapHash(keyInfos, function (info, key) {
  4283. return _this.eventUiBuilders[key] || memoize(buildEventUiForKey);
  4284. });
  4285. for (var key in keyInfos) {
  4286. var keyInfo = keyInfos[key];
  4287. var eventStore = eventStores[key] || EMPTY_EVENT_STORE;
  4288. var buildEventUi = this.eventUiBuilders[key];
  4289. splitProps[key] = {
  4290. businessHours: keyInfo.businessHours || props.businessHours,
  4291. dateSelection: dateSelections[key] || null,
  4292. eventStore: eventStore,
  4293. eventUiBases: buildEventUi(props.eventUiBases[''], keyInfo.ui, individualUi[key]),
  4294. eventSelection: eventStore.instances[props.eventSelection] ? props.eventSelection : '',
  4295. eventDrag: eventDrags[key] || null,
  4296. eventResize: eventResizes[key] || null
  4297. };
  4298. }
  4299. return splitProps;
  4300. };
  4301. Splitter.prototype._splitDateSpan = function (dateSpan) {
  4302. var dateSpans = {};
  4303. if (dateSpan) {
  4304. var keys = this.getKeysForDateSpan(dateSpan);
  4305. for (var _i = 0, keys_1 = keys; _i < keys_1.length; _i++) {
  4306. var key = keys_1[_i];
  4307. dateSpans[key] = dateSpan;
  4308. }
  4309. }
  4310. return dateSpans;
  4311. };
  4312. Splitter.prototype._getKeysForEventDefs = function (eventStore) {
  4313. var _this = this;
  4314. return mapHash(eventStore.defs, function (eventDef) {
  4315. return _this.getKeysForEventDef(eventDef);
  4316. });
  4317. };
  4318. Splitter.prototype._splitEventStore = function (eventStore, defKeys) {
  4319. var defs = eventStore.defs, instances = eventStore.instances;
  4320. var splitStores = {};
  4321. for (var defId in defs) {
  4322. for (var _i = 0, _a = defKeys[defId]; _i < _a.length; _i++) {
  4323. var key = _a[_i];
  4324. if (!splitStores[key]) {
  4325. splitStores[key] = createEmptyEventStore();
  4326. }
  4327. splitStores[key].defs[defId] = defs[defId];
  4328. }
  4329. }
  4330. for (var instanceId in instances) {
  4331. var instance = instances[instanceId];
  4332. for (var _b = 0, _c = defKeys[instance.defId]; _b < _c.length; _b++) {
  4333. var key = _c[_b];
  4334. if (splitStores[key]) { // must have already been created
  4335. splitStores[key].instances[instanceId] = instance;
  4336. }
  4337. }
  4338. }
  4339. return splitStores;
  4340. };
  4341. Splitter.prototype._splitIndividualUi = function (eventUiBases, defKeys) {
  4342. var splitHashes = {};
  4343. for (var defId in eventUiBases) {
  4344. if (defId) { // not the '' key
  4345. for (var _i = 0, _a = defKeys[defId]; _i < _a.length; _i++) {
  4346. var key = _a[_i];
  4347. if (!splitHashes[key]) {
  4348. splitHashes[key] = {};
  4349. }
  4350. splitHashes[key][defId] = eventUiBases[defId];
  4351. }
  4352. }
  4353. }
  4354. return splitHashes;
  4355. };
  4356. Splitter.prototype._splitInteraction = function (interaction) {
  4357. var splitStates = {};
  4358. if (interaction) {
  4359. var affectedStores_1 = this._splitEventStore(interaction.affectedEvents, this._getKeysForEventDefs(interaction.affectedEvents) // can't use cached. might be events from other calendar
  4360. );
  4361. // can't rely on defKeys because event data is mutated
  4362. var mutatedKeysByDefId = this._getKeysForEventDefs(interaction.mutatedEvents);
  4363. var mutatedStores_1 = this._splitEventStore(interaction.mutatedEvents, mutatedKeysByDefId);
  4364. var populate = function (key) {
  4365. if (!splitStates[key]) {
  4366. splitStates[key] = {
  4367. affectedEvents: affectedStores_1[key] || EMPTY_EVENT_STORE,
  4368. mutatedEvents: mutatedStores_1[key] || EMPTY_EVENT_STORE,
  4369. isEvent: interaction.isEvent
  4370. };
  4371. }
  4372. };
  4373. for (var key in affectedStores_1) {
  4374. populate(key);
  4375. }
  4376. for (var key in mutatedStores_1) {
  4377. populate(key);
  4378. }
  4379. }
  4380. return splitStates;
  4381. };
  4382. return Splitter;
  4383. }());
  4384. function buildEventUiForKey(allUi, eventUiForKey, individualUi) {
  4385. var baseParts = [];
  4386. if (allUi) {
  4387. baseParts.push(allUi);
  4388. }
  4389. if (eventUiForKey) {
  4390. baseParts.push(eventUiForKey);
  4391. }
  4392. var stuff = {
  4393. '': combineEventUis(baseParts)
  4394. };
  4395. if (individualUi) {
  4396. __assign(stuff, individualUi);
  4397. }
  4398. return stuff;
  4399. }
  4400. function getDateMeta(date, todayRange, nowDate, dateProfile) {
  4401. return {
  4402. dow: date.getUTCDay(),
  4403. isDisabled: Boolean(dateProfile && !rangeContainsMarker(dateProfile.activeRange, date)),
  4404. isOther: Boolean(dateProfile && !rangeContainsMarker(dateProfile.currentRange, date)),
  4405. isToday: Boolean(todayRange && rangeContainsMarker(todayRange, date)),
  4406. isPast: Boolean(nowDate ? (date < nowDate) : todayRange ? (date < todayRange.start) : false),
  4407. isFuture: Boolean(nowDate ? (date > nowDate) : todayRange ? (date >= todayRange.end) : false)
  4408. };
  4409. }
  4410. function getDayClassNames(meta, theme) {
  4411. var classNames = [
  4412. 'fc-day',
  4413. 'fc-day-' + DAY_IDS[meta.dow]
  4414. ];
  4415. if (meta.isDisabled) {
  4416. classNames.push('fc-day-disabled');
  4417. }
  4418. else {
  4419. if (meta.isToday) {
  4420. classNames.push('fc-day-today');
  4421. classNames.push(theme.getClass('today'));
  4422. }
  4423. if (meta.isPast) {
  4424. classNames.push('fc-day-past');
  4425. }
  4426. if (meta.isFuture) {
  4427. classNames.push('fc-day-future');
  4428. }
  4429. if (meta.isOther) {
  4430. classNames.push('fc-day-other');
  4431. }
  4432. }
  4433. return classNames;
  4434. }
  4435. function getSlotClassNames(meta, theme) {
  4436. var classNames = [
  4437. 'fc-slot',
  4438. 'fc-slot-' + DAY_IDS[meta.dow]
  4439. ];
  4440. if (meta.isDisabled) {
  4441. classNames.push('fc-slot-disabled');
  4442. }
  4443. else {
  4444. if (meta.isToday) {
  4445. classNames.push('fc-slot-today');
  4446. classNames.push(theme.getClass('today'));
  4447. }
  4448. if (meta.isPast) {
  4449. classNames.push('fc-slot-past');
  4450. }
  4451. if (meta.isFuture) {
  4452. classNames.push('fc-slot-future');
  4453. }
  4454. }
  4455. return classNames;
  4456. }
  4457. function buildNavLinkData(date, type) {
  4458. if (type === void 0) { type = 'day'; }
  4459. return JSON.stringify({
  4460. date: formatDayString(date),
  4461. type: type
  4462. });
  4463. }
  4464. var _isRtlScrollbarOnLeft = null;
  4465. function getIsRtlScrollbarOnLeft() {
  4466. if (_isRtlScrollbarOnLeft === null) {
  4467. _isRtlScrollbarOnLeft = computeIsRtlScrollbarOnLeft();
  4468. }
  4469. return _isRtlScrollbarOnLeft;
  4470. }
  4471. function computeIsRtlScrollbarOnLeft() {
  4472. // TODO: use htmlToElement
  4473. var outerEl = document.createElement('div');
  4474. applyStyle(outerEl, {
  4475. position: 'absolute',
  4476. top: -1000,
  4477. left: 0,
  4478. border: 0,
  4479. padding: 0,
  4480. overflow: 'scroll',
  4481. direction: 'rtl'
  4482. });
  4483. outerEl.innerHTML = '<div></div>';
  4484. document.body.appendChild(outerEl);
  4485. var innerEl = outerEl.firstChild;
  4486. var res = innerEl.getBoundingClientRect().left > outerEl.getBoundingClientRect().left;
  4487. removeElement(outerEl);
  4488. return res;
  4489. }
  4490. var _scrollbarWidths;
  4491. function getScrollbarWidths() {
  4492. if (!_scrollbarWidths) {
  4493. _scrollbarWidths = computeScrollbarWidths();
  4494. }
  4495. return _scrollbarWidths;
  4496. }
  4497. function computeScrollbarWidths() {
  4498. var el = document.createElement('div');
  4499. el.style.overflow = 'scroll';
  4500. document.body.appendChild(el);
  4501. var res = computeScrollbarWidthsForEl(el);
  4502. document.body.removeChild(el);
  4503. return res;
  4504. }
  4505. // WARNING: will include border
  4506. function computeScrollbarWidthsForEl(el) {
  4507. return {
  4508. x: el.offsetHeight - el.clientHeight,
  4509. y: el.offsetWidth - el.clientWidth
  4510. };
  4511. }
  4512. function computeEdges(el, getPadding) {
  4513. if (getPadding === void 0) { getPadding = false; }
  4514. var computedStyle = window.getComputedStyle(el);
  4515. var borderLeft = parseInt(computedStyle.borderLeftWidth, 10) || 0;
  4516. var borderRight = parseInt(computedStyle.borderRightWidth, 10) || 0;
  4517. var borderTop = parseInt(computedStyle.borderTopWidth, 10) || 0;
  4518. var borderBottom = parseInt(computedStyle.borderBottomWidth, 10) || 0;
  4519. var badScrollbarWidths = computeScrollbarWidthsForEl(el); // includes border!
  4520. var scrollbarLeftRight = badScrollbarWidths.y - borderLeft - borderRight;
  4521. var scrollbarBottom = badScrollbarWidths.x - borderTop - borderBottom;
  4522. var res = {
  4523. borderLeft: borderLeft,
  4524. borderRight: borderRight,
  4525. borderTop: borderTop,
  4526. borderBottom: borderBottom,
  4527. scrollbarBottom: scrollbarBottom,
  4528. scrollbarLeft: 0,
  4529. scrollbarRight: 0
  4530. };
  4531. if (getIsRtlScrollbarOnLeft() && computedStyle.direction === 'rtl') { // is the scrollbar on the left side?
  4532. res.scrollbarLeft = scrollbarLeftRight;
  4533. }
  4534. else {
  4535. res.scrollbarRight = scrollbarLeftRight;
  4536. }
  4537. if (getPadding) {
  4538. res.paddingLeft = parseInt(computedStyle.paddingLeft, 10) || 0;
  4539. res.paddingRight = parseInt(computedStyle.paddingRight, 10) || 0;
  4540. res.paddingTop = parseInt(computedStyle.paddingTop, 10) || 0;
  4541. res.paddingBottom = parseInt(computedStyle.paddingBottom, 10) || 0;
  4542. }
  4543. return res;
  4544. }
  4545. function computeInnerRect(el, goWithinPadding, doFromWindowViewport) {
  4546. if (goWithinPadding === void 0) { goWithinPadding = false; }
  4547. var outerRect = doFromWindowViewport ? el.getBoundingClientRect() : computeRect(el);
  4548. var edges = computeEdges(el, goWithinPadding);
  4549. var res = {
  4550. left: outerRect.left + edges.borderLeft + edges.scrollbarLeft,
  4551. right: outerRect.right - edges.borderRight - edges.scrollbarRight,
  4552. top: outerRect.top + edges.borderTop,
  4553. bottom: outerRect.bottom - edges.borderBottom - edges.scrollbarBottom
  4554. };
  4555. if (goWithinPadding) {
  4556. res.left += edges.paddingLeft;
  4557. res.right -= edges.paddingRight;
  4558. res.top += edges.paddingTop;
  4559. res.bottom -= edges.paddingBottom;
  4560. }
  4561. return res;
  4562. }
  4563. function computeRect(el) {
  4564. var rect = el.getBoundingClientRect();
  4565. return {
  4566. left: rect.left + window.pageXOffset,
  4567. top: rect.top + window.pageYOffset,
  4568. right: rect.right + window.pageXOffset,
  4569. bottom: rect.bottom + window.pageYOffset
  4570. };
  4571. }
  4572. function computeHeightAndMargins(el) {
  4573. return el.getBoundingClientRect().height + computeVMargins(el);
  4574. }
  4575. function computeVMargins(el) {
  4576. var computed = window.getComputedStyle(el);
  4577. return parseInt(computed.marginTop, 10) +
  4578. parseInt(computed.marginBottom, 10);
  4579. }
  4580. // does not return window
  4581. function getClippingParents(el) {
  4582. var parents = [];
  4583. while (el instanceof HTMLElement) { // will stop when gets to document or null
  4584. var computedStyle = window.getComputedStyle(el);
  4585. if (computedStyle.position === 'fixed') {
  4586. break;
  4587. }
  4588. if ((/(auto|scroll)/).test(computedStyle.overflow + computedStyle.overflowY + computedStyle.overflowX)) {
  4589. parents.push(el);
  4590. }
  4591. el = el.parentNode;
  4592. }
  4593. return parents;
  4594. }
  4595. // given a function that resolves a result asynchronously.
  4596. // the function can either call passed-in success and failure callbacks,
  4597. // or it can return a promise.
  4598. // if you need to pass additional params to func, bind them first.
  4599. function unpromisify(func, success, failure) {
  4600. // guard against success/failure callbacks being called more than once
  4601. // and guard against a promise AND callback being used together.
  4602. var isResolved = false;
  4603. var wrappedSuccess = function () {
  4604. if (!isResolved) {
  4605. isResolved = true;
  4606. success.apply(this, arguments);
  4607. }
  4608. };
  4609. var wrappedFailure = function () {
  4610. if (!isResolved) {
  4611. isResolved = true;
  4612. if (failure) {
  4613. failure.apply(this, arguments);
  4614. }
  4615. }
  4616. };
  4617. var res = func(wrappedSuccess, wrappedFailure);
  4618. if (res && typeof res.then === 'function') {
  4619. res.then(wrappedSuccess, wrappedFailure);
  4620. }
  4621. }
  4622. var Emitter = /** @class */ (function () {
  4623. function Emitter() {
  4624. this.handlers = {};
  4625. this.thisContext = null;
  4626. }
  4627. Emitter.prototype.setThisContext = function (thisContext) {
  4628. this.thisContext = thisContext;
  4629. };
  4630. Emitter.prototype.setOptions = function (options) {
  4631. this.options = options;
  4632. };
  4633. Emitter.prototype.on = function (type, handler) {
  4634. addToHash(this.handlers, type, handler);
  4635. };
  4636. Emitter.prototype.off = function (type, handler) {
  4637. removeFromHash(this.handlers, type, handler);
  4638. };
  4639. Emitter.prototype.trigger = function (type) {
  4640. var args = [];
  4641. for (var _i = 1; _i < arguments.length; _i++) {
  4642. args[_i - 1] = arguments[_i];
  4643. }
  4644. var attachedHandlers = this.handlers[type] || [];
  4645. var optionHandler = this.options && this.options[type];
  4646. var handlers = [].concat(optionHandler || [], attachedHandlers);
  4647. for (var _a = 0, handlers_1 = handlers; _a < handlers_1.length; _a++) {
  4648. var handler = handlers_1[_a];
  4649. handler.apply(this.thisContext, args);
  4650. }
  4651. };
  4652. Emitter.prototype.hasHandlers = function (type) {
  4653. return (this.handlers[type] && this.handlers[type].length) ||
  4654. (this.options && this.options[type]);
  4655. };
  4656. return Emitter;
  4657. }());
  4658. function addToHash(hash, type, handler) {
  4659. (hash[type] || (hash[type] = []))
  4660. .push(handler);
  4661. }
  4662. function removeFromHash(hash, type, handler) {
  4663. if (handler) {
  4664. if (hash[type]) {
  4665. hash[type] = hash[type].filter(function (func) {
  4666. return func !== handler;
  4667. });
  4668. }
  4669. }
  4670. else {
  4671. delete hash[type]; // remove all handler funcs for this type
  4672. }
  4673. }
  4674. /*
  4675. Records offset information for a set of elements, relative to an origin element.
  4676. Can record the left/right OR the top/bottom OR both.
  4677. Provides methods for querying the cache by position.
  4678. */
  4679. var PositionCache = /** @class */ (function () {
  4680. function PositionCache(originEl, els, isHorizontal, isVertical) {
  4681. this.els = els;
  4682. var originClientRect = this.originClientRect = originEl.getBoundingClientRect(); // relative to viewport top-left
  4683. if (isHorizontal) {
  4684. this.buildElHorizontals(originClientRect.left);
  4685. }
  4686. if (isVertical) {
  4687. this.buildElVerticals(originClientRect.top);
  4688. }
  4689. }
  4690. // Populates the left/right internal coordinate arrays
  4691. PositionCache.prototype.buildElHorizontals = function (originClientLeft) {
  4692. var lefts = [];
  4693. var rights = [];
  4694. for (var _i = 0, _a = this.els; _i < _a.length; _i++) {
  4695. var el = _a[_i];
  4696. var rect = el.getBoundingClientRect();
  4697. lefts.push(rect.left - originClientLeft);
  4698. rights.push(rect.right - originClientLeft);
  4699. }
  4700. this.lefts = lefts;
  4701. this.rights = rights;
  4702. };
  4703. // Populates the top/bottom internal coordinate arrays
  4704. PositionCache.prototype.buildElVerticals = function (originClientTop) {
  4705. var tops = [];
  4706. var bottoms = [];
  4707. for (var _i = 0, _a = this.els; _i < _a.length; _i++) {
  4708. var el = _a[_i];
  4709. var rect = el.getBoundingClientRect();
  4710. tops.push(rect.top - originClientTop);
  4711. bottoms.push(rect.bottom - originClientTop);
  4712. }
  4713. this.tops = tops;
  4714. this.bottoms = bottoms;
  4715. };
  4716. // Given a left offset (from document left), returns the index of the el that it horizontally intersects.
  4717. // If no intersection is made, returns undefined.
  4718. PositionCache.prototype.leftToIndex = function (leftPosition) {
  4719. var lefts = this.lefts;
  4720. var rights = this.rights;
  4721. var len = lefts.length;
  4722. var i;
  4723. for (i = 0; i < len; i++) {
  4724. if (leftPosition >= lefts[i] && leftPosition < rights[i]) {
  4725. return i;
  4726. }
  4727. }
  4728. };
  4729. // Given a top offset (from document top), returns the index of the el that it vertically intersects.
  4730. // If no intersection is made, returns undefined.
  4731. PositionCache.prototype.topToIndex = function (topPosition) {
  4732. var tops = this.tops;
  4733. var bottoms = this.bottoms;
  4734. var len = tops.length;
  4735. var i;
  4736. for (i = 0; i < len; i++) {
  4737. if (topPosition >= tops[i] && topPosition < bottoms[i]) {
  4738. return i;
  4739. }
  4740. }
  4741. };
  4742. // Gets the width of the element at the given index
  4743. PositionCache.prototype.getWidth = function (leftIndex) {
  4744. return this.rights[leftIndex] - this.lefts[leftIndex];
  4745. };
  4746. // Gets the height of the element at the given index
  4747. PositionCache.prototype.getHeight = function (topIndex) {
  4748. return this.bottoms[topIndex] - this.tops[topIndex];
  4749. };
  4750. return PositionCache;
  4751. }());
  4752. /*
  4753. An object for getting/setting scroll-related information for an element.
  4754. Internally, this is done very differently for window versus DOM element,
  4755. so this object serves as a common interface.
  4756. */
  4757. var ScrollController = /** @class */ (function () {
  4758. function ScrollController() {
  4759. }
  4760. ScrollController.prototype.getMaxScrollTop = function () {
  4761. return this.getScrollHeight() - this.getClientHeight();
  4762. };
  4763. ScrollController.prototype.getMaxScrollLeft = function () {
  4764. return this.getScrollWidth() - this.getClientWidth();
  4765. };
  4766. ScrollController.prototype.canScrollVertically = function () {
  4767. return this.getMaxScrollTop() > 0;
  4768. };
  4769. ScrollController.prototype.canScrollHorizontally = function () {
  4770. return this.getMaxScrollLeft() > 0;
  4771. };
  4772. ScrollController.prototype.canScrollUp = function () {
  4773. return this.getScrollTop() > 0;
  4774. };
  4775. ScrollController.prototype.canScrollDown = function () {
  4776. return this.getScrollTop() < this.getMaxScrollTop();
  4777. };
  4778. ScrollController.prototype.canScrollLeft = function () {
  4779. return this.getScrollLeft() > 0;
  4780. };
  4781. ScrollController.prototype.canScrollRight = function () {
  4782. return this.getScrollLeft() < this.getMaxScrollLeft();
  4783. };
  4784. return ScrollController;
  4785. }());
  4786. var ElementScrollController = /** @class */ (function (_super) {
  4787. __extends(ElementScrollController, _super);
  4788. function ElementScrollController(el) {
  4789. var _this = _super.call(this) || this;
  4790. _this.el = el;
  4791. return _this;
  4792. }
  4793. ElementScrollController.prototype.getScrollTop = function () {
  4794. return this.el.scrollTop;
  4795. };
  4796. ElementScrollController.prototype.getScrollLeft = function () {
  4797. return this.el.scrollLeft;
  4798. };
  4799. ElementScrollController.prototype.setScrollTop = function (top) {
  4800. this.el.scrollTop = top;
  4801. };
  4802. ElementScrollController.prototype.setScrollLeft = function (left) {
  4803. this.el.scrollLeft = left;
  4804. };
  4805. ElementScrollController.prototype.getScrollWidth = function () {
  4806. return this.el.scrollWidth;
  4807. };
  4808. ElementScrollController.prototype.getScrollHeight = function () {
  4809. return this.el.scrollHeight;
  4810. };
  4811. ElementScrollController.prototype.getClientHeight = function () {
  4812. return this.el.clientHeight;
  4813. };
  4814. ElementScrollController.prototype.getClientWidth = function () {
  4815. return this.el.clientWidth;
  4816. };
  4817. return ElementScrollController;
  4818. }(ScrollController));
  4819. var WindowScrollController = /** @class */ (function (_super) {
  4820. __extends(WindowScrollController, _super);
  4821. function WindowScrollController() {
  4822. return _super !== null && _super.apply(this, arguments) || this;
  4823. }
  4824. WindowScrollController.prototype.getScrollTop = function () {
  4825. return window.pageYOffset;
  4826. };
  4827. WindowScrollController.prototype.getScrollLeft = function () {
  4828. return window.pageXOffset;
  4829. };
  4830. WindowScrollController.prototype.setScrollTop = function (n) {
  4831. window.scroll(window.pageXOffset, n);
  4832. };
  4833. WindowScrollController.prototype.setScrollLeft = function (n) {
  4834. window.scroll(n, window.pageYOffset);
  4835. };
  4836. WindowScrollController.prototype.getScrollWidth = function () {
  4837. return document.documentElement.scrollWidth;
  4838. };
  4839. WindowScrollController.prototype.getScrollHeight = function () {
  4840. return document.documentElement.scrollHeight;
  4841. };
  4842. WindowScrollController.prototype.getClientHeight = function () {
  4843. return document.documentElement.clientHeight;
  4844. };
  4845. WindowScrollController.prototype.getClientWidth = function () {
  4846. return document.documentElement.clientWidth;
  4847. };
  4848. return WindowScrollController;
  4849. }(ScrollController));
  4850. var Theme = /** @class */ (function () {
  4851. function Theme(calendarOptions) {
  4852. if (this.iconOverrideOption) {
  4853. this.setIconOverride(calendarOptions[this.iconOverrideOption]);
  4854. }
  4855. }
  4856. Theme.prototype.setIconOverride = function (iconOverrideHash) {
  4857. var iconClassesCopy;
  4858. var buttonName;
  4859. if (typeof iconOverrideHash === 'object' && iconOverrideHash) { // non-null object
  4860. iconClassesCopy = __assign({}, this.iconClasses);
  4861. for (buttonName in iconOverrideHash) {
  4862. iconClassesCopy[buttonName] = this.applyIconOverridePrefix(iconOverrideHash[buttonName]);
  4863. }
  4864. this.iconClasses = iconClassesCopy;
  4865. }
  4866. else if (iconOverrideHash === false) {
  4867. this.iconClasses = {};
  4868. }
  4869. };
  4870. Theme.prototype.applyIconOverridePrefix = function (className) {
  4871. var prefix = this.iconOverridePrefix;
  4872. if (prefix && className.indexOf(prefix) !== 0) { // if not already present
  4873. className = prefix + className;
  4874. }
  4875. return className;
  4876. };
  4877. Theme.prototype.getClass = function (key) {
  4878. return this.classes[key] || '';
  4879. };
  4880. Theme.prototype.getIconClass = function (buttonName, isRtl) {
  4881. var className;
  4882. if (isRtl && this.rtlIconClasses) {
  4883. className = this.rtlIconClasses[buttonName] || this.iconClasses[buttonName];
  4884. }
  4885. else {
  4886. className = this.iconClasses[buttonName];
  4887. }
  4888. if (className) {
  4889. return this.baseIconClass + ' ' + className;
  4890. }
  4891. return '';
  4892. };
  4893. Theme.prototype.getCustomButtonIconClass = function (customButtonProps) {
  4894. var className;
  4895. if (this.iconOverrideCustomButtonOption) {
  4896. className = customButtonProps[this.iconOverrideCustomButtonOption];
  4897. if (className) {
  4898. return this.baseIconClass + ' ' + this.applyIconOverridePrefix(className);
  4899. }
  4900. }
  4901. return '';
  4902. };
  4903. return Theme;
  4904. }());
  4905. Theme.prototype.classes = {};
  4906. Theme.prototype.iconClasses = {};
  4907. Theme.prototype.baseIconClass = '';
  4908. Theme.prototype.iconOverridePrefix = '';
  4909. /// <reference types="@fullcalendar/core-vdom" />
  4910. if (typeof FullCalendarVDom === 'undefined') {
  4911. throw new Error('Please import the top-level fullcalendar lib before attempting to import a plugin.');
  4912. }
  4913. var Component = FullCalendarVDom.Component;
  4914. var createElement = FullCalendarVDom.createElement;
  4915. var render = FullCalendarVDom.render;
  4916. var createRef = FullCalendarVDom.createRef;
  4917. var Fragment = FullCalendarVDom.Fragment;
  4918. var createContext$1 = FullCalendarVDom.createContext;
  4919. var flushToDom$1 = FullCalendarVDom.flushToDom;
  4920. var ScrollResponder = /** @class */ (function () {
  4921. function ScrollResponder(execFunc, emitter, scrollTime) {
  4922. var _this = this;
  4923. this.execFunc = execFunc;
  4924. this.emitter = emitter;
  4925. this.scrollTime = scrollTime;
  4926. this.handleScrollRequest = function (request) {
  4927. _this.queuedRequest = __assign({}, _this.queuedRequest || {}, request);
  4928. _this.drain();
  4929. };
  4930. emitter.on('_scrollRequest', this.handleScrollRequest);
  4931. this.fireInitialScroll();
  4932. }
  4933. ScrollResponder.prototype.detach = function () {
  4934. this.emitter.off('_scrollRequest', this.handleScrollRequest);
  4935. };
  4936. ScrollResponder.prototype.update = function (isDatesNew) {
  4937. if (isDatesNew) {
  4938. this.fireInitialScroll(); // will drain
  4939. }
  4940. else {
  4941. this.drain();
  4942. }
  4943. };
  4944. ScrollResponder.prototype.fireInitialScroll = function () {
  4945. this.handleScrollRequest({
  4946. time: this.scrollTime
  4947. });
  4948. };
  4949. ScrollResponder.prototype.drain = function () {
  4950. if (this.queuedRequest && this.execFunc(this.queuedRequest)) {
  4951. this.queuedRequest = null;
  4952. }
  4953. };
  4954. return ScrollResponder;
  4955. }());
  4956. var ViewContextType = createContext$1({}); // for Components
  4957. function buildViewContext(viewSpec, viewApi, viewOptions, dateProfileGenerator, dateEnv, theme, pluginHooks, dispatch, getCurrentData, emitter, calendarApi, registerInteractiveComponent, unregisterInteractiveComponent) {
  4958. return {
  4959. dateEnv: dateEnv,
  4960. options: viewOptions,
  4961. pluginHooks: pluginHooks,
  4962. emitter: emitter,
  4963. dispatch: dispatch,
  4964. getCurrentData: getCurrentData,
  4965. calendarApi: calendarApi,
  4966. viewSpec: viewSpec,
  4967. viewApi: viewApi,
  4968. dateProfileGenerator: dateProfileGenerator,
  4969. theme: theme,
  4970. isRtl: viewOptions.direction === 'rtl',
  4971. addResizeHandler: function (handler) {
  4972. emitter.on('_resize', handler);
  4973. },
  4974. removeResizeHandler: function (handler) {
  4975. emitter.off('_resize', handler);
  4976. },
  4977. createScrollResponder: function (execFunc) {
  4978. return new ScrollResponder(execFunc, emitter, createDuration(viewOptions.scrollTime));
  4979. },
  4980. registerInteractiveComponent: registerInteractiveComponent,
  4981. unregisterInteractiveComponent: unregisterInteractiveComponent
  4982. };
  4983. }
  4984. var PureComponent = /** @class */ (function (_super) {
  4985. __extends(PureComponent, _super);
  4986. function PureComponent() {
  4987. return _super !== null && _super.apply(this, arguments) || this;
  4988. }
  4989. PureComponent.prototype.shouldComponentUpdate = function (nextProps, nextState) {
  4990. if (this.debug) {
  4991. console.log(getUnequalProps(nextProps, this.props), getUnequalProps(nextState, this.state));
  4992. }
  4993. return !compareObjs(this.props, nextProps, this.propEquality) ||
  4994. !compareObjs(this.state, nextState, this.stateEquality);
  4995. };
  4996. PureComponent.addPropsEquality = addPropsEquality;
  4997. PureComponent.addStateEquality = addStateEquality;
  4998. PureComponent.contextType = ViewContextType;
  4999. return PureComponent;
  5000. }(Component));
  5001. PureComponent.prototype.propEquality = {};
  5002. PureComponent.prototype.stateEquality = {};
  5003. var BaseComponent = /** @class */ (function (_super) {
  5004. __extends(BaseComponent, _super);
  5005. function BaseComponent() {
  5006. return _super !== null && _super.apply(this, arguments) || this;
  5007. }
  5008. BaseComponent.contextType = ViewContextType;
  5009. return BaseComponent;
  5010. }(PureComponent));
  5011. function addPropsEquality(propEquality) {
  5012. var hash = Object.create(this.prototype.propEquality);
  5013. __assign(hash, propEquality);
  5014. this.prototype.propEquality = hash;
  5015. }
  5016. function addStateEquality(stateEquality) {
  5017. var hash = Object.create(this.prototype.stateEquality);
  5018. __assign(hash, stateEquality);
  5019. this.prototype.stateEquality = hash;
  5020. }
  5021. // use other one
  5022. function setRef(ref, current) {
  5023. if (typeof ref === 'function') {
  5024. ref(current);
  5025. }
  5026. else if (ref) {
  5027. // see https://github.com/facebook/react/issues/13029
  5028. ref.current = current;
  5029. }
  5030. }
  5031. function reduceEventStore(eventStore, action, eventSources, dateProfile, context) {
  5032. switch (action.type) {
  5033. case 'RECEIVE_EVENTS': // raw
  5034. return receiveRawEvents(eventStore, eventSources[action.sourceId], action.fetchId, action.fetchRange, action.rawEvents, context);
  5035. case 'ADD_EVENTS': // already parsed, but not expanded
  5036. return addEvent(eventStore, action.eventStore, // new ones
  5037. dateProfile ? dateProfile.activeRange : null, context);
  5038. case 'MERGE_EVENTS': // already parsed and expanded
  5039. return mergeEventStores(eventStore, action.eventStore);
  5040. case 'PREV': // TODO: how do we track all actions that affect dateProfile :(
  5041. case 'NEXT':
  5042. case 'CHANGE_DATE':
  5043. case 'CHANGE_VIEW_TYPE':
  5044. if (dateProfile) {
  5045. return expandRecurring(eventStore, dateProfile.activeRange, context);
  5046. }
  5047. else {
  5048. return eventStore;
  5049. }
  5050. case 'REMOVE_EVENTS':
  5051. return excludeSubEventStore(eventStore, action.eventStore);
  5052. case 'REMOVE_EVENT_SOURCE':
  5053. return excludeEventsBySourceId(eventStore, action.sourceId);
  5054. case 'REMOVE_ALL_EVENT_SOURCES':
  5055. return filterEventStoreDefs(eventStore, function (eventDef) {
  5056. return !eventDef.sourceId; // only keep events with no source id
  5057. });
  5058. case 'REMOVE_ALL_EVENTS':
  5059. return createEmptyEventStore();
  5060. default:
  5061. return eventStore;
  5062. }
  5063. }
  5064. function receiveRawEvents(eventStore, eventSource, fetchId, fetchRange, rawEvents, context) {
  5065. if (eventSource && // not already removed
  5066. fetchId === eventSource.latestFetchId // TODO: wish this logic was always in event-sources
  5067. ) {
  5068. var subset = parseEvents(transformRawEvents(rawEvents, eventSource, context), eventSource, context);
  5069. if (fetchRange) {
  5070. subset = expandRecurring(subset, fetchRange, context);
  5071. }
  5072. return mergeEventStores(excludeEventsBySourceId(eventStore, eventSource.sourceId), subset);
  5073. }
  5074. return eventStore;
  5075. }
  5076. function transformRawEvents(rawEvents, eventSource, context) {
  5077. var calEachTransform = context.options.eventDataTransform;
  5078. var sourceEachTransform = eventSource ? eventSource.eventDataTransform : null;
  5079. if (sourceEachTransform) {
  5080. rawEvents = transformEachRawEvent(rawEvents, sourceEachTransform);
  5081. }
  5082. if (calEachTransform) {
  5083. rawEvents = transformEachRawEvent(rawEvents, calEachTransform);
  5084. }
  5085. return rawEvents;
  5086. }
  5087. function transformEachRawEvent(rawEvents, func) {
  5088. var refinedEvents;
  5089. if (!func) {
  5090. refinedEvents = rawEvents;
  5091. }
  5092. else {
  5093. refinedEvents = [];
  5094. for (var _i = 0, rawEvents_1 = rawEvents; _i < rawEvents_1.length; _i++) {
  5095. var rawEvent = rawEvents_1[_i];
  5096. var refinedEvent = func(rawEvent);
  5097. if (refinedEvent) {
  5098. refinedEvents.push(refinedEvent);
  5099. }
  5100. else if (refinedEvent == null) {
  5101. refinedEvents.push(rawEvent);
  5102. } // if a different falsy value, do nothing
  5103. }
  5104. }
  5105. return refinedEvents;
  5106. }
  5107. function addEvent(eventStore, subset, expandRange, context) {
  5108. if (expandRange) {
  5109. subset = expandRecurring(subset, expandRange, context);
  5110. }
  5111. return mergeEventStores(eventStore, subset);
  5112. }
  5113. function rezoneEventStoreDates(eventStore, oldDateEnv, newDateEnv) {
  5114. var defs = eventStore.defs;
  5115. var instances = mapHash(eventStore.instances, function (instance) {
  5116. var def = defs[instance.defId];
  5117. if (def.allDay || def.recurringDef) {
  5118. return instance; // isn't dependent on timezone
  5119. }
  5120. else {
  5121. return __assign(__assign({}, instance), { range: {
  5122. start: newDateEnv.createMarker(oldDateEnv.toDate(instance.range.start, instance.forcedStartTzo)),
  5123. end: newDateEnv.createMarker(oldDateEnv.toDate(instance.range.end, instance.forcedEndTzo))
  5124. }, forcedStartTzo: newDateEnv.canComputeOffset ? null : instance.forcedStartTzo, forcedEndTzo: newDateEnv.canComputeOffset ? null : instance.forcedEndTzo });
  5125. }
  5126. });
  5127. return { defs: defs, instances: instances };
  5128. }
  5129. function excludeEventsBySourceId(eventStore, sourceId) {
  5130. return filterEventStoreDefs(eventStore, function (eventDef) {
  5131. return eventDef.sourceId !== sourceId;
  5132. });
  5133. }
  5134. // QUESTION: why not just return instances? do a general object-property-exclusion util
  5135. function excludeInstances(eventStore, removals) {
  5136. return {
  5137. defs: eventStore.defs,
  5138. instances: filterHash(eventStore.instances, function (instance) {
  5139. return !removals[instance.instanceId];
  5140. })
  5141. };
  5142. }
  5143. // high-level segmenting-aware tester functions
  5144. // ------------------------------------------------------------------------------------------------------------------------
  5145. function isInteractionValid(interaction, context) {
  5146. return isNewPropsValid({ eventDrag: interaction }, context); // HACK: the eventDrag props is used for ALL interactions
  5147. }
  5148. function isDateSelectionValid(dateSelection, context) {
  5149. return isNewPropsValid({ dateSelection: dateSelection }, context);
  5150. }
  5151. function isNewPropsValid(newProps, context) {
  5152. var calendarState = context.getCurrentData();
  5153. var props = __assign({ businessHours: calendarState.businessHours, dateSelection: '', eventStore: calendarState.eventStore, eventUiBases: calendarState.eventUiBases, eventSelection: '', eventDrag: null, eventResize: null }, newProps);
  5154. return (context.pluginHooks.isPropsValid || isPropsValid)(props, context);
  5155. }
  5156. function isPropsValid(state, context, dateSpanMeta, filterConfig) {
  5157. if (dateSpanMeta === void 0) { dateSpanMeta = {}; }
  5158. if (state.eventDrag && !isInteractionPropsValid(state, context, dateSpanMeta, filterConfig)) {
  5159. return false;
  5160. }
  5161. if (state.dateSelection && !isDateSelectionPropsValid(state, context, dateSpanMeta, filterConfig)) {
  5162. return false;
  5163. }
  5164. return true;
  5165. }
  5166. // Moving Event Validation
  5167. // ------------------------------------------------------------------------------------------------------------------------
  5168. function isInteractionPropsValid(state, context, dateSpanMeta, filterConfig) {
  5169. var currentState = context.getCurrentData();
  5170. var interaction = state.eventDrag; // HACK: the eventDrag props is used for ALL interactions
  5171. var subjectEventStore = interaction.mutatedEvents;
  5172. var subjectDefs = subjectEventStore.defs;
  5173. var subjectInstances = subjectEventStore.instances;
  5174. var subjectConfigs = compileEventUis(subjectDefs, interaction.isEvent ?
  5175. state.eventUiBases :
  5176. { '': currentState.selectionConfig } // if not a real event, validate as a selection
  5177. );
  5178. if (filterConfig) {
  5179. subjectConfigs = mapHash(subjectConfigs, filterConfig);
  5180. }
  5181. var otherEventStore = excludeInstances(state.eventStore, interaction.affectedEvents.instances); // exclude the subject events. TODO: exclude defs too?
  5182. var otherDefs = otherEventStore.defs;
  5183. var otherInstances = otherEventStore.instances;
  5184. var otherConfigs = compileEventUis(otherDefs, state.eventUiBases);
  5185. for (var subjectInstanceId in subjectInstances) {
  5186. var subjectInstance = subjectInstances[subjectInstanceId];
  5187. var subjectRange = subjectInstance.range;
  5188. var subjectConfig = subjectConfigs[subjectInstance.defId];
  5189. var subjectDef = subjectDefs[subjectInstance.defId];
  5190. // constraint
  5191. if (!allConstraintsPass(subjectConfig.constraints, subjectRange, otherEventStore, state.businessHours, context)) {
  5192. return false;
  5193. }
  5194. // overlap
  5195. var eventOverlap = context.options.eventOverlap;
  5196. var eventOverlapFunc = typeof eventOverlap === 'function' ? eventOverlap : null;
  5197. for (var otherInstanceId in otherInstances) {
  5198. var otherInstance = otherInstances[otherInstanceId];
  5199. // intersect! evaluate
  5200. if (rangesIntersect(subjectRange, otherInstance.range)) {
  5201. var otherOverlap = otherConfigs[otherInstance.defId].overlap;
  5202. // consider the other event's overlap. only do this if the subject event is a "real" event
  5203. if (otherOverlap === false && interaction.isEvent) {
  5204. return false;
  5205. }
  5206. if (subjectConfig.overlap === false) {
  5207. return false;
  5208. }
  5209. if (eventOverlapFunc && !eventOverlapFunc(new EventApi(context, otherDefs[otherInstance.defId], otherInstance), // still event
  5210. new EventApi(context, subjectDef, subjectInstance) // moving event
  5211. )) {
  5212. return false;
  5213. }
  5214. }
  5215. }
  5216. // allow (a function)
  5217. var calendarEventStore = currentState.eventStore; // need global-to-calendar, not local to component (splittable)state
  5218. for (var _i = 0, _a = subjectConfig.allows; _i < _a.length; _i++) {
  5219. var subjectAllow = _a[_i];
  5220. var subjectDateSpan = __assign(__assign({}, dateSpanMeta), { range: subjectInstance.range, allDay: subjectDef.allDay });
  5221. var origDef = calendarEventStore.defs[subjectDef.defId];
  5222. var origInstance = calendarEventStore.instances[subjectInstanceId];
  5223. var eventApi = void 0;
  5224. if (origDef) { // was previously in the calendar
  5225. eventApi = new EventApi(context, origDef, origInstance);
  5226. }
  5227. else { // was an external event
  5228. eventApi = new EventApi(context, subjectDef); // no instance, because had no dates
  5229. }
  5230. if (!subjectAllow(buildDateSpanApiWithContext(subjectDateSpan, context), eventApi)) {
  5231. return false;
  5232. }
  5233. }
  5234. }
  5235. return true;
  5236. }
  5237. // Date Selection Validation
  5238. // ------------------------------------------------------------------------------------------------------------------------
  5239. function isDateSelectionPropsValid(state, context, dateSpanMeta, filterConfig) {
  5240. var relevantEventStore = state.eventStore;
  5241. var relevantDefs = relevantEventStore.defs;
  5242. var relevantInstances = relevantEventStore.instances;
  5243. var selection = state.dateSelection;
  5244. var selectionRange = selection.range;
  5245. var selectionConfig = context.getCurrentData().selectionConfig;
  5246. if (filterConfig) {
  5247. selectionConfig = filterConfig(selectionConfig);
  5248. }
  5249. // constraint
  5250. if (!allConstraintsPass(selectionConfig.constraints, selectionRange, relevantEventStore, state.businessHours, context)) {
  5251. return false;
  5252. }
  5253. // overlap
  5254. var selectOverlap = context.options.selectOverlap;
  5255. var selectOverlapFunc = typeof selectOverlap === 'function' ? selectOverlap : null;
  5256. for (var relevantInstanceId in relevantInstances) {
  5257. var relevantInstance = relevantInstances[relevantInstanceId];
  5258. // intersect! evaluate
  5259. if (rangesIntersect(selectionRange, relevantInstance.range)) {
  5260. if (selectionConfig.overlap === false) {
  5261. return false;
  5262. }
  5263. if (selectOverlapFunc && !selectOverlapFunc(new EventApi(context, relevantDefs[relevantInstance.defId], relevantInstance), null)) {
  5264. return false;
  5265. }
  5266. }
  5267. }
  5268. // allow (a function)
  5269. for (var _i = 0, _a = selectionConfig.allows; _i < _a.length; _i++) {
  5270. var selectionAllow = _a[_i];
  5271. var fullDateSpan = __assign(__assign({}, dateSpanMeta), selection);
  5272. if (!selectionAllow(buildDateSpanApiWithContext(fullDateSpan, context), null)) {
  5273. return false;
  5274. }
  5275. }
  5276. return true;
  5277. }
  5278. // Constraint Utils
  5279. // ------------------------------------------------------------------------------------------------------------------------
  5280. function allConstraintsPass(constraints, subjectRange, otherEventStore, businessHoursUnexpanded, context) {
  5281. for (var _i = 0, constraints_1 = constraints; _i < constraints_1.length; _i++) {
  5282. var constraint = constraints_1[_i];
  5283. if (!anyRangesContainRange(constraintToRanges(constraint, subjectRange, otherEventStore, businessHoursUnexpanded, context), subjectRange)) {
  5284. return false;
  5285. }
  5286. }
  5287. return true;
  5288. }
  5289. function constraintToRanges(constraint, subjectRange, // for expanding a recurring constraint, or expanding business hours
  5290. otherEventStore, // for if constraint is an even group ID
  5291. businessHoursUnexpanded, // for if constraint is 'businessHours'
  5292. context // for expanding businesshours
  5293. ) {
  5294. if (constraint === 'businessHours') {
  5295. return eventStoreToRanges(expandRecurring(businessHoursUnexpanded, subjectRange, context));
  5296. }
  5297. else if (typeof constraint === 'string') { // an group ID
  5298. return eventStoreToRanges(filterEventStoreDefs(otherEventStore, function (eventDef) {
  5299. return eventDef.groupId === constraint;
  5300. }));
  5301. }
  5302. else if (typeof constraint === 'object' && constraint) { // non-null object
  5303. return eventStoreToRanges(expandRecurring(constraint, subjectRange, context));
  5304. }
  5305. return []; // if it's false
  5306. }
  5307. // TODO: move to event-store file?
  5308. function eventStoreToRanges(eventStore) {
  5309. var instances = eventStore.instances;
  5310. var ranges = [];
  5311. for (var instanceId in instances) {
  5312. ranges.push(instances[instanceId].range);
  5313. }
  5314. return ranges;
  5315. }
  5316. // TODO: move to geom file?
  5317. function anyRangesContainRange(outerRanges, innerRange) {
  5318. for (var _i = 0, outerRanges_1 = outerRanges; _i < outerRanges_1.length; _i++) {
  5319. var outerRange = outerRanges_1[_i];
  5320. if (rangeContainsRange(outerRange, innerRange)) {
  5321. return true;
  5322. }
  5323. }
  5324. return false;
  5325. }
  5326. /*
  5327. an INTERACTABLE date component
  5328. PURPOSES:
  5329. - hook up to fg, fill, and mirror renderers
  5330. - interface for dragging and hits
  5331. */
  5332. var DateComponent = /** @class */ (function (_super) {
  5333. __extends(DateComponent, _super);
  5334. function DateComponent() {
  5335. var _this = _super !== null && _super.apply(this, arguments) || this;
  5336. _this.uid = guid();
  5337. return _this;
  5338. }
  5339. // Hit System
  5340. // -----------------------------------------------------------------------------------------------------------------
  5341. DateComponent.prototype.prepareHits = function () {
  5342. };
  5343. DateComponent.prototype.queryHit = function (positionLeft, positionTop, elWidth, elHeight) {
  5344. return null; // this should be abstract
  5345. };
  5346. // Validation
  5347. // -----------------------------------------------------------------------------------------------------------------
  5348. DateComponent.prototype.isInteractionValid = function (interaction) {
  5349. var dateProfile = this.props.dateProfile; // HACK
  5350. var instances = interaction.mutatedEvents.instances;
  5351. if (dateProfile) { // HACK for MorePopover
  5352. for (var instanceId in instances) {
  5353. if (!rangeContainsRange(dateProfile.validRange, instances[instanceId].range)) {
  5354. return false;
  5355. }
  5356. }
  5357. }
  5358. return isInteractionValid(interaction, this.context);
  5359. };
  5360. DateComponent.prototype.isDateSelectionValid = function (selection) {
  5361. var dateProfile = this.props.dateProfile; // HACK
  5362. if (dateProfile && // HACK for MorePopover
  5363. !rangeContainsRange(dateProfile.validRange, selection.range)) {
  5364. return false;
  5365. }
  5366. return isDateSelectionValid(selection, this.context);
  5367. };
  5368. // Pointer Interaction Utils
  5369. // -----------------------------------------------------------------------------------------------------------------
  5370. DateComponent.prototype.isValidSegDownEl = function (el) {
  5371. return !this.props.eventDrag && // HACK
  5372. !this.props.eventResize && // HACK
  5373. !elementClosest(el, '.fc-event-mirror') &&
  5374. (this.isPopover() || !this.isInPopover(el));
  5375. // ^above line ensures we don't detect a seg interaction within a nested component.
  5376. // it's a HACK because it only supports a popover as the nested component.
  5377. };
  5378. DateComponent.prototype.isValidDateDownEl = function (el) {
  5379. return !elementClosest(el, '.fc-event:not(.fc-bg-event)') &&
  5380. !elementClosest(el, '.fc-daygrid-more-link') && // a "more.." link
  5381. !elementClosest(el, 'a[data-navlink]') && // a clickable nav link
  5382. !this.isInPopover(el);
  5383. };
  5384. DateComponent.prototype.isPopover = function () {
  5385. return false;
  5386. };
  5387. DateComponent.prototype.isInPopover = function (el) {
  5388. return Boolean(elementClosest(el, '.fc-popover'));
  5389. };
  5390. return DateComponent;
  5391. }(BaseComponent));
  5392. // TODO: easier way to add new hooks? need to update a million things
  5393. function createPlugin(input) {
  5394. return {
  5395. id: guid(),
  5396. deps: input.deps || [],
  5397. reducers: input.reducers || [],
  5398. contextInit: [].concat(input.contextInit || []),
  5399. eventRefiners: input.eventRefiners || {},
  5400. eventDefMemberAdders: input.eventDefMemberAdders || [],
  5401. eventSourceRefiners: input.eventSourceRefiners || {},
  5402. isDraggableTransformers: input.isDraggableTransformers || [],
  5403. eventDragMutationMassagers: input.eventDragMutationMassagers || [],
  5404. eventDefMutationAppliers: input.eventDefMutationAppliers || [],
  5405. dateSelectionTransformers: input.dateSelectionTransformers || [],
  5406. datePointTransforms: input.datePointTransforms || [],
  5407. dateSpanTransforms: input.dateSpanTransforms || [],
  5408. views: input.views || {},
  5409. viewPropsTransformers: input.viewPropsTransformers || [],
  5410. isPropsValid: input.isPropsValid || null,
  5411. externalDefTransforms: input.externalDefTransforms || [],
  5412. eventResizeJoinTransforms: input.eventResizeJoinTransforms || [],
  5413. viewContainerAppends: input.viewContainerAppends || [],
  5414. eventDropTransformers: input.eventDropTransformers || [],
  5415. componentInteractions: input.componentInteractions || [],
  5416. calendarInteractions: input.calendarInteractions || [],
  5417. themeClasses: input.themeClasses || {},
  5418. eventSourceDefs: input.eventSourceDefs || [],
  5419. cmdFormatter: input.cmdFormatter,
  5420. recurringTypes: input.recurringTypes || [],
  5421. namedTimeZonedImpl: input.namedTimeZonedImpl,
  5422. initialView: input.initialView || '',
  5423. elementDraggingImpl: input.elementDraggingImpl,
  5424. optionChangeHandlers: input.optionChangeHandlers || {},
  5425. scrollGridImpl: input.scrollGridImpl || null,
  5426. contentTypeHandlers: input.contentTypeHandlers || {},
  5427. listenerRefiners: input.listenerRefiners || {},
  5428. optionRefiners: input.optionRefiners || {},
  5429. propSetHandlers: input.propSetHandlers || {}
  5430. };
  5431. }
  5432. function buildPluginHooks(pluginDefs, globalDefs) {
  5433. var isAdded = {};
  5434. var hooks = {
  5435. reducers: [],
  5436. contextInit: [],
  5437. eventRefiners: {},
  5438. eventDefMemberAdders: [],
  5439. eventSourceRefiners: {},
  5440. isDraggableTransformers: [],
  5441. eventDragMutationMassagers: [],
  5442. eventDefMutationAppliers: [],
  5443. dateSelectionTransformers: [],
  5444. datePointTransforms: [],
  5445. dateSpanTransforms: [],
  5446. views: {},
  5447. viewPropsTransformers: [],
  5448. isPropsValid: null,
  5449. externalDefTransforms: [],
  5450. eventResizeJoinTransforms: [],
  5451. viewContainerAppends: [],
  5452. eventDropTransformers: [],
  5453. componentInteractions: [],
  5454. calendarInteractions: [],
  5455. themeClasses: {},
  5456. eventSourceDefs: [],
  5457. cmdFormatter: null,
  5458. recurringTypes: [],
  5459. namedTimeZonedImpl: null,
  5460. initialView: '',
  5461. elementDraggingImpl: null,
  5462. optionChangeHandlers: {},
  5463. scrollGridImpl: null,
  5464. contentTypeHandlers: {},
  5465. listenerRefiners: {},
  5466. optionRefiners: {},
  5467. propSetHandlers: {}
  5468. };
  5469. function addDefs(defs) {
  5470. for (var _i = 0, defs_1 = defs; _i < defs_1.length; _i++) {
  5471. var def = defs_1[_i];
  5472. if (!isAdded[def.id]) {
  5473. isAdded[def.id] = true;
  5474. addDefs(def.deps);
  5475. hooks = combineHooks(hooks, def);
  5476. }
  5477. }
  5478. }
  5479. if (pluginDefs) {
  5480. addDefs(pluginDefs);
  5481. }
  5482. addDefs(globalDefs);
  5483. return hooks;
  5484. }
  5485. function buildBuildPluginHooks() {
  5486. var currentOverrideDefs = [];
  5487. var currentGlobalDefs = [];
  5488. var currentHooks;
  5489. return function (overrideDefs, globalDefs) {
  5490. if (!currentHooks || !isArraysEqual(overrideDefs, currentOverrideDefs) || !isArraysEqual(globalDefs, currentGlobalDefs)) {
  5491. currentHooks = buildPluginHooks(overrideDefs, globalDefs);
  5492. }
  5493. currentOverrideDefs = overrideDefs;
  5494. currentGlobalDefs = globalDefs;
  5495. return currentHooks;
  5496. };
  5497. }
  5498. function combineHooks(hooks0, hooks1) {
  5499. return {
  5500. reducers: hooks0.reducers.concat(hooks1.reducers),
  5501. contextInit: hooks0.contextInit.concat(hooks1.contextInit),
  5502. eventRefiners: __assign(__assign({}, hooks0.eventRefiners), hooks1.eventRefiners),
  5503. eventDefMemberAdders: hooks0.eventDefMemberAdders.concat(hooks1.eventDefMemberAdders),
  5504. eventSourceRefiners: __assign(__assign({}, hooks0.eventSourceRefiners), hooks1.eventSourceRefiners),
  5505. isDraggableTransformers: hooks0.isDraggableTransformers.concat(hooks1.isDraggableTransformers),
  5506. eventDragMutationMassagers: hooks0.eventDragMutationMassagers.concat(hooks1.eventDragMutationMassagers),
  5507. eventDefMutationAppliers: hooks0.eventDefMutationAppliers.concat(hooks1.eventDefMutationAppliers),
  5508. dateSelectionTransformers: hooks0.dateSelectionTransformers.concat(hooks1.dateSelectionTransformers),
  5509. datePointTransforms: hooks0.datePointTransforms.concat(hooks1.datePointTransforms),
  5510. dateSpanTransforms: hooks0.dateSpanTransforms.concat(hooks1.dateSpanTransforms),
  5511. views: __assign(__assign({}, hooks0.views), hooks1.views),
  5512. viewPropsTransformers: hooks0.viewPropsTransformers.concat(hooks1.viewPropsTransformers),
  5513. isPropsValid: hooks1.isPropsValid || hooks0.isPropsValid,
  5514. externalDefTransforms: hooks0.externalDefTransforms.concat(hooks1.externalDefTransforms),
  5515. eventResizeJoinTransforms: hooks0.eventResizeJoinTransforms.concat(hooks1.eventResizeJoinTransforms),
  5516. viewContainerAppends: hooks0.viewContainerAppends.concat(hooks1.viewContainerAppends),
  5517. eventDropTransformers: hooks0.eventDropTransformers.concat(hooks1.eventDropTransformers),
  5518. calendarInteractions: hooks0.calendarInteractions.concat(hooks1.calendarInteractions),
  5519. componentInteractions: hooks0.componentInteractions.concat(hooks1.componentInteractions),
  5520. themeClasses: __assign(__assign({}, hooks0.themeClasses), hooks1.themeClasses),
  5521. eventSourceDefs: hooks0.eventSourceDefs.concat(hooks1.eventSourceDefs),
  5522. cmdFormatter: hooks1.cmdFormatter || hooks0.cmdFormatter,
  5523. recurringTypes: hooks0.recurringTypes.concat(hooks1.recurringTypes),
  5524. namedTimeZonedImpl: hooks1.namedTimeZonedImpl || hooks0.namedTimeZonedImpl,
  5525. initialView: hooks0.initialView || hooks1.initialView,
  5526. elementDraggingImpl: hooks0.elementDraggingImpl || hooks1.elementDraggingImpl,
  5527. optionChangeHandlers: __assign(__assign({}, hooks0.optionChangeHandlers), hooks1.optionChangeHandlers),
  5528. scrollGridImpl: hooks1.scrollGridImpl || hooks0.scrollGridImpl,
  5529. contentTypeHandlers: __assign(__assign({}, hooks0.contentTypeHandlers), hooks1.contentTypeHandlers),
  5530. listenerRefiners: __assign(__assign({}, hooks0.listenerRefiners), hooks1.listenerRefiners),
  5531. optionRefiners: __assign(__assign({}, hooks0.optionRefiners), hooks1.optionRefiners),
  5532. propSetHandlers: __assign(__assign({}, hooks0.propSetHandlers), hooks1.propSetHandlers)
  5533. };
  5534. }
  5535. var StandardTheme = /** @class */ (function (_super) {
  5536. __extends(StandardTheme, _super);
  5537. function StandardTheme() {
  5538. return _super !== null && _super.apply(this, arguments) || this;
  5539. }
  5540. return StandardTheme;
  5541. }(Theme));
  5542. StandardTheme.prototype.classes = {
  5543. root: 'fc-theme-standard',
  5544. tableCellShaded: 'fc-cell-shaded',
  5545. buttonGroup: 'fc-button-group',
  5546. button: 'fc-button fc-button-primary',
  5547. buttonActive: 'fc-button-active'
  5548. };
  5549. StandardTheme.prototype.baseIconClass = 'fc-icon';
  5550. StandardTheme.prototype.iconClasses = {
  5551. close: 'fc-icon-x',
  5552. prev: 'fc-icon-chevron-left',
  5553. next: 'fc-icon-chevron-right',
  5554. prevYear: 'fc-icon-chevrons-left',
  5555. nextYear: 'fc-icon-chevrons-right'
  5556. };
  5557. StandardTheme.prototype.rtlIconClasses = {
  5558. prev: 'fc-icon-chevron-right',
  5559. next: 'fc-icon-chevron-left',
  5560. prevYear: 'fc-icon-chevrons-right',
  5561. nextYear: 'fc-icon-chevrons-left'
  5562. };
  5563. StandardTheme.prototype.iconOverrideOption = 'buttonIcons'; // TODO: make TS-friendly
  5564. StandardTheme.prototype.iconOverrideCustomButtonOption = 'icon';
  5565. StandardTheme.prototype.iconOverridePrefix = 'fc-icon-';
  5566. function compileViewDefs(defaultConfigs, overrideConfigs) {
  5567. var hash = {};
  5568. var viewType;
  5569. for (viewType in defaultConfigs) {
  5570. ensureViewDef(viewType, hash, defaultConfigs, overrideConfigs);
  5571. }
  5572. for (viewType in overrideConfigs) {
  5573. ensureViewDef(viewType, hash, defaultConfigs, overrideConfigs);
  5574. }
  5575. return hash;
  5576. }
  5577. function ensureViewDef(viewType, hash, defaultConfigs, overrideConfigs) {
  5578. if (hash[viewType]) {
  5579. return hash[viewType];
  5580. }
  5581. var viewDef = buildViewDef(viewType, hash, defaultConfigs, overrideConfigs);
  5582. if (viewDef) {
  5583. hash[viewType] = viewDef;
  5584. }
  5585. return viewDef;
  5586. }
  5587. function buildViewDef(viewType, hash, defaultConfigs, overrideConfigs) {
  5588. var defaultConfig = defaultConfigs[viewType];
  5589. var overrideConfig = overrideConfigs[viewType];
  5590. var queryProp = function (name) {
  5591. return (defaultConfig && defaultConfig[name] !== null) ? defaultConfig[name] :
  5592. ((overrideConfig && overrideConfig[name] !== null) ? overrideConfig[name] : null);
  5593. };
  5594. var theComponent = queryProp('component');
  5595. var superType = queryProp('superType');
  5596. var superDef = null;
  5597. if (superType) {
  5598. if (superType === viewType) {
  5599. throw new Error('Can\'t have a custom view type that references itself');
  5600. }
  5601. superDef = ensureViewDef(superType, hash, defaultConfigs, overrideConfigs);
  5602. }
  5603. if (!theComponent && superDef) {
  5604. theComponent = superDef.component;
  5605. }
  5606. if (!theComponent) {
  5607. return null; // don't throw a warning, might be settings for a single-unit view
  5608. }
  5609. return {
  5610. type: viewType,
  5611. component: theComponent,
  5612. defaults: __assign(__assign({}, (superDef ? superDef.defaults : {})), (defaultConfig ? defaultConfig.rawOptions : {})),
  5613. overrides: __assign(__assign({}, (superDef ? superDef.overrides : {})), (overrideConfig ? overrideConfig.rawOptions : {}))
  5614. };
  5615. }
  5616. // NOTE: in JSX, you should always use this class with <HookProps> arg. otherwise, will default to any???
  5617. var RenderHook = /** @class */ (function (_super) {
  5618. __extends(RenderHook, _super);
  5619. function RenderHook() {
  5620. var _this = _super !== null && _super.apply(this, arguments) || this;
  5621. _this.rootElRef = createRef();
  5622. _this.handleRootEl = function (el) {
  5623. setRef(_this.rootElRef, el);
  5624. if (_this.props.elRef) {
  5625. setRef(_this.props.elRef, el);
  5626. }
  5627. };
  5628. return _this;
  5629. }
  5630. RenderHook.prototype.render = function () {
  5631. var _this = this;
  5632. var props = this.props;
  5633. var hookProps = props.hookProps;
  5634. return (createElement(MountHook, { hookProps: hookProps, didMount: props.didMount, willUnmount: props.willUnmount, elRef: this.handleRootEl }, function (rootElRef) { return (createElement(ContentHook, { hookProps: hookProps, content: props.content, defaultContent: props.defaultContent, backupElRef: _this.rootElRef }, function (innerElRef, innerContent) { return props.children(rootElRef, normalizeClassNames(props.classNames, hookProps), innerElRef, innerContent); })); }));
  5635. };
  5636. return RenderHook;
  5637. }(BaseComponent));
  5638. // for forcing rerender of components that use the ContentHook
  5639. var CustomContentRenderContext = createContext$1(0);
  5640. var ContentHook = /** @class */ (function (_super) {
  5641. __extends(ContentHook, _super);
  5642. function ContentHook() {
  5643. var _this = _super !== null && _super.apply(this, arguments) || this;
  5644. _this.innerElRef = createRef();
  5645. return _this;
  5646. }
  5647. ContentHook.prototype.render = function () {
  5648. var _this = this;
  5649. return (createElement(CustomContentRenderContext.Consumer, null, function () { return (_this.props.children(_this.innerElRef, _this.renderInnerContent())); }));
  5650. };
  5651. ContentHook.prototype.componentDidMount = function () {
  5652. this.updateCustomContent();
  5653. };
  5654. ContentHook.prototype.componentDidUpdate = function () {
  5655. this.updateCustomContent();
  5656. };
  5657. ContentHook.prototype.renderInnerContent = function () {
  5658. var contentTypeHandlers = this.context.pluginHooks.contentTypeHandlers;
  5659. var _a = this, props = _a.props, customContentInfo = _a.customContentInfo;
  5660. var rawVal = props.content;
  5661. var innerContent = normalizeContent(rawVal, props.hookProps);
  5662. var innerContentVDom = null;
  5663. if (innerContent === undefined) { // use the default
  5664. innerContent = normalizeContent(props.defaultContent, props.hookProps);
  5665. }
  5666. if (innerContent !== undefined) { // we allow custom content handlers to return nothing
  5667. if (customContentInfo) {
  5668. customContentInfo.contentVal = innerContent[customContentInfo.contentKey];
  5669. }
  5670. else if (typeof innerContent === 'object') {
  5671. // look for a prop that would indicate a custom content handler is needed
  5672. for (var contentKey in contentTypeHandlers) {
  5673. if (innerContent[contentKey] !== undefined) {
  5674. customContentInfo = this.customContentInfo = {
  5675. contentKey: contentKey,
  5676. contentVal: innerContent[contentKey],
  5677. handler: contentTypeHandlers[contentKey]()
  5678. };
  5679. break;
  5680. }
  5681. }
  5682. }
  5683. if (customContentInfo) {
  5684. innerContentVDom = []; // signal that something was specified
  5685. }
  5686. else {
  5687. innerContentVDom = innerContent; // assume a [p]react vdom node. use it
  5688. }
  5689. }
  5690. return innerContentVDom;
  5691. };
  5692. ContentHook.prototype.updateCustomContent = function () {
  5693. if (this.customContentInfo) {
  5694. this.customContentInfo.handler(this.innerElRef.current || this.props.backupElRef.current, // the element to render into
  5695. this.customContentInfo.contentVal);
  5696. }
  5697. };
  5698. return ContentHook;
  5699. }(BaseComponent));
  5700. var MountHook = /** @class */ (function (_super) {
  5701. __extends(MountHook, _super);
  5702. function MountHook() {
  5703. var _this = _super !== null && _super.apply(this, arguments) || this;
  5704. _this.handleRootEl = function (rootEl) {
  5705. _this.rootEl = rootEl;
  5706. if (_this.props.elRef) {
  5707. setRef(_this.props.elRef, rootEl);
  5708. }
  5709. };
  5710. return _this;
  5711. }
  5712. MountHook.prototype.render = function () {
  5713. return this.props.children(this.handleRootEl);
  5714. };
  5715. MountHook.prototype.componentDidMount = function () {
  5716. var callback = this.props.didMount;
  5717. callback && callback(__assign(__assign({}, this.props.hookProps), { el: this.rootEl }));
  5718. };
  5719. MountHook.prototype.componentWillUnmount = function () {
  5720. var callback = this.props.willUnmount;
  5721. callback && callback(__assign(__assign({}, this.props.hookProps), { el: this.rootEl }));
  5722. };
  5723. return MountHook;
  5724. }(BaseComponent));
  5725. function buildClassNameNormalizer() {
  5726. var currentGenerator;
  5727. var currentHookProps;
  5728. var currentClassNames = [];
  5729. return function (generator, hookProps) {
  5730. if (!currentHookProps || !isPropsEqual(currentHookProps, hookProps) || generator !== currentGenerator) {
  5731. currentGenerator = generator;
  5732. currentHookProps = hookProps;
  5733. currentClassNames = normalizeClassNames(generator, hookProps);
  5734. }
  5735. return currentClassNames;
  5736. };
  5737. }
  5738. function normalizeClassNames(classNames, hookProps) {
  5739. if (typeof classNames === 'function') {
  5740. classNames = classNames(hookProps);
  5741. }
  5742. return parseClassNames(classNames);
  5743. }
  5744. function normalizeContent(input, hookProps) {
  5745. if (typeof input === 'function') {
  5746. return input(hookProps, createElement); // give the function the vdom-creation func
  5747. }
  5748. else {
  5749. return input;
  5750. }
  5751. }
  5752. var ViewRoot = /** @class */ (function (_super) {
  5753. __extends(ViewRoot, _super);
  5754. function ViewRoot() {
  5755. var _this = _super !== null && _super.apply(this, arguments) || this;
  5756. _this.normalizeClassNames = buildClassNameNormalizer();
  5757. return _this;
  5758. }
  5759. ViewRoot.prototype.render = function () {
  5760. var _a = this, props = _a.props, context = _a.context;
  5761. var options = context.options;
  5762. var hookProps = { view: context.viewApi };
  5763. var customClassNames = this.normalizeClassNames(options.viewClassNames, hookProps);
  5764. return (createElement(MountHook, { hookProps: hookProps, didMount: options.viewDidMount, willUnmount: options.viewWillUnmount, elRef: props.elRef }, function (rootElRef) { return props.children(rootElRef, ["fc-" + props.viewSpec.type + "-view", 'fc-view'].concat(customClassNames)); }));
  5765. };
  5766. return ViewRoot;
  5767. }(BaseComponent));
  5768. function parseViewConfigs(inputs) {
  5769. return mapHash(inputs, parseViewConfig);
  5770. }
  5771. function parseViewConfig(input) {
  5772. var rawOptions = typeof input === 'function' ?
  5773. { component: input } :
  5774. input;
  5775. var component = rawOptions.component;
  5776. if (rawOptions.content) {
  5777. component = createViewHookComponent(rawOptions);
  5778. // TODO: remove content/classNames/didMount/etc from options?
  5779. }
  5780. return {
  5781. superType: rawOptions.type,
  5782. component: component,
  5783. rawOptions: rawOptions // includes type and component too :(
  5784. };
  5785. }
  5786. function createViewHookComponent(options) {
  5787. return function (viewProps) {
  5788. return (createElement(ViewContextType.Consumer, null, function (context) { return (createElement(ViewRoot, { viewSpec: context.viewSpec }, function (rootElRef, viewClassNames) {
  5789. var hookProps = __assign(__assign({}, viewProps), { nextDayThreshold: context.options.nextDayThreshold });
  5790. return (createElement(RenderHook, { hookProps: hookProps, classNames: options.classNames, content: options.content, didMount: options.didMount, willUnmount: options.willUnmount, elRef: rootElRef }, function (rootElRef, customClassNames, innerElRef, innerContent) { return (createElement("div", { className: viewClassNames.concat(customClassNames).join(' '), ref: rootElRef }, innerContent)); }));
  5791. })); }));
  5792. };
  5793. }
  5794. function buildViewSpecs(defaultInputs, optionOverrides, dynamicOptionOverrides, localeDefaults) {
  5795. var defaultConfigs = parseViewConfigs(defaultInputs);
  5796. var overrideConfigs = parseViewConfigs(optionOverrides.views);
  5797. var viewDefs = compileViewDefs(defaultConfigs, overrideConfigs);
  5798. return mapHash(viewDefs, function (viewDef) {
  5799. return buildViewSpec(viewDef, overrideConfigs, optionOverrides, dynamicOptionOverrides, localeDefaults);
  5800. });
  5801. }
  5802. function buildViewSpec(viewDef, overrideConfigs, optionOverrides, dynamicOptionOverrides, localeDefaults) {
  5803. var durationInput = viewDef.overrides.duration ||
  5804. viewDef.defaults.duration ||
  5805. dynamicOptionOverrides.duration ||
  5806. optionOverrides.duration;
  5807. var duration = null;
  5808. var durationUnit = '';
  5809. var singleUnit = '';
  5810. var singleUnitOverrides = {};
  5811. if (durationInput) {
  5812. duration = createDurationCached(durationInput);
  5813. if (duration) { // valid?
  5814. var denom = greatestDurationDenominator(duration);
  5815. durationUnit = denom.unit;
  5816. if (denom.value === 1) {
  5817. singleUnit = durationUnit;
  5818. singleUnitOverrides = overrideConfigs[durationUnit] ? overrideConfigs[durationUnit].rawOptions : {};
  5819. }
  5820. }
  5821. }
  5822. var queryButtonText = function (optionsSubset) {
  5823. var buttonTextMap = optionsSubset.buttonText || {};
  5824. var buttonTextKey = viewDef.defaults.buttonTextKey;
  5825. if (buttonTextKey != null && buttonTextMap[buttonTextKey] != null) {
  5826. return buttonTextMap[buttonTextKey];
  5827. }
  5828. if (buttonTextMap[viewDef.type] != null) {
  5829. return buttonTextMap[viewDef.type];
  5830. }
  5831. if (buttonTextMap[singleUnit] != null) {
  5832. return buttonTextMap[singleUnit];
  5833. }
  5834. };
  5835. return {
  5836. type: viewDef.type,
  5837. component: viewDef.component,
  5838. duration: duration,
  5839. durationUnit: durationUnit,
  5840. singleUnit: singleUnit,
  5841. optionDefaults: viewDef.defaults,
  5842. optionOverrides: __assign(__assign({}, singleUnitOverrides), viewDef.overrides),
  5843. buttonTextOverride: queryButtonText(dynamicOptionOverrides) ||
  5844. queryButtonText(optionOverrides) || // constructor-specified buttonText lookup hash takes precedence
  5845. viewDef.overrides.buttonText,
  5846. buttonTextDefault: queryButtonText(localeDefaults) ||
  5847. viewDef.defaults.buttonText ||
  5848. queryButtonText(BASE_OPTION_DEFAULTS) ||
  5849. viewDef.type // fall back to given view name
  5850. };
  5851. }
  5852. // hack to get memoization working
  5853. var durationInputMap = {};
  5854. function createDurationCached(durationInput) {
  5855. var json = JSON.stringify(durationInput);
  5856. var res = durationInputMap[json];
  5857. if (res === undefined) {
  5858. res = createDuration(durationInput);
  5859. durationInputMap[json] = res;
  5860. }
  5861. return res;
  5862. }
  5863. var DateProfileGenerator = /** @class */ (function () {
  5864. function DateProfileGenerator(props) {
  5865. this.props = props;
  5866. this.nowDate = getNow(props.nowInput, props.dateEnv);
  5867. this.initHiddenDays();
  5868. }
  5869. /* Date Range Computation
  5870. ------------------------------------------------------------------------------------------------------------------*/
  5871. // Builds a structure with info about what the dates/ranges will be for the "prev" view.
  5872. DateProfileGenerator.prototype.buildPrev = function (currentDateProfile, currentDate, forceToValid) {
  5873. var dateEnv = this.props.dateEnv;
  5874. var prevDate = dateEnv.subtract(dateEnv.startOf(currentDate, currentDateProfile.currentRangeUnit), // important for start-of-month
  5875. currentDateProfile.dateIncrement);
  5876. return this.build(prevDate, -1, forceToValid);
  5877. };
  5878. // Builds a structure with info about what the dates/ranges will be for the "next" view.
  5879. DateProfileGenerator.prototype.buildNext = function (currentDateProfile, currentDate, forceToValid) {
  5880. var dateEnv = this.props.dateEnv;
  5881. var nextDate = dateEnv.add(dateEnv.startOf(currentDate, currentDateProfile.currentRangeUnit), // important for start-of-month
  5882. currentDateProfile.dateIncrement);
  5883. return this.build(nextDate, 1, forceToValid);
  5884. };
  5885. // Builds a structure holding dates/ranges for rendering around the given date.
  5886. // Optional direction param indicates whether the date is being incremented/decremented
  5887. // from its previous value. decremented = -1, incremented = 1 (default).
  5888. DateProfileGenerator.prototype.build = function (currentDate, direction, forceToValid) {
  5889. if (forceToValid === void 0) { forceToValid = true; }
  5890. var props = this.props;
  5891. var validRange;
  5892. var currentInfo;
  5893. var isRangeAllDay;
  5894. var renderRange;
  5895. var activeRange;
  5896. var isValid;
  5897. validRange = this.buildValidRange();
  5898. validRange = this.trimHiddenDays(validRange);
  5899. if (forceToValid) {
  5900. currentDate = constrainMarkerToRange(currentDate, validRange);
  5901. }
  5902. currentInfo = this.buildCurrentRangeInfo(currentDate, direction);
  5903. isRangeAllDay = /^(year|month|week|day)$/.test(currentInfo.unit);
  5904. renderRange = this.buildRenderRange(this.trimHiddenDays(currentInfo.range), currentInfo.unit, isRangeAllDay);
  5905. renderRange = this.trimHiddenDays(renderRange);
  5906. activeRange = renderRange;
  5907. if (!props.showNonCurrentDates) {
  5908. activeRange = intersectRanges(activeRange, currentInfo.range);
  5909. }
  5910. activeRange = this.adjustActiveRange(activeRange);
  5911. activeRange = intersectRanges(activeRange, validRange); // might return null
  5912. // it's invalid if the originally requested date is not contained,
  5913. // or if the range is completely outside of the valid range.
  5914. isValid = rangesIntersect(currentInfo.range, validRange);
  5915. return {
  5916. // constraint for where prev/next operations can go and where events can be dragged/resized to.
  5917. // an object with optional start and end properties.
  5918. validRange: validRange,
  5919. // range the view is formally responsible for.
  5920. // for example, a month view might have 1st-31st, excluding padded dates
  5921. currentRange: currentInfo.range,
  5922. // name of largest unit being displayed, like "month" or "week"
  5923. currentRangeUnit: currentInfo.unit,
  5924. isRangeAllDay: isRangeAllDay,
  5925. // dates that display events and accept drag-n-drop
  5926. // will be `null` if no dates accept events
  5927. activeRange: activeRange,
  5928. // date range with a rendered skeleton
  5929. // includes not-active days that need some sort of DOM
  5930. renderRange: renderRange,
  5931. // Duration object that denotes the first visible time of any given day
  5932. slotMinTime: props.slotMinTime,
  5933. // Duration object that denotes the exclusive visible end time of any given day
  5934. slotMaxTime: props.slotMaxTime,
  5935. isValid: isValid,
  5936. // how far the current date will move for a prev/next operation
  5937. dateIncrement: this.buildDateIncrement(currentInfo.duration)
  5938. // pass a fallback (might be null) ^
  5939. };
  5940. };
  5941. // Builds an object with optional start/end properties.
  5942. // Indicates the minimum/maximum dates to display.
  5943. // not responsible for trimming hidden days.
  5944. DateProfileGenerator.prototype.buildValidRange = function () {
  5945. var input = this.props.validRangeInput;
  5946. var simpleInput = typeof input === 'function'
  5947. ? input.call(this.props.calendarApi, this.nowDate)
  5948. : input;
  5949. return this.refineRange(simpleInput) ||
  5950. { start: null, end: null }; // completely open-ended
  5951. };
  5952. // Builds a structure with info about the "current" range, the range that is
  5953. // highlighted as being the current month for example.
  5954. // See build() for a description of `direction`.
  5955. // Guaranteed to have `range` and `unit` properties. `duration` is optional.
  5956. DateProfileGenerator.prototype.buildCurrentRangeInfo = function (date, direction) {
  5957. var props = this.props;
  5958. var duration = null;
  5959. var unit = null;
  5960. var range = null;
  5961. var dayCount;
  5962. if (props.duration) {
  5963. duration = props.duration;
  5964. unit = props.durationUnit;
  5965. range = this.buildRangeFromDuration(date, direction, duration, unit);
  5966. }
  5967. else if ((dayCount = this.props.dayCount)) {
  5968. unit = 'day';
  5969. range = this.buildRangeFromDayCount(date, direction, dayCount);
  5970. }
  5971. else if ((range = this.buildCustomVisibleRange(date))) {
  5972. unit = props.dateEnv.greatestWholeUnit(range.start, range.end).unit;
  5973. }
  5974. else {
  5975. duration = this.getFallbackDuration();
  5976. unit = greatestDurationDenominator(duration).unit;
  5977. range = this.buildRangeFromDuration(date, direction, duration, unit);
  5978. }
  5979. return { duration: duration, unit: unit, range: range };
  5980. };
  5981. DateProfileGenerator.prototype.getFallbackDuration = function () {
  5982. return createDuration({ day: 1 });
  5983. };
  5984. // Returns a new activeRange to have time values (un-ambiguate)
  5985. // slotMinTime or slotMaxTime causes the range to expand.
  5986. DateProfileGenerator.prototype.adjustActiveRange = function (range) {
  5987. var _a = this.props, dateEnv = _a.dateEnv, usesMinMaxTime = _a.usesMinMaxTime, slotMinTime = _a.slotMinTime, slotMaxTime = _a.slotMaxTime;
  5988. var start = range.start;
  5989. var end = range.end;
  5990. if (usesMinMaxTime) {
  5991. // expand active range if slotMinTime is negative (why not when positive?)
  5992. if (asRoughDays(slotMinTime) < 0) {
  5993. start = startOfDay(start); // necessary?
  5994. start = dateEnv.add(start, slotMinTime);
  5995. }
  5996. // expand active range if slotMaxTime is beyond one day (why not when negative?)
  5997. if (asRoughDays(slotMaxTime) > 1) {
  5998. end = startOfDay(end); // necessary?
  5999. end = addDays(end, -1);
  6000. end = dateEnv.add(end, slotMaxTime);
  6001. }
  6002. }
  6003. return { start: start, end: end };
  6004. };
  6005. // Builds the "current" range when it is specified as an explicit duration.
  6006. // `unit` is the already-computed greatestDurationDenominator unit of duration.
  6007. DateProfileGenerator.prototype.buildRangeFromDuration = function (date, direction, duration, unit) {
  6008. var _a = this.props, dateEnv = _a.dateEnv, dateAlignment = _a.dateAlignment;
  6009. var start;
  6010. var end;
  6011. var res;
  6012. // compute what the alignment should be
  6013. if (!dateAlignment) {
  6014. var dateIncrement = this.props.dateIncrement;
  6015. if (dateIncrement) {
  6016. // use the smaller of the two units
  6017. if (asRoughMs(dateIncrement) < asRoughMs(duration)) {
  6018. dateAlignment = greatestDurationDenominator(dateIncrement).unit;
  6019. }
  6020. else {
  6021. dateAlignment = unit;
  6022. }
  6023. }
  6024. else {
  6025. dateAlignment = unit;
  6026. }
  6027. }
  6028. // if the view displays a single day or smaller
  6029. if (asRoughDays(duration) <= 1) {
  6030. if (this.isHiddenDay(start)) {
  6031. start = this.skipHiddenDays(start, direction);
  6032. start = startOfDay(start);
  6033. }
  6034. }
  6035. function computeRes() {
  6036. start = dateEnv.startOf(date, dateAlignment);
  6037. end = dateEnv.add(start, duration);
  6038. res = { start: start, end: end };
  6039. }
  6040. computeRes();
  6041. // if range is completely enveloped by hidden days, go past the hidden days
  6042. if (!this.trimHiddenDays(res)) {
  6043. date = this.skipHiddenDays(date, direction);
  6044. computeRes();
  6045. }
  6046. return res;
  6047. };
  6048. // Builds the "current" range when a dayCount is specified.
  6049. DateProfileGenerator.prototype.buildRangeFromDayCount = function (date, direction, dayCount) {
  6050. var _a = this.props, dateEnv = _a.dateEnv, dateAlignment = _a.dateAlignment;
  6051. var runningCount = 0;
  6052. var start = date;
  6053. var end;
  6054. if (dateAlignment) {
  6055. start = dateEnv.startOf(start, dateAlignment);
  6056. }
  6057. start = startOfDay(start);
  6058. start = this.skipHiddenDays(start, direction);
  6059. end = start;
  6060. do {
  6061. end = addDays(end, 1);
  6062. if (!this.isHiddenDay(end)) {
  6063. runningCount++;
  6064. }
  6065. } while (runningCount < dayCount);
  6066. return { start: start, end: end };
  6067. };
  6068. // Builds a normalized range object for the "visible" range,
  6069. // which is a way to define the currentRange and activeRange at the same time.
  6070. DateProfileGenerator.prototype.buildCustomVisibleRange = function (date) {
  6071. var props = this.props;
  6072. var input = props.visibleRangeInput;
  6073. var simpleInput = typeof input === 'function'
  6074. ? input.call(props.calendarApi, props.dateEnv.toDate(date))
  6075. : input;
  6076. var range = this.refineRange(simpleInput);
  6077. if (range && (range.start == null || range.end == null)) {
  6078. return null;
  6079. }
  6080. return range;
  6081. };
  6082. // Computes the range that will represent the element/cells for *rendering*,
  6083. // but which may have voided days/times.
  6084. // not responsible for trimming hidden days.
  6085. DateProfileGenerator.prototype.buildRenderRange = function (currentRange, currentRangeUnit, isRangeAllDay) {
  6086. return currentRange;
  6087. };
  6088. // Compute the duration value that should be added/substracted to the current date
  6089. // when a prev/next operation happens.
  6090. DateProfileGenerator.prototype.buildDateIncrement = function (fallback) {
  6091. var dateIncrement = this.props.dateIncrement;
  6092. var customAlignment;
  6093. if (dateIncrement) {
  6094. return dateIncrement;
  6095. }
  6096. else if ((customAlignment = this.props.dateAlignment)) {
  6097. return createDuration(1, customAlignment);
  6098. }
  6099. else if (fallback) {
  6100. return fallback;
  6101. }
  6102. else {
  6103. return createDuration({ days: 1 });
  6104. }
  6105. };
  6106. DateProfileGenerator.prototype.refineRange = function (rangeInput) {
  6107. if (rangeInput) {
  6108. var range = parseRange(rangeInput, this.props.dateEnv);
  6109. if (range) {
  6110. range = computeVisibleDayRange(range);
  6111. }
  6112. return range;
  6113. }
  6114. return null;
  6115. };
  6116. /* Hidden Days
  6117. ------------------------------------------------------------------------------------------------------------------*/
  6118. // Initializes internal variables related to calculating hidden days-of-week
  6119. DateProfileGenerator.prototype.initHiddenDays = function () {
  6120. var hiddenDays = this.props.hiddenDays || []; // array of day-of-week indices that are hidden
  6121. var isHiddenDayHash = []; // is the day-of-week hidden? (hash with day-of-week-index -> bool)
  6122. var dayCnt = 0;
  6123. var i;
  6124. if (this.props.weekends === false) {
  6125. hiddenDays.push(0, 6); // 0=sunday, 6=saturday
  6126. }
  6127. for (i = 0; i < 7; i++) {
  6128. if (!(isHiddenDayHash[i] = hiddenDays.indexOf(i) !== -1)) {
  6129. dayCnt++;
  6130. }
  6131. }
  6132. if (!dayCnt) {
  6133. throw new Error('invalid hiddenDays'); // all days were hidden? bad.
  6134. }
  6135. this.isHiddenDayHash = isHiddenDayHash;
  6136. };
  6137. // Remove days from the beginning and end of the range that are computed as hidden.
  6138. // If the whole range is trimmed off, returns null
  6139. DateProfileGenerator.prototype.trimHiddenDays = function (range) {
  6140. var start = range.start;
  6141. var end = range.end;
  6142. if (start) {
  6143. start = this.skipHiddenDays(start);
  6144. }
  6145. if (end) {
  6146. end = this.skipHiddenDays(end, -1, true);
  6147. }
  6148. if (start == null || end == null || start < end) {
  6149. return { start: start, end: end };
  6150. }
  6151. return null;
  6152. };
  6153. // Is the current day hidden?
  6154. // `day` is a day-of-week index (0-6), or a Date (used for UTC)
  6155. DateProfileGenerator.prototype.isHiddenDay = function (day) {
  6156. if (day instanceof Date) {
  6157. day = day.getUTCDay();
  6158. }
  6159. return this.isHiddenDayHash[day];
  6160. };
  6161. // Incrementing the current day until it is no longer a hidden day, returning a copy.
  6162. // DOES NOT CONSIDER validRange!
  6163. // If the initial value of `date` is not a hidden day, don't do anything.
  6164. // Pass `isExclusive` as `true` if you are dealing with an end date.
  6165. // `inc` defaults to `1` (increment one day forward each time)
  6166. DateProfileGenerator.prototype.skipHiddenDays = function (date, inc, isExclusive) {
  6167. if (inc === void 0) { inc = 1; }
  6168. if (isExclusive === void 0) { isExclusive = false; }
  6169. while (this.isHiddenDayHash[(date.getUTCDay() + (isExclusive ? inc : 0) + 7) % 7]) {
  6170. date = addDays(date, inc);
  6171. }
  6172. return date;
  6173. };
  6174. return DateProfileGenerator;
  6175. }());
  6176. function reduceViewType(viewType, action) {
  6177. switch (action.type) {
  6178. case 'CHANGE_VIEW_TYPE':
  6179. return viewType = action.viewType;
  6180. }
  6181. return viewType;
  6182. }
  6183. function reduceDynamicOptionOverrides(dynamicOptionOverrides, action) {
  6184. var _a;
  6185. switch (action.type) {
  6186. case 'SET_OPTION':
  6187. return __assign(__assign({}, dynamicOptionOverrides), (_a = {}, _a[action.optionName] = action.rawOptionValue, _a));
  6188. default:
  6189. return dynamicOptionOverrides;
  6190. }
  6191. }
  6192. function reduceDateProfile(currentDateProfile, action, currentDate, dateProfileGenerator) {
  6193. var dp;
  6194. switch (action.type) {
  6195. case 'CHANGE_VIEW_TYPE':
  6196. return dateProfileGenerator.build(action.dateMarker || currentDate);
  6197. case 'CHANGE_DATE':
  6198. if (!currentDateProfile.activeRange ||
  6199. !rangeContainsMarker(currentDateProfile.currentRange, action.dateMarker) // don't move if date already in view
  6200. ) {
  6201. return dateProfileGenerator.build(action.dateMarker);
  6202. }
  6203. break;
  6204. case 'PREV':
  6205. dp = dateProfileGenerator.buildPrev(currentDateProfile, currentDate);
  6206. if (dp.isValid) {
  6207. return dp;
  6208. }
  6209. break;
  6210. case 'NEXT':
  6211. dp = dateProfileGenerator.buildNext(currentDateProfile, currentDate);
  6212. if (dp.isValid) {
  6213. return dp;
  6214. }
  6215. break;
  6216. }
  6217. return currentDateProfile;
  6218. }
  6219. function initEventSources(calendarOptions, dateProfile, context) {
  6220. var activeRange = dateProfile ? dateProfile.activeRange : null;
  6221. return addSources({}, parseInitialSources(calendarOptions, context), activeRange, context);
  6222. }
  6223. function reduceEventSources(eventSources, action, dateProfile, context) {
  6224. var activeRange = dateProfile ? dateProfile.activeRange : null; // need this check?
  6225. switch (action.type) {
  6226. case 'ADD_EVENT_SOURCES': // already parsed
  6227. return addSources(eventSources, action.sources, activeRange, context);
  6228. case 'REMOVE_EVENT_SOURCE':
  6229. return removeSource(eventSources, action.sourceId);
  6230. case 'PREV': // TODO: how do we track all actions that affect dateProfile :(
  6231. case 'NEXT':
  6232. case 'CHANGE_DATE':
  6233. case 'CHANGE_VIEW_TYPE':
  6234. if (dateProfile) {
  6235. return fetchDirtySources(eventSources, activeRange, context);
  6236. }
  6237. else {
  6238. return eventSources;
  6239. }
  6240. case 'FETCH_EVENT_SOURCES':
  6241. return fetchSourcesByIds(eventSources, action.sourceIds ? // why no type?
  6242. arrayToHash(action.sourceIds) :
  6243. excludeStaticSources(eventSources, context), activeRange, context);
  6244. case 'RECEIVE_EVENTS':
  6245. case 'RECEIVE_EVENT_ERROR':
  6246. return receiveResponse(eventSources, action.sourceId, action.fetchId, action.fetchRange);
  6247. case 'REMOVE_ALL_EVENT_SOURCES':
  6248. return {};
  6249. default:
  6250. return eventSources;
  6251. }
  6252. }
  6253. function reduceEventSourcesNewTimeZone(eventSources, dateProfile, context) {
  6254. var activeRange = dateProfile ? dateProfile.activeRange : null; // need this check?
  6255. return fetchSourcesByIds(eventSources, excludeStaticSources(eventSources, context), activeRange, context);
  6256. }
  6257. function computeEventSourceLoadingLevel(eventSources) {
  6258. var cnt = 0;
  6259. for (var sourceId in eventSources) {
  6260. if (eventSources[sourceId].isFetching) {
  6261. cnt++;
  6262. }
  6263. }
  6264. return cnt;
  6265. }
  6266. function addSources(eventSourceHash, sources, fetchRange, context) {
  6267. var hash = {};
  6268. for (var _i = 0, sources_1 = sources; _i < sources_1.length; _i++) {
  6269. var source = sources_1[_i];
  6270. hash[source.sourceId] = source;
  6271. }
  6272. if (fetchRange) {
  6273. hash = fetchDirtySources(hash, fetchRange, context);
  6274. }
  6275. return __assign(__assign({}, eventSourceHash), hash);
  6276. }
  6277. function removeSource(eventSourceHash, sourceId) {
  6278. return filterHash(eventSourceHash, function (eventSource) {
  6279. return eventSource.sourceId !== sourceId;
  6280. });
  6281. }
  6282. function fetchDirtySources(sourceHash, fetchRange, context) {
  6283. return fetchSourcesByIds(sourceHash, filterHash(sourceHash, function (eventSource) {
  6284. return isSourceDirty(eventSource, fetchRange, context);
  6285. }), fetchRange, context);
  6286. }
  6287. function isSourceDirty(eventSource, fetchRange, context) {
  6288. if (!doesSourceNeedRange(eventSource, context)) {
  6289. return !eventSource.latestFetchId;
  6290. }
  6291. else {
  6292. return !context.options.lazyFetching ||
  6293. !eventSource.fetchRange ||
  6294. eventSource.isFetching || // always cancel outdated in-progress fetches
  6295. fetchRange.start < eventSource.fetchRange.start ||
  6296. fetchRange.end > eventSource.fetchRange.end;
  6297. }
  6298. }
  6299. function fetchSourcesByIds(prevSources, sourceIdHash, fetchRange, context) {
  6300. var nextSources = {};
  6301. for (var sourceId in prevSources) {
  6302. var source = prevSources[sourceId];
  6303. if (sourceIdHash[sourceId]) {
  6304. nextSources[sourceId] = fetchSource(source, fetchRange, context);
  6305. }
  6306. else {
  6307. nextSources[sourceId] = source;
  6308. }
  6309. }
  6310. return nextSources;
  6311. }
  6312. function fetchSource(eventSource, fetchRange, context) {
  6313. var options = context.options, calendarApi = context.calendarApi;
  6314. var sourceDef = context.pluginHooks.eventSourceDefs[eventSource.sourceDefId];
  6315. var fetchId = guid();
  6316. sourceDef.fetch({
  6317. eventSource: eventSource,
  6318. range: fetchRange,
  6319. context: context
  6320. }, function (res) {
  6321. var rawEvents = res.rawEvents;
  6322. if (options.eventSourceSuccess) {
  6323. rawEvents = options.eventSourceSuccess.call(calendarApi, rawEvents, res.xhr) || rawEvents;
  6324. }
  6325. if (eventSource.success) {
  6326. rawEvents = eventSource.success.call(calendarApi, rawEvents, res.xhr) || rawEvents;
  6327. }
  6328. context.dispatch({
  6329. type: 'RECEIVE_EVENTS',
  6330. sourceId: eventSource.sourceId,
  6331. fetchId: fetchId,
  6332. fetchRange: fetchRange,
  6333. rawEvents: rawEvents
  6334. });
  6335. }, function (error) {
  6336. console.warn(error.message, error);
  6337. if (options.eventSourceFailure) {
  6338. options.eventSourceFailure.call(calendarApi, error);
  6339. }
  6340. if (eventSource.failure) {
  6341. eventSource.failure(error);
  6342. }
  6343. context.dispatch({
  6344. type: 'RECEIVE_EVENT_ERROR',
  6345. sourceId: eventSource.sourceId,
  6346. fetchId: fetchId,
  6347. fetchRange: fetchRange,
  6348. error: error
  6349. });
  6350. });
  6351. return __assign(__assign({}, eventSource), { isFetching: true, latestFetchId: fetchId });
  6352. }
  6353. function receiveResponse(sourceHash, sourceId, fetchId, fetchRange) {
  6354. var _a;
  6355. var eventSource = sourceHash[sourceId];
  6356. if (eventSource && // not already removed
  6357. fetchId === eventSource.latestFetchId) {
  6358. return __assign(__assign({}, sourceHash), (_a = {}, _a[sourceId] = __assign(__assign({}, eventSource), { isFetching: false, fetchRange: fetchRange // also serves as a marker that at least one fetch has completed
  6359. }), _a));
  6360. }
  6361. return sourceHash;
  6362. }
  6363. function excludeStaticSources(eventSources, context) {
  6364. return filterHash(eventSources, function (eventSource) {
  6365. return doesSourceNeedRange(eventSource, context);
  6366. });
  6367. }
  6368. function parseInitialSources(rawOptions, context) {
  6369. var refiners = buildEventSourceRefiners(context);
  6370. var rawSources = [].concat(rawOptions.eventSources || []);
  6371. var sources = []; // parsed
  6372. if (rawOptions.initialEvents) {
  6373. rawSources.unshift(rawOptions.initialEvents);
  6374. }
  6375. if (rawOptions.events) {
  6376. rawSources.unshift(rawOptions.events);
  6377. }
  6378. for (var _i = 0, rawSources_1 = rawSources; _i < rawSources_1.length; _i++) {
  6379. var rawSource = rawSources_1[_i];
  6380. var source = parseEventSource(rawSource, context, refiners);
  6381. if (source) {
  6382. sources.push(source);
  6383. }
  6384. }
  6385. return sources;
  6386. }
  6387. function doesSourceNeedRange(eventSource, context) {
  6388. var defs = context.pluginHooks.eventSourceDefs;
  6389. return !defs[eventSource.sourceDefId].ignoreRange;
  6390. }
  6391. function reduceDateSelection(currentSelection, action) {
  6392. switch (action.type) {
  6393. case 'UNSELECT_DATES':
  6394. return null;
  6395. case 'SELECT_DATES':
  6396. return action.selection;
  6397. default:
  6398. return currentSelection;
  6399. }
  6400. }
  6401. function reduceSelectedEvent(currentInstanceId, action) {
  6402. switch (action.type) {
  6403. case 'UNSELECT_EVENT':
  6404. return '';
  6405. case 'SELECT_EVENT':
  6406. return action.eventInstanceId;
  6407. default:
  6408. return currentInstanceId;
  6409. }
  6410. }
  6411. function reduceEventDrag(currentDrag, action) {
  6412. var newDrag;
  6413. switch (action.type) {
  6414. case 'UNSET_EVENT_DRAG':
  6415. return null;
  6416. case 'SET_EVENT_DRAG':
  6417. newDrag = action.state;
  6418. return {
  6419. affectedEvents: newDrag.affectedEvents,
  6420. mutatedEvents: newDrag.mutatedEvents,
  6421. isEvent: newDrag.isEvent
  6422. };
  6423. default:
  6424. return currentDrag;
  6425. }
  6426. }
  6427. function reduceEventResize(currentResize, action) {
  6428. var newResize;
  6429. switch (action.type) {
  6430. case 'UNSET_EVENT_RESIZE':
  6431. return null;
  6432. case 'SET_EVENT_RESIZE':
  6433. newResize = action.state;
  6434. return {
  6435. affectedEvents: newResize.affectedEvents,
  6436. mutatedEvents: newResize.mutatedEvents,
  6437. isEvent: newResize.isEvent
  6438. };
  6439. default:
  6440. return currentResize;
  6441. }
  6442. }
  6443. function parseToolbars(calendarOptions, calendarOptionOverrides, theme, viewSpecs, calendarApi) {
  6444. var viewsWithButtons = [];
  6445. var headerToolbar = calendarOptions.headerToolbar ? parseToolbar(calendarOptions.headerToolbar, calendarOptions, calendarOptionOverrides, theme, viewSpecs, calendarApi, viewsWithButtons) : null;
  6446. var footerToolbar = calendarOptions.footerToolbar ? parseToolbar(calendarOptions.footerToolbar, calendarOptions, calendarOptionOverrides, theme, viewSpecs, calendarApi, viewsWithButtons) : null;
  6447. return { headerToolbar: headerToolbar, footerToolbar: footerToolbar, viewsWithButtons: viewsWithButtons };
  6448. }
  6449. function parseToolbar(sectionStrHash, calendarOptions, calendarOptionOverrides, theme, viewSpecs, calendarApi, viewsWithButtons // dump side effects
  6450. ) {
  6451. return mapHash(sectionStrHash, function (sectionStr) { return parseSection(sectionStr, calendarOptions, calendarOptionOverrides, theme, viewSpecs, calendarApi, viewsWithButtons); });
  6452. }
  6453. /*
  6454. BAD: querying icons and text here. should be done at render time
  6455. */
  6456. function parseSection(sectionStr, calendarOptions, calendarOptionOverrides, theme, viewSpecs, calendarApi, viewsWithButtons // dump side effects
  6457. ) {
  6458. var isRtl = calendarOptions.direction === 'rtl';
  6459. var calendarCustomButtons = calendarOptions.customButtons || {};
  6460. var calendarButtonTextOverrides = calendarOptionOverrides.buttonText || {};
  6461. var calendarButtonText = calendarOptions.buttonText || {};
  6462. var sectionSubstrs = sectionStr ? sectionStr.split(' ') : [];
  6463. return sectionSubstrs.map(function (buttonGroupStr) {
  6464. return buttonGroupStr.split(',').map(function (buttonName) {
  6465. if (buttonName === 'title') {
  6466. return { buttonName: buttonName };
  6467. }
  6468. else {
  6469. var customButtonProps_1;
  6470. var viewSpec = void 0;
  6471. var buttonClick = void 0;
  6472. var buttonIcon = void 0; // only one of these will be set
  6473. var buttonText = void 0; // "
  6474. if ((customButtonProps_1 = calendarCustomButtons[buttonName])) {
  6475. buttonClick = function (ev) {
  6476. if (customButtonProps_1.click) {
  6477. customButtonProps_1.click.call(ev.target, ev); // TODO: correct to use `target`?
  6478. }
  6479. };
  6480. (buttonIcon = theme.getCustomButtonIconClass(customButtonProps_1)) ||
  6481. (buttonIcon = theme.getIconClass(buttonName, isRtl)) ||
  6482. (buttonText = customButtonProps_1.text);
  6483. }
  6484. else if ((viewSpec = viewSpecs[buttonName])) {
  6485. viewsWithButtons.push(buttonName);
  6486. buttonClick = function () {
  6487. calendarApi.changeView(buttonName);
  6488. };
  6489. (buttonText = viewSpec.buttonTextOverride) ||
  6490. (buttonIcon = theme.getIconClass(buttonName, isRtl)) ||
  6491. (buttonText = viewSpec.buttonTextDefault);
  6492. }
  6493. else if (calendarApi[buttonName]) { // a calendarApi method
  6494. buttonClick = function () {
  6495. calendarApi[buttonName]();
  6496. };
  6497. (buttonText = calendarButtonTextOverrides[buttonName]) ||
  6498. (buttonIcon = theme.getIconClass(buttonName, isRtl)) ||
  6499. (buttonText = calendarButtonText[buttonName]);
  6500. // ^ everything else is considered default
  6501. }
  6502. return { buttonName: buttonName, buttonClick: buttonClick, buttonIcon: buttonIcon, buttonText: buttonText };
  6503. }
  6504. });
  6505. });
  6506. }
  6507. var eventSourceDef = {
  6508. ignoreRange: true,
  6509. parseMeta: function (refined) {
  6510. if (Array.isArray(refined.events)) {
  6511. return refined.events;
  6512. }
  6513. return null;
  6514. },
  6515. fetch: function (arg, success) {
  6516. success({
  6517. rawEvents: arg.eventSource.meta
  6518. });
  6519. }
  6520. };
  6521. var arrayEventSourcePlugin = createPlugin({
  6522. eventSourceDefs: [eventSourceDef]
  6523. });
  6524. var eventSourceDef$1 = {
  6525. parseMeta: function (refined) {
  6526. if (typeof refined.events === 'function') {
  6527. return refined.events;
  6528. }
  6529. return null;
  6530. },
  6531. fetch: function (arg, success, failure) {
  6532. var dateEnv = arg.context.dateEnv;
  6533. var func = arg.eventSource.meta;
  6534. unpromisify(func.bind(null, buildRangeApiWithTimeZone(arg.range, dateEnv)), function (rawEvents) {
  6535. success({ rawEvents: rawEvents }); // needs an object response
  6536. }, failure // send errorObj directly to failure callback
  6537. );
  6538. }
  6539. };
  6540. var funcEventSourcePlugin = createPlugin({
  6541. eventSourceDefs: [eventSourceDef$1]
  6542. });
  6543. function requestJson(method, url, params, successCallback, failureCallback) {
  6544. method = method.toUpperCase();
  6545. var body = null;
  6546. if (method === 'GET') {
  6547. url = injectQueryStringParams(url, params);
  6548. }
  6549. else {
  6550. body = encodeParams(params);
  6551. }
  6552. var xhr = new XMLHttpRequest();
  6553. xhr.open(method, url, true);
  6554. if (method !== 'GET') {
  6555. xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
  6556. }
  6557. xhr.onload = function () {
  6558. if (xhr.status >= 200 && xhr.status < 400) {
  6559. var parsed = false;
  6560. var res = void 0;
  6561. try {
  6562. res = JSON.parse(xhr.responseText);
  6563. parsed = true;
  6564. }
  6565. catch (err) {
  6566. // will handle parsed=false
  6567. }
  6568. if (parsed) {
  6569. successCallback(res, xhr);
  6570. }
  6571. else {
  6572. failureCallback('Failure parsing JSON', xhr);
  6573. }
  6574. }
  6575. else {
  6576. failureCallback('Request failed', xhr);
  6577. }
  6578. };
  6579. xhr.onerror = function () {
  6580. failureCallback('Request failed', xhr);
  6581. };
  6582. xhr.send(body);
  6583. }
  6584. function injectQueryStringParams(url, params) {
  6585. return url +
  6586. (url.indexOf('?') === -1 ? '?' : '&') +
  6587. encodeParams(params);
  6588. }
  6589. function encodeParams(params) {
  6590. var parts = [];
  6591. for (var key in params) {
  6592. parts.push(encodeURIComponent(key) + '=' + encodeURIComponent(params[key]));
  6593. }
  6594. return parts.join('&');
  6595. }
  6596. var JSON_FEED_EVENT_SOURCE_REFINERS = {
  6597. method: String,
  6598. extraParams: identity,
  6599. startParam: String,
  6600. endParam: String,
  6601. timeZoneParam: String
  6602. };
  6603. var eventSourceDef$2 = {
  6604. parseMeta: function (refined) {
  6605. if (refined.url) {
  6606. return {
  6607. url: refined.url,
  6608. method: (refined.method || 'GET').toUpperCase(),
  6609. extraParams: refined.extraParams,
  6610. startParam: refined.startParam,
  6611. endParam: refined.endParam,
  6612. timeZoneParam: refined.timeZoneParam
  6613. };
  6614. }
  6615. return null;
  6616. },
  6617. fetch: function (arg, success, failure) {
  6618. var meta = arg.eventSource.meta;
  6619. var requestParams = buildRequestParams(meta, arg.range, arg.context);
  6620. requestJson(meta.method, meta.url, requestParams, function (rawEvents, xhr) {
  6621. success({ rawEvents: rawEvents, xhr: xhr });
  6622. }, function (errorMessage, xhr) {
  6623. failure({ message: errorMessage, xhr: xhr });
  6624. });
  6625. }
  6626. };
  6627. var jsonFeedEventSourcePlugin = createPlugin({
  6628. eventSourceRefiners: JSON_FEED_EVENT_SOURCE_REFINERS,
  6629. eventSourceDefs: [eventSourceDef$2]
  6630. });
  6631. function buildRequestParams(meta, range, context) {
  6632. var dateEnv = context.dateEnv, options = context.options;
  6633. var startParam;
  6634. var endParam;
  6635. var timeZoneParam;
  6636. var customRequestParams;
  6637. var params = {};
  6638. startParam = meta.startParam;
  6639. if (startParam == null) {
  6640. startParam = options.startParam;
  6641. }
  6642. endParam = meta.endParam;
  6643. if (endParam == null) {
  6644. endParam = options.endParam;
  6645. }
  6646. timeZoneParam = meta.timeZoneParam;
  6647. if (timeZoneParam == null) {
  6648. timeZoneParam = options.timeZoneParam;
  6649. }
  6650. // retrieve any outbound GET/POST data from the options
  6651. if (typeof meta.extraParams === 'function') {
  6652. // supplied as a function that returns a key/value object
  6653. customRequestParams = meta.extraParams();
  6654. }
  6655. else {
  6656. // probably supplied as a straight key/value object
  6657. customRequestParams = meta.extraParams || {};
  6658. }
  6659. __assign(params, customRequestParams);
  6660. params[startParam] = dateEnv.formatIso(range.start);
  6661. params[endParam] = dateEnv.formatIso(range.end);
  6662. if (dateEnv.timeZone !== 'local') {
  6663. params[timeZoneParam] = dateEnv.timeZone;
  6664. }
  6665. return params;
  6666. }
  6667. var SIMPLE_RECURRING_REFINERS = {
  6668. daysOfWeek: identity,
  6669. startTime: createDuration,
  6670. endTime: createDuration,
  6671. duration: createDuration,
  6672. startRecur: identity,
  6673. endRecur: identity
  6674. };
  6675. var recurring = {
  6676. parse: function (refined, dateEnv) {
  6677. if (refined.daysOfWeek || refined.startTime || refined.endTime || refined.startRecur || refined.endRecur) {
  6678. var recurringData = {
  6679. daysOfWeek: refined.daysOfWeek || null,
  6680. startTime: refined.startTime || null,
  6681. endTime: refined.endTime || null,
  6682. startRecur: refined.startRecur ? dateEnv.createMarker(refined.startRecur) : null,
  6683. endRecur: refined.endRecur ? dateEnv.createMarker(refined.endRecur) : null
  6684. };
  6685. var duration = void 0;
  6686. if (refined.duration) {
  6687. duration = refined.duration;
  6688. }
  6689. if (!duration && refined.startTime && refined.endTime) {
  6690. duration = subtractDurations(refined.endTime, refined.startTime);
  6691. }
  6692. return {
  6693. allDayGuess: Boolean(!refined.startTime && !refined.endTime),
  6694. duration: duration,
  6695. typeData: recurringData // doesn't need endTime anymore but oh well
  6696. };
  6697. }
  6698. return null;
  6699. },
  6700. expand: function (typeData, framingRange, dateEnv) {
  6701. var clippedFramingRange = intersectRanges(framingRange, { start: typeData.startRecur, end: typeData.endRecur });
  6702. if (clippedFramingRange) {
  6703. return expandRanges(typeData.daysOfWeek, typeData.startTime, clippedFramingRange, dateEnv);
  6704. }
  6705. else {
  6706. return [];
  6707. }
  6708. }
  6709. };
  6710. var simpleRecurringEventsPlugin = createPlugin({
  6711. recurringTypes: [recurring],
  6712. eventRefiners: SIMPLE_RECURRING_REFINERS
  6713. });
  6714. function expandRanges(daysOfWeek, startTime, framingRange, dateEnv) {
  6715. var dowHash = daysOfWeek ? arrayToHash(daysOfWeek) : null;
  6716. var dayMarker = startOfDay(framingRange.start);
  6717. var endMarker = framingRange.end;
  6718. var instanceStarts = [];
  6719. while (dayMarker < endMarker) {
  6720. var instanceStart
  6721. // if everyday, or this particular day-of-week
  6722. = void 0;
  6723. // if everyday, or this particular day-of-week
  6724. if (!dowHash || dowHash[dayMarker.getUTCDay()]) {
  6725. if (startTime) {
  6726. instanceStart = dateEnv.add(dayMarker, startTime);
  6727. }
  6728. else {
  6729. instanceStart = dayMarker;
  6730. }
  6731. instanceStarts.push(instanceStart);
  6732. }
  6733. dayMarker = addDays(dayMarker, 1);
  6734. }
  6735. return instanceStarts;
  6736. }
  6737. var changeHandlerPlugin = createPlugin({
  6738. optionChangeHandlers: {
  6739. events: function (events, context) {
  6740. handleEventSources([events], context);
  6741. },
  6742. eventSources: handleEventSources
  6743. }
  6744. });
  6745. /*
  6746. BUG: if `event` was supplied, all previously-given `eventSources` will be wiped out
  6747. */
  6748. function handleEventSources(inputs, context) {
  6749. var unfoundSources = hashValuesToArray(context.getCurrentData().eventSources);
  6750. var newInputs = [];
  6751. for (var _i = 0, inputs_1 = inputs; _i < inputs_1.length; _i++) {
  6752. var input = inputs_1[_i];
  6753. var inputFound = false;
  6754. for (var i = 0; i < unfoundSources.length; i++) {
  6755. if (unfoundSources[i]._raw === input) {
  6756. unfoundSources.splice(i, 1); // delete
  6757. inputFound = true;
  6758. break;
  6759. }
  6760. }
  6761. if (!inputFound) {
  6762. newInputs.push(input);
  6763. }
  6764. }
  6765. for (var _a = 0, unfoundSources_1 = unfoundSources; _a < unfoundSources_1.length; _a++) {
  6766. var unfoundSource = unfoundSources_1[_a];
  6767. context.dispatch({
  6768. type: 'REMOVE_EVENT_SOURCE',
  6769. sourceId: unfoundSource.sourceId
  6770. });
  6771. }
  6772. for (var _b = 0, newInputs_1 = newInputs; _b < newInputs_1.length; _b++) {
  6773. var newInput = newInputs_1[_b];
  6774. context.calendarApi.addEventSource(newInput);
  6775. }
  6776. }
  6777. function handleDateProfile(dateProfile, context) {
  6778. context.emitter.trigger('datesSet', __assign(__assign({}, buildRangeApiWithTimeZone(dateProfile.activeRange, context.dateEnv)), { view: context.viewApi }));
  6779. }
  6780. function handleEventStore(eventStore, context) {
  6781. var emitter = context.emitter;
  6782. if (emitter.hasHandlers('eventsSet')) {
  6783. emitter.trigger('eventsSet', buildEventApis(eventStore, context));
  6784. }
  6785. }
  6786. /*
  6787. this array is exposed on the root namespace so that UMD plugins can add to it.
  6788. see the rollup-bundles script.
  6789. */
  6790. var globalPlugins = [
  6791. arrayEventSourcePlugin,
  6792. funcEventSourcePlugin,
  6793. jsonFeedEventSourcePlugin,
  6794. simpleRecurringEventsPlugin,
  6795. changeHandlerPlugin,
  6796. createPlugin({
  6797. contentTypeHandlers: {
  6798. html: function () { return injectHtml; },
  6799. domNodes: function () { return injectDomNodes; }
  6800. },
  6801. propSetHandlers: {
  6802. dateProfile: handleDateProfile,
  6803. eventStore: handleEventStore
  6804. }
  6805. })
  6806. ];
  6807. var DelayedRunner = /** @class */ (function () {
  6808. function DelayedRunner(drainedOption) {
  6809. this.drainedOption = drainedOption;
  6810. this.isRunning = false;
  6811. this.isDirty = false;
  6812. this.pauseDepths = {};
  6813. this.timeoutId = 0;
  6814. }
  6815. DelayedRunner.prototype.request = function (delay) {
  6816. this.isDirty = true;
  6817. if (!this.isPaused()) {
  6818. this.clearTimeout();
  6819. if (delay == null) {
  6820. this.tryDrain();
  6821. }
  6822. else {
  6823. this.timeoutId = setTimeout(// NOT OPTIMAL! TODO: look at debounce
  6824. this.tryDrain.bind(this), delay);
  6825. }
  6826. }
  6827. };
  6828. DelayedRunner.prototype.pause = function (scope) {
  6829. if (scope === void 0) { scope = ''; }
  6830. var pauseDepths = this.pauseDepths;
  6831. pauseDepths[scope] = (pauseDepths[scope] || 0) + 1;
  6832. this.clearTimeout();
  6833. };
  6834. DelayedRunner.prototype.resume = function (scope, force) {
  6835. if (scope === void 0) { scope = ''; }
  6836. var pauseDepths = this.pauseDepths;
  6837. if (scope in pauseDepths) {
  6838. if (force) {
  6839. delete pauseDepths[scope];
  6840. }
  6841. else {
  6842. var depth = --pauseDepths[scope];
  6843. if (depth <= 0) {
  6844. delete pauseDepths[scope];
  6845. }
  6846. }
  6847. this.tryDrain();
  6848. }
  6849. };
  6850. DelayedRunner.prototype.isPaused = function () {
  6851. return Object.keys(this.pauseDepths).length;
  6852. };
  6853. DelayedRunner.prototype.tryDrain = function () {
  6854. if (!this.isRunning && !this.isPaused()) {
  6855. this.isRunning = true;
  6856. while (this.isDirty) {
  6857. this.isDirty = false;
  6858. this.drained(); // might set isDirty to true again
  6859. }
  6860. this.isRunning = false;
  6861. }
  6862. };
  6863. DelayedRunner.prototype.clear = function () {
  6864. this.clearTimeout();
  6865. this.isDirty = false;
  6866. this.pauseDepths = {};
  6867. };
  6868. DelayedRunner.prototype.clearTimeout = function () {
  6869. if (this.timeoutId) {
  6870. clearTimeout(this.timeoutId);
  6871. this.timeoutId = 0;
  6872. }
  6873. };
  6874. DelayedRunner.prototype.drained = function () {
  6875. if (this.drainedOption) {
  6876. this.drainedOption();
  6877. }
  6878. };
  6879. return DelayedRunner;
  6880. }());
  6881. var TaskRunner = /** @class */ (function () {
  6882. function TaskRunner(runTaskOption, drainedOption) {
  6883. this.runTaskOption = runTaskOption;
  6884. this.drainedOption = drainedOption;
  6885. this.queue = [];
  6886. this.delayedRunner = new DelayedRunner(this.drain.bind(this));
  6887. }
  6888. TaskRunner.prototype.request = function (task, delay) {
  6889. this.queue.push(task);
  6890. this.delayedRunner.request(delay);
  6891. };
  6892. TaskRunner.prototype.pause = function (scope) {
  6893. this.delayedRunner.pause(scope);
  6894. };
  6895. TaskRunner.prototype.resume = function (scope, force) {
  6896. this.delayedRunner.resume(scope, force);
  6897. };
  6898. TaskRunner.prototype.drain = function () {
  6899. var queue = this.queue;
  6900. while (queue.length) {
  6901. var completedTasks = [];
  6902. var task = void 0;
  6903. while ((task = queue.shift())) {
  6904. this.runTask(task);
  6905. completedTasks.push(task);
  6906. }
  6907. this.drained(completedTasks);
  6908. } // keep going, in case new tasks were added in the drained handler
  6909. };
  6910. TaskRunner.prototype.runTask = function (task) {
  6911. if (this.runTaskOption) {
  6912. this.runTaskOption(task);
  6913. }
  6914. };
  6915. TaskRunner.prototype.drained = function (completedTasks) {
  6916. if (this.drainedOption) {
  6917. this.drainedOption(completedTasks);
  6918. }
  6919. };
  6920. return TaskRunner;
  6921. }());
  6922. // Computes what the title at the top of the calendarApi should be for this view
  6923. function buildTitle(dateProfile, viewOptions, dateEnv) {
  6924. var range;
  6925. // for views that span a large unit of time, show the proper interval, ignoring stray days before and after
  6926. if (/^(year|month)$/.test(dateProfile.currentRangeUnit)) {
  6927. range = dateProfile.currentRange;
  6928. }
  6929. else { // for day units or smaller, use the actual day range
  6930. range = dateProfile.activeRange;
  6931. }
  6932. return dateEnv.formatRange(range.start, range.end, createFormatter(viewOptions.titleFormat || buildTitleFormat(dateProfile)), {
  6933. isEndExclusive: dateProfile.isRangeAllDay,
  6934. defaultSeparator: viewOptions.titleRangeSeparator
  6935. });
  6936. }
  6937. // Generates the format string that should be used to generate the title for the current date range.
  6938. // Attempts to compute the most appropriate format if not explicitly specified with `titleFormat`.
  6939. function buildTitleFormat(dateProfile) {
  6940. var currentRangeUnit = dateProfile.currentRangeUnit;
  6941. if (currentRangeUnit === 'year') {
  6942. return { year: 'numeric' };
  6943. }
  6944. else if (currentRangeUnit === 'month') {
  6945. return { year: 'numeric', month: 'long' }; // like "September 2014"
  6946. }
  6947. else {
  6948. var days = diffWholeDays(dateProfile.currentRange.start, dateProfile.currentRange.end);
  6949. if (days !== null && days > 1) {
  6950. // multi-day range. shorter, like "Sep 9 - 10 2014"
  6951. return { year: 'numeric', month: 'short', day: 'numeric' };
  6952. }
  6953. else {
  6954. // one day. longer, like "September 9 2014"
  6955. return { year: 'numeric', month: 'long', day: 'numeric' };
  6956. }
  6957. }
  6958. }
  6959. // in future refactor, do the redux-style function(state=initial) for initial-state
  6960. // also, whatever is happening in constructor, have it happen in action queue too
  6961. var CalendarDataManager = /** @class */ (function () {
  6962. function CalendarDataManager(props) {
  6963. var _this = this;
  6964. this.computeOptionsData = memoize(this._computeOptionsData);
  6965. this.computeCurrentViewData = memoize(this._computeCurrentViewData);
  6966. this.organizeRawLocales = memoize(organizeRawLocales);
  6967. this.buildLocale = memoize(buildLocale);
  6968. this.buildPluginHooks = buildBuildPluginHooks();
  6969. this.buildDateEnv = memoize(buildDateEnv$1);
  6970. this.buildTheme = memoize(buildTheme);
  6971. this.parseToolbars = memoize(parseToolbars);
  6972. this.buildViewSpecs = memoize(buildViewSpecs);
  6973. this.buildDateProfileGenerator = memoizeObjArg(buildDateProfileGenerator);
  6974. this.buildViewApi = memoize(buildViewApi);
  6975. this.buildViewUiProps = memoizeObjArg(buildViewUiProps);
  6976. this.buildEventUiBySource = memoize(buildEventUiBySource, isPropsEqual);
  6977. this.buildEventUiBases = memoize(buildEventUiBases);
  6978. this.parseContextBusinessHours = memoizeObjArg(parseContextBusinessHours);
  6979. this.buildTitle = memoize(buildTitle);
  6980. this.emitter = new Emitter();
  6981. this.actionRunner = new TaskRunner(this._handleAction.bind(this), this.updateData.bind(this));
  6982. this.currentCalendarOptionsInput = {};
  6983. this.currentCalendarOptionsRefined = {};
  6984. this.currentViewOptionsInput = {};
  6985. this.currentViewOptionsRefined = {};
  6986. this.currentCalendarOptionsRefiners = {};
  6987. this.getCurrentData = function () {
  6988. return _this.data;
  6989. };
  6990. this.dispatch = function (action) {
  6991. _this.actionRunner.request(action); // protects against recursive calls to _handleAction
  6992. };
  6993. this.props = props;
  6994. this.actionRunner.pause();
  6995. var dynamicOptionOverrides = {};
  6996. var optionsData = this.computeOptionsData(props.optionOverrides, dynamicOptionOverrides, props.calendarApi);
  6997. var currentViewType = optionsData.calendarOptions.initialView || optionsData.pluginHooks.initialView;
  6998. var currentViewData = this.computeCurrentViewData(currentViewType, optionsData, props.optionOverrides, dynamicOptionOverrides);
  6999. // wire things up
  7000. // TODO: not DRY
  7001. props.calendarApi.currentDataManager = this;
  7002. this.emitter.setThisContext(props.calendarApi);
  7003. this.emitter.setOptions(currentViewData.options);
  7004. var currentDate = getInitialDate(optionsData.calendarOptions, optionsData.dateEnv);
  7005. var dateProfile = currentViewData.dateProfileGenerator.build(currentDate);
  7006. if (!rangeContainsMarker(dateProfile.activeRange, currentDate)) {
  7007. currentDate = dateProfile.currentRange.start;
  7008. }
  7009. var calendarContext = {
  7010. dateEnv: optionsData.dateEnv,
  7011. options: optionsData.calendarOptions,
  7012. pluginHooks: optionsData.pluginHooks,
  7013. calendarApi: props.calendarApi,
  7014. dispatch: this.dispatch,
  7015. emitter: this.emitter,
  7016. getCurrentData: this.getCurrentData
  7017. };
  7018. // needs to be after setThisContext
  7019. for (var _i = 0, _a = optionsData.pluginHooks.contextInit; _i < _a.length; _i++) {
  7020. var callback = _a[_i];
  7021. callback(calendarContext);
  7022. }
  7023. // NOT DRY
  7024. var eventSources = initEventSources(optionsData.calendarOptions, dateProfile, calendarContext);
  7025. var initialState = {
  7026. dynamicOptionOverrides: dynamicOptionOverrides,
  7027. currentViewType: currentViewType,
  7028. currentDate: currentDate,
  7029. dateProfile: dateProfile,
  7030. businessHours: this.parseContextBusinessHours(calendarContext),
  7031. eventSources: eventSources,
  7032. eventUiBases: {},
  7033. loadingLevel: computeEventSourceLoadingLevel(eventSources),
  7034. eventStore: createEmptyEventStore(),
  7035. renderableEventStore: createEmptyEventStore(),
  7036. dateSelection: null,
  7037. eventSelection: '',
  7038. eventDrag: null,
  7039. eventResize: null,
  7040. selectionConfig: this.buildViewUiProps(calendarContext).selectionConfig
  7041. };
  7042. var contextAndState = __assign(__assign({}, calendarContext), initialState);
  7043. for (var _b = 0, _c = optionsData.pluginHooks.reducers; _b < _c.length; _b++) {
  7044. var reducer = _c[_b];
  7045. __assign(initialState, reducer(null, null, contextAndState));
  7046. }
  7047. if (initialState.loadingLevel) {
  7048. this.emitter.trigger('loading', true); // NOT DRY
  7049. }
  7050. this.state = initialState;
  7051. this.updateData();
  7052. this.actionRunner.resume();
  7053. }
  7054. CalendarDataManager.prototype.resetOptions = function (optionOverrides, append) {
  7055. var props = this.props;
  7056. props.optionOverrides = append
  7057. ? __assign(__assign({}, props.optionOverrides), optionOverrides) : optionOverrides;
  7058. this.actionRunner.request({
  7059. type: 'NOTHING'
  7060. });
  7061. };
  7062. CalendarDataManager.prototype._handleAction = function (action) {
  7063. var _a = this, props = _a.props, state = _a.state, emitter = _a.emitter;
  7064. var dynamicOptionOverrides = reduceDynamicOptionOverrides(state.dynamicOptionOverrides, action);
  7065. var optionsData = this.computeOptionsData(props.optionOverrides, dynamicOptionOverrides, props.calendarApi);
  7066. var currentViewType = reduceViewType(state.currentViewType, action);
  7067. var currentViewData = this.computeCurrentViewData(currentViewType, optionsData, props.optionOverrides, dynamicOptionOverrides);
  7068. // wire things up
  7069. // TODO: not DRY
  7070. props.calendarApi.currentDataManager = this;
  7071. emitter.setThisContext(props.calendarApi);
  7072. emitter.setOptions(currentViewData.options);
  7073. var calendarContext = {
  7074. dateEnv: optionsData.dateEnv,
  7075. options: optionsData.calendarOptions,
  7076. pluginHooks: optionsData.pluginHooks,
  7077. calendarApi: props.calendarApi,
  7078. dispatch: this.dispatch,
  7079. emitter: emitter,
  7080. getCurrentData: this.getCurrentData
  7081. };
  7082. var currentDate = state.currentDate;
  7083. var dateProfile = state.dateProfile;
  7084. if (this.data && this.data.dateProfileGenerator !== currentViewData.dateProfileGenerator) { // hack
  7085. dateProfile = currentViewData.dateProfileGenerator.build(currentDate);
  7086. }
  7087. currentDate = reduceCurrentDate(currentDate, action);
  7088. dateProfile = reduceDateProfile(dateProfile, action, currentDate, currentViewData.dateProfileGenerator);
  7089. if (!rangeContainsMarker(dateProfile.currentRange, currentDate)) {
  7090. currentDate = dateProfile.currentRange.start;
  7091. }
  7092. var eventSources = reduceEventSources(state.eventSources, action, dateProfile, calendarContext);
  7093. var eventSourceLoadingLevel = computeEventSourceLoadingLevel(eventSources);
  7094. var eventStore = reduceEventStore(state.eventStore, action, eventSources, dateProfile, calendarContext);
  7095. var renderableEventStore = (eventSourceLoadingLevel && !currentViewData.options.progressiveEventRendering) ?
  7096. (state.renderableEventStore || eventStore) : // try from previous state
  7097. eventStore;
  7098. var _b = this.buildViewUiProps(calendarContext), eventUiSingleBase = _b.eventUiSingleBase, selectionConfig = _b.selectionConfig; // will memoize obj
  7099. var eventUiBySource = this.buildEventUiBySource(eventSources);
  7100. var eventUiBases = this.buildEventUiBases(renderableEventStore.defs, eventUiSingleBase, eventUiBySource);
  7101. var prevLoadingLevel = state.loadingLevel || 0;
  7102. var loadingLevel = eventSourceLoadingLevel;
  7103. var newState = {
  7104. dynamicOptionOverrides: dynamicOptionOverrides,
  7105. currentViewType: currentViewType,
  7106. currentDate: currentDate,
  7107. dateProfile: dateProfile,
  7108. eventSources: eventSources,
  7109. eventStore: eventStore,
  7110. renderableEventStore: renderableEventStore,
  7111. selectionConfig: selectionConfig,
  7112. eventUiBases: eventUiBases,
  7113. loadingLevel: loadingLevel,
  7114. businessHours: this.parseContextBusinessHours(calendarContext),
  7115. dateSelection: reduceDateSelection(state.dateSelection, action),
  7116. eventSelection: reduceSelectedEvent(state.eventSelection, action),
  7117. eventDrag: reduceEventDrag(state.eventDrag, action),
  7118. eventResize: reduceEventResize(state.eventResize, action)
  7119. };
  7120. var contextAndState = __assign(__assign({}, calendarContext), newState);
  7121. for (var _i = 0, _c = optionsData.pluginHooks.reducers; _i < _c.length; _i++) {
  7122. var reducer = _c[_i];
  7123. __assign(newState, reducer(state, action, contextAndState)); // give the OLD state, for old value
  7124. }
  7125. // TODO: use propSetHandlers in plugin system
  7126. if (!prevLoadingLevel && loadingLevel) {
  7127. emitter.trigger('loading', true);
  7128. }
  7129. else if (prevLoadingLevel && !loadingLevel) {
  7130. emitter.trigger('loading', false);
  7131. }
  7132. this.state = newState;
  7133. if (props.onAction) {
  7134. props.onAction(action);
  7135. }
  7136. };
  7137. CalendarDataManager.prototype.updateData = function () {
  7138. var _a = this, props = _a.props, state = _a.state;
  7139. var oldData = this.data;
  7140. var optionsData = this.computeOptionsData(props.optionOverrides, state.dynamicOptionOverrides, props.calendarApi);
  7141. var currentViewData = this.computeCurrentViewData(state.currentViewType, optionsData, props.optionOverrides, state.dynamicOptionOverrides);
  7142. var data = this.data = __assign(__assign(__assign({ viewTitle: this.buildTitle(state.dateProfile, currentViewData.options, optionsData.dateEnv), calendarApi: props.calendarApi, dispatch: this.dispatch, emitter: this.emitter, getCurrentData: this.getCurrentData }, optionsData), currentViewData), state);
  7143. var changeHandlers = optionsData.pluginHooks.optionChangeHandlers;
  7144. var oldCalendarOptions = oldData && oldData.calendarOptions;
  7145. var newCalendarOptions = optionsData.calendarOptions;
  7146. if (oldCalendarOptions && oldCalendarOptions !== newCalendarOptions) {
  7147. if (oldCalendarOptions.timeZone !== newCalendarOptions.timeZone) {
  7148. // hack
  7149. state.eventSources = data.eventSources = reduceEventSourcesNewTimeZone(data.eventSources, state.dateProfile, data);
  7150. state.eventStore = data.eventStore = rezoneEventStoreDates(data.eventStore, oldData.dateEnv, data.dateEnv);
  7151. }
  7152. for (var optionName in changeHandlers) {
  7153. if (oldCalendarOptions[optionName] !== newCalendarOptions[optionName]) {
  7154. changeHandlers[optionName](newCalendarOptions[optionName], data);
  7155. }
  7156. }
  7157. }
  7158. if (props.onData) {
  7159. props.onData(data);
  7160. }
  7161. };
  7162. CalendarDataManager.prototype._computeOptionsData = function (optionOverrides, dynamicOptionOverrides, calendarApi) {
  7163. // TODO: blacklist options that are handled by optionChangeHandlers
  7164. var _a = this.processRawCalendarOptions(optionOverrides, dynamicOptionOverrides), refinedOptions = _a.refinedOptions, pluginHooks = _a.pluginHooks, localeDefaults = _a.localeDefaults, availableLocaleData = _a.availableLocaleData, extra = _a.extra;
  7165. warnUnknownOptions(extra);
  7166. var dateEnv = this.buildDateEnv(refinedOptions.timeZone, refinedOptions.locale, refinedOptions.weekNumberCalculation, refinedOptions.firstDay, refinedOptions.weekText, pluginHooks, availableLocaleData, refinedOptions.defaultRangeSeparator);
  7167. var viewSpecs = this.buildViewSpecs(pluginHooks.views, optionOverrides, dynamicOptionOverrides, localeDefaults);
  7168. var theme = this.buildTheme(refinedOptions, pluginHooks);
  7169. var toolbarConfig = this.parseToolbars(refinedOptions, optionOverrides, theme, viewSpecs, calendarApi);
  7170. return {
  7171. calendarOptions: refinedOptions,
  7172. pluginHooks: pluginHooks,
  7173. dateEnv: dateEnv,
  7174. viewSpecs: viewSpecs,
  7175. theme: theme,
  7176. toolbarConfig: toolbarConfig,
  7177. localeDefaults: localeDefaults,
  7178. availableRawLocales: availableLocaleData.map
  7179. };
  7180. };
  7181. // always called from behind a memoizer
  7182. CalendarDataManager.prototype.processRawCalendarOptions = function (optionOverrides, dynamicOptionOverrides) {
  7183. var _a = mergeRawOptions([
  7184. BASE_OPTION_DEFAULTS,
  7185. optionOverrides,
  7186. dynamicOptionOverrides
  7187. ]), locales = _a.locales, locale = _a.locale;
  7188. var availableLocaleData = this.organizeRawLocales(locales);
  7189. var availableRawLocales = availableLocaleData.map;
  7190. var localeDefaults = this.buildLocale(locale || availableLocaleData.defaultCode, availableRawLocales).options;
  7191. var pluginHooks = this.buildPluginHooks(optionOverrides.plugins || [], globalPlugins);
  7192. var refiners = this.currentCalendarOptionsRefiners = __assign(__assign(__assign(__assign(__assign({}, BASE_OPTION_REFINERS), CALENDAR_LISTENER_REFINERS), CALENDAR_OPTION_REFINERS), pluginHooks.listenerRefiners), pluginHooks.optionRefiners);
  7193. var extra = {};
  7194. var raw = mergeRawOptions([
  7195. BASE_OPTION_DEFAULTS,
  7196. localeDefaults,
  7197. optionOverrides,
  7198. dynamicOptionOverrides
  7199. ]);
  7200. var refined = {};
  7201. var currentRaw = this.currentCalendarOptionsInput;
  7202. var currentRefined = this.currentCalendarOptionsRefined;
  7203. var anyChanges = false;
  7204. for (var optionName in raw) {
  7205. if (optionName !== 'plugins') { // because plugins is special-cased
  7206. if (raw[optionName] === currentRaw[optionName] ||
  7207. (COMPLEX_OPTION_COMPARATORS[optionName] && (optionName in currentRaw) && COMPLEX_OPTION_COMPARATORS[optionName](currentRaw[optionName], raw[optionName]))) {
  7208. refined[optionName] = currentRefined[optionName];
  7209. }
  7210. else if (refiners[optionName]) {
  7211. refined[optionName] = refiners[optionName](raw[optionName]);
  7212. anyChanges = true;
  7213. }
  7214. else {
  7215. extra[optionName] = currentRaw[optionName];
  7216. }
  7217. }
  7218. }
  7219. if (anyChanges) {
  7220. this.currentCalendarOptionsInput = raw;
  7221. this.currentCalendarOptionsRefined = refined;
  7222. }
  7223. return {
  7224. rawOptions: this.currentCalendarOptionsInput,
  7225. refinedOptions: this.currentCalendarOptionsRefined,
  7226. pluginHooks: pluginHooks,
  7227. availableLocaleData: availableLocaleData,
  7228. localeDefaults: localeDefaults,
  7229. extra: extra
  7230. };
  7231. };
  7232. CalendarDataManager.prototype._computeCurrentViewData = function (viewType, optionsData, optionOverrides, dynamicOptionOverrides) {
  7233. var viewSpec = optionsData.viewSpecs[viewType];
  7234. if (!viewSpec) {
  7235. throw new Error("viewType \"" + viewType + "\" is not available. Please make sure you've loaded all neccessary plugins");
  7236. }
  7237. var _a = this.processRawViewOptions(viewSpec, optionsData.pluginHooks, optionsData.localeDefaults, optionOverrides, dynamicOptionOverrides), refinedOptions = _a.refinedOptions, extra = _a.extra;
  7238. warnUnknownOptions(extra);
  7239. var dateProfileGenerator = this.buildDateProfileGenerator({
  7240. dateProfileGeneratorClass: viewSpec.optionDefaults.dateProfileGeneratorClass,
  7241. duration: viewSpec.duration,
  7242. durationUnit: viewSpec.durationUnit,
  7243. usesMinMaxTime: viewSpec.optionDefaults.usesMinMaxTime,
  7244. dateEnv: optionsData.dateEnv,
  7245. calendarApi: this.props.calendarApi,
  7246. slotMinTime: refinedOptions.slotMinTime,
  7247. slotMaxTime: refinedOptions.slotMaxTime,
  7248. showNonCurrentDates: refinedOptions.showNonCurrentDates,
  7249. dayCount: refinedOptions.dayCount,
  7250. dateAlignment: refinedOptions.dateAlignment,
  7251. dateIncrement: refinedOptions.dateIncrement,
  7252. hiddenDays: refinedOptions.hiddenDays,
  7253. weekends: refinedOptions.weekends,
  7254. nowInput: refinedOptions.now,
  7255. validRangeInput: refinedOptions.validRange,
  7256. visibleRangeInput: refinedOptions.visibleRange,
  7257. monthMode: refinedOptions.monthMode,
  7258. fixedWeekCount: refinedOptions.fixedWeekCount
  7259. });
  7260. var viewApi = this.buildViewApi(viewType, this.getCurrentData, optionsData.dateEnv);
  7261. return { viewSpec: viewSpec, options: refinedOptions, dateProfileGenerator: dateProfileGenerator, viewApi: viewApi };
  7262. };
  7263. CalendarDataManager.prototype.processRawViewOptions = function (viewSpec, pluginHooks, localeDefaults, optionOverrides, dynamicOptionOverrides) {
  7264. var raw = mergeRawOptions([
  7265. BASE_OPTION_DEFAULTS,
  7266. viewSpec.optionDefaults,
  7267. localeDefaults,
  7268. optionOverrides,
  7269. viewSpec.optionOverrides,
  7270. dynamicOptionOverrides
  7271. ]);
  7272. var refiners = __assign(__assign(__assign(__assign(__assign(__assign({}, BASE_OPTION_REFINERS), CALENDAR_LISTENER_REFINERS), CALENDAR_OPTION_REFINERS), VIEW_OPTION_REFINERS), pluginHooks.listenerRefiners), pluginHooks.optionRefiners);
  7273. var refined = {};
  7274. var currentRaw = this.currentViewOptionsInput;
  7275. var currentRefined = this.currentViewOptionsRefined;
  7276. var anyChanges = false;
  7277. var extra = {};
  7278. for (var optionName in raw) {
  7279. if (raw[optionName] === currentRaw[optionName]) {
  7280. refined[optionName] = currentRefined[optionName];
  7281. }
  7282. else {
  7283. if (raw[optionName] === this.currentCalendarOptionsInput[optionName]) {
  7284. if (optionName in this.currentCalendarOptionsRefined) { // might be an "extra" prop
  7285. refined[optionName] = this.currentCalendarOptionsRefined[optionName];
  7286. }
  7287. }
  7288. else if (refiners[optionName]) {
  7289. refined[optionName] = refiners[optionName](raw[optionName]);
  7290. }
  7291. else {
  7292. extra[optionName] = raw[optionName];
  7293. }
  7294. anyChanges = true;
  7295. }
  7296. }
  7297. if (anyChanges) {
  7298. this.currentViewOptionsInput = raw;
  7299. this.currentViewOptionsRefined = refined;
  7300. }
  7301. return {
  7302. rawOptions: this.currentViewOptionsInput,
  7303. refinedOptions: this.currentViewOptionsRefined,
  7304. extra: extra
  7305. };
  7306. };
  7307. return CalendarDataManager;
  7308. }());
  7309. function buildDateEnv$1(timeZone, explicitLocale, weekNumberCalculation, firstDay, weekText, pluginHooks, availableLocaleData, defaultSeparator) {
  7310. var locale = buildLocale(explicitLocale || availableLocaleData.defaultCode, availableLocaleData.map);
  7311. return new DateEnv({
  7312. calendarSystem: 'gregory',
  7313. timeZone: timeZone,
  7314. namedTimeZoneImpl: pluginHooks.namedTimeZonedImpl,
  7315. locale: locale,
  7316. weekNumberCalculation: weekNumberCalculation,
  7317. firstDay: firstDay,
  7318. weekText: weekText,
  7319. cmdFormatter: pluginHooks.cmdFormatter,
  7320. defaultSeparator: defaultSeparator
  7321. });
  7322. }
  7323. function buildTheme(options, pluginHooks) {
  7324. var ThemeClass = pluginHooks.themeClasses[options.themeSystem] || StandardTheme;
  7325. return new ThemeClass(options);
  7326. }
  7327. function buildDateProfileGenerator(props) {
  7328. var DateProfileGeneratorClass = props.dateProfileGeneratorClass || DateProfileGenerator;
  7329. return new DateProfileGeneratorClass(props);
  7330. }
  7331. function buildViewApi(type, getCurrentData, dateEnv) {
  7332. return new ViewApi(type, getCurrentData, dateEnv);
  7333. }
  7334. function buildEventUiBySource(eventSources) {
  7335. return mapHash(eventSources, function (eventSource) {
  7336. return eventSource.ui;
  7337. });
  7338. }
  7339. function buildEventUiBases(eventDefs, eventUiSingleBase, eventUiBySource) {
  7340. var eventUiBases = { '': eventUiSingleBase };
  7341. for (var defId in eventDefs) {
  7342. var def = eventDefs[defId];
  7343. if (def.sourceId && eventUiBySource[def.sourceId]) {
  7344. eventUiBases[defId] = eventUiBySource[def.sourceId];
  7345. }
  7346. }
  7347. return eventUiBases;
  7348. }
  7349. function buildViewUiProps(calendarContext) {
  7350. var options = calendarContext.options;
  7351. return {
  7352. eventUiSingleBase: createEventUi({
  7353. display: options.eventDisplay,
  7354. editable: options.editable,
  7355. startEditable: options.eventStartEditable,
  7356. durationEditable: options.eventDurationEditable,
  7357. constraint: options.eventConstraint,
  7358. overlap: typeof options.eventOverlap === 'boolean' ? options.eventOverlap : undefined,
  7359. allow: options.eventAllow,
  7360. backgroundColor: options.eventBackgroundColor,
  7361. borderColor: options.eventBorderColor,
  7362. textColor: options.eventTextColor,
  7363. color: options.eventColor
  7364. // classNames: options.eventClassNames // render hook will handle this
  7365. }, calendarContext),
  7366. selectionConfig: createEventUi({
  7367. constraint: options.selectConstraint,
  7368. overlap: typeof options.selectOverlap === 'boolean' ? options.selectOverlap : undefined,
  7369. allow: options.selectAllow
  7370. }, calendarContext)
  7371. };
  7372. }
  7373. function parseContextBusinessHours(calendarContext) {
  7374. return parseBusinessHours(calendarContext.options.businessHours, calendarContext);
  7375. }
  7376. function warnUnknownOptions(options, viewName) {
  7377. for (var optionName in options) {
  7378. console.warn("Unknown option '" + optionName + "'" +
  7379. (viewName ? " for view '" + viewName + "'" : ''));
  7380. }
  7381. }
  7382. // TODO: move this to react plugin?
  7383. var CalendarDataProvider = /** @class */ (function (_super) {
  7384. __extends(CalendarDataProvider, _super);
  7385. function CalendarDataProvider(props) {
  7386. var _this = _super.call(this, props) || this;
  7387. _this.handleData = function (data) {
  7388. if (!_this.dataManager) { // still within initial run, before assignment in constructor
  7389. // eslint-disable-next-line react/no-direct-mutation-state
  7390. _this.state = data; // can't use setState yet
  7391. }
  7392. else {
  7393. _this.setState(data);
  7394. }
  7395. };
  7396. _this.dataManager = new CalendarDataManager({
  7397. optionOverrides: props.optionOverrides,
  7398. calendarApi: props.calendarApi,
  7399. onData: _this.handleData
  7400. });
  7401. return _this;
  7402. }
  7403. CalendarDataProvider.prototype.render = function () {
  7404. return this.props.children(this.state);
  7405. };
  7406. CalendarDataProvider.prototype.componentDidUpdate = function (prevProps) {
  7407. var newOptionOverrides = this.props.optionOverrides;
  7408. if (newOptionOverrides !== prevProps.optionOverrides) { // prevent recursive handleData
  7409. this.dataManager.resetOptions(newOptionOverrides);
  7410. }
  7411. };
  7412. return CalendarDataProvider;
  7413. }(Component));
  7414. // HELPERS
  7415. /*
  7416. if nextDayThreshold is specified, slicing is done in an all-day fashion.
  7417. you can get nextDayThreshold from context.nextDayThreshold
  7418. */
  7419. function sliceEvents(props, allDay) {
  7420. return sliceEventStore(props.eventStore, props.eventUiBases, props.dateProfile.activeRange, allDay ? props.nextDayThreshold : null).fg;
  7421. }
  7422. var NamedTimeZoneImpl = /** @class */ (function () {
  7423. function NamedTimeZoneImpl(timeZoneName) {
  7424. this.timeZoneName = timeZoneName;
  7425. }
  7426. return NamedTimeZoneImpl;
  7427. }());
  7428. var Interaction = /** @class */ (function () {
  7429. function Interaction(settings) {
  7430. this.component = settings.component;
  7431. }
  7432. Interaction.prototype.destroy = function () {
  7433. };
  7434. return Interaction;
  7435. }());
  7436. function parseInteractionSettings(component, input) {
  7437. return {
  7438. component: component,
  7439. el: input.el,
  7440. useEventCenter: input.useEventCenter != null ? input.useEventCenter : true
  7441. };
  7442. }
  7443. function interactionSettingsToStore(settings) {
  7444. var _a;
  7445. return _a = {},
  7446. _a[settings.component.uid] = settings,
  7447. _a;
  7448. }
  7449. // global state
  7450. var interactionSettingsStore = {};
  7451. /*
  7452. An abstraction for a dragging interaction originating on an event.
  7453. Does higher-level things than PointerDragger, such as possibly:
  7454. - a "mirror" that moves with the pointer
  7455. - a minimum number of pixels or other criteria for a true drag to begin
  7456. subclasses must emit:
  7457. - pointerdown
  7458. - dragstart
  7459. - dragmove
  7460. - pointerup
  7461. - dragend
  7462. */
  7463. var ElementDragging = /** @class */ (function () {
  7464. function ElementDragging(el, selector) {
  7465. this.emitter = new Emitter();
  7466. }
  7467. ElementDragging.prototype.destroy = function () {
  7468. };
  7469. ElementDragging.prototype.setMirrorIsVisible = function (bool) {
  7470. // optional if subclass doesn't want to support a mirror
  7471. };
  7472. ElementDragging.prototype.setMirrorNeedsRevert = function (bool) {
  7473. // optional if subclass doesn't want to support a mirror
  7474. };
  7475. ElementDragging.prototype.setAutoScrollEnabled = function (bool) {
  7476. // optional
  7477. };
  7478. return ElementDragging;
  7479. }());
  7480. // TODO: get rid of this in favor of options system,
  7481. // tho it's really easy to access this globally rather than pass thru options.
  7482. var config = {};
  7483. /*
  7484. Information about what will happen when an external element is dragged-and-dropped
  7485. onto a calendar. Contains information for creating an event.
  7486. */
  7487. var DRAG_META_REFINERS = {
  7488. startTime: createDuration,
  7489. duration: createDuration,
  7490. create: Boolean,
  7491. sourceId: String
  7492. };
  7493. function parseDragMeta(raw) {
  7494. var _a = refineProps(raw, DRAG_META_REFINERS), refined = _a.refined, extra = _a.extra;
  7495. return {
  7496. startTime: refined.startTime || null,
  7497. duration: refined.duration || null,
  7498. create: refined.create != null ? refined.create : true,
  7499. sourceId: refined.sourceId,
  7500. leftoverProps: extra
  7501. };
  7502. }
  7503. var Toolbar = /** @class */ (function (_super) {
  7504. __extends(Toolbar, _super);
  7505. function Toolbar() {
  7506. return _super !== null && _super.apply(this, arguments) || this;
  7507. }
  7508. Toolbar.prototype.render = function () {
  7509. var _a = this.props, model = _a.model, extraClassName = _a.extraClassName;
  7510. var forceLtr = false;
  7511. var startContent, endContent;
  7512. var centerContent = model.center;
  7513. if (model.left) {
  7514. forceLtr = true;
  7515. startContent = model.left;
  7516. }
  7517. else {
  7518. startContent = model.start;
  7519. }
  7520. if (model.right) {
  7521. forceLtr = true;
  7522. endContent = model.right;
  7523. }
  7524. else {
  7525. endContent = model.end;
  7526. }
  7527. var classNames = [
  7528. extraClassName || '',
  7529. 'fc-toolbar',
  7530. forceLtr ? 'fc-toolbar-ltr' : ''
  7531. ];
  7532. return (createElement("div", { className: classNames.join(' ') },
  7533. this.renderSection('start', startContent || []),
  7534. this.renderSection('center', centerContent || []),
  7535. this.renderSection('end', endContent || [])));
  7536. };
  7537. Toolbar.prototype.renderSection = function (key, widgetGroups) {
  7538. var props = this.props;
  7539. return (createElement(ToolbarSection, { key: key, widgetGroups: widgetGroups, title: props.title, activeButton: props.activeButton, isTodayEnabled: props.isTodayEnabled, isPrevEnabled: props.isPrevEnabled, isNextEnabled: props.isNextEnabled }));
  7540. };
  7541. return Toolbar;
  7542. }(BaseComponent));
  7543. var ToolbarSection = /** @class */ (function (_super) {
  7544. __extends(ToolbarSection, _super);
  7545. function ToolbarSection() {
  7546. return _super !== null && _super.apply(this, arguments) || this;
  7547. }
  7548. ToolbarSection.prototype.render = function () {
  7549. var _this = this;
  7550. var children = this.props.widgetGroups.map(function (widgetGroup) { return _this.renderWidgetGroup(widgetGroup); });
  7551. return createElement.apply(void 0, __spreadArrays(['div', { className: 'fc-toolbar-chunk' }], children));
  7552. };
  7553. ToolbarSection.prototype.renderWidgetGroup = function (widgetGroup) {
  7554. var props = this.props;
  7555. var theme = this.context.theme;
  7556. var children = [];
  7557. var isOnlyButtons = true;
  7558. for (var _i = 0, widgetGroup_1 = widgetGroup; _i < widgetGroup_1.length; _i++) {
  7559. var widget = widgetGroup_1[_i];
  7560. var buttonName = widget.buttonName, buttonClick = widget.buttonClick, buttonText = widget.buttonText, buttonIcon = widget.buttonIcon;
  7561. if (buttonName === 'title') {
  7562. isOnlyButtons = false;
  7563. children.push(createElement("h2", { className: 'fc-toolbar-title' }, props.title));
  7564. }
  7565. else {
  7566. var ariaAttrs = buttonIcon ? { 'aria-label': buttonName } : {};
  7567. var buttonClasses = ['fc-' + buttonName + '-button', theme.getClass('button')];
  7568. if (buttonName === props.activeButton) {
  7569. buttonClasses.push(theme.getClass('buttonActive'));
  7570. }
  7571. var isDisabled = (!props.isTodayEnabled && buttonName === 'today') ||
  7572. (!props.isPrevEnabled && buttonName === 'prev') ||
  7573. (!props.isNextEnabled && buttonName === 'next');
  7574. children.push(createElement("button", __assign({ disabled: isDisabled, className: buttonClasses.join(' '), onClick: buttonClick, type: 'button' }, ariaAttrs), buttonText || (buttonIcon ? createElement("span", { className: buttonIcon }) : '')));
  7575. }
  7576. }
  7577. if (children.length > 1) {
  7578. var groupClassName = (isOnlyButtons && theme.getClass('buttonGroup')) || '';
  7579. return createElement.apply(void 0, __spreadArrays(['div', { className: groupClassName }], children));
  7580. }
  7581. else {
  7582. return children[0];
  7583. }
  7584. };
  7585. return ToolbarSection;
  7586. }(BaseComponent));
  7587. // TODO: do function component?
  7588. var ViewContainer = /** @class */ (function (_super) {
  7589. __extends(ViewContainer, _super);
  7590. function ViewContainer() {
  7591. return _super !== null && _super.apply(this, arguments) || this;
  7592. }
  7593. ViewContainer.prototype.render = function () {
  7594. var props = this.props;
  7595. var aspectRatio = props.aspectRatio;
  7596. var classNames = [
  7597. 'fc-view-harness',
  7598. (aspectRatio || props.liquid || props.height)
  7599. ? 'fc-view-harness-active' // harness controls the height
  7600. : 'fc-view-harness-passive' // let the view do the height
  7601. ];
  7602. var height = '';
  7603. var paddingBottom = '';
  7604. if (aspectRatio) {
  7605. paddingBottom = (1 / aspectRatio) * 100 + '%';
  7606. }
  7607. else {
  7608. height = props.height || '';
  7609. }
  7610. return (createElement("div", { ref: props.elRef, onClick: props.onClick, className: classNames.join(' '), style: { height: height, paddingBottom: paddingBottom } }, props.children));
  7611. };
  7612. return ViewContainer;
  7613. }(BaseComponent));
  7614. /*
  7615. Detects when the user clicks on an event within a DateComponent
  7616. */
  7617. var EventClicking = /** @class */ (function (_super) {
  7618. __extends(EventClicking, _super);
  7619. function EventClicking(settings) {
  7620. var _this = _super.call(this, settings) || this;
  7621. _this.handleSegClick = function (ev, segEl) {
  7622. var component = _this.component;
  7623. var context = component.context;
  7624. var seg = getElSeg(segEl);
  7625. if (seg && // might be the <div> surrounding the more link
  7626. component.isValidSegDownEl(ev.target)) {
  7627. // our way to simulate a link click for elements that can't be <a> tags
  7628. // grab before trigger fired in case trigger trashes DOM thru rerendering
  7629. var hasUrlContainer = elementClosest(ev.target, '.fc-event-forced-url');
  7630. var url = hasUrlContainer ? hasUrlContainer.querySelector('a[href]').href : '';
  7631. context.emitter.trigger('eventClick', {
  7632. el: segEl,
  7633. event: new EventApi(component.context, seg.eventRange.def, seg.eventRange.instance),
  7634. jsEvent: ev,
  7635. view: context.viewApi
  7636. });
  7637. if (url && !ev.defaultPrevented) {
  7638. window.location.href = url;
  7639. }
  7640. }
  7641. };
  7642. _this.destroy = listenBySelector(settings.el, 'click', '.fc-event', // on both fg and bg events
  7643. _this.handleSegClick);
  7644. return _this;
  7645. }
  7646. return EventClicking;
  7647. }(Interaction));
  7648. /*
  7649. Triggers events and adds/removes core classNames when the user's pointer
  7650. enters/leaves event-elements of a component.
  7651. */
  7652. var EventHovering = /** @class */ (function (_super) {
  7653. __extends(EventHovering, _super);
  7654. function EventHovering(settings) {
  7655. var _this = _super.call(this, settings) || this;
  7656. // for simulating an eventMouseLeave when the event el is destroyed while mouse is over it
  7657. _this.handleEventElRemove = function (el) {
  7658. if (el === _this.currentSegEl) {
  7659. _this.handleSegLeave(null, _this.currentSegEl);
  7660. }
  7661. };
  7662. _this.handleSegEnter = function (ev, segEl) {
  7663. if (getElSeg(segEl)) { // TODO: better way to make sure not hovering over more+ link or its wrapper
  7664. _this.currentSegEl = segEl;
  7665. _this.triggerEvent('eventMouseEnter', ev, segEl);
  7666. }
  7667. };
  7668. _this.handleSegLeave = function (ev, segEl) {
  7669. if (_this.currentSegEl) {
  7670. _this.currentSegEl = null;
  7671. _this.triggerEvent('eventMouseLeave', ev, segEl);
  7672. }
  7673. };
  7674. _this.removeHoverListeners = listenToHoverBySelector(settings.el, '.fc-event', // on both fg and bg events
  7675. _this.handleSegEnter, _this.handleSegLeave);
  7676. return _this;
  7677. }
  7678. EventHovering.prototype.destroy = function () {
  7679. this.removeHoverListeners();
  7680. };
  7681. EventHovering.prototype.triggerEvent = function (publicEvName, ev, segEl) {
  7682. var component = this.component;
  7683. var context = component.context;
  7684. var seg = getElSeg(segEl);
  7685. if (!ev || component.isValidSegDownEl(ev.target)) {
  7686. context.emitter.trigger(publicEvName, {
  7687. el: segEl,
  7688. event: new EventApi(context, seg.eventRange.def, seg.eventRange.instance),
  7689. jsEvent: ev,
  7690. view: context.viewApi
  7691. });
  7692. }
  7693. };
  7694. return EventHovering;
  7695. }(Interaction));
  7696. var CalendarContent = /** @class */ (function (_super) {
  7697. __extends(CalendarContent, _super);
  7698. function CalendarContent() {
  7699. var _this = _super !== null && _super.apply(this, arguments) || this;
  7700. _this.buildViewContext = memoize(buildViewContext);
  7701. _this.buildViewPropTransformers = memoize(buildViewPropTransformers);
  7702. _this.buildToolbarProps = memoize(buildToolbarProps);
  7703. _this.handleNavLinkClick = buildDelegationHandler('a[data-navlink]', _this._handleNavLinkClick.bind(_this));
  7704. _this.headerRef = createRef();
  7705. _this.footerRef = createRef();
  7706. _this.interactionsStore = {};
  7707. // Component Registration
  7708. // -----------------------------------------------------------------------------------------------------------------
  7709. _this.registerInteractiveComponent = function (component, settingsInput) {
  7710. var settings = parseInteractionSettings(component, settingsInput);
  7711. var DEFAULT_INTERACTIONS = [
  7712. EventClicking,
  7713. EventHovering
  7714. ];
  7715. var interactionClasses = DEFAULT_INTERACTIONS.concat(_this.props.pluginHooks.componentInteractions);
  7716. var interactions = interactionClasses.map(function (interactionClass) {
  7717. return new interactionClass(settings);
  7718. });
  7719. _this.interactionsStore[component.uid] = interactions;
  7720. interactionSettingsStore[component.uid] = settings;
  7721. };
  7722. _this.unregisterInteractiveComponent = function (component) {
  7723. for (var _i = 0, _a = _this.interactionsStore[component.uid]; _i < _a.length; _i++) {
  7724. var listener = _a[_i];
  7725. listener.destroy();
  7726. }
  7727. delete _this.interactionsStore[component.uid];
  7728. delete interactionSettingsStore[component.uid];
  7729. };
  7730. // Resizing
  7731. // -----------------------------------------------------------------------------------------------------------------
  7732. _this.resizeRunner = new DelayedRunner(function () {
  7733. _this.props.emitter.trigger('_resize', true); // should window resizes be considered "forced" ?
  7734. _this.props.emitter.trigger('windowResize', { view: _this.props.viewApi });
  7735. });
  7736. _this.handleWindowResize = function (ev) {
  7737. var options = _this.props.options;
  7738. if (options.handleWindowResize &&
  7739. ev.target === window // avoid jqui events
  7740. ) {
  7741. _this.resizeRunner.request(options.windowResizeDelay);
  7742. }
  7743. };
  7744. return _this;
  7745. }
  7746. /*
  7747. renders INSIDE of an outer div
  7748. */
  7749. CalendarContent.prototype.render = function () {
  7750. var props = this.props;
  7751. var toolbarConfig = props.toolbarConfig, options = props.options;
  7752. var toolbarProps = this.buildToolbarProps(props.viewSpec, props.dateProfile, props.dateProfileGenerator, props.currentDate, getNow(props.options.now, props.dateEnv), // TODO: use NowTimer????
  7753. props.viewTitle);
  7754. var viewVGrow = false;
  7755. var viewHeight = '';
  7756. var viewAspectRatio;
  7757. if (props.isHeightAuto || props.forPrint) {
  7758. viewHeight = '';
  7759. }
  7760. else if (options.height != null) {
  7761. viewVGrow = true;
  7762. }
  7763. else if (options.contentHeight != null) {
  7764. viewHeight = options.contentHeight;
  7765. }
  7766. else {
  7767. viewAspectRatio = Math.max(options.aspectRatio, 0.5); // prevent from getting too tall
  7768. }
  7769. var viewContext = this.buildViewContext(props.viewSpec, props.viewApi, props.options, props.dateProfileGenerator, props.dateEnv, props.theme, props.pluginHooks, props.dispatch, props.getCurrentData, props.emitter, props.calendarApi, this.registerInteractiveComponent, this.unregisterInteractiveComponent);
  7770. return (createElement(ViewContextType.Provider, { value: viewContext },
  7771. toolbarConfig.headerToolbar &&
  7772. createElement(Toolbar, __assign({ ref: this.headerRef, extraClassName: 'fc-header-toolbar', model: toolbarConfig.headerToolbar }, toolbarProps)),
  7773. createElement(ViewContainer, { liquid: viewVGrow, height: viewHeight, aspectRatio: viewAspectRatio, onClick: this.handleNavLinkClick },
  7774. this.renderView(props),
  7775. this.buildAppendContent()),
  7776. toolbarConfig.footerToolbar &&
  7777. createElement(Toolbar, __assign({ ref: this.footerRef, extraClassName: 'fc-footer-toolbar', model: toolbarConfig.footerToolbar }, toolbarProps))));
  7778. };
  7779. CalendarContent.prototype.componentDidMount = function () {
  7780. var props = this.props;
  7781. this.calendarInteractions = props.pluginHooks.calendarInteractions
  7782. .map(function (calendarInteractionClass) {
  7783. return new calendarInteractionClass(props);
  7784. });
  7785. window.addEventListener('resize', this.handleWindowResize);
  7786. var propSetHandlers = props.pluginHooks.propSetHandlers;
  7787. for (var propName in propSetHandlers) {
  7788. propSetHandlers[propName](props[propName], props);
  7789. }
  7790. };
  7791. CalendarContent.prototype.componentDidUpdate = function (prevProps) {
  7792. var props = this.props;
  7793. var propSetHandlers = props.pluginHooks.propSetHandlers;
  7794. for (var propName in propSetHandlers) {
  7795. if (props[propName] !== prevProps[propName]) {
  7796. propSetHandlers[propName](props[propName], props);
  7797. }
  7798. }
  7799. };
  7800. CalendarContent.prototype.componentWillUnmount = function () {
  7801. window.removeEventListener('resize', this.handleWindowResize);
  7802. this.resizeRunner.clear();
  7803. for (var _i = 0, _a = this.calendarInteractions; _i < _a.length; _i++) {
  7804. var interaction = _a[_i];
  7805. interaction.destroy();
  7806. }
  7807. this.props.emitter.trigger('_unmount');
  7808. };
  7809. CalendarContent.prototype._handleNavLinkClick = function (ev, anchorEl) {
  7810. var _a = this.props, dateEnv = _a.dateEnv, options = _a.options, calendarApi = _a.calendarApi;
  7811. var navLinkOptions = anchorEl.getAttribute('data-navlink');
  7812. navLinkOptions = navLinkOptions ? JSON.parse(navLinkOptions) : {};
  7813. var dateMarker = dateEnv.createMarker(navLinkOptions.date);
  7814. var viewType = navLinkOptions.type;
  7815. var customAction = viewType === 'day' ? options.navLinkDayClick :
  7816. viewType === 'week' ? options.navLinkWeekClick : null;
  7817. if (typeof customAction === 'function') {
  7818. customAction.call(calendarApi, dateEnv.toDate(dateMarker), ev);
  7819. }
  7820. else {
  7821. if (typeof customAction === 'string') {
  7822. viewType = customAction;
  7823. }
  7824. calendarApi.zoomTo(dateMarker, viewType);
  7825. }
  7826. };
  7827. CalendarContent.prototype.buildAppendContent = function () {
  7828. var props = this.props;
  7829. var children = props.pluginHooks.viewContainerAppends.map(function (buildAppendContent) { return buildAppendContent(props); });
  7830. return createElement.apply(void 0, __spreadArrays([Fragment, {}], children));
  7831. };
  7832. CalendarContent.prototype.renderView = function (props) {
  7833. var pluginHooks = props.pluginHooks;
  7834. var viewSpec = props.viewSpec;
  7835. var viewProps = {
  7836. dateProfile: props.dateProfile,
  7837. businessHours: props.businessHours,
  7838. eventStore: props.renderableEventStore,
  7839. eventUiBases: props.eventUiBases,
  7840. dateSelection: props.dateSelection,
  7841. eventSelection: props.eventSelection,
  7842. eventDrag: props.eventDrag,
  7843. eventResize: props.eventResize,
  7844. isHeightAuto: props.isHeightAuto,
  7845. forPrint: props.forPrint
  7846. };
  7847. var transformers = this.buildViewPropTransformers(pluginHooks.viewPropsTransformers);
  7848. for (var _i = 0, transformers_1 = transformers; _i < transformers_1.length; _i++) {
  7849. var transformer = transformers_1[_i];
  7850. __assign(viewProps, transformer.transform(viewProps, props));
  7851. }
  7852. var ViewComponent = viewSpec.component;
  7853. return (createElement(ViewComponent, __assign({}, viewProps)));
  7854. };
  7855. return CalendarContent;
  7856. }(PureComponent));
  7857. function buildToolbarProps(viewSpec, dateProfile, dateProfileGenerator, currentDate, now, title) {
  7858. // don't force any date-profiles to valid date profiles (the `false`) so that we can tell if it's invalid
  7859. var todayInfo = dateProfileGenerator.build(now, undefined, false); // TODO: need `undefined` or else INFINITE LOOP for some reason
  7860. var prevInfo = dateProfileGenerator.buildPrev(dateProfile, currentDate, false);
  7861. var nextInfo = dateProfileGenerator.buildNext(dateProfile, currentDate, false);
  7862. return {
  7863. title: title,
  7864. activeButton: viewSpec.type,
  7865. isTodayEnabled: todayInfo.isValid && !rangeContainsMarker(dateProfile.currentRange, now),
  7866. isPrevEnabled: prevInfo.isValid,
  7867. isNextEnabled: nextInfo.isValid
  7868. };
  7869. }
  7870. // Plugin
  7871. // -----------------------------------------------------------------------------------------------------------------
  7872. function buildViewPropTransformers(theClasses) {
  7873. return theClasses.map(function (theClass) {
  7874. return new theClass();
  7875. });
  7876. }
  7877. var canVGrowWithinCell;
  7878. function getCanVGrowWithinCell() {
  7879. if (canVGrowWithinCell == null) {
  7880. canVGrowWithinCell = computeCanVGrowWithinCell();
  7881. }
  7882. return canVGrowWithinCell;
  7883. }
  7884. function computeCanVGrowWithinCell() {
  7885. // TODO: abstraction for creating these temporary detection-based els
  7886. var el = document.createElement('div');
  7887. el.style.position = 'absolute'; // for not interfering with current layout
  7888. el.style.top = '0';
  7889. el.style.left = '0';
  7890. el.innerHTML = '<table style="height:100px"><tr><td><div style="height:100%"></div></td></tr></table>';
  7891. document.body.appendChild(el);
  7892. var div = el.querySelector('div');
  7893. var possible = div.offsetHeight > 0;
  7894. document.body.removeChild(el);
  7895. return possible;
  7896. }
  7897. var CalendarRoot = /** @class */ (function (_super) {
  7898. __extends(CalendarRoot, _super);
  7899. function CalendarRoot() {
  7900. var _this = _super !== null && _super.apply(this, arguments) || this;
  7901. _this.state = {
  7902. forPrint: false
  7903. };
  7904. _this.handleBeforePrint = function () {
  7905. _this.setState({ forPrint: true });
  7906. };
  7907. _this.handleAfterPrint = function () {
  7908. _this.setState({ forPrint: false });
  7909. };
  7910. return _this;
  7911. }
  7912. CalendarRoot.prototype.render = function () {
  7913. var props = this.props;
  7914. var options = props.options;
  7915. var forPrint = this.state.forPrint;
  7916. var isHeightAuto = forPrint || options.height === 'auto' || options.contentHeight === 'auto';
  7917. var height = (!isHeightAuto && options.height != null) ? options.height : '';
  7918. var classNames = [
  7919. 'fc',
  7920. forPrint ? 'fc-media-print' : 'fc-media-screen',
  7921. 'fc-direction-' + options.direction,
  7922. props.theme.getClass('root')
  7923. ];
  7924. if (!getCanVGrowWithinCell()) {
  7925. classNames.push('fc-liquid-hack');
  7926. }
  7927. return props.children(classNames, height, isHeightAuto, forPrint);
  7928. };
  7929. CalendarRoot.prototype.componentDidMount = function () {
  7930. var emitter = this.props.emitter;
  7931. emitter.on('_beforeprint', this.handleBeforePrint);
  7932. emitter.on('_afterprint', this.handleAfterPrint);
  7933. };
  7934. CalendarRoot.prototype.componentWillUnmount = function () {
  7935. var emitter = this.props.emitter;
  7936. emitter.off('_beforeprint', this.handleBeforePrint);
  7937. emitter.off('_afterprint', this.handleAfterPrint);
  7938. };
  7939. return CalendarRoot;
  7940. }(BaseComponent));
  7941. // Computes a default column header formatting string if `colFormat` is not explicitly defined
  7942. function computeFallbackHeaderFormat(datesRepDistinctDays, dayCnt) {
  7943. // if more than one week row, or if there are a lot of columns with not much space,
  7944. // put just the day numbers will be in each cell
  7945. if (!datesRepDistinctDays || dayCnt > 10) {
  7946. return createFormatter({ weekday: 'short' }); // "Sat"
  7947. }
  7948. else if (dayCnt > 1) {
  7949. return createFormatter({ weekday: 'short', month: 'numeric', day: 'numeric', omitCommas: true }); // "Sat 11/12"
  7950. }
  7951. else {
  7952. return createFormatter({ weekday: 'long' }); // "Saturday"
  7953. }
  7954. }
  7955. var CLASS_NAME = 'fc-col-header-cell'; // do the cushion too? no
  7956. var TableDateCell = /** @class */ (function (_super) {
  7957. __extends(TableDateCell, _super);
  7958. function TableDateCell() {
  7959. return _super !== null && _super.apply(this, arguments) || this;
  7960. }
  7961. TableDateCell.prototype.render = function () {
  7962. var _a = this.context, dateEnv = _a.dateEnv, options = _a.options, theme = _a.theme, viewApi = _a.viewApi;
  7963. var props = this.props;
  7964. var date = props.date, dateProfile = props.dateProfile;
  7965. var dayMeta = getDateMeta(date, props.todayRange, null, dateProfile);
  7966. var classNames = [CLASS_NAME].concat(getDayClassNames(dayMeta, theme));
  7967. var text = dateEnv.format(date, props.dayHeaderFormat);
  7968. // if colCnt is 1, we are already in a day-view and don't need a navlink
  7969. var navLinkAttrs = (options.navLinks && !dayMeta.isDisabled && props.colCnt > 1)
  7970. ? { 'data-navlink': buildNavLinkData(date), tabIndex: 0 }
  7971. : {};
  7972. var hookProps = __assign(__assign(__assign({ date: dateEnv.toDate(date), view: viewApi }, props.extraHookProps), { text: text }), dayMeta);
  7973. return (createElement(RenderHook, { hookProps: hookProps, classNames: options.dayHeaderClassNames, content: options.dayHeaderContent, defaultContent: renderInner, didMount: options.dayHeaderDidMount, willUnmount: options.dayHeaderWillUnmount }, function (rootElRef, customClassNames, innerElRef, innerContent) { return (createElement("th", __assign({ ref: rootElRef, className: classNames.concat(customClassNames).join(' '), "data-date": !dayMeta.isDisabled ? formatDayString(date) : undefined, colSpan: props.colSpan }, props.extraDataAttrs),
  7974. createElement("div", { className: 'fc-scrollgrid-sync-inner' }, !dayMeta.isDisabled &&
  7975. createElement("a", __assign({ ref: innerElRef, className: [
  7976. 'fc-col-header-cell-cushion',
  7977. props.isSticky ? 'fc-sticky' : ''
  7978. ].join(' ') }, navLinkAttrs), innerContent)))); }));
  7979. };
  7980. return TableDateCell;
  7981. }(BaseComponent));
  7982. var TableDowCell = /** @class */ (function (_super) {
  7983. __extends(TableDowCell, _super);
  7984. function TableDowCell() {
  7985. return _super !== null && _super.apply(this, arguments) || this;
  7986. }
  7987. TableDowCell.prototype.render = function () {
  7988. var props = this.props;
  7989. var _a = this.context, dateEnv = _a.dateEnv, theme = _a.theme, viewApi = _a.viewApi, options = _a.options;
  7990. var date = addDays(new Date(259200000), props.dow); // start with Sun, 04 Jan 1970 00:00:00 GMT
  7991. var dateMeta = {
  7992. dow: props.dow,
  7993. isDisabled: false,
  7994. isFuture: false,
  7995. isPast: false,
  7996. isToday: false,
  7997. isOther: false
  7998. };
  7999. var classNames = [CLASS_NAME].concat(getDayClassNames(dateMeta, theme), props.extraClassNames || []);
  8000. var text = dateEnv.format(date, props.dayHeaderFormat);
  8001. var hookProps = __assign(__assign(__assign(__assign({ // TODO: make this public?
  8002. date: date }, dateMeta), { view: viewApi }), props.extraHookProps), { text: text });
  8003. return (createElement(RenderHook, { hookProps: hookProps, classNames: options.dayHeaderClassNames, content: options.dayHeaderContent, defaultContent: renderInner, didMount: options.dayHeaderDidMount, willUnmount: options.dayHeaderWillUnmount }, function (rootElRef, customClassNames, innerElRef, innerContent) { return (createElement("th", __assign({ ref: rootElRef, className: classNames.concat(customClassNames).join(' '), colSpan: props.colSpan }, props.extraDataAttrs),
  8004. createElement("div", { className: 'fc-scrollgrid-sync-inner' },
  8005. createElement("a", { className: [
  8006. 'fc-col-header-cell-cushion',
  8007. props.isSticky ? 'fc-sticky' : ''
  8008. ].join(' '), ref: innerElRef }, innerContent)))); }));
  8009. };
  8010. return TableDowCell;
  8011. }(BaseComponent));
  8012. function renderInner(hookProps) {
  8013. return hookProps.text;
  8014. }
  8015. var NowTimer = /** @class */ (function (_super) {
  8016. __extends(NowTimer, _super);
  8017. function NowTimer(props, context) {
  8018. var _this = _super.call(this, props, context) || this;
  8019. _this.initialNowDate = getNow(context.options.now, context.dateEnv);
  8020. _this.initialNowQueriedMs = new Date().valueOf();
  8021. _this.state = _this.computeTiming().currentState;
  8022. return _this;
  8023. }
  8024. NowTimer.prototype.render = function () {
  8025. var _a = this, props = _a.props, state = _a.state;
  8026. return props.children(state.nowDate, state.todayRange);
  8027. };
  8028. NowTimer.prototype.componentDidMount = function () {
  8029. this.setTimeout();
  8030. };
  8031. NowTimer.prototype.componentDidUpdate = function (prevProps) {
  8032. if (prevProps.unit !== this.props.unit) {
  8033. this.clearTimeout();
  8034. this.setTimeout();
  8035. }
  8036. };
  8037. NowTimer.prototype.componentWillUnmount = function () {
  8038. this.clearTimeout();
  8039. };
  8040. NowTimer.prototype.computeTiming = function () {
  8041. var _a = this, props = _a.props, context = _a.context;
  8042. var unroundedNow = addMs(this.initialNowDate, new Date().valueOf() - this.initialNowQueriedMs);
  8043. var currentUnitStart = context.dateEnv.startOf(unroundedNow, props.unit);
  8044. var nextUnitStart = context.dateEnv.add(currentUnitStart, createDuration(1, props.unit));
  8045. var waitMs = nextUnitStart.valueOf() - unroundedNow.valueOf();
  8046. return {
  8047. currentState: { nowDate: currentUnitStart, todayRange: buildDayRange(currentUnitStart) },
  8048. nextState: { nowDate: nextUnitStart, todayRange: buildDayRange(nextUnitStart) },
  8049. waitMs: waitMs
  8050. };
  8051. };
  8052. NowTimer.prototype.setTimeout = function () {
  8053. var _this = this;
  8054. var _a = this.computeTiming(), nextState = _a.nextState, waitMs = _a.waitMs;
  8055. this.timeoutId = setTimeout(function () {
  8056. _this.setState(nextState, function () {
  8057. _this.setTimeout();
  8058. });
  8059. }, waitMs);
  8060. };
  8061. NowTimer.prototype.clearTimeout = function () {
  8062. if (this.timeoutId) {
  8063. clearTimeout(this.timeoutId);
  8064. }
  8065. };
  8066. NowTimer.contextType = ViewContextType;
  8067. return NowTimer;
  8068. }(Component));
  8069. function buildDayRange(date) {
  8070. var start = startOfDay(date);
  8071. var end = addDays(start, 1);
  8072. return { start: start, end: end };
  8073. }
  8074. var DayHeader = /** @class */ (function (_super) {
  8075. __extends(DayHeader, _super);
  8076. function DayHeader() {
  8077. var _this = _super !== null && _super.apply(this, arguments) || this;
  8078. _this.createDayHeaderFormatter = memoize(createDayHeaderFormatter);
  8079. return _this;
  8080. }
  8081. DayHeader.prototype.render = function () {
  8082. var context = this.context;
  8083. var _a = this.props, dates = _a.dates, dateProfile = _a.dateProfile, datesRepDistinctDays = _a.datesRepDistinctDays, renderIntro = _a.renderIntro;
  8084. var dayHeaderFormat = this.createDayHeaderFormatter(context.options.dayHeaderFormat, datesRepDistinctDays, dates.length);
  8085. return (createElement(NowTimer, { unit: 'day' }, function (nowDate, todayRange) { return (createElement("tr", null,
  8086. renderIntro && renderIntro(),
  8087. dates.map(function (date) { return (datesRepDistinctDays ?
  8088. createElement(TableDateCell, { key: date.toISOString(), date: date, dateProfile: dateProfile, todayRange: todayRange, colCnt: dates.length, dayHeaderFormat: dayHeaderFormat }) :
  8089. createElement(TableDowCell, { key: date.getUTCDay(), dow: date.getUTCDay(), dayHeaderFormat: dayHeaderFormat })); }))); }));
  8090. };
  8091. return DayHeader;
  8092. }(BaseComponent));
  8093. function createDayHeaderFormatter(explicitFormat, datesRepDistinctDays, dateCnt) {
  8094. return explicitFormat || computeFallbackHeaderFormat(datesRepDistinctDays, dateCnt);
  8095. }
  8096. var DaySeriesModel = /** @class */ (function () {
  8097. function DaySeriesModel(range, dateProfileGenerator) {
  8098. var date = range.start;
  8099. var end = range.end;
  8100. var indices = [];
  8101. var dates = [];
  8102. var dayIndex = -1;
  8103. while (date < end) { // loop each day from start to end
  8104. if (dateProfileGenerator.isHiddenDay(date)) {
  8105. indices.push(dayIndex + 0.5); // mark that it's between indices
  8106. }
  8107. else {
  8108. dayIndex++;
  8109. indices.push(dayIndex);
  8110. dates.push(date);
  8111. }
  8112. date = addDays(date, 1);
  8113. }
  8114. this.dates = dates;
  8115. this.indices = indices;
  8116. this.cnt = dates.length;
  8117. }
  8118. DaySeriesModel.prototype.sliceRange = function (range) {
  8119. var firstIndex = this.getDateDayIndex(range.start); // inclusive first index
  8120. var lastIndex = this.getDateDayIndex(addDays(range.end, -1)); // inclusive last index
  8121. var clippedFirstIndex = Math.max(0, firstIndex);
  8122. var clippedLastIndex = Math.min(this.cnt - 1, lastIndex);
  8123. // deal with in-between indices
  8124. clippedFirstIndex = Math.ceil(clippedFirstIndex); // in-between starts round to next cell
  8125. clippedLastIndex = Math.floor(clippedLastIndex); // in-between ends round to prev cell
  8126. if (clippedFirstIndex <= clippedLastIndex) {
  8127. return {
  8128. firstIndex: clippedFirstIndex,
  8129. lastIndex: clippedLastIndex,
  8130. isStart: firstIndex === clippedFirstIndex,
  8131. isEnd: lastIndex === clippedLastIndex
  8132. };
  8133. }
  8134. else {
  8135. return null;
  8136. }
  8137. };
  8138. // Given a date, returns its chronolocial cell-index from the first cell of the grid.
  8139. // If the date lies between cells (because of hiddenDays), returns a floating-point value between offsets.
  8140. // If before the first offset, returns a negative number.
  8141. // If after the last offset, returns an offset past the last cell offset.
  8142. // Only works for *start* dates of cells. Will not work for exclusive end dates for cells.
  8143. DaySeriesModel.prototype.getDateDayIndex = function (date) {
  8144. var indices = this.indices;
  8145. var dayOffset = Math.floor(diffDays(this.dates[0], date));
  8146. if (dayOffset < 0) {
  8147. return indices[0] - 1;
  8148. }
  8149. else if (dayOffset >= indices.length) {
  8150. return indices[indices.length - 1] + 1;
  8151. }
  8152. else {
  8153. return indices[dayOffset];
  8154. }
  8155. };
  8156. return DaySeriesModel;
  8157. }());
  8158. var DayTableModel = /** @class */ (function () {
  8159. function DayTableModel(daySeries, breakOnWeeks) {
  8160. var dates = daySeries.dates;
  8161. var daysPerRow;
  8162. var firstDay;
  8163. var rowCnt;
  8164. if (breakOnWeeks) {
  8165. // count columns until the day-of-week repeats
  8166. firstDay = dates[0].getUTCDay();
  8167. for (daysPerRow = 1; daysPerRow < dates.length; daysPerRow++) {
  8168. if (dates[daysPerRow].getUTCDay() === firstDay) {
  8169. break;
  8170. }
  8171. }
  8172. rowCnt = Math.ceil(dates.length / daysPerRow);
  8173. }
  8174. else {
  8175. rowCnt = 1;
  8176. daysPerRow = dates.length;
  8177. }
  8178. this.rowCnt = rowCnt;
  8179. this.colCnt = daysPerRow;
  8180. this.daySeries = daySeries;
  8181. this.cells = this.buildCells();
  8182. this.headerDates = this.buildHeaderDates();
  8183. }
  8184. DayTableModel.prototype.buildCells = function () {
  8185. var rows = [];
  8186. for (var row = 0; row < this.rowCnt; row++) {
  8187. var cells = [];
  8188. for (var col = 0; col < this.colCnt; col++) {
  8189. cells.push(this.buildCell(row, col));
  8190. }
  8191. rows.push(cells);
  8192. }
  8193. return rows;
  8194. };
  8195. DayTableModel.prototype.buildCell = function (row, col) {
  8196. var date = this.daySeries.dates[row * this.colCnt + col];
  8197. return {
  8198. key: date.toISOString(),
  8199. date: date
  8200. };
  8201. };
  8202. DayTableModel.prototype.buildHeaderDates = function () {
  8203. var dates = [];
  8204. for (var col = 0; col < this.colCnt; col++) {
  8205. dates.push(this.cells[0][col].date);
  8206. }
  8207. return dates;
  8208. };
  8209. DayTableModel.prototype.sliceRange = function (range) {
  8210. var colCnt = this.colCnt;
  8211. var seriesSeg = this.daySeries.sliceRange(range);
  8212. var segs = [];
  8213. if (seriesSeg) {
  8214. var firstIndex = seriesSeg.firstIndex, lastIndex = seriesSeg.lastIndex;
  8215. var index = firstIndex;
  8216. while (index <= lastIndex) {
  8217. var row = Math.floor(index / colCnt);
  8218. var nextIndex = Math.min((row + 1) * colCnt, lastIndex + 1);
  8219. segs.push({
  8220. row: row,
  8221. firstCol: index % colCnt,
  8222. lastCol: (nextIndex - 1) % colCnt,
  8223. isStart: seriesSeg.isStart && index === firstIndex,
  8224. isEnd: seriesSeg.isEnd && (nextIndex - 1) === lastIndex
  8225. });
  8226. index = nextIndex;
  8227. }
  8228. }
  8229. return segs;
  8230. };
  8231. return DayTableModel;
  8232. }());
  8233. var Slicer = /** @class */ (function () {
  8234. function Slicer() {
  8235. this.sliceBusinessHours = memoize(this._sliceBusinessHours);
  8236. this.sliceDateSelection = memoize(this._sliceDateSpan);
  8237. this.sliceEventStore = memoize(this._sliceEventStore);
  8238. this.sliceEventDrag = memoize(this._sliceInteraction);
  8239. this.sliceEventResize = memoize(this._sliceInteraction);
  8240. this.forceDayIfListItem = false; // hack
  8241. }
  8242. Slicer.prototype.sliceProps = function (props, dateProfile, nextDayThreshold, context) {
  8243. var extraArgs = [];
  8244. for (var _i = 4; _i < arguments.length; _i++) {
  8245. extraArgs[_i - 4] = arguments[_i];
  8246. }
  8247. var eventUiBases = props.eventUiBases;
  8248. var eventSegs = this.sliceEventStore.apply(this, __spreadArrays([props.eventStore, eventUiBases, dateProfile, nextDayThreshold], extraArgs));
  8249. return {
  8250. dateSelectionSegs: this.sliceDateSelection.apply(this, __spreadArrays([props.dateSelection, eventUiBases, context], extraArgs)),
  8251. businessHourSegs: this.sliceBusinessHours.apply(this, __spreadArrays([props.businessHours, dateProfile, nextDayThreshold, context], extraArgs)),
  8252. fgEventSegs: eventSegs.fg,
  8253. bgEventSegs: eventSegs.bg,
  8254. eventDrag: this.sliceEventDrag.apply(this, __spreadArrays([props.eventDrag, eventUiBases, dateProfile, nextDayThreshold], extraArgs)),
  8255. eventResize: this.sliceEventResize.apply(this, __spreadArrays([props.eventResize, eventUiBases, dateProfile, nextDayThreshold], extraArgs)),
  8256. eventSelection: props.eventSelection
  8257. }; // TODO: give interactionSegs?
  8258. };
  8259. Slicer.prototype.sliceNowDate = function (// does not memoize
  8260. date, context) {
  8261. var extraArgs = [];
  8262. for (var _i = 2; _i < arguments.length; _i++) {
  8263. extraArgs[_i - 2] = arguments[_i];
  8264. }
  8265. return this._sliceDateSpan.apply(this, __spreadArrays([{ range: { start: date, end: addMs(date, 1) }, allDay: false },
  8266. {},
  8267. context], extraArgs));
  8268. };
  8269. Slicer.prototype._sliceBusinessHours = function (businessHours, dateProfile, nextDayThreshold, context) {
  8270. var extraArgs = [];
  8271. for (var _i = 4; _i < arguments.length; _i++) {
  8272. extraArgs[_i - 4] = arguments[_i];
  8273. }
  8274. if (!businessHours) {
  8275. return [];
  8276. }
  8277. return this._sliceEventStore.apply(this, __spreadArrays([expandRecurring(businessHours, computeActiveRange(dateProfile, Boolean(nextDayThreshold)), context),
  8278. {},
  8279. dateProfile,
  8280. nextDayThreshold], extraArgs)).bg;
  8281. };
  8282. Slicer.prototype._sliceEventStore = function (eventStore, eventUiBases, dateProfile, nextDayThreshold) {
  8283. var extraArgs = [];
  8284. for (var _i = 4; _i < arguments.length; _i++) {
  8285. extraArgs[_i - 4] = arguments[_i];
  8286. }
  8287. if (eventStore) {
  8288. var rangeRes = sliceEventStore(eventStore, eventUiBases, computeActiveRange(dateProfile, Boolean(nextDayThreshold)), nextDayThreshold);
  8289. return {
  8290. bg: this.sliceEventRanges(rangeRes.bg, extraArgs),
  8291. fg: this.sliceEventRanges(rangeRes.fg, extraArgs)
  8292. };
  8293. }
  8294. else {
  8295. return { bg: [], fg: [] };
  8296. }
  8297. };
  8298. Slicer.prototype._sliceInteraction = function (interaction, eventUiBases, dateProfile, nextDayThreshold) {
  8299. var extraArgs = [];
  8300. for (var _i = 4; _i < arguments.length; _i++) {
  8301. extraArgs[_i - 4] = arguments[_i];
  8302. }
  8303. if (!interaction) {
  8304. return null;
  8305. }
  8306. var rangeRes = sliceEventStore(interaction.mutatedEvents, eventUiBases, computeActiveRange(dateProfile, Boolean(nextDayThreshold)), nextDayThreshold);
  8307. return {
  8308. segs: this.sliceEventRanges(rangeRes.fg, extraArgs),
  8309. affectedInstances: interaction.affectedEvents.instances,
  8310. isEvent: interaction.isEvent
  8311. };
  8312. };
  8313. Slicer.prototype._sliceDateSpan = function (dateSpan, eventUiBases, context) {
  8314. var extraArgs = [];
  8315. for (var _i = 3; _i < arguments.length; _i++) {
  8316. extraArgs[_i - 3] = arguments[_i];
  8317. }
  8318. if (!dateSpan) {
  8319. return [];
  8320. }
  8321. var eventRange = fabricateEventRange(dateSpan, eventUiBases, context);
  8322. var segs = this.sliceRange.apply(this, __spreadArrays([dateSpan.range], extraArgs));
  8323. for (var _a = 0, segs_1 = segs; _a < segs_1.length; _a++) {
  8324. var seg = segs_1[_a];
  8325. seg.eventRange = eventRange;
  8326. }
  8327. return segs;
  8328. };
  8329. /*
  8330. "complete" seg means it has component and eventRange
  8331. */
  8332. Slicer.prototype.sliceEventRanges = function (eventRanges, extraArgs) {
  8333. var segs = [];
  8334. for (var _i = 0, eventRanges_1 = eventRanges; _i < eventRanges_1.length; _i++) {
  8335. var eventRange = eventRanges_1[_i];
  8336. segs.push.apply(segs, this.sliceEventRange(eventRange, extraArgs));
  8337. }
  8338. return segs;
  8339. };
  8340. /*
  8341. "complete" seg means it has component and eventRange
  8342. */
  8343. Slicer.prototype.sliceEventRange = function (eventRange, extraArgs) {
  8344. var dateRange = eventRange.range;
  8345. // hack to make multi-day events that are being force-displayed as list-items to take up only one day
  8346. if (this.forceDayIfListItem && eventRange.ui.display === 'list-item') {
  8347. dateRange = {
  8348. start: dateRange.start,
  8349. end: addDays(dateRange.start, 1)
  8350. };
  8351. }
  8352. var segs = this.sliceRange.apply(this, __spreadArrays([dateRange], extraArgs));
  8353. for (var _i = 0, segs_2 = segs; _i < segs_2.length; _i++) {
  8354. var seg = segs_2[_i];
  8355. seg.eventRange = eventRange;
  8356. seg.isStart = eventRange.isStart && seg.isStart;
  8357. seg.isEnd = eventRange.isEnd && seg.isEnd;
  8358. }
  8359. return segs;
  8360. };
  8361. return Slicer;
  8362. }());
  8363. /*
  8364. for incorporating slotMinTime/slotMaxTime if appropriate
  8365. TODO: should be part of DateProfile!
  8366. TimelineDateProfile already does this btw
  8367. */
  8368. function computeActiveRange(dateProfile, isComponentAllDay) {
  8369. var range = dateProfile.activeRange;
  8370. if (isComponentAllDay) {
  8371. return range;
  8372. }
  8373. return {
  8374. start: addMs(range.start, dateProfile.slotMinTime.milliseconds),
  8375. end: addMs(range.end, dateProfile.slotMaxTime.milliseconds - 864e5) // 864e5 = ms in a day
  8376. };
  8377. }
  8378. var VISIBLE_HIDDEN_RE = /^(visible|hidden)$/;
  8379. var Scroller = /** @class */ (function (_super) {
  8380. __extends(Scroller, _super);
  8381. function Scroller() {
  8382. var _this = _super !== null && _super.apply(this, arguments) || this;
  8383. _this.handleEl = function (el) {
  8384. _this.el = el;
  8385. setRef(_this.props.elRef, el);
  8386. };
  8387. return _this;
  8388. }
  8389. Scroller.prototype.render = function () {
  8390. var props = this.props;
  8391. var liquid = props.liquid, liquidIsAbsolute = props.liquidIsAbsolute;
  8392. var isAbsolute = liquid && liquidIsAbsolute;
  8393. var className = ['fc-scroller'];
  8394. if (liquid) {
  8395. if (liquidIsAbsolute) {
  8396. className.push('fc-scroller-liquid-absolute');
  8397. }
  8398. else {
  8399. className.push('fc-scroller-liquid');
  8400. }
  8401. }
  8402. return (createElement("div", { ref: this.handleEl, className: className.join(' '), style: {
  8403. overflowX: props.overflowX,
  8404. overflowY: props.overflowY,
  8405. left: (isAbsolute && -(props.overcomeLeft || 0)) || '',
  8406. right: (isAbsolute && -(props.overcomeRight || 0)) || '',
  8407. bottom: (isAbsolute && -(props.overcomeBottom || 0)) || '',
  8408. marginLeft: (!isAbsolute && -(props.overcomeLeft || 0)) || '',
  8409. marginRight: (!isAbsolute && -(props.overcomeRight || 0)) || '',
  8410. marginBottom: (!isAbsolute && -(props.overcomeBottom || 0)) || '',
  8411. maxHeight: props.maxHeight || ''
  8412. } }, props.children));
  8413. };
  8414. Scroller.prototype.needsXScrolling = function () {
  8415. if (VISIBLE_HIDDEN_RE.test(this.props.overflowX)) {
  8416. return false;
  8417. }
  8418. // testing scrollWidth>clientWidth is unreliable cross-browser when pixel heights aren't integers.
  8419. // much more reliable to see if children are taller than the scroller, even tho doesn't account for
  8420. // inner-child margins and absolute positioning
  8421. var el = this.el;
  8422. var realClientWidth = this.el.getBoundingClientRect().width - this.getYScrollbarWidth();
  8423. var children = el.children;
  8424. for (var i = 0; i < children.length; i++) {
  8425. var childEl = children[i];
  8426. if (childEl.getBoundingClientRect().width > realClientWidth) {
  8427. return true;
  8428. }
  8429. }
  8430. return false;
  8431. };
  8432. Scroller.prototype.needsYScrolling = function () {
  8433. if (VISIBLE_HIDDEN_RE.test(this.props.overflowY)) {
  8434. return false;
  8435. }
  8436. // testing scrollHeight>clientHeight is unreliable cross-browser when pixel heights aren't integers.
  8437. // much more reliable to see if children are taller than the scroller, even tho doesn't account for
  8438. // inner-child margins and absolute positioning
  8439. var el = this.el;
  8440. var realClientHeight = this.el.getBoundingClientRect().height - this.getXScrollbarWidth();
  8441. var children = el.children;
  8442. for (var i = 0; i < children.length; i++) {
  8443. var childEl = children[i];
  8444. if (childEl.getBoundingClientRect().height > realClientHeight) {
  8445. return true;
  8446. }
  8447. }
  8448. return false;
  8449. };
  8450. Scroller.prototype.getXScrollbarWidth = function () {
  8451. if (VISIBLE_HIDDEN_RE.test(this.props.overflowX)) {
  8452. return 0;
  8453. }
  8454. else {
  8455. return this.el.offsetHeight - this.el.clientHeight; // only works because we guarantee no borders. TODO: add to CSS with important?
  8456. }
  8457. };
  8458. Scroller.prototype.getYScrollbarWidth = function () {
  8459. if (VISIBLE_HIDDEN_RE.test(this.props.overflowY)) {
  8460. return 0;
  8461. }
  8462. else {
  8463. return this.el.offsetWidth - this.el.clientWidth; // only works because we guarantee no borders. TODO: add to CSS with important?
  8464. }
  8465. };
  8466. return Scroller;
  8467. }(BaseComponent));
  8468. /*
  8469. TODO: somehow infer OtherArgs from masterCallback?
  8470. TODO: infer RefType from masterCallback if provided
  8471. */
  8472. var RefMap = /** @class */ (function () {
  8473. function RefMap(masterCallback) {
  8474. var _this = this;
  8475. this.masterCallback = masterCallback;
  8476. this.currentMap = {};
  8477. this.depths = {};
  8478. this.callbackMap = {};
  8479. this.handleValue = function (val, key) {
  8480. var _a = _this, depths = _a.depths, currentMap = _a.currentMap;
  8481. var removed = false;
  8482. var added = false;
  8483. if (val !== null) {
  8484. removed = (key in currentMap); // for bug... ACTUALLY: can probably do away with this now that callers don't share numeric indices anymore
  8485. currentMap[key] = val;
  8486. depths[key] = (depths[key] || 0) + 1;
  8487. added = true;
  8488. }
  8489. else if (--depths[key] === 0) {
  8490. delete currentMap[key];
  8491. delete _this.callbackMap[key];
  8492. removed = true;
  8493. }
  8494. if (_this.masterCallback) {
  8495. if (removed) {
  8496. _this.masterCallback(null, String(key));
  8497. }
  8498. if (added) {
  8499. _this.masterCallback(val, String(key));
  8500. }
  8501. }
  8502. };
  8503. }
  8504. RefMap.prototype.createRef = function (key) {
  8505. var _this = this;
  8506. var refCallback = this.callbackMap[key];
  8507. if (!refCallback) {
  8508. refCallback = this.callbackMap[key] = function (val) {
  8509. _this.handleValue(val, String(key));
  8510. };
  8511. }
  8512. return refCallback;
  8513. };
  8514. // TODO: check callers that don't care about order. should use getAll instead
  8515. // NOTE: this method has become less valuable now that we are encouraged to map order by some other index
  8516. // TODO: provide ONE array-export function, buildArray, which fails on non-numeric indexes. caller can manipulate and "collect"
  8517. RefMap.prototype.collect = function (startIndex, endIndex, step) {
  8518. return collectFromHash(this.currentMap, startIndex, endIndex, step);
  8519. };
  8520. RefMap.prototype.getAll = function () {
  8521. return hashValuesToArray(this.currentMap);
  8522. };
  8523. return RefMap;
  8524. }());
  8525. function computeShrinkWidth(chunkEls) {
  8526. var shrinkCells = findElements(chunkEls, '.fc-scrollgrid-shrink');
  8527. var largestWidth = 0;
  8528. for (var _i = 0, shrinkCells_1 = shrinkCells; _i < shrinkCells_1.length; _i++) {
  8529. var shrinkCell = shrinkCells_1[_i];
  8530. largestWidth = Math.max(largestWidth, computeSmallestCellWidth(shrinkCell));
  8531. }
  8532. return Math.ceil(largestWidth); // <table> elements work best with integers. round up to ensure contents fits
  8533. }
  8534. function getSectionHasLiquidHeight(props, sectionConfig) {
  8535. return props.liquid && sectionConfig.liquid; // does the section do liquid-height? (need to have whole scrollgrid liquid-height as well)
  8536. }
  8537. function getAllowYScrolling(props, sectionConfig) {
  8538. return sectionConfig.maxHeight != null || // if its possible for the height to max out, we might need scrollbars
  8539. getSectionHasLiquidHeight(props, sectionConfig); // if the section is liquid height, it might condense enough to require scrollbars
  8540. }
  8541. // TODO: ONLY use `arg`. force out internal function to use same API
  8542. function renderChunkContent(sectionConfig, chunkConfig, arg) {
  8543. var expandRows = arg.expandRows;
  8544. var content = typeof chunkConfig.content === 'function' ?
  8545. chunkConfig.content(arg) :
  8546. createElement('table', {
  8547. className: [
  8548. chunkConfig.tableClassName,
  8549. sectionConfig.syncRowHeights ? 'fc-scrollgrid-sync-table' : ''
  8550. ].join(' '),
  8551. style: {
  8552. minWidth: arg.tableMinWidth,
  8553. width: arg.clientWidth,
  8554. height: expandRows ? arg.clientHeight : '' // css `height` on a <table> serves as a min-height
  8555. }
  8556. }, arg.tableColGroupNode, createElement('tbody', {}, typeof chunkConfig.rowContent === 'function' ? chunkConfig.rowContent(arg) : chunkConfig.rowContent));
  8557. return content;
  8558. }
  8559. function isColPropsEqual(cols0, cols1) {
  8560. return isArraysEqual(cols0, cols1, isPropsEqual);
  8561. }
  8562. function renderMicroColGroup(cols, shrinkWidth) {
  8563. var colNodes = [];
  8564. /*
  8565. for ColProps with spans, it would have been great to make a single <col span="">
  8566. HOWEVER, Chrome was getting messing up distributing the width to <td>/<th> elements with colspans.
  8567. SOLUTION: making individual <col> elements makes Chrome behave.
  8568. */
  8569. for (var _i = 0, cols_1 = cols; _i < cols_1.length; _i++) {
  8570. var colProps = cols_1[_i];
  8571. var span = colProps.span || 1;
  8572. for (var i = 0; i < span; i++) {
  8573. colNodes.push(createElement("col", { style: {
  8574. width: colProps.width === 'shrink' ? sanitizeShrinkWidth(shrinkWidth) : (colProps.width || ''),
  8575. minWidth: colProps.minWidth || ''
  8576. } }));
  8577. }
  8578. }
  8579. return createElement.apply(void 0, __spreadArrays(['colgroup', {}], colNodes));
  8580. }
  8581. function sanitizeShrinkWidth(shrinkWidth) {
  8582. /* why 4? if we do 0, it will kill any border, which are needed for computeSmallestCellWidth
  8583. 4 accounts for 2 2-pixel borders. TODO: better solution? */
  8584. return shrinkWidth == null ? 4 : shrinkWidth;
  8585. }
  8586. function hasShrinkWidth(cols) {
  8587. for (var _i = 0, cols_2 = cols; _i < cols_2.length; _i++) {
  8588. var col = cols_2[_i];
  8589. if (col.width === 'shrink') {
  8590. return true;
  8591. }
  8592. }
  8593. return false;
  8594. }
  8595. function getScrollGridClassNames(liquid, context) {
  8596. var classNames = [
  8597. 'fc-scrollgrid',
  8598. context.theme.getClass('table')
  8599. ];
  8600. if (liquid) {
  8601. classNames.push('fc-scrollgrid-liquid');
  8602. }
  8603. return classNames;
  8604. }
  8605. function getSectionClassNames(sectionConfig, wholeTableVGrow) {
  8606. var classNames = [
  8607. 'fc-scrollgrid-section',
  8608. sectionConfig.className // used?
  8609. ];
  8610. if (wholeTableVGrow && sectionConfig.liquid && sectionConfig.maxHeight == null) {
  8611. classNames.push('fc-scrollgrid-section-liquid');
  8612. }
  8613. if (sectionConfig.isSticky) {
  8614. classNames.push('fc-scrollgrid-section-sticky');
  8615. }
  8616. return classNames;
  8617. }
  8618. function renderScrollShim(arg) {
  8619. return (createElement("div", { className: 'fc-scrollgrid-sticky-shim', style: {
  8620. width: arg.clientWidth,
  8621. minWidth: arg.tableMinWidth
  8622. } }));
  8623. }
  8624. function getStickyHeaderDates(options) {
  8625. var stickyHeaderDates = options.stickyHeaderDates;
  8626. if (stickyHeaderDates == null || stickyHeaderDates === 'auto') {
  8627. stickyHeaderDates = options.height === 'auto' || options.viewHeight === 'auto';
  8628. }
  8629. return stickyHeaderDates;
  8630. }
  8631. function getStickyFooterScrollbar(options) {
  8632. var stickyFooterScrollbar = options.stickyFooterScrollbar;
  8633. if (stickyFooterScrollbar == null || stickyFooterScrollbar === 'auto') {
  8634. stickyFooterScrollbar = options.height === 'auto' || options.viewHeight === 'auto';
  8635. }
  8636. return stickyFooterScrollbar;
  8637. }
  8638. var SimpleScrollGrid = /** @class */ (function (_super) {
  8639. __extends(SimpleScrollGrid, _super);
  8640. function SimpleScrollGrid() {
  8641. var _this = _super !== null && _super.apply(this, arguments) || this;
  8642. _this.processCols = memoize(function (a) { return a; }, isColPropsEqual); // so we get same `cols` props every time
  8643. _this.renderMicroColGroup = memoize(renderMicroColGroup); // yucky to memoize VNodes, but much more efficient for consumers
  8644. _this.scrollerRefs = new RefMap();
  8645. _this.scrollerElRefs = new RefMap(_this._handleScrollerEl.bind(_this));
  8646. _this.state = {
  8647. shrinkWidth: null,
  8648. forceYScrollbars: false,
  8649. scrollerClientWidths: {},
  8650. scrollerClientHeights: {}
  8651. };
  8652. // TODO: can do a really simple print-view. dont need to join rows
  8653. _this.handleSizing = function () {
  8654. _this.setState(__assign({ shrinkWidth: _this.computeShrinkWidth() }, _this.computeScrollerDims()));
  8655. };
  8656. return _this;
  8657. }
  8658. SimpleScrollGrid.prototype.render = function () {
  8659. var _a = this, props = _a.props, state = _a.state, context = _a.context;
  8660. var sectionConfigs = props.sections || [];
  8661. var cols = this.processCols(props.cols);
  8662. var microColGroupNode = this.renderMicroColGroup(cols, state.shrinkWidth);
  8663. var classNames = getScrollGridClassNames(props.liquid, context);
  8664. // TODO: make DRY
  8665. var configCnt = sectionConfigs.length;
  8666. var configI = 0;
  8667. var currentConfig;
  8668. var headSectionNodes = [];
  8669. var bodySectionNodes = [];
  8670. var footSectionNodes = [];
  8671. while (configI < configCnt && (currentConfig = sectionConfigs[configI]).type === 'header') {
  8672. headSectionNodes.push(this.renderSection(currentConfig, configI, microColGroupNode));
  8673. configI++;
  8674. }
  8675. while (configI < configCnt && (currentConfig = sectionConfigs[configI]).type === 'body') {
  8676. bodySectionNodes.push(this.renderSection(currentConfig, configI, microColGroupNode));
  8677. configI++;
  8678. }
  8679. while (configI < configCnt && (currentConfig = sectionConfigs[configI]).type === 'footer') {
  8680. footSectionNodes.push(this.renderSection(currentConfig, configI, microColGroupNode));
  8681. configI++;
  8682. }
  8683. return (createElement("table", { className: classNames.join(' '), style: { height: props.height } },
  8684. Boolean(headSectionNodes.length) && createElement.apply(void 0, __spreadArrays(['thead', {}], headSectionNodes)),
  8685. Boolean(bodySectionNodes.length) && createElement.apply(void 0, __spreadArrays(['tbody', {}], bodySectionNodes)),
  8686. Boolean(footSectionNodes.length) && createElement.apply(void 0, __spreadArrays(['tfoot', {}], footSectionNodes))));
  8687. };
  8688. SimpleScrollGrid.prototype.renderSection = function (sectionConfig, sectionI, microColGroupNode) {
  8689. if ('outerContent' in sectionConfig) {
  8690. return (createElement(Fragment, { key: sectionConfig.key }, sectionConfig.outerContent));
  8691. }
  8692. return (createElement("tr", { key: sectionConfig.key, className: getSectionClassNames(sectionConfig, this.props.liquid).join(' ') }, this.renderChunkTd(sectionConfig, sectionI, microColGroupNode, sectionConfig.chunk)));
  8693. };
  8694. SimpleScrollGrid.prototype.renderChunkTd = function (sectionConfig, sectionI, microColGroupNode, chunkConfig) {
  8695. if ('outerContent' in chunkConfig) {
  8696. return chunkConfig.outerContent;
  8697. }
  8698. var props = this.props;
  8699. var _a = this.state, forceYScrollbars = _a.forceYScrollbars, scrollerClientWidths = _a.scrollerClientWidths, scrollerClientHeights = _a.scrollerClientHeights;
  8700. var needsYScrolling = getAllowYScrolling(props, sectionConfig); // TODO: do lazily. do in section config?
  8701. var isLiquid = getSectionHasLiquidHeight(props, sectionConfig);
  8702. // for `!props.liquid` - is WHOLE scrollgrid natural height?
  8703. // TODO: do same thing in advanced scrollgrid? prolly not b/c always has horizontal scrollbars
  8704. var overflowY = !props.liquid ? 'visible' :
  8705. forceYScrollbars ? 'scroll' :
  8706. !needsYScrolling ? 'hidden' :
  8707. 'auto';
  8708. var content = renderChunkContent(sectionConfig, chunkConfig, {
  8709. tableColGroupNode: microColGroupNode,
  8710. tableMinWidth: '',
  8711. clientWidth: scrollerClientWidths[sectionI] !== undefined ? scrollerClientWidths[sectionI] : null,
  8712. clientHeight: scrollerClientHeights[sectionI] !== undefined ? scrollerClientHeights[sectionI] : null,
  8713. expandRows: sectionConfig.expandRows,
  8714. syncRowHeights: false,
  8715. rowSyncHeights: [],
  8716. reportRowHeightChange: function () { }
  8717. });
  8718. return (createElement("td", { ref: chunkConfig.elRef },
  8719. createElement("div", { className: 'fc-scroller-harness' + (isLiquid ? ' fc-scroller-harness-liquid' : '') },
  8720. createElement(Scroller, { ref: this.scrollerRefs.createRef(sectionI), elRef: this.scrollerElRefs.createRef(sectionI), overflowY: overflowY, overflowX: !props.liquid ? 'visible' : 'hidden' /* natural height? */, maxHeight: sectionConfig.maxHeight, liquid: isLiquid, liquidIsAbsolute: true /* because its within a harness */ }, content))));
  8721. };
  8722. SimpleScrollGrid.prototype._handleScrollerEl = function (scrollerEl, key) {
  8723. var sectionI = parseInt(key, 10);
  8724. var chunkConfig = this.props.sections[sectionI].chunk;
  8725. setRef(chunkConfig.scrollerElRef, scrollerEl);
  8726. };
  8727. SimpleScrollGrid.prototype.componentDidMount = function () {
  8728. this.handleSizing();
  8729. this.context.addResizeHandler(this.handleSizing);
  8730. };
  8731. SimpleScrollGrid.prototype.componentDidUpdate = function () {
  8732. // TODO: need better solution when state contains non-sizing things
  8733. this.handleSizing();
  8734. };
  8735. SimpleScrollGrid.prototype.componentWillUnmount = function () {
  8736. this.context.removeResizeHandler(this.handleSizing);
  8737. };
  8738. SimpleScrollGrid.prototype.computeShrinkWidth = function () {
  8739. return hasShrinkWidth(this.props.cols)
  8740. ? computeShrinkWidth(this.scrollerElRefs.getAll())
  8741. : 0;
  8742. };
  8743. SimpleScrollGrid.prototype.computeScrollerDims = function () {
  8744. var scrollbarWidth = getScrollbarWidths();
  8745. var sectionCnt = this.props.sections.length;
  8746. var _a = this, scrollerRefs = _a.scrollerRefs, scrollerElRefs = _a.scrollerElRefs;
  8747. var forceYScrollbars = false;
  8748. var scrollerClientWidths = {};
  8749. var scrollerClientHeights = {};
  8750. for (var sectionI = 0; sectionI < sectionCnt; sectionI++) { // along edge
  8751. var scroller = scrollerRefs.currentMap[sectionI];
  8752. if (scroller && scroller.needsYScrolling()) {
  8753. forceYScrollbars = true;
  8754. break;
  8755. }
  8756. }
  8757. for (var sectionI = 0; sectionI < sectionCnt; sectionI++) { // along edge
  8758. var scrollerEl = scrollerElRefs.currentMap[sectionI];
  8759. if (scrollerEl) {
  8760. var harnessEl = scrollerEl.parentNode; // TODO: weird way to get this. need harness b/c doesn't include table borders
  8761. scrollerClientWidths[sectionI] = Math.floor(harnessEl.getBoundingClientRect().width - (forceYScrollbars
  8762. ? scrollbarWidth.y // use global because scroller might not have scrollbars yet but will need them in future
  8763. : 0));
  8764. scrollerClientHeights[sectionI] = Math.floor(harnessEl.getBoundingClientRect().height // never has horizontal scrollbars
  8765. );
  8766. }
  8767. }
  8768. return { forceYScrollbars: forceYScrollbars, scrollerClientWidths: scrollerClientWidths, scrollerClientHeights: scrollerClientHeights };
  8769. };
  8770. return SimpleScrollGrid;
  8771. }(BaseComponent));
  8772. SimpleScrollGrid.addStateEquality({
  8773. scrollerClientWidths: isPropsEqual,
  8774. scrollerClientHeights: isPropsEqual
  8775. });
  8776. var EventRoot = /** @class */ (function (_super) {
  8777. __extends(EventRoot, _super);
  8778. function EventRoot() {
  8779. var _this = _super !== null && _super.apply(this, arguments) || this;
  8780. _this.elRef = createRef();
  8781. return _this;
  8782. }
  8783. EventRoot.prototype.render = function () {
  8784. var _a = this, props = _a.props, context = _a.context;
  8785. var options = context.options;
  8786. var seg = props.seg;
  8787. var eventRange = seg.eventRange;
  8788. var ui = eventRange.ui;
  8789. var hookProps = {
  8790. event: new EventApi(context, eventRange.def, eventRange.instance),
  8791. view: context.viewApi,
  8792. timeText: props.timeText,
  8793. textColor: ui.textColor,
  8794. backgroundColor: ui.backgroundColor,
  8795. borderColor: ui.borderColor,
  8796. isDraggable: !props.disableDragging && computeSegDraggable(seg, context),
  8797. isStartResizable: !props.disableResizing && computeSegStartResizable(seg, context),
  8798. isEndResizable: !props.disableResizing && computeSegEndResizable(seg),
  8799. isMirror: Boolean(props.isDragging || props.isResizing || props.isDateSelecting),
  8800. isStart: Boolean(seg.isStart),
  8801. isEnd: Boolean(seg.isEnd),
  8802. isPast: Boolean(props.isPast),
  8803. isFuture: Boolean(props.isFuture),
  8804. isToday: Boolean(props.isToday),
  8805. isSelected: Boolean(props.isSelected),
  8806. isDragging: Boolean(props.isDragging),
  8807. isResizing: Boolean(props.isResizing)
  8808. };
  8809. var standardClassNames = getEventClassNames(hookProps).concat(ui.classNames);
  8810. return (createElement(RenderHook, { hookProps: hookProps, classNames: options.eventClassNames, content: options.eventContent, defaultContent: props.defaultContent, didMount: options.eventDidMount, willUnmount: options.eventWillUnmount, elRef: this.elRef }, function (rootElRef, customClassNames, innerElRef, innerContent) { return props.children(rootElRef, standardClassNames.concat(customClassNames), innerElRef, innerContent, hookProps); }));
  8811. };
  8812. EventRoot.prototype.componentDidMount = function () {
  8813. setElSeg(this.elRef.current, this.props.seg);
  8814. };
  8815. /*
  8816. need to re-assign seg to the element if seg changes, even if the element is the same
  8817. */
  8818. EventRoot.prototype.componentDidUpdate = function (prevProps) {
  8819. var seg = this.props.seg;
  8820. if (seg !== prevProps.seg) {
  8821. setElSeg(this.elRef.current, seg);
  8822. }
  8823. };
  8824. return EventRoot;
  8825. }(BaseComponent));
  8826. // should not be a purecomponent
  8827. var StandardEvent = /** @class */ (function (_super) {
  8828. __extends(StandardEvent, _super);
  8829. function StandardEvent() {
  8830. return _super !== null && _super.apply(this, arguments) || this;
  8831. }
  8832. StandardEvent.prototype.render = function () {
  8833. var _a = this, props = _a.props, context = _a.context;
  8834. var seg = props.seg;
  8835. var timeFormat = context.options.eventTimeFormat || props.defaultTimeFormat;
  8836. var timeText = buildSegTimeText(seg, timeFormat, context, props.defaultDisplayEventTime, props.defaultDisplayEventEnd);
  8837. return (createElement(EventRoot, { seg: seg, timeText: timeText, disableDragging: props.disableDragging, disableResizing: props.disableResizing, defaultContent: props.defaultContent || renderInnerContent, isDragging: props.isDragging, isResizing: props.isResizing, isDateSelecting: props.isDateSelecting, isSelected: props.isSelected, isPast: props.isPast, isFuture: props.isFuture, isToday: props.isToday }, function (rootElRef, classNames, innerElRef, innerContent, hookProps) { return (createElement("a", __assign({ className: props.extraClassNames.concat(classNames).join(' '), style: {
  8838. borderColor: hookProps.borderColor,
  8839. backgroundColor: hookProps.backgroundColor
  8840. }, ref: rootElRef }, getSegAnchorAttrs(seg)),
  8841. createElement("div", { className: 'fc-event-main', ref: innerElRef, style: { color: hookProps.textColor } }, innerContent),
  8842. hookProps.isStartResizable &&
  8843. createElement("div", { className: 'fc-event-resizer fc-event-resizer-start' }),
  8844. hookProps.isEndResizable &&
  8845. createElement("div", { className: 'fc-event-resizer fc-event-resizer-end' }))); }));
  8846. };
  8847. return StandardEvent;
  8848. }(BaseComponent));
  8849. function renderInnerContent(innerProps) {
  8850. return (createElement("div", { className: 'fc-event-main-frame' },
  8851. innerProps.timeText &&
  8852. createElement("div", { className: 'fc-event-time' }, innerProps.timeText),
  8853. createElement("div", { className: 'fc-event-title-container' },
  8854. createElement("div", { className: 'fc-event-title fc-sticky' }, innerProps.event.title || createElement(Fragment, null, "\u00A0")))));
  8855. }
  8856. function getSegAnchorAttrs(seg) {
  8857. var url = seg.eventRange.def.url;
  8858. return url ? { href: url } : {};
  8859. }
  8860. var NowIndicatorRoot = function (props) { return (createElement(ViewContextType.Consumer, null, function (context) {
  8861. var options = context.options;
  8862. var hookProps = {
  8863. isAxis: props.isAxis,
  8864. date: context.dateEnv.toDate(props.date),
  8865. view: context.viewApi
  8866. };
  8867. return (createElement(RenderHook, { hookProps: hookProps, classNames: options.nowIndicatorClassNames, content: options.nowIndicatorContent, didMount: options.nowIndicatorDidMount, willUnmount: options.nowIndicatorWillUnmount }, props.children));
  8868. })); };
  8869. var DAY_NUM_FORMAT = createFormatter({ day: 'numeric' });
  8870. var DayCellRoot = /** @class */ (function (_super) {
  8871. __extends(DayCellRoot, _super);
  8872. function DayCellRoot() {
  8873. var _this = _super !== null && _super.apply(this, arguments) || this;
  8874. _this.refineHookProps = memoizeObjArg(refineHookProps);
  8875. _this.normalizeClassNames = buildClassNameNormalizer();
  8876. return _this;
  8877. }
  8878. DayCellRoot.prototype.render = function () {
  8879. var _a = this, props = _a.props, context = _a.context;
  8880. var options = context.options;
  8881. var hookProps = this.refineHookProps({
  8882. date: props.date,
  8883. dateProfile: props.dateProfile,
  8884. todayRange: props.todayRange,
  8885. showDayNumber: props.showDayNumber,
  8886. extraProps: props.extraHookProps,
  8887. viewApi: context.viewApi,
  8888. dateEnv: context.dateEnv
  8889. });
  8890. var classNames = getDayClassNames(hookProps, context.theme).concat(hookProps.isDisabled
  8891. ? [] // don't use custom classNames if disabled
  8892. : this.normalizeClassNames(options.dayCellClassNames, hookProps));
  8893. var dataAttrs = hookProps.isDisabled ? {} : {
  8894. 'data-date': formatDayString(props.date)
  8895. };
  8896. return (createElement(MountHook, { hookProps: hookProps, didMount: options.dayCellDidMount, willUnmount: options.dayCellWillUnmount, elRef: props.elRef }, function (rootElRef) { return props.children(rootElRef, classNames, dataAttrs, hookProps.isDisabled); }));
  8897. };
  8898. return DayCellRoot;
  8899. }(BaseComponent));
  8900. var DayCellContent = /** @class */ (function (_super) {
  8901. __extends(DayCellContent, _super);
  8902. function DayCellContent() {
  8903. return _super !== null && _super.apply(this, arguments) || this;
  8904. }
  8905. DayCellContent.prototype.render = function () {
  8906. var _a = this, props = _a.props, context = _a.context;
  8907. var options = context.options;
  8908. var hookProps = refineHookProps({
  8909. date: props.date,
  8910. dateProfile: props.dateProfile,
  8911. todayRange: props.todayRange,
  8912. showDayNumber: props.showDayNumber,
  8913. extraProps: props.extraHookProps,
  8914. viewApi: context.viewApi,
  8915. dateEnv: context.dateEnv
  8916. });
  8917. return (createElement(ContentHook, { hookProps: hookProps, content: options.dayCellContent, defaultContent: props.defaultContent }, props.children));
  8918. };
  8919. return DayCellContent;
  8920. }(BaseComponent));
  8921. function refineHookProps(raw) {
  8922. var date = raw.date, dateEnv = raw.dateEnv;
  8923. var dayMeta = getDateMeta(date, raw.todayRange, null, raw.dateProfile);
  8924. return __assign(__assign(__assign({ date: dateEnv.toDate(date), view: raw.viewApi }, dayMeta), { dayNumberText: raw.showDayNumber ? dateEnv.format(date, DAY_NUM_FORMAT) : '' }), raw.extraProps);
  8925. }
  8926. function renderFill(fillType) {
  8927. return (createElement("div", { className: "fc-" + fillType }));
  8928. }
  8929. var BgEvent = function (props) { return (createElement(EventRoot, { defaultContent: renderInnerContent$1, seg: props.seg /* uselesss i think */, timeText: '' /* weird */, disableDragging: true, disableResizing: true, isDragging: false, isResizing: false, isDateSelecting: false, isSelected: false, isPast: props.isPast, isFuture: props.isFuture, isToday: props.isToday }, function (rootElRef, classNames, innerElRef, innerContent, hookProps) { return (createElement("div", { ref: rootElRef, className: ['fc-bg-event'].concat(classNames).join(' '), style: {
  8930. backgroundColor: hookProps.backgroundColor
  8931. } }, innerContent)); })); };
  8932. function renderInnerContent$1(props) {
  8933. var title = props.event.title;
  8934. return title && (createElement("div", { className: 'fc-event-title' }, props.event.title));
  8935. }
  8936. var WeekNumberRoot = function (props) { return (createElement(ViewContextType.Consumer, null, function (context) {
  8937. var dateEnv = context.dateEnv, options = context.options;
  8938. var date = props.date;
  8939. var format = options.weekNumberFormat || props.defaultFormat;
  8940. var num = dateEnv.computeWeekNumber(date); // TODO: somehow use for formatting as well?
  8941. var text = dateEnv.format(date, format);
  8942. var hookProps = { num: num, text: text, date: date };
  8943. return (createElement(RenderHook, { hookProps: hookProps, classNames: options.weekNumberClassNames, content: options.weekNumberContent, defaultContent: renderInner$1, didMount: options.weekNumberDidMount, willUnmount: options.weekNumberWillUnmount }, props.children));
  8944. })); };
  8945. function renderInner$1(innerProps) {
  8946. return innerProps.text;
  8947. }
  8948. // exports
  8949. // --------------------------------------------------------------------------------------------------
  8950. var version = '<%= version %>'; // important to type it, so .d.ts has generic string
  8951. var Calendar = /** @class */ (function (_super) {
  8952. __extends(Calendar, _super);
  8953. function Calendar(el, optionOverrides) {
  8954. if (optionOverrides === void 0) { optionOverrides = {}; }
  8955. var _this = _super.call(this) || this;
  8956. _this.isRendering = false;
  8957. _this.isRendered = false;
  8958. _this.currentClassNames = [];
  8959. _this.customContentRenderId = 0; // will affect custom generated classNames?
  8960. _this.handleAction = function (action) {
  8961. // actions we know we want to render immediately
  8962. switch (action.type) {
  8963. case 'SET_EVENT_DRAG':
  8964. case 'SET_EVENT_RESIZE':
  8965. _this.renderRunner.tryDrain();
  8966. }
  8967. };
  8968. _this.handleData = function (data) {
  8969. _this.currentData = data;
  8970. _this.renderRunner.request(data.calendarOptions.rerenderDelay);
  8971. };
  8972. _this.handleRenderRequest = function () {
  8973. if (_this.isRendering) {
  8974. _this.isRendered = true;
  8975. var currentData_1 = _this.currentData;
  8976. render(createElement(CalendarRoot, { options: currentData_1.calendarOptions, theme: currentData_1.theme, emitter: currentData_1.emitter }, function (classNames, height, isHeightAuto, forPrint) {
  8977. _this.setClassNames(classNames);
  8978. _this.setHeight(height);
  8979. return (createElement(CustomContentRenderContext.Provider, { value: _this.customContentRenderId },
  8980. createElement(CalendarContent, __assign({ isHeightAuto: isHeightAuto, forPrint: forPrint }, currentData_1))));
  8981. }), _this.el);
  8982. }
  8983. else if (_this.isRendered) {
  8984. _this.isRendered = false;
  8985. render(null, _this.el);
  8986. _this.setClassNames([]);
  8987. _this.setHeight('');
  8988. }
  8989. flushToDom$1();
  8990. };
  8991. _this.el = el;
  8992. _this.renderRunner = new DelayedRunner(_this.handleRenderRequest);
  8993. new CalendarDataManager({
  8994. optionOverrides: optionOverrides,
  8995. calendarApi: _this,
  8996. onAction: _this.handleAction,
  8997. onData: _this.handleData
  8998. });
  8999. return _this;
  9000. }
  9001. Object.defineProperty(Calendar.prototype, "view", {
  9002. get: function () { return this.currentData.viewApi; } // for public API
  9003. ,
  9004. enumerable: false,
  9005. configurable: true
  9006. });
  9007. Calendar.prototype.render = function () {
  9008. if (!this.isRendering) {
  9009. this.isRendering = true;
  9010. }
  9011. else {
  9012. this.customContentRenderId++;
  9013. }
  9014. this.renderRunner.request();
  9015. };
  9016. Calendar.prototype.destroy = function () {
  9017. if (this.isRendering) {
  9018. this.isRendering = false;
  9019. this.renderRunner.request();
  9020. }
  9021. };
  9022. Calendar.prototype.updateSize = function () {
  9023. _super.prototype.updateSize.call(this);
  9024. flushToDom$1();
  9025. };
  9026. Calendar.prototype.batchRendering = function (func) {
  9027. this.renderRunner.pause('batchRendering');
  9028. func();
  9029. this.renderRunner.resume('batchRendering');
  9030. };
  9031. Calendar.prototype.pauseRendering = function () {
  9032. this.renderRunner.pause('pauseRendering');
  9033. };
  9034. Calendar.prototype.resumeRendering = function () {
  9035. this.renderRunner.resume('pauseRendering', true);
  9036. };
  9037. Calendar.prototype.resetOptions = function (optionOverrides, append) {
  9038. this.currentDataManager.resetOptions(optionOverrides, append);
  9039. };
  9040. Calendar.prototype.setClassNames = function (classNames) {
  9041. if (!isArraysEqual(classNames, this.currentClassNames)) {
  9042. var classList = this.el.classList;
  9043. for (var _i = 0, _a = this.currentClassNames; _i < _a.length; _i++) {
  9044. var className = _a[_i];
  9045. classList.remove(className);
  9046. }
  9047. for (var _b = 0, classNames_1 = classNames; _b < classNames_1.length; _b++) {
  9048. var className = classNames_1[_b];
  9049. classList.add(className);
  9050. }
  9051. this.currentClassNames = classNames;
  9052. }
  9053. };
  9054. Calendar.prototype.setHeight = function (height) {
  9055. applyStyleProp(this.el, 'height', height);
  9056. };
  9057. return Calendar;
  9058. }(CalendarApi));
  9059. config.touchMouseIgnoreWait = 500;
  9060. var ignoreMouseDepth = 0;
  9061. var listenerCnt = 0;
  9062. var isWindowTouchMoveCancelled = false;
  9063. /*
  9064. Uses a "pointer" abstraction, which monitors UI events for both mouse and touch.
  9065. Tracks when the pointer "drags" on a certain element, meaning down+move+up.
  9066. Also, tracks if there was touch-scrolling.
  9067. Also, can prevent touch-scrolling from happening.
  9068. Also, can fire pointermove events when scrolling happens underneath, even when no real pointer movement.
  9069. emits:
  9070. - pointerdown
  9071. - pointermove
  9072. - pointerup
  9073. */
  9074. var PointerDragging = /** @class */ (function () {
  9075. function PointerDragging(containerEl) {
  9076. var _this = this;
  9077. this.subjectEl = null;
  9078. this.downEl = null;
  9079. // options that can be directly assigned by caller
  9080. this.selector = ''; // will cause subjectEl in all emitted events to be this element
  9081. this.handleSelector = '';
  9082. this.shouldIgnoreMove = false;
  9083. this.shouldWatchScroll = true; // for simulating pointermove on scroll
  9084. // internal states
  9085. this.isDragging = false;
  9086. this.isTouchDragging = false;
  9087. this.wasTouchScroll = false;
  9088. // Mouse
  9089. // ----------------------------------------------------------------------------------------------------
  9090. this.handleMouseDown = function (ev) {
  9091. if (!_this.shouldIgnoreMouse() &&
  9092. isPrimaryMouseButton(ev) &&
  9093. _this.tryStart(ev)) {
  9094. var pev = _this.createEventFromMouse(ev, true);
  9095. _this.emitter.trigger('pointerdown', pev);
  9096. _this.initScrollWatch(pev);
  9097. if (!_this.shouldIgnoreMove) {
  9098. document.addEventListener('mousemove', _this.handleMouseMove);
  9099. }
  9100. document.addEventListener('mouseup', _this.handleMouseUp);
  9101. }
  9102. };
  9103. this.handleMouseMove = function (ev) {
  9104. var pev = _this.createEventFromMouse(ev);
  9105. _this.recordCoords(pev);
  9106. _this.emitter.trigger('pointermove', pev);
  9107. };
  9108. this.handleMouseUp = function (ev) {
  9109. document.removeEventListener('mousemove', _this.handleMouseMove);
  9110. document.removeEventListener('mouseup', _this.handleMouseUp);
  9111. _this.emitter.trigger('pointerup', _this.createEventFromMouse(ev));
  9112. _this.cleanup(); // call last so that pointerup has access to props
  9113. };
  9114. // Touch
  9115. // ----------------------------------------------------------------------------------------------------
  9116. this.handleTouchStart = function (ev) {
  9117. if (_this.tryStart(ev)) {
  9118. _this.isTouchDragging = true;
  9119. var pev = _this.createEventFromTouch(ev, true);
  9120. _this.emitter.trigger('pointerdown', pev);
  9121. _this.initScrollWatch(pev);
  9122. // unlike mouse, need to attach to target, not document
  9123. // https://stackoverflow.com/a/45760014
  9124. var target = ev.target;
  9125. if (!_this.shouldIgnoreMove) {
  9126. target.addEventListener('touchmove', _this.handleTouchMove);
  9127. }
  9128. target.addEventListener('touchend', _this.handleTouchEnd);
  9129. target.addEventListener('touchcancel', _this.handleTouchEnd); // treat it as a touch end
  9130. // attach a handler to get called when ANY scroll action happens on the page.
  9131. // this was impossible to do with normal on/off because 'scroll' doesn't bubble.
  9132. // http://stackoverflow.com/a/32954565/96342
  9133. window.addEventListener('scroll', _this.handleTouchScroll, true // useCapture
  9134. );
  9135. }
  9136. };
  9137. this.handleTouchMove = function (ev) {
  9138. var pev = _this.createEventFromTouch(ev);
  9139. _this.recordCoords(pev);
  9140. _this.emitter.trigger('pointermove', pev);
  9141. };
  9142. this.handleTouchEnd = function (ev) {
  9143. if (_this.isDragging) { // done to guard against touchend followed by touchcancel
  9144. var target = ev.target;
  9145. target.removeEventListener('touchmove', _this.handleTouchMove);
  9146. target.removeEventListener('touchend', _this.handleTouchEnd);
  9147. target.removeEventListener('touchcancel', _this.handleTouchEnd);
  9148. window.removeEventListener('scroll', _this.handleTouchScroll, true); // useCaptured=true
  9149. _this.emitter.trigger('pointerup', _this.createEventFromTouch(ev));
  9150. _this.cleanup(); // call last so that pointerup has access to props
  9151. _this.isTouchDragging = false;
  9152. startIgnoringMouse();
  9153. }
  9154. };
  9155. this.handleTouchScroll = function () {
  9156. _this.wasTouchScroll = true;
  9157. };
  9158. this.handleScroll = function (ev) {
  9159. if (!_this.shouldIgnoreMove) {
  9160. var pageX = (window.pageXOffset - _this.prevScrollX) + _this.prevPageX;
  9161. var pageY = (window.pageYOffset - _this.prevScrollY) + _this.prevPageY;
  9162. _this.emitter.trigger('pointermove', {
  9163. origEvent: ev,
  9164. isTouch: _this.isTouchDragging,
  9165. subjectEl: _this.subjectEl,
  9166. pageX: pageX,
  9167. pageY: pageY,
  9168. deltaX: pageX - _this.origPageX,
  9169. deltaY: pageY - _this.origPageY
  9170. });
  9171. }
  9172. };
  9173. this.containerEl = containerEl;
  9174. this.emitter = new Emitter();
  9175. containerEl.addEventListener('mousedown', this.handleMouseDown);
  9176. containerEl.addEventListener('touchstart', this.handleTouchStart, { passive: true });
  9177. listenerCreated();
  9178. }
  9179. PointerDragging.prototype.destroy = function () {
  9180. this.containerEl.removeEventListener('mousedown', this.handleMouseDown);
  9181. this.containerEl.removeEventListener('touchstart', this.handleTouchStart, { passive: true });
  9182. listenerDestroyed();
  9183. };
  9184. PointerDragging.prototype.tryStart = function (ev) {
  9185. var subjectEl = this.querySubjectEl(ev);
  9186. var downEl = ev.target;
  9187. if (subjectEl &&
  9188. (!this.handleSelector || elementClosest(downEl, this.handleSelector))) {
  9189. this.subjectEl = subjectEl;
  9190. this.downEl = downEl;
  9191. this.isDragging = true; // do this first so cancelTouchScroll will work
  9192. this.wasTouchScroll = false;
  9193. return true;
  9194. }
  9195. return false;
  9196. };
  9197. PointerDragging.prototype.cleanup = function () {
  9198. isWindowTouchMoveCancelled = false;
  9199. this.isDragging = false;
  9200. this.subjectEl = null;
  9201. this.downEl = null;
  9202. // keep wasTouchScroll around for later access
  9203. this.destroyScrollWatch();
  9204. };
  9205. PointerDragging.prototype.querySubjectEl = function (ev) {
  9206. if (this.selector) {
  9207. return elementClosest(ev.target, this.selector);
  9208. }
  9209. else {
  9210. return this.containerEl;
  9211. }
  9212. };
  9213. PointerDragging.prototype.shouldIgnoreMouse = function () {
  9214. return ignoreMouseDepth || this.isTouchDragging;
  9215. };
  9216. // can be called by user of this class, to cancel touch-based scrolling for the current drag
  9217. PointerDragging.prototype.cancelTouchScroll = function () {
  9218. if (this.isDragging) {
  9219. isWindowTouchMoveCancelled = true;
  9220. }
  9221. };
  9222. // Scrolling that simulates pointermoves
  9223. // ----------------------------------------------------------------------------------------------------
  9224. PointerDragging.prototype.initScrollWatch = function (ev) {
  9225. if (this.shouldWatchScroll) {
  9226. this.recordCoords(ev);
  9227. window.addEventListener('scroll', this.handleScroll, true); // useCapture=true
  9228. }
  9229. };
  9230. PointerDragging.prototype.recordCoords = function (ev) {
  9231. if (this.shouldWatchScroll) {
  9232. this.prevPageX = ev.pageX;
  9233. this.prevPageY = ev.pageY;
  9234. this.prevScrollX = window.pageXOffset;
  9235. this.prevScrollY = window.pageYOffset;
  9236. }
  9237. };
  9238. PointerDragging.prototype.destroyScrollWatch = function () {
  9239. if (this.shouldWatchScroll) {
  9240. window.removeEventListener('scroll', this.handleScroll, true); // useCaptured=true
  9241. }
  9242. };
  9243. // Event Normalization
  9244. // ----------------------------------------------------------------------------------------------------
  9245. PointerDragging.prototype.createEventFromMouse = function (ev, isFirst) {
  9246. var deltaX = 0;
  9247. var deltaY = 0;
  9248. // TODO: repeat code
  9249. if (isFirst) {
  9250. this.origPageX = ev.pageX;
  9251. this.origPageY = ev.pageY;
  9252. }
  9253. else {
  9254. deltaX = ev.pageX - this.origPageX;
  9255. deltaY = ev.pageY - this.origPageY;
  9256. }
  9257. return {
  9258. origEvent: ev,
  9259. isTouch: false,
  9260. subjectEl: this.subjectEl,
  9261. pageX: ev.pageX,
  9262. pageY: ev.pageY,
  9263. deltaX: deltaX,
  9264. deltaY: deltaY
  9265. };
  9266. };
  9267. PointerDragging.prototype.createEventFromTouch = function (ev, isFirst) {
  9268. var touches = ev.touches;
  9269. var pageX;
  9270. var pageY;
  9271. var deltaX = 0;
  9272. var deltaY = 0;
  9273. // if touch coords available, prefer,
  9274. // because FF would give bad ev.pageX ev.pageY
  9275. if (touches && touches.length) {
  9276. pageX = touches[0].pageX;
  9277. pageY = touches[0].pageY;
  9278. }
  9279. else {
  9280. pageX = ev.pageX;
  9281. pageY = ev.pageY;
  9282. }
  9283. // TODO: repeat code
  9284. if (isFirst) {
  9285. this.origPageX = pageX;
  9286. this.origPageY = pageY;
  9287. }
  9288. else {
  9289. deltaX = pageX - this.origPageX;
  9290. deltaY = pageY - this.origPageY;
  9291. }
  9292. return {
  9293. origEvent: ev,
  9294. isTouch: true,
  9295. subjectEl: this.subjectEl,
  9296. pageX: pageX,
  9297. pageY: pageY,
  9298. deltaX: deltaX,
  9299. deltaY: deltaY
  9300. };
  9301. };
  9302. return PointerDragging;
  9303. }());
  9304. // Returns a boolean whether this was a left mouse click and no ctrl key (which means right click on Mac)
  9305. function isPrimaryMouseButton(ev) {
  9306. return ev.button === 0 && !ev.ctrlKey;
  9307. }
  9308. // Ignoring fake mouse events generated by touch
  9309. // ----------------------------------------------------------------------------------------------------
  9310. function startIgnoringMouse() {
  9311. ignoreMouseDepth++;
  9312. setTimeout(function () {
  9313. ignoreMouseDepth--;
  9314. }, config.touchMouseIgnoreWait);
  9315. }
  9316. // We want to attach touchmove as early as possible for Safari
  9317. // ----------------------------------------------------------------------------------------------------
  9318. function listenerCreated() {
  9319. if (!(listenerCnt++)) {
  9320. window.addEventListener('touchmove', onWindowTouchMove, { passive: false });
  9321. }
  9322. }
  9323. function listenerDestroyed() {
  9324. if (!(--listenerCnt)) {
  9325. window.removeEventListener('touchmove', onWindowTouchMove, { passive: false });
  9326. }
  9327. }
  9328. function onWindowTouchMove(ev) {
  9329. if (isWindowTouchMoveCancelled) {
  9330. ev.preventDefault();
  9331. }
  9332. }
  9333. /*
  9334. An effect in which an element follows the movement of a pointer across the screen.
  9335. The moving element is a clone of some other element.
  9336. Must call start + handleMove + stop.
  9337. */
  9338. var ElementMirror = /** @class */ (function () {
  9339. function ElementMirror() {
  9340. this.isVisible = false; // must be explicitly enabled
  9341. this.sourceEl = null;
  9342. this.mirrorEl = null;
  9343. this.sourceElRect = null; // screen coords relative to viewport
  9344. // options that can be set directly by caller
  9345. this.parentNode = document.body;
  9346. this.zIndex = 9999;
  9347. this.revertDuration = 0;
  9348. }
  9349. ElementMirror.prototype.start = function (sourceEl, pageX, pageY) {
  9350. this.sourceEl = sourceEl;
  9351. this.sourceElRect = this.sourceEl.getBoundingClientRect();
  9352. this.origScreenX = pageX - window.pageXOffset;
  9353. this.origScreenY = pageY - window.pageYOffset;
  9354. this.deltaX = 0;
  9355. this.deltaY = 0;
  9356. this.updateElPosition();
  9357. };
  9358. ElementMirror.prototype.handleMove = function (pageX, pageY) {
  9359. this.deltaX = (pageX - window.pageXOffset) - this.origScreenX;
  9360. this.deltaY = (pageY - window.pageYOffset) - this.origScreenY;
  9361. this.updateElPosition();
  9362. };
  9363. // can be called before start
  9364. ElementMirror.prototype.setIsVisible = function (bool) {
  9365. if (bool) {
  9366. if (!this.isVisible) {
  9367. if (this.mirrorEl) {
  9368. this.mirrorEl.style.display = '';
  9369. }
  9370. this.isVisible = bool; // needs to happen before updateElPosition
  9371. this.updateElPosition(); // because was not updating the position while invisible
  9372. }
  9373. }
  9374. else {
  9375. if (this.isVisible) {
  9376. if (this.mirrorEl) {
  9377. this.mirrorEl.style.display = 'none';
  9378. }
  9379. this.isVisible = bool;
  9380. }
  9381. }
  9382. };
  9383. // always async
  9384. ElementMirror.prototype.stop = function (needsRevertAnimation, callback) {
  9385. var _this = this;
  9386. var done = function () {
  9387. _this.cleanup();
  9388. callback();
  9389. };
  9390. if (needsRevertAnimation &&
  9391. this.mirrorEl &&
  9392. this.isVisible &&
  9393. this.revertDuration && // if 0, transition won't work
  9394. (this.deltaX || this.deltaY) // if same coords, transition won't work
  9395. ) {
  9396. this.doRevertAnimation(done, this.revertDuration);
  9397. }
  9398. else {
  9399. setTimeout(done, 0);
  9400. }
  9401. };
  9402. ElementMirror.prototype.doRevertAnimation = function (callback, revertDuration) {
  9403. var mirrorEl = this.mirrorEl;
  9404. var finalSourceElRect = this.sourceEl.getBoundingClientRect(); // because autoscrolling might have happened
  9405. mirrorEl.style.transition =
  9406. 'top ' + revertDuration + 'ms,' +
  9407. 'left ' + revertDuration + 'ms';
  9408. applyStyle(mirrorEl, {
  9409. left: finalSourceElRect.left,
  9410. top: finalSourceElRect.top
  9411. });
  9412. whenTransitionDone(mirrorEl, function () {
  9413. mirrorEl.style.transition = '';
  9414. callback();
  9415. });
  9416. };
  9417. ElementMirror.prototype.cleanup = function () {
  9418. if (this.mirrorEl) {
  9419. removeElement(this.mirrorEl);
  9420. this.mirrorEl = null;
  9421. }
  9422. this.sourceEl = null;
  9423. };
  9424. ElementMirror.prototype.updateElPosition = function () {
  9425. if (this.sourceEl && this.isVisible) {
  9426. applyStyle(this.getMirrorEl(), {
  9427. left: this.sourceElRect.left + this.deltaX,
  9428. top: this.sourceElRect.top + this.deltaY
  9429. });
  9430. }
  9431. };
  9432. ElementMirror.prototype.getMirrorEl = function () {
  9433. var sourceElRect = this.sourceElRect;
  9434. var mirrorEl = this.mirrorEl;
  9435. if (!mirrorEl) {
  9436. mirrorEl = this.mirrorEl = this.sourceEl.cloneNode(true); // cloneChildren=true
  9437. // we don't want long taps or any mouse interaction causing selection/menus.
  9438. // would use preventSelection(), but that prevents selectstart, causing problems.
  9439. mirrorEl.classList.add('fc-unselectable');
  9440. mirrorEl.classList.add('fc-event-dragging');
  9441. applyStyle(mirrorEl, {
  9442. position: 'fixed',
  9443. zIndex: this.zIndex,
  9444. visibility: '',
  9445. boxSizing: 'border-box',
  9446. width: sourceElRect.right - sourceElRect.left,
  9447. height: sourceElRect.bottom - sourceElRect.top,
  9448. right: 'auto',
  9449. bottom: 'auto',
  9450. margin: 0
  9451. });
  9452. this.parentNode.appendChild(mirrorEl);
  9453. }
  9454. return mirrorEl;
  9455. };
  9456. return ElementMirror;
  9457. }());
  9458. /*
  9459. Is a cache for a given element's scroll information (all the info that ScrollController stores)
  9460. in addition the "client rectangle" of the element.. the area within the scrollbars.
  9461. The cache can be in one of two modes:
  9462. - doesListening:false - ignores when the container is scrolled by someone else
  9463. - doesListening:true - watch for scrolling and update the cache
  9464. */
  9465. var ScrollGeomCache = /** @class */ (function (_super) {
  9466. __extends(ScrollGeomCache, _super);
  9467. function ScrollGeomCache(scrollController, doesListening) {
  9468. var _this = _super.call(this) || this;
  9469. _this.handleScroll = function () {
  9470. _this.scrollTop = _this.scrollController.getScrollTop();
  9471. _this.scrollLeft = _this.scrollController.getScrollLeft();
  9472. _this.handleScrollChange();
  9473. };
  9474. _this.scrollController = scrollController;
  9475. _this.doesListening = doesListening;
  9476. _this.scrollTop = _this.origScrollTop = scrollController.getScrollTop();
  9477. _this.scrollLeft = _this.origScrollLeft = scrollController.getScrollLeft();
  9478. _this.scrollWidth = scrollController.getScrollWidth();
  9479. _this.scrollHeight = scrollController.getScrollHeight();
  9480. _this.clientWidth = scrollController.getClientWidth();
  9481. _this.clientHeight = scrollController.getClientHeight();
  9482. _this.clientRect = _this.computeClientRect(); // do last in case it needs cached values
  9483. if (_this.doesListening) {
  9484. _this.getEventTarget().addEventListener('scroll', _this.handleScroll);
  9485. }
  9486. return _this;
  9487. }
  9488. ScrollGeomCache.prototype.destroy = function () {
  9489. if (this.doesListening) {
  9490. this.getEventTarget().removeEventListener('scroll', this.handleScroll);
  9491. }
  9492. };
  9493. ScrollGeomCache.prototype.getScrollTop = function () {
  9494. return this.scrollTop;
  9495. };
  9496. ScrollGeomCache.prototype.getScrollLeft = function () {
  9497. return this.scrollLeft;
  9498. };
  9499. ScrollGeomCache.prototype.setScrollTop = function (top) {
  9500. this.scrollController.setScrollTop(top);
  9501. if (!this.doesListening) {
  9502. // we are not relying on the element to normalize out-of-bounds scroll values
  9503. // so we need to sanitize ourselves
  9504. this.scrollTop = Math.max(Math.min(top, this.getMaxScrollTop()), 0);
  9505. this.handleScrollChange();
  9506. }
  9507. };
  9508. ScrollGeomCache.prototype.setScrollLeft = function (top) {
  9509. this.scrollController.setScrollLeft(top);
  9510. if (!this.doesListening) {
  9511. // we are not relying on the element to normalize out-of-bounds scroll values
  9512. // so we need to sanitize ourselves
  9513. this.scrollLeft = Math.max(Math.min(top, this.getMaxScrollLeft()), 0);
  9514. this.handleScrollChange();
  9515. }
  9516. };
  9517. ScrollGeomCache.prototype.getClientWidth = function () {
  9518. return this.clientWidth;
  9519. };
  9520. ScrollGeomCache.prototype.getClientHeight = function () {
  9521. return this.clientHeight;
  9522. };
  9523. ScrollGeomCache.prototype.getScrollWidth = function () {
  9524. return this.scrollWidth;
  9525. };
  9526. ScrollGeomCache.prototype.getScrollHeight = function () {
  9527. return this.scrollHeight;
  9528. };
  9529. ScrollGeomCache.prototype.handleScrollChange = function () {
  9530. };
  9531. return ScrollGeomCache;
  9532. }(ScrollController));
  9533. var ElementScrollGeomCache = /** @class */ (function (_super) {
  9534. __extends(ElementScrollGeomCache, _super);
  9535. function ElementScrollGeomCache(el, doesListening) {
  9536. return _super.call(this, new ElementScrollController(el), doesListening) || this;
  9537. }
  9538. ElementScrollGeomCache.prototype.getEventTarget = function () {
  9539. return this.scrollController.el;
  9540. };
  9541. ElementScrollGeomCache.prototype.computeClientRect = function () {
  9542. return computeInnerRect(this.scrollController.el);
  9543. };
  9544. return ElementScrollGeomCache;
  9545. }(ScrollGeomCache));
  9546. var WindowScrollGeomCache = /** @class */ (function (_super) {
  9547. __extends(WindowScrollGeomCache, _super);
  9548. function WindowScrollGeomCache(doesListening) {
  9549. return _super.call(this, new WindowScrollController(), doesListening) || this;
  9550. }
  9551. WindowScrollGeomCache.prototype.getEventTarget = function () {
  9552. return window;
  9553. };
  9554. WindowScrollGeomCache.prototype.computeClientRect = function () {
  9555. return {
  9556. left: this.scrollLeft,
  9557. right: this.scrollLeft + this.clientWidth,
  9558. top: this.scrollTop,
  9559. bottom: this.scrollTop + this.clientHeight
  9560. };
  9561. };
  9562. // the window is the only scroll object that changes it's rectangle relative
  9563. // to the document's topleft as it scrolls
  9564. WindowScrollGeomCache.prototype.handleScrollChange = function () {
  9565. this.clientRect = this.computeClientRect();
  9566. };
  9567. return WindowScrollGeomCache;
  9568. }(ScrollGeomCache));
  9569. // If available we are using native "performance" API instead of "Date"
  9570. // Read more about it on MDN:
  9571. // https://developer.mozilla.org/en-US/docs/Web/API/Performance
  9572. var getTime = typeof performance === 'function' ? performance.now : Date.now;
  9573. /*
  9574. For a pointer interaction, automatically scrolls certain scroll containers when the pointer
  9575. approaches the edge.
  9576. The caller must call start + handleMove + stop.
  9577. */
  9578. var AutoScroller = /** @class */ (function () {
  9579. function AutoScroller() {
  9580. var _this = this;
  9581. // options that can be set by caller
  9582. this.isEnabled = true;
  9583. this.scrollQuery = [window, '.fc-scroller'];
  9584. this.edgeThreshold = 50; // pixels
  9585. this.maxVelocity = 300; // pixels per second
  9586. // internal state
  9587. this.pointerScreenX = null;
  9588. this.pointerScreenY = null;
  9589. this.isAnimating = false;
  9590. this.scrollCaches = null;
  9591. // protect against the initial pointerdown being too close to an edge and starting the scroll
  9592. this.everMovedUp = false;
  9593. this.everMovedDown = false;
  9594. this.everMovedLeft = false;
  9595. this.everMovedRight = false;
  9596. this.animate = function () {
  9597. if (_this.isAnimating) { // wasn't cancelled between animation calls
  9598. var edge = _this.computeBestEdge(_this.pointerScreenX + window.pageXOffset, _this.pointerScreenY + window.pageYOffset);
  9599. if (edge) {
  9600. var now = getTime();
  9601. _this.handleSide(edge, (now - _this.msSinceRequest) / 1000);
  9602. _this.requestAnimation(now);
  9603. }
  9604. else {
  9605. _this.isAnimating = false; // will stop animation
  9606. }
  9607. }
  9608. };
  9609. }
  9610. AutoScroller.prototype.start = function (pageX, pageY) {
  9611. if (this.isEnabled) {
  9612. this.scrollCaches = this.buildCaches();
  9613. this.pointerScreenX = null;
  9614. this.pointerScreenY = null;
  9615. this.everMovedUp = false;
  9616. this.everMovedDown = false;
  9617. this.everMovedLeft = false;
  9618. this.everMovedRight = false;
  9619. this.handleMove(pageX, pageY);
  9620. }
  9621. };
  9622. AutoScroller.prototype.handleMove = function (pageX, pageY) {
  9623. if (this.isEnabled) {
  9624. var pointerScreenX = pageX - window.pageXOffset;
  9625. var pointerScreenY = pageY - window.pageYOffset;
  9626. var yDelta = this.pointerScreenY === null ? 0 : pointerScreenY - this.pointerScreenY;
  9627. var xDelta = this.pointerScreenX === null ? 0 : pointerScreenX - this.pointerScreenX;
  9628. if (yDelta < 0) {
  9629. this.everMovedUp = true;
  9630. }
  9631. else if (yDelta > 0) {
  9632. this.everMovedDown = true;
  9633. }
  9634. if (xDelta < 0) {
  9635. this.everMovedLeft = true;
  9636. }
  9637. else if (xDelta > 0) {
  9638. this.everMovedRight = true;
  9639. }
  9640. this.pointerScreenX = pointerScreenX;
  9641. this.pointerScreenY = pointerScreenY;
  9642. if (!this.isAnimating) {
  9643. this.isAnimating = true;
  9644. this.requestAnimation(getTime());
  9645. }
  9646. }
  9647. };
  9648. AutoScroller.prototype.stop = function () {
  9649. if (this.isEnabled) {
  9650. this.isAnimating = false; // will stop animation
  9651. for (var _i = 0, _a = this.scrollCaches; _i < _a.length; _i++) {
  9652. var scrollCache = _a[_i];
  9653. scrollCache.destroy();
  9654. }
  9655. this.scrollCaches = null;
  9656. }
  9657. };
  9658. AutoScroller.prototype.requestAnimation = function (now) {
  9659. this.msSinceRequest = now;
  9660. requestAnimationFrame(this.animate);
  9661. };
  9662. AutoScroller.prototype.handleSide = function (edge, seconds) {
  9663. var scrollCache = edge.scrollCache;
  9664. var edgeThreshold = this.edgeThreshold;
  9665. var invDistance = edgeThreshold - edge.distance;
  9666. var velocity = // the closer to the edge, the faster we scroll
  9667. (invDistance * invDistance) / (edgeThreshold * edgeThreshold) * // quadratic
  9668. this.maxVelocity * seconds;
  9669. var sign = 1;
  9670. switch (edge.name) {
  9671. case 'left':
  9672. sign = -1;
  9673. // falls through
  9674. case 'right':
  9675. scrollCache.setScrollLeft(scrollCache.getScrollLeft() + velocity * sign);
  9676. break;
  9677. case 'top':
  9678. sign = -1;
  9679. // falls through
  9680. case 'bottom':
  9681. scrollCache.setScrollTop(scrollCache.getScrollTop() + velocity * sign);
  9682. break;
  9683. }
  9684. };
  9685. // left/top are relative to document topleft
  9686. AutoScroller.prototype.computeBestEdge = function (left, top) {
  9687. var edgeThreshold = this.edgeThreshold;
  9688. var bestSide = null;
  9689. for (var _i = 0, _a = this.scrollCaches; _i < _a.length; _i++) {
  9690. var scrollCache = _a[_i];
  9691. var rect = scrollCache.clientRect;
  9692. var leftDist = left - rect.left;
  9693. var rightDist = rect.right - left;
  9694. var topDist = top - rect.top;
  9695. var bottomDist = rect.bottom - top;
  9696. // completely within the rect?
  9697. if (leftDist >= 0 && rightDist >= 0 && topDist >= 0 && bottomDist >= 0) {
  9698. if (topDist <= edgeThreshold && this.everMovedUp && scrollCache.canScrollUp() &&
  9699. (!bestSide || bestSide.distance > topDist)) {
  9700. bestSide = { scrollCache: scrollCache, name: 'top', distance: topDist };
  9701. }
  9702. if (bottomDist <= edgeThreshold && this.everMovedDown && scrollCache.canScrollDown() &&
  9703. (!bestSide || bestSide.distance > bottomDist)) {
  9704. bestSide = { scrollCache: scrollCache, name: 'bottom', distance: bottomDist };
  9705. }
  9706. if (leftDist <= edgeThreshold && this.everMovedLeft && scrollCache.canScrollLeft() &&
  9707. (!bestSide || bestSide.distance > leftDist)) {
  9708. bestSide = { scrollCache: scrollCache, name: 'left', distance: leftDist };
  9709. }
  9710. if (rightDist <= edgeThreshold && this.everMovedRight && scrollCache.canScrollRight() &&
  9711. (!bestSide || bestSide.distance > rightDist)) {
  9712. bestSide = { scrollCache: scrollCache, name: 'right', distance: rightDist };
  9713. }
  9714. }
  9715. }
  9716. return bestSide;
  9717. };
  9718. AutoScroller.prototype.buildCaches = function () {
  9719. return this.queryScrollEls().map(function (el) {
  9720. if (el === window) {
  9721. return new WindowScrollGeomCache(false); // false = don't listen to user-generated scrolls
  9722. }
  9723. else {
  9724. return new ElementScrollGeomCache(el, false); // false = don't listen to user-generated scrolls
  9725. }
  9726. });
  9727. };
  9728. AutoScroller.prototype.queryScrollEls = function () {
  9729. var els = [];
  9730. for (var _i = 0, _a = this.scrollQuery; _i < _a.length; _i++) {
  9731. var query = _a[_i];
  9732. if (typeof query === 'object') {
  9733. els.push(query);
  9734. }
  9735. else {
  9736. els.push.apply(els, Array.prototype.slice.call(document.querySelectorAll(query)));
  9737. }
  9738. }
  9739. return els;
  9740. };
  9741. return AutoScroller;
  9742. }());
  9743. /*
  9744. Monitors dragging on an element. Has a number of high-level features:
  9745. - minimum distance required before dragging
  9746. - minimum wait time ("delay") before dragging
  9747. - a mirror element that follows the pointer
  9748. */
  9749. var FeaturefulElementDragging = /** @class */ (function (_super) {
  9750. __extends(FeaturefulElementDragging, _super);
  9751. function FeaturefulElementDragging(containerEl, selector) {
  9752. var _this = _super.call(this, containerEl) || this;
  9753. // options that can be directly set by caller
  9754. // the caller can also set the PointerDragging's options as well
  9755. _this.delay = null;
  9756. _this.minDistance = 0;
  9757. _this.touchScrollAllowed = true; // prevents drag from starting and blocks scrolling during drag
  9758. _this.mirrorNeedsRevert = false;
  9759. _this.isInteracting = false; // is the user validly moving the pointer? lasts until pointerup
  9760. _this.isDragging = false; // is it INTENTFULLY dragging? lasts until after revert animation
  9761. _this.isDelayEnded = false;
  9762. _this.isDistanceSurpassed = false;
  9763. _this.delayTimeoutId = null;
  9764. _this.onPointerDown = function (ev) {
  9765. if (!_this.isDragging) { // so new drag doesn't happen while revert animation is going
  9766. _this.isInteracting = true;
  9767. _this.isDelayEnded = false;
  9768. _this.isDistanceSurpassed = false;
  9769. preventSelection(document.body);
  9770. preventContextMenu(document.body);
  9771. // prevent links from being visited if there's an eventual drag.
  9772. // also prevents selection in older browsers (maybe?).
  9773. // not necessary for touch, besides, browser would complain about passiveness.
  9774. if (!ev.isTouch) {
  9775. ev.origEvent.preventDefault();
  9776. }
  9777. _this.emitter.trigger('pointerdown', ev);
  9778. if (_this.isInteracting && // not destroyed via pointerdown handler
  9779. !_this.pointer.shouldIgnoreMove) {
  9780. // actions related to initiating dragstart+dragmove+dragend...
  9781. _this.mirror.setIsVisible(false); // reset. caller must set-visible
  9782. _this.mirror.start(ev.subjectEl, ev.pageX, ev.pageY); // must happen on first pointer down
  9783. _this.startDelay(ev);
  9784. if (!_this.minDistance) {
  9785. _this.handleDistanceSurpassed(ev);
  9786. }
  9787. }
  9788. }
  9789. };
  9790. _this.onPointerMove = function (ev) {
  9791. if (_this.isInteracting) {
  9792. _this.emitter.trigger('pointermove', ev);
  9793. if (!_this.isDistanceSurpassed) {
  9794. var minDistance = _this.minDistance;
  9795. var distanceSq = void 0; // current distance from the origin, squared
  9796. var deltaX = ev.deltaX, deltaY = ev.deltaY;
  9797. distanceSq = deltaX * deltaX + deltaY * deltaY;
  9798. if (distanceSq >= minDistance * minDistance) { // use pythagorean theorem
  9799. _this.handleDistanceSurpassed(ev);
  9800. }
  9801. }
  9802. if (_this.isDragging) {
  9803. // a real pointer move? (not one simulated by scrolling)
  9804. if (ev.origEvent.type !== 'scroll') {
  9805. _this.mirror.handleMove(ev.pageX, ev.pageY);
  9806. _this.autoScroller.handleMove(ev.pageX, ev.pageY);
  9807. }
  9808. _this.emitter.trigger('dragmove', ev);
  9809. }
  9810. }
  9811. };
  9812. _this.onPointerUp = function (ev) {
  9813. if (_this.isInteracting) {
  9814. _this.isInteracting = false;
  9815. allowSelection(document.body);
  9816. allowContextMenu(document.body);
  9817. _this.emitter.trigger('pointerup', ev); // can potentially set mirrorNeedsRevert
  9818. if (_this.isDragging) {
  9819. _this.autoScroller.stop();
  9820. _this.tryStopDrag(ev); // which will stop the mirror
  9821. }
  9822. if (_this.delayTimeoutId) {
  9823. clearTimeout(_this.delayTimeoutId);
  9824. _this.delayTimeoutId = null;
  9825. }
  9826. }
  9827. };
  9828. var pointer = _this.pointer = new PointerDragging(containerEl);
  9829. pointer.emitter.on('pointerdown', _this.onPointerDown);
  9830. pointer.emitter.on('pointermove', _this.onPointerMove);
  9831. pointer.emitter.on('pointerup', _this.onPointerUp);
  9832. if (selector) {
  9833. pointer.selector = selector;
  9834. }
  9835. _this.mirror = new ElementMirror();
  9836. _this.autoScroller = new AutoScroller();
  9837. return _this;
  9838. }
  9839. FeaturefulElementDragging.prototype.destroy = function () {
  9840. this.pointer.destroy();
  9841. // HACK: simulate a pointer-up to end the current drag
  9842. // TODO: fire 'dragend' directly and stop interaction. discourage use of pointerup event (b/c might not fire)
  9843. this.onPointerUp({});
  9844. };
  9845. FeaturefulElementDragging.prototype.startDelay = function (ev) {
  9846. var _this = this;
  9847. if (typeof this.delay === 'number') {
  9848. this.delayTimeoutId = setTimeout(function () {
  9849. _this.delayTimeoutId = null;
  9850. _this.handleDelayEnd(ev);
  9851. }, this.delay); // not assignable to number!
  9852. }
  9853. else {
  9854. this.handleDelayEnd(ev);
  9855. }
  9856. };
  9857. FeaturefulElementDragging.prototype.handleDelayEnd = function (ev) {
  9858. this.isDelayEnded = true;
  9859. this.tryStartDrag(ev);
  9860. };
  9861. FeaturefulElementDragging.prototype.handleDistanceSurpassed = function (ev) {
  9862. this.isDistanceSurpassed = true;
  9863. this.tryStartDrag(ev);
  9864. };
  9865. FeaturefulElementDragging.prototype.tryStartDrag = function (ev) {
  9866. if (this.isDelayEnded && this.isDistanceSurpassed) {
  9867. if (!this.pointer.wasTouchScroll || this.touchScrollAllowed) {
  9868. this.isDragging = true;
  9869. this.mirrorNeedsRevert = false;
  9870. this.autoScroller.start(ev.pageX, ev.pageY);
  9871. this.emitter.trigger('dragstart', ev);
  9872. if (this.touchScrollAllowed === false) {
  9873. this.pointer.cancelTouchScroll();
  9874. }
  9875. }
  9876. }
  9877. };
  9878. FeaturefulElementDragging.prototype.tryStopDrag = function (ev) {
  9879. // .stop() is ALWAYS asynchronous, which we NEED because we want all pointerup events
  9880. // that come from the document to fire beforehand. much more convenient this way.
  9881. this.mirror.stop(this.mirrorNeedsRevert, this.stopDrag.bind(this, ev) // bound with args
  9882. );
  9883. };
  9884. FeaturefulElementDragging.prototype.stopDrag = function (ev) {
  9885. this.isDragging = false;
  9886. this.emitter.trigger('dragend', ev);
  9887. };
  9888. // fill in the implementations...
  9889. FeaturefulElementDragging.prototype.setIgnoreMove = function (bool) {
  9890. this.pointer.shouldIgnoreMove = bool;
  9891. };
  9892. FeaturefulElementDragging.prototype.setMirrorIsVisible = function (bool) {
  9893. this.mirror.setIsVisible(bool);
  9894. };
  9895. FeaturefulElementDragging.prototype.setMirrorNeedsRevert = function (bool) {
  9896. this.mirrorNeedsRevert = bool;
  9897. };
  9898. FeaturefulElementDragging.prototype.setAutoScrollEnabled = function (bool) {
  9899. this.autoScroller.isEnabled = bool;
  9900. };
  9901. return FeaturefulElementDragging;
  9902. }(ElementDragging));
  9903. /*
  9904. When this class is instantiated, it records the offset of an element (relative to the document topleft),
  9905. and continues to monitor scrolling, updating the cached coordinates if it needs to.
  9906. Does not access the DOM after instantiation, so highly performant.
  9907. Also keeps track of all scrolling/overflow:hidden containers that are parents of the given element
  9908. and an determine if a given point is inside the combined clipping rectangle.
  9909. */
  9910. var OffsetTracker = /** @class */ (function () {
  9911. function OffsetTracker(el) {
  9912. this.origRect = computeRect(el);
  9913. // will work fine for divs that have overflow:hidden
  9914. this.scrollCaches = getClippingParents(el).map(function (el) {
  9915. return new ElementScrollGeomCache(el, true); // listen=true
  9916. });
  9917. }
  9918. OffsetTracker.prototype.destroy = function () {
  9919. for (var _i = 0, _a = this.scrollCaches; _i < _a.length; _i++) {
  9920. var scrollCache = _a[_i];
  9921. scrollCache.destroy();
  9922. }
  9923. };
  9924. OffsetTracker.prototype.computeLeft = function () {
  9925. var left = this.origRect.left;
  9926. for (var _i = 0, _a = this.scrollCaches; _i < _a.length; _i++) {
  9927. var scrollCache = _a[_i];
  9928. left += scrollCache.origScrollLeft - scrollCache.getScrollLeft();
  9929. }
  9930. return left;
  9931. };
  9932. OffsetTracker.prototype.computeTop = function () {
  9933. var top = this.origRect.top;
  9934. for (var _i = 0, _a = this.scrollCaches; _i < _a.length; _i++) {
  9935. var scrollCache = _a[_i];
  9936. top += scrollCache.origScrollTop - scrollCache.getScrollTop();
  9937. }
  9938. return top;
  9939. };
  9940. OffsetTracker.prototype.isWithinClipping = function (pageX, pageY) {
  9941. var point = { left: pageX, top: pageY };
  9942. for (var _i = 0, _a = this.scrollCaches; _i < _a.length; _i++) {
  9943. var scrollCache = _a[_i];
  9944. if (!isIgnoredClipping(scrollCache.getEventTarget()) &&
  9945. !pointInsideRect(point, scrollCache.clientRect)) {
  9946. return false;
  9947. }
  9948. }
  9949. return true;
  9950. };
  9951. return OffsetTracker;
  9952. }());
  9953. // certain clipping containers should never constrain interactions, like <html> and <body>
  9954. // https://github.com/fullcalendar/fullcalendar/issues/3615
  9955. function isIgnoredClipping(node) {
  9956. var tagName = node.tagName;
  9957. return tagName === 'HTML' || tagName === 'BODY';
  9958. }
  9959. /*
  9960. Tracks movement over multiple droppable areas (aka "hits")
  9961. that exist in one or more DateComponents.
  9962. Relies on an existing draggable.
  9963. emits:
  9964. - pointerdown
  9965. - dragstart
  9966. - hitchange - fires initially, even if not over a hit
  9967. - pointerup
  9968. - (hitchange - again, to null, if ended over a hit)
  9969. - dragend
  9970. */
  9971. var HitDragging = /** @class */ (function () {
  9972. function HitDragging(dragging, droppableStore) {
  9973. var _this = this;
  9974. // options that can be set by caller
  9975. this.useSubjectCenter = false;
  9976. this.requireInitial = true; // if doesn't start out on a hit, won't emit any events
  9977. this.initialHit = null;
  9978. this.movingHit = null;
  9979. this.finalHit = null; // won't ever be populated if shouldIgnoreMove
  9980. this.handlePointerDown = function (ev) {
  9981. var dragging = _this.dragging;
  9982. _this.initialHit = null;
  9983. _this.movingHit = null;
  9984. _this.finalHit = null;
  9985. _this.prepareHits();
  9986. _this.processFirstCoord(ev);
  9987. if (_this.initialHit || !_this.requireInitial) {
  9988. dragging.setIgnoreMove(false);
  9989. _this.emitter.trigger('pointerdown', ev); // TODO: fire this before computing processFirstCoord, so listeners can cancel. this gets fired by almost every handler :(
  9990. }
  9991. else {
  9992. dragging.setIgnoreMove(true);
  9993. }
  9994. };
  9995. this.handleDragStart = function (ev) {
  9996. _this.emitter.trigger('dragstart', ev);
  9997. _this.handleMove(ev, true); // force = fire even if initially null
  9998. };
  9999. this.handleDragMove = function (ev) {
  10000. _this.emitter.trigger('dragmove', ev);
  10001. _this.handleMove(ev);
  10002. };
  10003. this.handlePointerUp = function (ev) {
  10004. _this.releaseHits();
  10005. _this.emitter.trigger('pointerup', ev);
  10006. };
  10007. this.handleDragEnd = function (ev) {
  10008. if (_this.movingHit) {
  10009. _this.emitter.trigger('hitupdate', null, true, ev);
  10010. }
  10011. _this.finalHit = _this.movingHit;
  10012. _this.movingHit = null;
  10013. _this.emitter.trigger('dragend', ev);
  10014. };
  10015. this.droppableStore = droppableStore;
  10016. dragging.emitter.on('pointerdown', this.handlePointerDown);
  10017. dragging.emitter.on('dragstart', this.handleDragStart);
  10018. dragging.emitter.on('dragmove', this.handleDragMove);
  10019. dragging.emitter.on('pointerup', this.handlePointerUp);
  10020. dragging.emitter.on('dragend', this.handleDragEnd);
  10021. this.dragging = dragging;
  10022. this.emitter = new Emitter();
  10023. }
  10024. // sets initialHit
  10025. // sets coordAdjust
  10026. HitDragging.prototype.processFirstCoord = function (ev) {
  10027. var origPoint = { left: ev.pageX, top: ev.pageY };
  10028. var adjustedPoint = origPoint;
  10029. var subjectEl = ev.subjectEl;
  10030. var subjectRect;
  10031. if (subjectEl !== document) {
  10032. subjectRect = computeRect(subjectEl);
  10033. adjustedPoint = constrainPoint(adjustedPoint, subjectRect);
  10034. }
  10035. var initialHit = this.initialHit = this.queryHitForOffset(adjustedPoint.left, adjustedPoint.top);
  10036. if (initialHit) {
  10037. if (this.useSubjectCenter && subjectRect) {
  10038. var slicedSubjectRect = intersectRects(subjectRect, initialHit.rect);
  10039. if (slicedSubjectRect) {
  10040. adjustedPoint = getRectCenter(slicedSubjectRect);
  10041. }
  10042. }
  10043. this.coordAdjust = diffPoints(adjustedPoint, origPoint);
  10044. }
  10045. else {
  10046. this.coordAdjust = { left: 0, top: 0 };
  10047. }
  10048. };
  10049. HitDragging.prototype.handleMove = function (ev, forceHandle) {
  10050. var hit = this.queryHitForOffset(ev.pageX + this.coordAdjust.left, ev.pageY + this.coordAdjust.top);
  10051. if (forceHandle || !isHitsEqual(this.movingHit, hit)) {
  10052. this.movingHit = hit;
  10053. this.emitter.trigger('hitupdate', hit, false, ev);
  10054. }
  10055. };
  10056. HitDragging.prototype.prepareHits = function () {
  10057. this.offsetTrackers = mapHash(this.droppableStore, function (interactionSettings) {
  10058. interactionSettings.component.prepareHits();
  10059. return new OffsetTracker(interactionSettings.el);
  10060. });
  10061. };
  10062. HitDragging.prototype.releaseHits = function () {
  10063. var offsetTrackers = this.offsetTrackers;
  10064. for (var id in offsetTrackers) {
  10065. offsetTrackers[id].destroy();
  10066. }
  10067. this.offsetTrackers = {};
  10068. };
  10069. HitDragging.prototype.queryHitForOffset = function (offsetLeft, offsetTop) {
  10070. var _a = this, droppableStore = _a.droppableStore, offsetTrackers = _a.offsetTrackers;
  10071. var bestHit = null;
  10072. for (var id in droppableStore) {
  10073. var component = droppableStore[id].component;
  10074. var offsetTracker = offsetTrackers[id];
  10075. if (offsetTracker && // wasn't destroyed mid-drag
  10076. offsetTracker.isWithinClipping(offsetLeft, offsetTop)) {
  10077. var originLeft = offsetTracker.computeLeft();
  10078. var originTop = offsetTracker.computeTop();
  10079. var positionLeft = offsetLeft - originLeft;
  10080. var positionTop = offsetTop - originTop;
  10081. var origRect = offsetTracker.origRect;
  10082. var width = origRect.right - origRect.left;
  10083. var height = origRect.bottom - origRect.top;
  10084. if (
  10085. // must be within the element's bounds
  10086. positionLeft >= 0 && positionLeft < width &&
  10087. positionTop >= 0 && positionTop < height) {
  10088. var hit = component.queryHit(positionLeft, positionTop, width, height);
  10089. var dateProfile = component.context.getCurrentData().dateProfile;
  10090. if (hit &&
  10091. (
  10092. // make sure the hit is within activeRange, meaning it's not a deal cell
  10093. rangeContainsRange(dateProfile.activeRange, hit.dateSpan.range)) &&
  10094. (!bestHit || hit.layer > bestHit.layer)) {
  10095. // TODO: better way to re-orient rectangle
  10096. hit.rect.left += originLeft;
  10097. hit.rect.right += originLeft;
  10098. hit.rect.top += originTop;
  10099. hit.rect.bottom += originTop;
  10100. bestHit = hit;
  10101. }
  10102. }
  10103. }
  10104. }
  10105. return bestHit;
  10106. };
  10107. return HitDragging;
  10108. }());
  10109. function isHitsEqual(hit0, hit1) {
  10110. if (!hit0 && !hit1) {
  10111. return true;
  10112. }
  10113. if (Boolean(hit0) !== Boolean(hit1)) {
  10114. return false;
  10115. }
  10116. return isDateSpansEqual(hit0.dateSpan, hit1.dateSpan);
  10117. }
  10118. function buildDatePointApiWithContext(dateSpan, context) {
  10119. var props = {};
  10120. for (var _i = 0, _a = context.pluginHooks.datePointTransforms; _i < _a.length; _i++) {
  10121. var transform = _a[_i];
  10122. __assign(props, transform(dateSpan, context));
  10123. }
  10124. __assign(props, buildDatePointApi(dateSpan, context.dateEnv));
  10125. return props;
  10126. }
  10127. function buildDatePointApi(span, dateEnv) {
  10128. return {
  10129. date: dateEnv.toDate(span.range.start),
  10130. dateStr: dateEnv.formatIso(span.range.start, { omitTime: span.allDay }),
  10131. allDay: span.allDay
  10132. };
  10133. }
  10134. /*
  10135. Monitors when the user clicks on a specific date/time of a component.
  10136. A pointerdown+pointerup on the same "hit" constitutes a click.
  10137. */
  10138. var DateClicking = /** @class */ (function (_super) {
  10139. __extends(DateClicking, _super);
  10140. function DateClicking(settings) {
  10141. var _this = _super.call(this, settings) || this;
  10142. _this.handlePointerDown = function (ev) {
  10143. var dragging = _this.dragging;
  10144. // do this in pointerdown (not dragend) because DOM might be mutated by the time dragend is fired
  10145. dragging.setIgnoreMove(!_this.component.isValidDateDownEl(dragging.pointer.downEl));
  10146. };
  10147. // won't even fire if moving was ignored
  10148. _this.handleDragEnd = function (ev) {
  10149. var component = _this.component;
  10150. var pointer = _this.dragging.pointer;
  10151. if (!pointer.wasTouchScroll) {
  10152. var _a = _this.hitDragging, initialHit = _a.initialHit, finalHit = _a.finalHit;
  10153. if (initialHit && finalHit && isHitsEqual(initialHit, finalHit)) {
  10154. var context = component.context;
  10155. var arg = __assign(__assign({}, buildDatePointApiWithContext(initialHit.dateSpan, context)), { dayEl: initialHit.dayEl, jsEvent: ev.origEvent, view: context.viewApi || context.calendarApi.view });
  10156. context.emitter.trigger('dateClick', arg);
  10157. }
  10158. }
  10159. };
  10160. // we DO want to watch pointer moves because otherwise finalHit won't get populated
  10161. _this.dragging = new FeaturefulElementDragging(settings.el);
  10162. _this.dragging.autoScroller.isEnabled = false;
  10163. var hitDragging = _this.hitDragging = new HitDragging(_this.dragging, interactionSettingsToStore(settings));
  10164. hitDragging.emitter.on('pointerdown', _this.handlePointerDown);
  10165. hitDragging.emitter.on('dragend', _this.handleDragEnd);
  10166. return _this;
  10167. }
  10168. DateClicking.prototype.destroy = function () {
  10169. this.dragging.destroy();
  10170. };
  10171. return DateClicking;
  10172. }(Interaction));
  10173. /*
  10174. Tracks when the user selects a portion of time of a component,
  10175. constituted by a drag over date cells, with a possible delay at the beginning of the drag.
  10176. */
  10177. var DateSelecting = /** @class */ (function (_super) {
  10178. __extends(DateSelecting, _super);
  10179. function DateSelecting(settings) {
  10180. var _this = _super.call(this, settings) || this;
  10181. _this.dragSelection = null;
  10182. _this.handlePointerDown = function (ev) {
  10183. var _a = _this, component = _a.component, dragging = _a.dragging;
  10184. var options = component.context.options;
  10185. var canSelect = options.selectable &&
  10186. component.isValidDateDownEl(ev.origEvent.target);
  10187. // don't bother to watch expensive moves if component won't do selection
  10188. dragging.setIgnoreMove(!canSelect);
  10189. // if touch, require user to hold down
  10190. dragging.delay = ev.isTouch ? getComponentTouchDelay(component) : null;
  10191. };
  10192. _this.handleDragStart = function (ev) {
  10193. _this.component.context.calendarApi.unselect(ev); // unselect previous selections
  10194. };
  10195. _this.handleHitUpdate = function (hit, isFinal) {
  10196. var context = _this.component.context;
  10197. var dragSelection = null;
  10198. var isInvalid = false;
  10199. if (hit) {
  10200. dragSelection = joinHitsIntoSelection(_this.hitDragging.initialHit, hit, context.pluginHooks.dateSelectionTransformers);
  10201. if (!dragSelection || !_this.component.isDateSelectionValid(dragSelection)) {
  10202. isInvalid = true;
  10203. dragSelection = null;
  10204. }
  10205. }
  10206. if (dragSelection) {
  10207. context.dispatch({ type: 'SELECT_DATES', selection: dragSelection });
  10208. }
  10209. else if (!isFinal) { // only unselect if moved away while dragging
  10210. context.dispatch({ type: 'UNSELECT_DATES' });
  10211. }
  10212. if (!isInvalid) {
  10213. enableCursor();
  10214. }
  10215. else {
  10216. disableCursor();
  10217. }
  10218. if (!isFinal) {
  10219. _this.dragSelection = dragSelection; // only clear if moved away from all hits while dragging
  10220. }
  10221. };
  10222. _this.handlePointerUp = function (pev) {
  10223. if (_this.dragSelection) {
  10224. // selection is already rendered, so just need to report selection
  10225. triggerDateSelect(_this.dragSelection, pev, _this.component.context);
  10226. _this.dragSelection = null;
  10227. }
  10228. };
  10229. var component = settings.component;
  10230. var options = component.context.options;
  10231. var dragging = _this.dragging = new FeaturefulElementDragging(settings.el);
  10232. dragging.touchScrollAllowed = false;
  10233. dragging.minDistance = options.selectMinDistance || 0;
  10234. dragging.autoScroller.isEnabled = options.dragScroll;
  10235. var hitDragging = _this.hitDragging = new HitDragging(_this.dragging, interactionSettingsToStore(settings));
  10236. hitDragging.emitter.on('pointerdown', _this.handlePointerDown);
  10237. hitDragging.emitter.on('dragstart', _this.handleDragStart);
  10238. hitDragging.emitter.on('hitupdate', _this.handleHitUpdate);
  10239. hitDragging.emitter.on('pointerup', _this.handlePointerUp);
  10240. return _this;
  10241. }
  10242. DateSelecting.prototype.destroy = function () {
  10243. this.dragging.destroy();
  10244. };
  10245. return DateSelecting;
  10246. }(Interaction));
  10247. function getComponentTouchDelay(component) {
  10248. var options = component.context.options;
  10249. var delay = options.selectLongPressDelay;
  10250. if (delay == null) {
  10251. delay = options.longPressDelay;
  10252. }
  10253. return delay;
  10254. }
  10255. function joinHitsIntoSelection(hit0, hit1, dateSelectionTransformers) {
  10256. var dateSpan0 = hit0.dateSpan;
  10257. var dateSpan1 = hit1.dateSpan;
  10258. var ms = [
  10259. dateSpan0.range.start,
  10260. dateSpan0.range.end,
  10261. dateSpan1.range.start,
  10262. dateSpan1.range.end
  10263. ];
  10264. ms.sort(compareNumbers);
  10265. var props = {};
  10266. for (var _i = 0, dateSelectionTransformers_1 = dateSelectionTransformers; _i < dateSelectionTransformers_1.length; _i++) {
  10267. var transformer = dateSelectionTransformers_1[_i];
  10268. var res = transformer(hit0, hit1);
  10269. if (res === false) {
  10270. return null;
  10271. }
  10272. else if (res) {
  10273. __assign(props, res);
  10274. }
  10275. }
  10276. props.range = { start: ms[0], end: ms[3] };
  10277. props.allDay = dateSpan0.allDay;
  10278. return props;
  10279. }
  10280. var EventDragging = /** @class */ (function (_super) {
  10281. __extends(EventDragging, _super);
  10282. function EventDragging(settings) {
  10283. var _this = _super.call(this, settings) || this;
  10284. // internal state
  10285. _this.subjectEl = null;
  10286. _this.subjectSeg = null; // the seg being selected/dragged
  10287. _this.isDragging = false;
  10288. _this.eventRange = null;
  10289. _this.relevantEvents = null; // the events being dragged
  10290. _this.receivingContext = null;
  10291. _this.validMutation = null;
  10292. _this.mutatedRelevantEvents = null;
  10293. _this.handlePointerDown = function (ev) {
  10294. var origTarget = ev.origEvent.target;
  10295. var _a = _this, component = _a.component, dragging = _a.dragging;
  10296. var mirror = dragging.mirror;
  10297. var options = component.context.options;
  10298. var initialContext = component.context;
  10299. _this.subjectEl = ev.subjectEl;
  10300. var subjectSeg = _this.subjectSeg = getElSeg(ev.subjectEl);
  10301. var eventRange = _this.eventRange = subjectSeg.eventRange;
  10302. var eventInstanceId = eventRange.instance.instanceId;
  10303. _this.relevantEvents = getRelevantEvents(initialContext.getCurrentData().eventStore, eventInstanceId);
  10304. dragging.minDistance = ev.isTouch ? 0 : options.eventDragMinDistance;
  10305. dragging.delay =
  10306. // only do a touch delay if touch and this event hasn't been selected yet
  10307. (ev.isTouch && eventInstanceId !== component.props.eventSelection) ?
  10308. getComponentTouchDelay$1(component) :
  10309. null;
  10310. mirror.parentNode = elementClosest(origTarget, '.fc');
  10311. mirror.revertDuration = options.dragRevertDuration;
  10312. var isValid = component.isValidSegDownEl(origTarget) &&
  10313. !elementClosest(origTarget, '.fc-event-resizer'); // NOT on a resizer
  10314. dragging.setIgnoreMove(!isValid);
  10315. // disable dragging for elements that are resizable (ie, selectable)
  10316. // but are not draggable
  10317. _this.isDragging = isValid &&
  10318. ev.subjectEl.classList.contains('fc-event-draggable');
  10319. };
  10320. _this.handleDragStart = function (ev) {
  10321. var initialContext = _this.component.context;
  10322. var eventRange = _this.eventRange;
  10323. var eventInstanceId = eventRange.instance.instanceId;
  10324. if (ev.isTouch) {
  10325. // need to select a different event?
  10326. if (eventInstanceId !== _this.component.props.eventSelection) {
  10327. initialContext.dispatch({ type: 'SELECT_EVENT', eventInstanceId: eventInstanceId });
  10328. }
  10329. }
  10330. else {
  10331. // if now using mouse, but was previous touch interaction, clear selected event
  10332. initialContext.dispatch({ type: 'UNSELECT_EVENT' });
  10333. }
  10334. if (_this.isDragging) {
  10335. initialContext.calendarApi.unselect(ev); // unselect *date* selection
  10336. initialContext.emitter.trigger('eventDragStart', {
  10337. el: _this.subjectEl,
  10338. event: new EventApi(initialContext, eventRange.def, eventRange.instance),
  10339. jsEvent: ev.origEvent,
  10340. view: initialContext.viewApi
  10341. });
  10342. }
  10343. };
  10344. _this.handleHitUpdate = function (hit, isFinal) {
  10345. if (!_this.isDragging) {
  10346. return;
  10347. }
  10348. var relevantEvents = _this.relevantEvents;
  10349. var initialHit = _this.hitDragging.initialHit;
  10350. var initialContext = _this.component.context;
  10351. // states based on new hit
  10352. var receivingContext = null;
  10353. var mutation = null;
  10354. var mutatedRelevantEvents = null;
  10355. var isInvalid = false;
  10356. var interaction = {
  10357. affectedEvents: relevantEvents,
  10358. mutatedEvents: createEmptyEventStore(),
  10359. isEvent: true
  10360. };
  10361. if (hit) {
  10362. var receivingComponent = hit.component;
  10363. receivingContext = receivingComponent.context;
  10364. var receivingOptions = receivingContext.options;
  10365. if (initialContext === receivingContext ||
  10366. receivingOptions.editable && receivingOptions.droppable) {
  10367. mutation = computeEventMutation(initialHit, hit, receivingContext.getCurrentData().pluginHooks.eventDragMutationMassagers);
  10368. if (mutation) {
  10369. mutatedRelevantEvents = applyMutationToEventStore(relevantEvents, receivingContext.getCurrentData().eventUiBases, mutation, receivingContext);
  10370. interaction.mutatedEvents = mutatedRelevantEvents;
  10371. if (!receivingComponent.isInteractionValid(interaction)) {
  10372. isInvalid = true;
  10373. mutation = null;
  10374. mutatedRelevantEvents = null;
  10375. interaction.mutatedEvents = createEmptyEventStore();
  10376. }
  10377. }
  10378. }
  10379. else {
  10380. receivingContext = null;
  10381. }
  10382. }
  10383. _this.displayDrag(receivingContext, interaction);
  10384. if (!isInvalid) {
  10385. enableCursor();
  10386. }
  10387. else {
  10388. disableCursor();
  10389. }
  10390. if (!isFinal) {
  10391. if (initialContext === receivingContext && // TODO: write test for this
  10392. isHitsEqual(initialHit, hit)) {
  10393. mutation = null;
  10394. }
  10395. _this.dragging.setMirrorNeedsRevert(!mutation);
  10396. // render the mirror if no already-rendered mirror
  10397. // TODO: wish we could somehow wait for dispatch to guarantee render
  10398. _this.dragging.setMirrorIsVisible(!hit || !document.querySelector('.fc-event-mirror'));
  10399. // assign states based on new hit
  10400. _this.receivingContext = receivingContext;
  10401. _this.validMutation = mutation;
  10402. _this.mutatedRelevantEvents = mutatedRelevantEvents;
  10403. }
  10404. };
  10405. _this.handlePointerUp = function () {
  10406. if (!_this.isDragging) {
  10407. _this.cleanup(); // because handleDragEnd won't fire
  10408. }
  10409. };
  10410. _this.handleDragEnd = function (ev) {
  10411. if (_this.isDragging) {
  10412. var initialContext_1 = _this.component.context;
  10413. var initialView = initialContext_1.viewApi;
  10414. var _a = _this, receivingContext_1 = _a.receivingContext, validMutation = _a.validMutation;
  10415. var eventDef = _this.eventRange.def;
  10416. var eventInstance = _this.eventRange.instance;
  10417. var eventApi = new EventApi(initialContext_1, eventDef, eventInstance);
  10418. var relevantEvents_1 = _this.relevantEvents;
  10419. var mutatedRelevantEvents_1 = _this.mutatedRelevantEvents;
  10420. var finalHit = _this.hitDragging.finalHit;
  10421. _this.clearDrag(); // must happen after revert animation
  10422. initialContext_1.emitter.trigger('eventDragStop', {
  10423. el: _this.subjectEl,
  10424. event: eventApi,
  10425. jsEvent: ev.origEvent,
  10426. view: initialView
  10427. });
  10428. if (validMutation) {
  10429. // dropped within same calendar
  10430. if (receivingContext_1 === initialContext_1) {
  10431. var updatedEventApi = new EventApi(initialContext_1, mutatedRelevantEvents_1.defs[eventDef.defId], eventInstance ? mutatedRelevantEvents_1.instances[eventInstance.instanceId] : null);
  10432. initialContext_1.dispatch({
  10433. type: 'MERGE_EVENTS',
  10434. eventStore: mutatedRelevantEvents_1
  10435. });
  10436. var eventChangeArg = {
  10437. oldEvent: eventApi,
  10438. event: updatedEventApi,
  10439. relatedEvents: buildEventApis(mutatedRelevantEvents_1, initialContext_1, eventInstance),
  10440. revert: function () {
  10441. initialContext_1.dispatch({
  10442. type: 'MERGE_EVENTS',
  10443. eventStore: relevantEvents_1 // the pre-change data
  10444. });
  10445. }
  10446. };
  10447. var transformed = {};
  10448. for (var _i = 0, _b = initialContext_1.getCurrentData().pluginHooks.eventDropTransformers; _i < _b.length; _i++) {
  10449. var transformer = _b[_i];
  10450. __assign(transformed, transformer(validMutation, initialContext_1));
  10451. }
  10452. initialContext_1.emitter.trigger('eventDrop', __assign(__assign(__assign({}, eventChangeArg), transformed), { el: ev.subjectEl, delta: validMutation.datesDelta, jsEvent: ev.origEvent, view: initialView }));
  10453. initialContext_1.emitter.trigger('eventChange', eventChangeArg);
  10454. // dropped in different calendar
  10455. }
  10456. else if (receivingContext_1) {
  10457. initialContext_1.emitter.trigger('eventLeave', {
  10458. draggedEl: ev.subjectEl,
  10459. event: eventApi,
  10460. view: initialView
  10461. });
  10462. initialContext_1.dispatch({
  10463. type: 'REMOVE_EVENTS',
  10464. eventStore: relevantEvents_1
  10465. });
  10466. initialContext_1.emitter.trigger('eventRemove', {
  10467. event: eventApi,
  10468. relatedEvents: buildEventApis(relevantEvents_1, initialContext_1, eventInstance),
  10469. revert: function () {
  10470. initialContext_1.dispatch({
  10471. type: 'MERGE_EVENTS',
  10472. eventStore: relevantEvents_1
  10473. });
  10474. }
  10475. });
  10476. var addedEventDef = mutatedRelevantEvents_1.defs[eventDef.defId];
  10477. var addedEventInstance = mutatedRelevantEvents_1.instances[eventInstance.instanceId];
  10478. var addedEventApi = new EventApi(receivingContext_1, addedEventDef, addedEventInstance);
  10479. receivingContext_1.dispatch({
  10480. type: 'MERGE_EVENTS',
  10481. eventStore: mutatedRelevantEvents_1
  10482. });
  10483. receivingContext_1.emitter.trigger('eventAdd', {
  10484. event: addedEventApi,
  10485. relatedEvents: buildEventApis(mutatedRelevantEvents_1, receivingContext_1, addedEventInstance),
  10486. revert: function () {
  10487. receivingContext_1.dispatch({
  10488. type: 'REMOVE_EVENTS',
  10489. eventStore: mutatedRelevantEvents_1
  10490. });
  10491. }
  10492. });
  10493. if (ev.isTouch) {
  10494. receivingContext_1.dispatch({
  10495. type: 'SELECT_EVENT',
  10496. eventInstanceId: eventInstance.instanceId
  10497. });
  10498. }
  10499. receivingContext_1.emitter.trigger('drop', __assign(__assign({}, buildDatePointApiWithContext(finalHit.dateSpan, receivingContext_1)), { draggedEl: ev.subjectEl, jsEvent: ev.origEvent, view: finalHit.component.context.viewApi }));
  10500. receivingContext_1.emitter.trigger('eventReceive', {
  10501. draggedEl: ev.subjectEl,
  10502. event: addedEventApi,
  10503. view: finalHit.component.context.viewApi
  10504. });
  10505. }
  10506. }
  10507. else {
  10508. initialContext_1.emitter.trigger('_noEventDrop');
  10509. }
  10510. }
  10511. _this.cleanup();
  10512. };
  10513. var component = _this.component;
  10514. var options = component.context.options;
  10515. var dragging = _this.dragging = new FeaturefulElementDragging(settings.el);
  10516. dragging.pointer.selector = EventDragging.SELECTOR;
  10517. dragging.touchScrollAllowed = false;
  10518. dragging.autoScroller.isEnabled = options.dragScroll;
  10519. var hitDragging = _this.hitDragging = new HitDragging(_this.dragging, interactionSettingsStore);
  10520. hitDragging.useSubjectCenter = settings.useEventCenter;
  10521. hitDragging.emitter.on('pointerdown', _this.handlePointerDown);
  10522. hitDragging.emitter.on('dragstart', _this.handleDragStart);
  10523. hitDragging.emitter.on('hitupdate', _this.handleHitUpdate);
  10524. hitDragging.emitter.on('pointerup', _this.handlePointerUp);
  10525. hitDragging.emitter.on('dragend', _this.handleDragEnd);
  10526. return _this;
  10527. }
  10528. EventDragging.prototype.destroy = function () {
  10529. this.dragging.destroy();
  10530. };
  10531. // render a drag state on the next receivingCalendar
  10532. EventDragging.prototype.displayDrag = function (nextContext, state) {
  10533. var initialContext = this.component.context;
  10534. var prevContext = this.receivingContext;
  10535. // does the previous calendar need to be cleared?
  10536. if (prevContext && prevContext !== nextContext) {
  10537. // does the initial calendar need to be cleared?
  10538. // if so, don't clear all the way. we still need to to hide the affectedEvents
  10539. if (prevContext === initialContext) {
  10540. prevContext.dispatch({
  10541. type: 'SET_EVENT_DRAG',
  10542. state: {
  10543. affectedEvents: state.affectedEvents,
  10544. mutatedEvents: createEmptyEventStore(),
  10545. isEvent: true
  10546. }
  10547. });
  10548. // completely clear the old calendar if it wasn't the initial
  10549. }
  10550. else {
  10551. prevContext.dispatch({ type: 'UNSET_EVENT_DRAG' });
  10552. }
  10553. }
  10554. if (nextContext) {
  10555. nextContext.dispatch({ type: 'SET_EVENT_DRAG', state: state });
  10556. }
  10557. };
  10558. EventDragging.prototype.clearDrag = function () {
  10559. var initialCalendar = this.component.context;
  10560. var receivingContext = this.receivingContext;
  10561. if (receivingContext) {
  10562. receivingContext.dispatch({ type: 'UNSET_EVENT_DRAG' });
  10563. }
  10564. // the initial calendar might have an dummy drag state from displayDrag
  10565. if (initialCalendar !== receivingContext) {
  10566. initialCalendar.dispatch({ type: 'UNSET_EVENT_DRAG' });
  10567. }
  10568. };
  10569. EventDragging.prototype.cleanup = function () {
  10570. this.subjectSeg = null;
  10571. this.isDragging = false;
  10572. this.eventRange = null;
  10573. this.relevantEvents = null;
  10574. this.receivingContext = null;
  10575. this.validMutation = null;
  10576. this.mutatedRelevantEvents = null;
  10577. };
  10578. // TODO: test this in IE11
  10579. // QUESTION: why do we need it on the resizable???
  10580. EventDragging.SELECTOR = '.fc-event-draggable, .fc-event-resizable';
  10581. return EventDragging;
  10582. }(Interaction));
  10583. function computeEventMutation(hit0, hit1, massagers) {
  10584. var dateSpan0 = hit0.dateSpan;
  10585. var dateSpan1 = hit1.dateSpan;
  10586. var date0 = dateSpan0.range.start;
  10587. var date1 = dateSpan1.range.start;
  10588. var standardProps = {};
  10589. if (dateSpan0.allDay !== dateSpan1.allDay) {
  10590. standardProps.allDay = dateSpan1.allDay;
  10591. standardProps.hasEnd = hit1.component.context.options.allDayMaintainDuration;
  10592. if (dateSpan1.allDay) {
  10593. // means date1 is already start-of-day,
  10594. // but date0 needs to be converted
  10595. date0 = startOfDay(date0);
  10596. }
  10597. }
  10598. var delta = diffDates(date0, date1, hit0.component.context.dateEnv, hit0.component === hit1.component ?
  10599. hit0.component.largeUnit :
  10600. null);
  10601. if (delta.milliseconds) { // has hours/minutes/seconds
  10602. standardProps.allDay = false;
  10603. }
  10604. var mutation = {
  10605. datesDelta: delta,
  10606. standardProps: standardProps
  10607. };
  10608. for (var _i = 0, massagers_1 = massagers; _i < massagers_1.length; _i++) {
  10609. var massager = massagers_1[_i];
  10610. massager(mutation, hit0, hit1);
  10611. }
  10612. return mutation;
  10613. }
  10614. function getComponentTouchDelay$1(component) {
  10615. var options = component.context.options;
  10616. var delay = options.eventLongPressDelay;
  10617. if (delay == null) {
  10618. delay = options.longPressDelay;
  10619. }
  10620. return delay;
  10621. }
  10622. var EventResizing = /** @class */ (function (_super) {
  10623. __extends(EventResizing, _super);
  10624. function EventResizing(settings) {
  10625. var _this = _super.call(this, settings) || this;
  10626. // internal state
  10627. _this.draggingSegEl = null;
  10628. _this.draggingSeg = null; // TODO: rename to resizingSeg? subjectSeg?
  10629. _this.eventRange = null;
  10630. _this.relevantEvents = null;
  10631. _this.validMutation = null;
  10632. _this.mutatedRelevantEvents = null;
  10633. _this.handlePointerDown = function (ev) {
  10634. var component = _this.component;
  10635. var segEl = _this.querySegEl(ev);
  10636. var seg = getElSeg(segEl);
  10637. var eventRange = _this.eventRange = seg.eventRange;
  10638. _this.dragging.minDistance = component.context.options.eventDragMinDistance;
  10639. // if touch, need to be working with a selected event
  10640. _this.dragging.setIgnoreMove(!_this.component.isValidSegDownEl(ev.origEvent.target) ||
  10641. (ev.isTouch && _this.component.props.eventSelection !== eventRange.instance.instanceId));
  10642. };
  10643. _this.handleDragStart = function (ev) {
  10644. var context = _this.component.context;
  10645. var eventRange = _this.eventRange;
  10646. _this.relevantEvents = getRelevantEvents(context.getCurrentData().eventStore, _this.eventRange.instance.instanceId);
  10647. var segEl = _this.querySegEl(ev);
  10648. _this.draggingSegEl = segEl;
  10649. _this.draggingSeg = getElSeg(segEl);
  10650. context.calendarApi.unselect();
  10651. context.emitter.trigger('eventResizeStart', {
  10652. el: segEl,
  10653. event: new EventApi(context, eventRange.def, eventRange.instance),
  10654. jsEvent: ev.origEvent,
  10655. view: context.viewApi
  10656. });
  10657. };
  10658. _this.handleHitUpdate = function (hit, isFinal, ev) {
  10659. var context = _this.component.context;
  10660. var relevantEvents = _this.relevantEvents;
  10661. var initialHit = _this.hitDragging.initialHit;
  10662. var eventInstance = _this.eventRange.instance;
  10663. var mutation = null;
  10664. var mutatedRelevantEvents = null;
  10665. var isInvalid = false;
  10666. var interaction = {
  10667. affectedEvents: relevantEvents,
  10668. mutatedEvents: createEmptyEventStore(),
  10669. isEvent: true
  10670. };
  10671. if (hit) {
  10672. mutation = computeMutation(initialHit, hit, ev.subjectEl.classList.contains('fc-event-resizer-start'), eventInstance.range, context.pluginHooks.eventResizeJoinTransforms);
  10673. }
  10674. if (mutation) {
  10675. mutatedRelevantEvents = applyMutationToEventStore(relevantEvents, context.getCurrentData().eventUiBases, mutation, context);
  10676. interaction.mutatedEvents = mutatedRelevantEvents;
  10677. if (!_this.component.isInteractionValid(interaction)) {
  10678. isInvalid = true;
  10679. mutation = null;
  10680. mutatedRelevantEvents = null;
  10681. interaction.mutatedEvents = null;
  10682. }
  10683. }
  10684. if (mutatedRelevantEvents) {
  10685. context.dispatch({
  10686. type: 'SET_EVENT_RESIZE',
  10687. state: interaction
  10688. });
  10689. }
  10690. else {
  10691. context.dispatch({ type: 'UNSET_EVENT_RESIZE' });
  10692. }
  10693. if (!isInvalid) {
  10694. enableCursor();
  10695. }
  10696. else {
  10697. disableCursor();
  10698. }
  10699. if (!isFinal) {
  10700. if (mutation && isHitsEqual(initialHit, hit)) {
  10701. mutation = null;
  10702. }
  10703. _this.validMutation = mutation;
  10704. _this.mutatedRelevantEvents = mutatedRelevantEvents;
  10705. }
  10706. };
  10707. _this.handleDragEnd = function (ev) {
  10708. var context = _this.component.context;
  10709. var eventDef = _this.eventRange.def;
  10710. var eventInstance = _this.eventRange.instance;
  10711. var eventApi = new EventApi(context, eventDef, eventInstance);
  10712. var relevantEvents = _this.relevantEvents;
  10713. var mutatedRelevantEvents = _this.mutatedRelevantEvents;
  10714. context.emitter.trigger('eventResizeStop', {
  10715. el: _this.draggingSegEl,
  10716. event: eventApi,
  10717. jsEvent: ev.origEvent,
  10718. view: context.viewApi
  10719. });
  10720. if (_this.validMutation) {
  10721. var updatedEventApi = new EventApi(context, mutatedRelevantEvents.defs[eventDef.defId], eventInstance ? mutatedRelevantEvents.instances[eventInstance.instanceId] : null);
  10722. context.dispatch({
  10723. type: 'MERGE_EVENTS',
  10724. eventStore: mutatedRelevantEvents
  10725. });
  10726. var eventChangeArg = {
  10727. oldEvent: eventApi,
  10728. event: updatedEventApi,
  10729. relatedEvents: buildEventApis(mutatedRelevantEvents, context, eventInstance),
  10730. revert: function () {
  10731. context.dispatch({
  10732. type: 'MERGE_EVENTS',
  10733. eventStore: relevantEvents // the pre-change events
  10734. });
  10735. }
  10736. };
  10737. context.emitter.trigger('eventResize', __assign(__assign({}, eventChangeArg), { el: _this.draggingSegEl, startDelta: _this.validMutation.startDelta || createDuration(0), endDelta: _this.validMutation.endDelta || createDuration(0), jsEvent: ev.origEvent, view: context.viewApi }));
  10738. context.emitter.trigger('eventChange', eventChangeArg);
  10739. }
  10740. else {
  10741. context.emitter.trigger('_noEventResize');
  10742. }
  10743. // reset all internal state
  10744. _this.draggingSeg = null;
  10745. _this.relevantEvents = null;
  10746. _this.validMutation = null;
  10747. // okay to keep eventInstance around. useful to set it in handlePointerDown
  10748. };
  10749. var component = settings.component;
  10750. var dragging = _this.dragging = new FeaturefulElementDragging(settings.el);
  10751. dragging.pointer.selector = '.fc-event-resizer';
  10752. dragging.touchScrollAllowed = false;
  10753. dragging.autoScroller.isEnabled = component.context.options.dragScroll;
  10754. var hitDragging = _this.hitDragging = new HitDragging(_this.dragging, interactionSettingsToStore(settings));
  10755. hitDragging.emitter.on('pointerdown', _this.handlePointerDown);
  10756. hitDragging.emitter.on('dragstart', _this.handleDragStart);
  10757. hitDragging.emitter.on('hitupdate', _this.handleHitUpdate);
  10758. hitDragging.emitter.on('dragend', _this.handleDragEnd);
  10759. return _this;
  10760. }
  10761. EventResizing.prototype.destroy = function () {
  10762. this.dragging.destroy();
  10763. };
  10764. EventResizing.prototype.querySegEl = function (ev) {
  10765. return elementClosest(ev.subjectEl, '.fc-event');
  10766. };
  10767. return EventResizing;
  10768. }(Interaction));
  10769. function computeMutation(hit0, hit1, isFromStart, instanceRange, transforms) {
  10770. var dateEnv = hit0.component.context.dateEnv;
  10771. var date0 = hit0.dateSpan.range.start;
  10772. var date1 = hit1.dateSpan.range.start;
  10773. var delta = diffDates(date0, date1, dateEnv, hit0.component.largeUnit);
  10774. var props = {};
  10775. for (var _i = 0, transforms_1 = transforms; _i < transforms_1.length; _i++) {
  10776. var transform = transforms_1[_i];
  10777. var res = transform(hit0, hit1);
  10778. if (res === false) {
  10779. return null;
  10780. }
  10781. else if (res) {
  10782. __assign(props, res);
  10783. }
  10784. }
  10785. if (isFromStart) {
  10786. if (dateEnv.add(instanceRange.start, delta) < instanceRange.end) {
  10787. props.startDelta = delta;
  10788. return props;
  10789. }
  10790. }
  10791. else {
  10792. if (dateEnv.add(instanceRange.end, delta) > instanceRange.start) {
  10793. props.endDelta = delta;
  10794. return props;
  10795. }
  10796. }
  10797. return null;
  10798. }
  10799. var UnselectAuto = /** @class */ (function () {
  10800. function UnselectAuto(context) {
  10801. var _this = this;
  10802. this.context = context;
  10803. this.isRecentPointerDateSelect = false; // wish we could use a selector to detect date selection, but uses hit system
  10804. this.onSelect = function (selectInfo) {
  10805. if (selectInfo.jsEvent) {
  10806. _this.isRecentPointerDateSelect = true;
  10807. }
  10808. };
  10809. this.onDocumentPointerUp = function (pev) {
  10810. var context = _this.context;
  10811. var documentPointer = _this.documentPointer;
  10812. var calendarState = context.getCurrentData();
  10813. // touch-scrolling should never unfocus any type of selection
  10814. if (!documentPointer.wasTouchScroll) {
  10815. if (calendarState.dateSelection && // an existing date selection?
  10816. !_this.isRecentPointerDateSelect // a new pointer-initiated date selection since last onDocumentPointerUp?
  10817. ) {
  10818. var unselectAuto = context.options.unselectAuto;
  10819. var unselectCancel = context.options.unselectCancel;
  10820. if (unselectAuto && (!unselectAuto || !elementClosest(documentPointer.downEl, unselectCancel))) {
  10821. context.calendarApi.unselect(pev);
  10822. }
  10823. }
  10824. if (calendarState.eventSelection && // an existing event selected?
  10825. !elementClosest(documentPointer.downEl, EventDragging.SELECTOR) // interaction DIDN'T start on an event
  10826. ) {
  10827. context.dispatch({ type: 'UNSELECT_EVENT' });
  10828. }
  10829. }
  10830. _this.isRecentPointerDateSelect = false;
  10831. };
  10832. var documentPointer = this.documentPointer = new PointerDragging(document);
  10833. documentPointer.shouldIgnoreMove = true;
  10834. documentPointer.shouldWatchScroll = false;
  10835. documentPointer.emitter.on('pointerup', this.onDocumentPointerUp);
  10836. /*
  10837. TODO: better way to know about whether there was a selection with the pointer
  10838. */
  10839. context.emitter.on('select', this.onSelect);
  10840. }
  10841. UnselectAuto.prototype.destroy = function () {
  10842. this.context.emitter.off('select', this.onSelect);
  10843. this.documentPointer.destroy();
  10844. };
  10845. return UnselectAuto;
  10846. }());
  10847. var LISTENER_REFINERS = {
  10848. dateClick: identity,
  10849. eventDragStart: identity,
  10850. eventDragStop: identity,
  10851. eventDrop: identity,
  10852. eventResizeStart: identity,
  10853. eventResizeStop: identity,
  10854. eventResize: identity,
  10855. drop: identity,
  10856. eventReceive: identity,
  10857. eventLeave: identity
  10858. };
  10859. /*
  10860. Given an already instantiated draggable object for one-or-more elements,
  10861. Interprets any dragging as an attempt to drag an events that lives outside
  10862. of a calendar onto a calendar.
  10863. */
  10864. var ExternalElementDragging = /** @class */ (function () {
  10865. function ExternalElementDragging(dragging, suppliedDragMeta) {
  10866. var _this = this;
  10867. this.receivingContext = null;
  10868. this.droppableEvent = null; // will exist for all drags, even if create:false
  10869. this.suppliedDragMeta = null;
  10870. this.dragMeta = null;
  10871. this.handleDragStart = function (ev) {
  10872. _this.dragMeta = _this.buildDragMeta(ev.subjectEl);
  10873. };
  10874. this.handleHitUpdate = function (hit, isFinal, ev) {
  10875. var dragging = _this.hitDragging.dragging;
  10876. var receivingContext = null;
  10877. var droppableEvent = null;
  10878. var isInvalid = false;
  10879. var interaction = {
  10880. affectedEvents: createEmptyEventStore(),
  10881. mutatedEvents: createEmptyEventStore(),
  10882. isEvent: _this.dragMeta.create
  10883. };
  10884. if (hit) {
  10885. receivingContext = hit.component.context;
  10886. if (_this.canDropElOnCalendar(ev.subjectEl, receivingContext)) {
  10887. droppableEvent = computeEventForDateSpan(hit.dateSpan, _this.dragMeta, receivingContext);
  10888. interaction.mutatedEvents = eventTupleToStore(droppableEvent);
  10889. isInvalid = !isInteractionValid(interaction, receivingContext);
  10890. if (isInvalid) {
  10891. interaction.mutatedEvents = createEmptyEventStore();
  10892. droppableEvent = null;
  10893. }
  10894. }
  10895. }
  10896. _this.displayDrag(receivingContext, interaction);
  10897. // show mirror if no already-rendered mirror element OR if we are shutting down the mirror (?)
  10898. // TODO: wish we could somehow wait for dispatch to guarantee render
  10899. dragging.setMirrorIsVisible(isFinal || !droppableEvent || !document.querySelector('.fc-event-mirror'));
  10900. if (!isInvalid) {
  10901. enableCursor();
  10902. }
  10903. else {
  10904. disableCursor();
  10905. }
  10906. if (!isFinal) {
  10907. dragging.setMirrorNeedsRevert(!droppableEvent);
  10908. _this.receivingContext = receivingContext;
  10909. _this.droppableEvent = droppableEvent;
  10910. }
  10911. };
  10912. this.handleDragEnd = function (pev) {
  10913. var _a = _this, receivingContext = _a.receivingContext, droppableEvent = _a.droppableEvent;
  10914. _this.clearDrag();
  10915. if (receivingContext && droppableEvent) {
  10916. var finalHit = _this.hitDragging.finalHit;
  10917. var finalView = finalHit.component.context.viewApi;
  10918. var dragMeta = _this.dragMeta;
  10919. receivingContext.emitter.trigger('drop', __assign(__assign({}, buildDatePointApiWithContext(finalHit.dateSpan, receivingContext)), { draggedEl: pev.subjectEl, jsEvent: pev.origEvent, view: finalView }));
  10920. if (dragMeta.create) {
  10921. receivingContext.dispatch({
  10922. type: 'MERGE_EVENTS',
  10923. eventStore: eventTupleToStore(droppableEvent)
  10924. });
  10925. if (pev.isTouch) {
  10926. receivingContext.dispatch({
  10927. type: 'SELECT_EVENT',
  10928. eventInstanceId: droppableEvent.instance.instanceId
  10929. });
  10930. }
  10931. // signal that an external event landed
  10932. receivingContext.emitter.trigger('eventReceive', {
  10933. draggedEl: pev.subjectEl,
  10934. event: new EventApi(receivingContext, droppableEvent.def, droppableEvent.instance),
  10935. view: finalView
  10936. });
  10937. }
  10938. }
  10939. _this.receivingContext = null;
  10940. _this.droppableEvent = null;
  10941. };
  10942. var hitDragging = this.hitDragging = new HitDragging(dragging, interactionSettingsStore);
  10943. hitDragging.requireInitial = false; // will start outside of a component
  10944. hitDragging.emitter.on('dragstart', this.handleDragStart);
  10945. hitDragging.emitter.on('hitupdate', this.handleHitUpdate);
  10946. hitDragging.emitter.on('dragend', this.handleDragEnd);
  10947. this.suppliedDragMeta = suppliedDragMeta;
  10948. }
  10949. ExternalElementDragging.prototype.buildDragMeta = function (subjectEl) {
  10950. if (typeof this.suppliedDragMeta === 'object') {
  10951. return parseDragMeta(this.suppliedDragMeta);
  10952. }
  10953. else if (typeof this.suppliedDragMeta === 'function') {
  10954. return parseDragMeta(this.suppliedDragMeta(subjectEl));
  10955. }
  10956. else {
  10957. return getDragMetaFromEl(subjectEl);
  10958. }
  10959. };
  10960. ExternalElementDragging.prototype.displayDrag = function (nextContext, state) {
  10961. var prevContext = this.receivingContext;
  10962. if (prevContext && prevContext !== nextContext) {
  10963. prevContext.dispatch({ type: 'UNSET_EVENT_DRAG' });
  10964. }
  10965. if (nextContext) {
  10966. nextContext.dispatch({ type: 'SET_EVENT_DRAG', state: state });
  10967. }
  10968. };
  10969. ExternalElementDragging.prototype.clearDrag = function () {
  10970. if (this.receivingContext) {
  10971. this.receivingContext.dispatch({ type: 'UNSET_EVENT_DRAG' });
  10972. }
  10973. };
  10974. ExternalElementDragging.prototype.canDropElOnCalendar = function (el, receivingContext) {
  10975. var dropAccept = receivingContext.options.dropAccept;
  10976. if (typeof dropAccept === 'function') {
  10977. return dropAccept.call(receivingContext.calendarApi, el);
  10978. }
  10979. else if (typeof dropAccept === 'string' && dropAccept) {
  10980. return Boolean(elementMatches(el, dropAccept));
  10981. }
  10982. return true;
  10983. };
  10984. return ExternalElementDragging;
  10985. }());
  10986. // Utils for computing event store from the DragMeta
  10987. // ----------------------------------------------------------------------------------------------------
  10988. function computeEventForDateSpan(dateSpan, dragMeta, context) {
  10989. var defProps = __assign({}, dragMeta.leftoverProps);
  10990. for (var _i = 0, _a = context.pluginHooks.externalDefTransforms; _i < _a.length; _i++) {
  10991. var transform = _a[_i];
  10992. __assign(defProps, transform(dateSpan, dragMeta));
  10993. }
  10994. var _b = refineEventDef(defProps, context), refined = _b.refined, extra = _b.extra;
  10995. var def = parseEventDef(refined, extra, dragMeta.sourceId, dateSpan.allDay, context.options.forceEventDuration || Boolean(dragMeta.duration), // hasEnd
  10996. context);
  10997. var start = dateSpan.range.start;
  10998. // only rely on time info if drop zone is all-day,
  10999. // otherwise, we already know the time
  11000. if (dateSpan.allDay && dragMeta.startTime) {
  11001. start = context.dateEnv.add(start, dragMeta.startTime);
  11002. }
  11003. var end = dragMeta.duration ?
  11004. context.dateEnv.add(start, dragMeta.duration) :
  11005. getDefaultEventEnd(dateSpan.allDay, start, context);
  11006. var instance = createEventInstance(def.defId, { start: start, end: end });
  11007. return { def: def, instance: instance };
  11008. }
  11009. // Utils for extracting data from element
  11010. // ----------------------------------------------------------------------------------------------------
  11011. function getDragMetaFromEl(el) {
  11012. var str = getEmbeddedElData(el, 'event');
  11013. var obj = str ?
  11014. JSON.parse(str) :
  11015. { create: false }; // if no embedded data, assume no event creation
  11016. return parseDragMeta(obj);
  11017. }
  11018. config.dataAttrPrefix = '';
  11019. function getEmbeddedElData(el, name) {
  11020. var prefix = config.dataAttrPrefix;
  11021. var prefixedName = (prefix ? prefix + '-' : '') + name;
  11022. return el.getAttribute('data-' + prefixedName) || '';
  11023. }
  11024. /*
  11025. Makes an element (that is *external* to any calendar) draggable.
  11026. Can pass in data that determines how an event will be created when dropped onto a calendar.
  11027. Leverages FullCalendar's internal drag-n-drop functionality WITHOUT a third-party drag system.
  11028. */
  11029. var ExternalDraggable = /** @class */ (function () {
  11030. function ExternalDraggable(el, settings) {
  11031. var _this = this;
  11032. if (settings === void 0) { settings = {}; }
  11033. this.handlePointerDown = function (ev) {
  11034. var dragging = _this.dragging;
  11035. var _a = _this.settings, minDistance = _a.minDistance, longPressDelay = _a.longPressDelay;
  11036. dragging.minDistance =
  11037. minDistance != null ?
  11038. minDistance :
  11039. (ev.isTouch ? 0 : BASE_OPTION_DEFAULTS.eventDragMinDistance);
  11040. dragging.delay =
  11041. ev.isTouch ? // TODO: eventually read eventLongPressDelay instead vvv
  11042. (longPressDelay != null ? longPressDelay : BASE_OPTION_DEFAULTS.longPressDelay) :
  11043. 0;
  11044. };
  11045. this.handleDragStart = function (ev) {
  11046. if (ev.isTouch &&
  11047. _this.dragging.delay &&
  11048. ev.subjectEl.classList.contains('fc-event')) {
  11049. _this.dragging.mirror.getMirrorEl().classList.add('fc-event-selected');
  11050. }
  11051. };
  11052. this.settings = settings;
  11053. var dragging = this.dragging = new FeaturefulElementDragging(el);
  11054. dragging.touchScrollAllowed = false;
  11055. if (settings.itemSelector != null) {
  11056. dragging.pointer.selector = settings.itemSelector;
  11057. }
  11058. if (settings.appendTo != null) {
  11059. dragging.mirror.parentNode = settings.appendTo; // TODO: write tests
  11060. }
  11061. dragging.emitter.on('pointerdown', this.handlePointerDown);
  11062. dragging.emitter.on('dragstart', this.handleDragStart);
  11063. new ExternalElementDragging(dragging, settings.eventData);
  11064. }
  11065. ExternalDraggable.prototype.destroy = function () {
  11066. this.dragging.destroy();
  11067. };
  11068. return ExternalDraggable;
  11069. }());
  11070. /*
  11071. Detects when a *THIRD-PARTY* drag-n-drop system interacts with elements.
  11072. The third-party system is responsible for drawing the visuals effects of the drag.
  11073. This class simply monitors for pointer movements and fires events.
  11074. It also has the ability to hide the moving element (the "mirror") during the drag.
  11075. */
  11076. var InferredElementDragging = /** @class */ (function (_super) {
  11077. __extends(InferredElementDragging, _super);
  11078. function InferredElementDragging(containerEl) {
  11079. var _this = _super.call(this, containerEl) || this;
  11080. _this.shouldIgnoreMove = false;
  11081. _this.mirrorSelector = '';
  11082. _this.currentMirrorEl = null;
  11083. _this.handlePointerDown = function (ev) {
  11084. _this.emitter.trigger('pointerdown', ev);
  11085. if (!_this.shouldIgnoreMove) {
  11086. // fire dragstart right away. does not support delay or min-distance
  11087. _this.emitter.trigger('dragstart', ev);
  11088. }
  11089. };
  11090. _this.handlePointerMove = function (ev) {
  11091. if (!_this.shouldIgnoreMove) {
  11092. _this.emitter.trigger('dragmove', ev);
  11093. }
  11094. };
  11095. _this.handlePointerUp = function (ev) {
  11096. _this.emitter.trigger('pointerup', ev);
  11097. if (!_this.shouldIgnoreMove) {
  11098. // fire dragend right away. does not support a revert animation
  11099. _this.emitter.trigger('dragend', ev);
  11100. }
  11101. };
  11102. var pointer = _this.pointer = new PointerDragging(containerEl);
  11103. pointer.emitter.on('pointerdown', _this.handlePointerDown);
  11104. pointer.emitter.on('pointermove', _this.handlePointerMove);
  11105. pointer.emitter.on('pointerup', _this.handlePointerUp);
  11106. return _this;
  11107. }
  11108. InferredElementDragging.prototype.destroy = function () {
  11109. this.pointer.destroy();
  11110. };
  11111. InferredElementDragging.prototype.setIgnoreMove = function (bool) {
  11112. this.shouldIgnoreMove = bool;
  11113. };
  11114. InferredElementDragging.prototype.setMirrorIsVisible = function (bool) {
  11115. if (bool) {
  11116. // restore a previously hidden element.
  11117. // use the reference in case the selector class has already been removed.
  11118. if (this.currentMirrorEl) {
  11119. this.currentMirrorEl.style.visibility = '';
  11120. this.currentMirrorEl = null;
  11121. }
  11122. }
  11123. else {
  11124. var mirrorEl = this.mirrorSelector ?
  11125. document.querySelector(this.mirrorSelector) :
  11126. null;
  11127. if (mirrorEl) {
  11128. this.currentMirrorEl = mirrorEl;
  11129. mirrorEl.style.visibility = 'hidden';
  11130. }
  11131. }
  11132. };
  11133. return InferredElementDragging;
  11134. }(ElementDragging));
  11135. /*
  11136. Bridges third-party drag-n-drop systems with FullCalendar.
  11137. Must be instantiated and destroyed by caller.
  11138. */
  11139. var ThirdPartyDraggable = /** @class */ (function () {
  11140. function ThirdPartyDraggable(containerOrSettings, settings) {
  11141. var containerEl = document;
  11142. if (
  11143. // wish we could just test instanceof EventTarget, but doesn't work in IE11
  11144. containerOrSettings === document ||
  11145. containerOrSettings instanceof Element) {
  11146. containerEl = containerOrSettings;
  11147. settings = settings || {};
  11148. }
  11149. else {
  11150. settings = (containerOrSettings || {});
  11151. }
  11152. var dragging = this.dragging = new InferredElementDragging(containerEl);
  11153. if (typeof settings.itemSelector === 'string') {
  11154. dragging.pointer.selector = settings.itemSelector;
  11155. }
  11156. else if (containerEl === document) {
  11157. dragging.pointer.selector = '[data-event]';
  11158. }
  11159. if (typeof settings.mirrorSelector === 'string') {
  11160. dragging.mirrorSelector = settings.mirrorSelector;
  11161. }
  11162. new ExternalElementDragging(dragging, settings.eventData);
  11163. }
  11164. ThirdPartyDraggable.prototype.destroy = function () {
  11165. this.dragging.destroy();
  11166. };
  11167. return ThirdPartyDraggable;
  11168. }());
  11169. var interactionPlugin = createPlugin({
  11170. componentInteractions: [DateClicking, DateSelecting, EventDragging, EventResizing],
  11171. calendarInteractions: [UnselectAuto],
  11172. elementDraggingImpl: FeaturefulElementDragging,
  11173. listenerRefiners: LISTENER_REFINERS
  11174. });
  11175. /* An abstract class for the daygrid views, as well as month view. Renders one or more rows of day cells.
  11176. ----------------------------------------------------------------------------------------------------------------------*/
  11177. // It is a manager for a Table subcomponent, which does most of the heavy lifting.
  11178. // It is responsible for managing width/height.
  11179. var TableView = /** @class */ (function (_super) {
  11180. __extends(TableView, _super);
  11181. function TableView() {
  11182. var _this = _super !== null && _super.apply(this, arguments) || this;
  11183. _this.headerElRef = createRef();
  11184. return _this;
  11185. }
  11186. TableView.prototype.renderSimpleLayout = function (headerRowContent, bodyContent) {
  11187. var _a = this, props = _a.props, context = _a.context;
  11188. var sections = [];
  11189. var stickyHeaderDates = getStickyHeaderDates(context.options);
  11190. if (headerRowContent) {
  11191. sections.push({
  11192. type: 'header',
  11193. key: 'header',
  11194. isSticky: stickyHeaderDates,
  11195. chunk: {
  11196. elRef: this.headerElRef,
  11197. tableClassName: 'fc-col-header',
  11198. rowContent: headerRowContent
  11199. }
  11200. });
  11201. }
  11202. sections.push({
  11203. type: 'body',
  11204. key: 'body',
  11205. liquid: true,
  11206. chunk: { content: bodyContent }
  11207. });
  11208. return (createElement(ViewRoot, { viewSpec: context.viewSpec }, function (rootElRef, classNames) { return (createElement("div", { ref: rootElRef, className: ['fc-daygrid'].concat(classNames).join(' ') },
  11209. createElement(SimpleScrollGrid, { liquid: !props.isHeightAuto && !props.forPrint, cols: [] /* TODO: make optional? */, sections: sections }))); }));
  11210. };
  11211. TableView.prototype.renderHScrollLayout = function (headerRowContent, bodyContent, colCnt, dayMinWidth) {
  11212. var ScrollGrid = this.context.pluginHooks.scrollGridImpl;
  11213. if (!ScrollGrid) {
  11214. throw new Error('No ScrollGrid implementation');
  11215. }
  11216. var _a = this, props = _a.props, context = _a.context;
  11217. var stickyHeaderDates = !props.forPrint && getStickyHeaderDates(context.options);
  11218. var stickyFooterScrollbar = !props.forPrint && getStickyFooterScrollbar(context.options);
  11219. var sections = [];
  11220. if (headerRowContent) {
  11221. sections.push({
  11222. type: 'header',
  11223. key: 'header',
  11224. isSticky: stickyHeaderDates,
  11225. chunks: [{
  11226. key: 'main',
  11227. elRef: this.headerElRef,
  11228. tableClassName: 'fc-col-header',
  11229. rowContent: headerRowContent
  11230. }]
  11231. });
  11232. }
  11233. sections.push({
  11234. type: 'body',
  11235. key: 'body',
  11236. liquid: true,
  11237. chunks: [{
  11238. key: 'main',
  11239. content: bodyContent
  11240. }]
  11241. });
  11242. if (stickyFooterScrollbar) {
  11243. sections.push({
  11244. type: 'footer',
  11245. key: 'footer',
  11246. isSticky: true,
  11247. chunks: [{
  11248. key: 'main',
  11249. content: renderScrollShim
  11250. }]
  11251. });
  11252. }
  11253. return (createElement(ViewRoot, { viewSpec: context.viewSpec }, function (rootElRef, classNames) { return (createElement("div", { ref: rootElRef, className: ['fc-daygrid'].concat(classNames).join(' ') },
  11254. createElement(ScrollGrid, { liquid: !props.isHeightAuto && !props.forPrint, colGroups: [{ cols: [{ span: colCnt, minWidth: dayMinWidth }] }], sections: sections }))); }));
  11255. };
  11256. return TableView;
  11257. }(DateComponent));
  11258. function splitSegsByRow(segs, rowCnt) {
  11259. var byRow = [];
  11260. for (var i = 0; i < rowCnt; i++) {
  11261. byRow[i] = [];
  11262. }
  11263. for (var _i = 0, segs_1 = segs; _i < segs_1.length; _i++) {
  11264. var seg = segs_1[_i];
  11265. byRow[seg.row].push(seg);
  11266. }
  11267. return byRow;
  11268. }
  11269. function splitSegsByFirstCol(segs, colCnt) {
  11270. var byCol = [];
  11271. for (var i = 0; i < colCnt; i++) {
  11272. byCol[i] = [];
  11273. }
  11274. for (var _i = 0, segs_2 = segs; _i < segs_2.length; _i++) {
  11275. var seg = segs_2[_i];
  11276. byCol[seg.firstCol].push(seg);
  11277. }
  11278. return byCol;
  11279. }
  11280. function splitInteractionByRow(ui, rowCnt) {
  11281. var byRow = [];
  11282. if (!ui) {
  11283. for (var i = 0; i < rowCnt; i++) {
  11284. byRow[i] = null;
  11285. }
  11286. }
  11287. else {
  11288. for (var i = 0; i < rowCnt; i++) {
  11289. byRow[i] = {
  11290. affectedInstances: ui.affectedInstances,
  11291. isEvent: ui.isEvent,
  11292. segs: []
  11293. };
  11294. }
  11295. for (var _i = 0, _a = ui.segs; _i < _a.length; _i++) {
  11296. var seg = _a[_i];
  11297. byRow[seg.row].segs.push(seg);
  11298. }
  11299. }
  11300. return byRow;
  11301. }
  11302. var DEFAULT_WEEK_NUM_FORMAT = createFormatter({ week: 'narrow' });
  11303. var TableCell = /** @class */ (function (_super) {
  11304. __extends(TableCell, _super);
  11305. function TableCell() {
  11306. var _this = _super !== null && _super.apply(this, arguments) || this;
  11307. _this.handleRootEl = function (el) {
  11308. _this.rootEl = el;
  11309. setRef(_this.props.elRef, el);
  11310. };
  11311. _this.handleMoreLinkClick = function (ev) {
  11312. var props = _this.props;
  11313. if (props.onMoreClick) {
  11314. var allSegs = props.segsByEachCol;
  11315. var hiddenSegs = allSegs.filter(function (seg) { return props.segIsHidden[seg.eventRange.instance.instanceId]; });
  11316. props.onMoreClick({
  11317. date: props.date,
  11318. allSegs: allSegs,
  11319. hiddenSegs: hiddenSegs,
  11320. moreCnt: props.moreCnt,
  11321. dayEl: _this.rootEl,
  11322. ev: ev
  11323. });
  11324. }
  11325. };
  11326. return _this;
  11327. }
  11328. TableCell.prototype.render = function () {
  11329. var _this = this;
  11330. var _a = this.context, options = _a.options, viewApi = _a.viewApi;
  11331. var props = this.props;
  11332. var date = props.date, dateProfile = props.dateProfile;
  11333. var hookProps = {
  11334. num: props.moreCnt,
  11335. text: props.buildMoreLinkText(props.moreCnt),
  11336. view: viewApi
  11337. };
  11338. var navLinkAttrs = options.navLinks
  11339. ? { 'data-navlink': buildNavLinkData(date, 'week'), tabIndex: 0 }
  11340. : {};
  11341. return (createElement(DayCellRoot, { date: date, dateProfile: dateProfile, todayRange: props.todayRange, showDayNumber: props.showDayNumber, extraHookProps: props.extraHookProps, elRef: this.handleRootEl }, function (rootElRef, classNames, rootDataAttrs, isDisabled) { return (createElement("td", __assign({ ref: rootElRef, className: ['fc-daygrid-day'].concat(classNames, props.extraClassNames || []).join(' ') }, rootDataAttrs, props.extraDataAttrs),
  11342. createElement("div", { className: 'fc-daygrid-day-frame fc-scrollgrid-sync-inner', ref: props.innerElRef /* different from hook system! RENAME */ },
  11343. props.showWeekNumber &&
  11344. createElement(WeekNumberRoot, { date: date, defaultFormat: DEFAULT_WEEK_NUM_FORMAT }, function (rootElRef, classNames, innerElRef, innerContent) { return (createElement("a", __assign({ ref: rootElRef, className: ['fc-daygrid-week-number'].concat(classNames).join(' ') }, navLinkAttrs), innerContent)); }),
  11345. !isDisabled &&
  11346. createElement(TableCellTop, { date: date, dateProfile: dateProfile, showDayNumber: props.showDayNumber, todayRange: props.todayRange, extraHookProps: props.extraHookProps }),
  11347. createElement("div", { className: 'fc-daygrid-day-events', ref: props.fgContentElRef, style: { paddingBottom: props.fgPaddingBottom } },
  11348. props.fgContent,
  11349. Boolean(props.moreCnt) &&
  11350. createElement("div", { className: 'fc-daygrid-day-bottom', style: { marginTop: props.moreMarginTop } },
  11351. createElement(RenderHook, { hookProps: hookProps, classNames: options.moreLinkClassNames, content: options.moreLinkContent, defaultContent: renderMoreLinkInner, didMount: options.moreLinkDidMount, willUnmount: options.moreLinkWillUnmount }, function (rootElRef, classNames, innerElRef, innerContent) { return (createElement("a", { onClick: _this.handleMoreLinkClick, ref: rootElRef, className: ['fc-daygrid-more-link'].concat(classNames).join(' ') }, innerContent)); }))),
  11352. createElement("div", { className: 'fc-daygrid-day-bg' }, props.bgContent)))); }));
  11353. };
  11354. return TableCell;
  11355. }(DateComponent));
  11356. function renderTopInner(props) {
  11357. return props.dayNumberText;
  11358. }
  11359. function renderMoreLinkInner(props) {
  11360. return props.text;
  11361. }
  11362. var TableCellTop = /** @class */ (function (_super) {
  11363. __extends(TableCellTop, _super);
  11364. function TableCellTop() {
  11365. return _super !== null && _super.apply(this, arguments) || this;
  11366. }
  11367. TableCellTop.prototype.render = function () {
  11368. var props = this.props;
  11369. var navLinkAttrs = this.context.options.navLinks
  11370. ? { 'data-navlink': buildNavLinkData(props.date), tabIndex: 0 }
  11371. : {};
  11372. return (createElement(DayCellContent, { date: props.date, dateProfile: props.dateProfile, todayRange: props.todayRange, showDayNumber: props.showDayNumber, extraHookProps: props.extraHookProps, defaultContent: renderTopInner }, function (innerElRef, innerContent) { return (innerContent &&
  11373. createElement("div", { className: 'fc-daygrid-day-top', ref: innerElRef },
  11374. createElement("a", __assign({ className: 'fc-daygrid-day-number' }, navLinkAttrs), innerContent))); }));
  11375. };
  11376. return TableCellTop;
  11377. }(BaseComponent));
  11378. var DEFAULT_TABLE_EVENT_TIME_FORMAT = createFormatter({
  11379. hour: 'numeric',
  11380. minute: '2-digit',
  11381. omitZeroMinute: true,
  11382. meridiem: 'narrow'
  11383. });
  11384. function hasListItemDisplay(seg) {
  11385. var display = seg.eventRange.ui.display;
  11386. return display === 'list-item' || (display === 'auto' &&
  11387. !seg.eventRange.def.allDay &&
  11388. seg.firstCol === seg.lastCol // can't be multi-day
  11389. );
  11390. }
  11391. var TableListItemEvent = /** @class */ (function (_super) {
  11392. __extends(TableListItemEvent, _super);
  11393. function TableListItemEvent() {
  11394. return _super !== null && _super.apply(this, arguments) || this;
  11395. }
  11396. TableListItemEvent.prototype.render = function () {
  11397. var _a = this, props = _a.props, context = _a.context;
  11398. var timeFormat = context.options.eventTimeFormat || DEFAULT_TABLE_EVENT_TIME_FORMAT;
  11399. var timeText = buildSegTimeText(props.seg, timeFormat, context, true, props.defaultDisplayEventEnd);
  11400. return (createElement(EventRoot, { seg: props.seg, timeText: timeText, defaultContent: renderInnerContent$2, isDragging: props.isDragging, isResizing: false, isDateSelecting: false, isSelected: props.isSelected, isPast: props.isPast, isFuture: props.isFuture, isToday: props.isToday }, function (rootElRef, classNames, innerElRef, innerContent) { return ( // we don't use styles!
  11401. createElement("a", __assign({ className: ['fc-daygrid-event', 'fc-daygrid-dot-event'].concat(classNames).join(' '), ref: rootElRef }, getSegAnchorAttrs$1(props.seg)), innerContent)); }));
  11402. };
  11403. return TableListItemEvent;
  11404. }(BaseComponent));
  11405. function renderInnerContent$2(innerProps) {
  11406. return (createElement(Fragment, null,
  11407. createElement("div", { className: 'fc-daygrid-event-dot', style: { borderColor: innerProps.borderColor || innerProps.backgroundColor } }),
  11408. innerProps.timeText &&
  11409. createElement("div", { className: 'fc-event-time' }, innerProps.timeText),
  11410. createElement("div", { className: 'fc-event-title' }, innerProps.event.title || createElement(Fragment, null, "\u00A0"))));
  11411. }
  11412. function getSegAnchorAttrs$1(seg) {
  11413. var url = seg.eventRange.def.url;
  11414. return url ? { href: url } : {};
  11415. }
  11416. var TableBlockEvent = /** @class */ (function (_super) {
  11417. __extends(TableBlockEvent, _super);
  11418. function TableBlockEvent() {
  11419. return _super !== null && _super.apply(this, arguments) || this;
  11420. }
  11421. TableBlockEvent.prototype.render = function () {
  11422. var props = this.props;
  11423. return (createElement(StandardEvent, __assign({}, props, { extraClassNames: ['fc-daygrid-event', 'fc-daygrid-block-event', 'fc-h-event'], defaultTimeFormat: DEFAULT_TABLE_EVENT_TIME_FORMAT, defaultDisplayEventEnd: props.defaultDisplayEventEnd, disableResizing: !props.seg.eventRange.def.allDay })));
  11424. };
  11425. return TableBlockEvent;
  11426. }(BaseComponent));
  11427. function computeFgSegPlacement(// for one row. TODO: print mode?
  11428. cellModels, segs, dayMaxEvents, dayMaxEventRows, eventHeights, maxContentHeight, colCnt, eventOrderSpecs) {
  11429. var colPlacements = []; // if event spans multiple cols, its present in each col
  11430. var moreCnts = []; // by-col
  11431. var segIsHidden = {};
  11432. var segTops = {}; // always populated for each seg
  11433. var segMarginTops = {}; // simetimes populated for each seg
  11434. var moreTops = {};
  11435. var paddingBottoms = {}; // for each cell's inner-wrapper div
  11436. for (var i = 0; i < colCnt; i++) {
  11437. colPlacements.push([]);
  11438. moreCnts.push(0);
  11439. }
  11440. segs = sortEventSegs(segs, eventOrderSpecs);
  11441. for (var _i = 0, segs_1 = segs; _i < segs_1.length; _i++) {
  11442. var seg = segs_1[_i];
  11443. var instanceId = seg.eventRange.instance.instanceId;
  11444. var eventHeight = eventHeights[instanceId + ':' + seg.firstCol];
  11445. placeSeg(seg, eventHeight || 0); // will keep colPlacements sorted by top
  11446. }
  11447. if (dayMaxEvents === true || dayMaxEventRows === true) {
  11448. limitByMaxHeight(moreCnts, segIsHidden, colPlacements, maxContentHeight); // populates moreCnts/segIsHidden
  11449. }
  11450. else if (typeof dayMaxEvents === 'number') {
  11451. limitByMaxEvents(moreCnts, segIsHidden, colPlacements, dayMaxEvents); // populates moreCnts/segIsHidden
  11452. }
  11453. else if (typeof dayMaxEventRows === 'number') {
  11454. limitByMaxRows(moreCnts, segIsHidden, colPlacements, dayMaxEventRows); // populates moreCnts/segIsHidden
  11455. }
  11456. // computes segTops/segMarginTops/moreTops/paddingBottoms
  11457. for (var col = 0; col < colCnt; col++) {
  11458. var placements = colPlacements[col];
  11459. var currentNonAbsBottom = 0;
  11460. var runningAbsHeight = 0;
  11461. for (var _a = 0, placements_1 = placements; _a < placements_1.length; _a++) {
  11462. var placement = placements_1[_a];
  11463. var seg = placement.seg;
  11464. if (!segIsHidden[seg.eventRange.instance.instanceId]) {
  11465. segTops[seg.eventRange.instance.instanceId] = placement.top; // from top of container
  11466. if (seg.firstCol === seg.lastCol && seg.isStart && seg.isEnd) { // TODO: simpler way? NOT DRY
  11467. segMarginTops[seg.eventRange.instance.instanceId] =
  11468. placement.top - currentNonAbsBottom; // from previous seg bottom
  11469. runningAbsHeight = 0;
  11470. currentNonAbsBottom = placement.bottom;
  11471. }
  11472. else { // multi-col event, abs positioned
  11473. runningAbsHeight += placement.bottom - placement.top;
  11474. }
  11475. }
  11476. }
  11477. if (runningAbsHeight) {
  11478. if (moreCnts[col]) {
  11479. moreTops[col] = runningAbsHeight;
  11480. }
  11481. else {
  11482. paddingBottoms[col] = runningAbsHeight;
  11483. }
  11484. }
  11485. }
  11486. function placeSeg(seg, segHeight) {
  11487. if (!tryPlaceSegAt(seg, segHeight, 0)) {
  11488. for (var col = seg.firstCol; col <= seg.lastCol; col++) {
  11489. for (var _i = 0, _a = colPlacements[col]; _i < _a.length; _i++) { // will repeat multi-day segs!!!!!!! bad!!!!!!
  11490. var placement = _a[_i];
  11491. if (tryPlaceSegAt(seg, segHeight, placement.bottom)) {
  11492. return;
  11493. }
  11494. }
  11495. }
  11496. }
  11497. }
  11498. function tryPlaceSegAt(seg, segHeight, top) {
  11499. if (canPlaceSegAt(seg, segHeight, top)) {
  11500. for (var col = seg.firstCol; col <= seg.lastCol; col++) {
  11501. var placements = colPlacements[col];
  11502. var insertionIndex = 0;
  11503. while (insertionIndex < placements.length &&
  11504. top >= placements[insertionIndex].top) {
  11505. insertionIndex++;
  11506. }
  11507. placements.splice(insertionIndex, 0, {
  11508. seg: seg,
  11509. top: top,
  11510. bottom: top + segHeight
  11511. });
  11512. }
  11513. return true;
  11514. }
  11515. else {
  11516. return false;
  11517. }
  11518. }
  11519. function canPlaceSegAt(seg, segHeight, top) {
  11520. for (var col = seg.firstCol; col <= seg.lastCol; col++) {
  11521. for (var _i = 0, _a = colPlacements[col]; _i < _a.length; _i++) {
  11522. var placement = _a[_i];
  11523. if (top < placement.bottom && top + segHeight > placement.top) { // collide?
  11524. return false;
  11525. }
  11526. }
  11527. }
  11528. return true;
  11529. }
  11530. // what does this do!?
  11531. for (var instanceIdAndFirstCol in eventHeights) {
  11532. if (!eventHeights[instanceIdAndFirstCol]) {
  11533. segIsHidden[instanceIdAndFirstCol.split(':')[0]] = true;
  11534. }
  11535. }
  11536. var segsByFirstCol = colPlacements.map(extractFirstColSegs); // operates on the sorted cols
  11537. var segsByEachCol = colPlacements.map(function (placements, col) {
  11538. var segs = extractAllColSegs(placements);
  11539. segs = resliceDaySegs(segs, cellModels[col].date, col);
  11540. return segs;
  11541. });
  11542. return {
  11543. segsByFirstCol: segsByFirstCol,
  11544. segsByEachCol: segsByEachCol,
  11545. segIsHidden: segIsHidden,
  11546. segTops: segTops,
  11547. segMarginTops: segMarginTops,
  11548. moreCnts: moreCnts,
  11549. moreTops: moreTops,
  11550. paddingBottoms: paddingBottoms
  11551. };
  11552. }
  11553. function extractFirstColSegs(oneColPlacements, col) {
  11554. var segs = [];
  11555. for (var _i = 0, oneColPlacements_1 = oneColPlacements; _i < oneColPlacements_1.length; _i++) {
  11556. var placement = oneColPlacements_1[_i];
  11557. if (placement.seg.firstCol === col) {
  11558. segs.push(placement.seg);
  11559. }
  11560. }
  11561. return segs;
  11562. }
  11563. function extractAllColSegs(oneColPlacements) {
  11564. var segs = [];
  11565. for (var _i = 0, oneColPlacements_2 = oneColPlacements; _i < oneColPlacements_2.length; _i++) {
  11566. var placement = oneColPlacements_2[_i];
  11567. segs.push(placement.seg);
  11568. }
  11569. return segs;
  11570. }
  11571. function limitByMaxHeight(hiddenCnts, segIsHidden, colPlacements, maxContentHeight) {
  11572. limitEvents(hiddenCnts, segIsHidden, colPlacements, true, function (placement) {
  11573. return placement.bottom <= maxContentHeight;
  11574. });
  11575. }
  11576. function limitByMaxEvents(hiddenCnts, segIsHidden, colPlacements, dayMaxEvents) {
  11577. limitEvents(hiddenCnts, segIsHidden, colPlacements, false, function (placement, levelIndex) {
  11578. return levelIndex < dayMaxEvents;
  11579. });
  11580. }
  11581. function limitByMaxRows(hiddenCnts, segIsHidden, colPlacements, dayMaxEventRows) {
  11582. limitEvents(hiddenCnts, segIsHidden, colPlacements, true, function (placement, levelIndex) {
  11583. return levelIndex < dayMaxEventRows;
  11584. });
  11585. }
  11586. /*
  11587. populates the given hiddenCnts/segIsHidden, which are supplied empty.
  11588. TODO: return them instead
  11589. */
  11590. function limitEvents(hiddenCnts, segIsHidden, colPlacements, moreLinkConsumesLevel, isPlacementInBounds) {
  11591. var colCnt = hiddenCnts.length;
  11592. var segIsVisible = {}; // TODO: instead, use segIsHidden with true/false?
  11593. var visibleColPlacements = []; // will mirror colPlacements
  11594. for (var col = 0; col < colCnt; col++) {
  11595. visibleColPlacements.push([]);
  11596. }
  11597. for (var col = 0; col < colCnt; col++) {
  11598. var placements = colPlacements[col];
  11599. var level = 0;
  11600. for (var _i = 0, placements_2 = placements; _i < placements_2.length; _i++) {
  11601. var placement = placements_2[_i];
  11602. if (isPlacementInBounds(placement, level)) {
  11603. recordVisible(placement);
  11604. }
  11605. else {
  11606. recordHidden(placement);
  11607. }
  11608. // only considered a level if the seg had height
  11609. if (placement.top !== placement.bottom) {
  11610. level++;
  11611. }
  11612. }
  11613. }
  11614. function recordVisible(placement) {
  11615. var seg = placement.seg;
  11616. var instanceId = seg.eventRange.instance.instanceId;
  11617. if (!segIsVisible[instanceId]) {
  11618. segIsVisible[instanceId] = true;
  11619. for (var col = seg.firstCol; col <= seg.lastCol; col++) {
  11620. visibleColPlacements[col].push(placement);
  11621. }
  11622. }
  11623. }
  11624. function recordHidden(placement) {
  11625. var seg = placement.seg;
  11626. var instanceId = seg.eventRange.instance.instanceId;
  11627. if (!segIsHidden[instanceId]) {
  11628. segIsHidden[instanceId] = true;
  11629. for (var col = seg.firstCol; col <= seg.lastCol; col++) {
  11630. var hiddenCnt = ++hiddenCnts[col];
  11631. if (moreLinkConsumesLevel && hiddenCnt === 1) {
  11632. var lastVisiblePlacement = visibleColPlacements[col].pop();
  11633. if (lastVisiblePlacement) {
  11634. recordHidden(lastVisiblePlacement);
  11635. }
  11636. }
  11637. }
  11638. }
  11639. }
  11640. }
  11641. // Given the events within an array of segment objects, reslice them to be in a single day
  11642. function resliceDaySegs(segs, dayDate, colIndex) {
  11643. var dayStart = dayDate;
  11644. var dayEnd = addDays(dayStart, 1);
  11645. var dayRange = { start: dayStart, end: dayEnd };
  11646. var newSegs = [];
  11647. for (var _i = 0, segs_2 = segs; _i < segs_2.length; _i++) {
  11648. var seg = segs_2[_i];
  11649. var eventRange = seg.eventRange;
  11650. var origRange = eventRange.range;
  11651. var slicedRange = intersectRanges(origRange, dayRange);
  11652. if (slicedRange) {
  11653. newSegs.push(__assign(__assign({}, seg), { firstCol: colIndex, lastCol: colIndex, eventRange: {
  11654. def: eventRange.def,
  11655. ui: __assign(__assign({}, eventRange.ui), { durationEditable: false }),
  11656. instance: eventRange.instance,
  11657. range: slicedRange
  11658. }, isStart: seg.isStart && slicedRange.start.valueOf() === origRange.start.valueOf(), isEnd: seg.isEnd && slicedRange.end.valueOf() === origRange.end.valueOf() }));
  11659. }
  11660. }
  11661. return newSegs;
  11662. }
  11663. var TableRow = /** @class */ (function (_super) {
  11664. __extends(TableRow, _super);
  11665. function TableRow() {
  11666. var _this = _super !== null && _super.apply(this, arguments) || this;
  11667. _this.cellElRefs = new RefMap(); // the <td>
  11668. _this.frameElRefs = new RefMap(); // the fc-daygrid-day-frame
  11669. _this.fgElRefs = new RefMap(); // the fc-daygrid-day-events
  11670. _this.segHarnessRefs = new RefMap(); // indexed by "instanceId:firstCol"
  11671. _this.rootElRef = createRef();
  11672. _this.state = {
  11673. framePositions: null,
  11674. maxContentHeight: null,
  11675. segHeights: {}
  11676. };
  11677. return _this;
  11678. }
  11679. TableRow.prototype.render = function () {
  11680. var _this = this;
  11681. var _a = this, props = _a.props, state = _a.state, context = _a.context;
  11682. var colCnt = props.cells.length;
  11683. var businessHoursByCol = splitSegsByFirstCol(props.businessHourSegs, colCnt);
  11684. var bgEventSegsByCol = splitSegsByFirstCol(props.bgEventSegs, colCnt);
  11685. var highlightSegsByCol = splitSegsByFirstCol(this.getHighlightSegs(), colCnt);
  11686. var mirrorSegsByCol = splitSegsByFirstCol(this.getMirrorSegs(), colCnt);
  11687. var _b = computeFgSegPlacement(props.cells, props.fgEventSegs, props.dayMaxEvents, props.dayMaxEventRows, state.segHeights, state.maxContentHeight, colCnt, context.options.eventOrder), paddingBottoms = _b.paddingBottoms, segsByFirstCol = _b.segsByFirstCol, segsByEachCol = _b.segsByEachCol, segIsHidden = _b.segIsHidden, segTops = _b.segTops, segMarginTops = _b.segMarginTops, moreCnts = _b.moreCnts, moreTops = _b.moreTops;
  11688. var selectedInstanceHash = // TODO: messy way to compute this
  11689. (props.eventDrag && props.eventDrag.affectedInstances) ||
  11690. (props.eventResize && props.eventResize.affectedInstances) ||
  11691. {};
  11692. return (createElement("tr", { ref: this.rootElRef },
  11693. props.renderIntro && props.renderIntro(),
  11694. props.cells.map(function (cell, col) {
  11695. var normalFgNodes = _this.renderFgSegs(segsByFirstCol[col], segIsHidden, segTops, segMarginTops, selectedInstanceHash, props.todayRange);
  11696. var mirrorFgNodes = _this.renderFgSegs(mirrorSegsByCol[col], {}, segTops, // use same tops as real rendering
  11697. {}, {}, props.todayRange, Boolean(props.eventDrag), Boolean(props.eventResize), false // date-selecting (because mirror is never drawn for date selection)
  11698. );
  11699. var showWeekNumber = props.showWeekNumbers && col === 0;
  11700. return (createElement(TableCell, { key: cell.key, elRef: _this.cellElRefs.createRef(cell.key), innerElRef: _this.frameElRefs.createRef(cell.key) /* FF <td> problem, but okay to use for left/right. TODO: rename prop */, dateProfile: props.dateProfile, date: cell.date, showDayNumber: props.showDayNumbers || showWeekNumber /* for spacing, we need to force day-numbers if week numbers */, showWeekNumber: showWeekNumber, todayRange: props.todayRange, extraHookProps: cell.extraHookProps, extraDataAttrs: cell.extraDataAttrs, extraClassNames: cell.extraClassNames, moreCnt: moreCnts[col], buildMoreLinkText: props.buildMoreLinkText, onMoreClick: props.onMoreClick, segIsHidden: segIsHidden, moreMarginTop: moreTops[col] /* rename */, segsByEachCol: segsByEachCol[col], fgPaddingBottom: paddingBottoms[col], fgContentElRef: _this.fgElRefs.createRef(cell.key), fgContent: ( // Fragment scopes the keys
  11701. createElement(Fragment, null,
  11702. createElement(Fragment, null, normalFgNodes),
  11703. createElement(Fragment, null, mirrorFgNodes))), bgContent: ( // Fragment scopes the keys
  11704. createElement(Fragment, null,
  11705. _this.renderFillSegs(highlightSegsByCol[col], 'highlight'),
  11706. _this.renderFillSegs(businessHoursByCol[col], 'non-business'),
  11707. _this.renderFillSegs(bgEventSegsByCol[col], 'bg-event'))) }));
  11708. })));
  11709. };
  11710. TableRow.prototype.componentDidMount = function () {
  11711. this.updateSizing(true);
  11712. };
  11713. TableRow.prototype.componentDidUpdate = function (prevProps, prevState) {
  11714. var currentProps = this.props;
  11715. this.updateSizing(!isPropsEqual(prevProps, currentProps));
  11716. };
  11717. TableRow.prototype.getHighlightSegs = function () {
  11718. var props = this.props;
  11719. if (props.eventDrag && props.eventDrag.segs.length) { // messy check
  11720. return props.eventDrag.segs;
  11721. }
  11722. else if (props.eventResize && props.eventResize.segs.length) { // messy check
  11723. return props.eventResize.segs;
  11724. }
  11725. else {
  11726. return props.dateSelectionSegs;
  11727. }
  11728. };
  11729. TableRow.prototype.getMirrorSegs = function () {
  11730. var props = this.props;
  11731. if (props.eventResize && props.eventResize.segs.length) { // messy check
  11732. return props.eventResize.segs;
  11733. }
  11734. else {
  11735. return [];
  11736. }
  11737. };
  11738. TableRow.prototype.renderFgSegs = function (segs, segIsHidden, // does NOT mean display:hidden
  11739. segTops, segMarginTops, selectedInstanceHash, todayRange, isDragging, isResizing, isDateSelecting) {
  11740. var context = this.context;
  11741. var eventSelection = this.props.eventSelection;
  11742. var framePositions = this.state.framePositions;
  11743. var defaultDisplayEventEnd = this.props.cells.length === 1; // colCnt === 1
  11744. var nodes = [];
  11745. if (framePositions) {
  11746. for (var _i = 0, segs_1 = segs; _i < segs_1.length; _i++) {
  11747. var seg = segs_1[_i];
  11748. var instanceId = seg.eventRange.instance.instanceId;
  11749. var isMirror = isDragging || isResizing || isDateSelecting;
  11750. var isSelected = selectedInstanceHash[instanceId];
  11751. var isInvisible = segIsHidden[instanceId] || isSelected;
  11752. var isAbsolute = segIsHidden[instanceId] || isMirror || seg.firstCol !== seg.lastCol || !seg.isStart || !seg.isEnd; // TODO: simpler way? NOT DRY
  11753. var marginTop = void 0;
  11754. var top_1 = void 0;
  11755. var left = void 0;
  11756. var right = void 0;
  11757. if (isAbsolute) {
  11758. top_1 = segTops[instanceId];
  11759. if (context.isRtl) {
  11760. right = 0;
  11761. left = framePositions.lefts[seg.lastCol] - framePositions.lefts[seg.firstCol];
  11762. }
  11763. else {
  11764. left = 0;
  11765. right = framePositions.rights[seg.firstCol] - framePositions.rights[seg.lastCol];
  11766. }
  11767. }
  11768. else {
  11769. marginTop = segMarginTops[instanceId];
  11770. }
  11771. /*
  11772. known bug: events that are force to be list-item but span multiple days still take up space in later columns
  11773. */
  11774. nodes.push(createElement("div", { className: 'fc-daygrid-event-harness' + (isAbsolute ? ' fc-daygrid-event-harness-abs' : ''), key: instanceId, ref: isMirror ? null : this.segHarnessRefs.createRef(instanceId + ':' + seg.firstCol) /* in print mode when in mult cols, could collide */, style: {
  11775. visibility: isInvisible ? 'hidden' : '',
  11776. marginTop: marginTop || '',
  11777. top: top_1 || '',
  11778. left: left || '',
  11779. right: right || ''
  11780. } }, hasListItemDisplay(seg) ?
  11781. createElement(TableListItemEvent, __assign({ seg: seg, isDragging: isDragging, isSelected: instanceId === eventSelection, defaultDisplayEventEnd: defaultDisplayEventEnd }, getSegMeta(seg, todayRange))) :
  11782. createElement(TableBlockEvent, __assign({ seg: seg, isDragging: isDragging, isResizing: isResizing, isDateSelecting: isDateSelecting, isSelected: instanceId === eventSelection, defaultDisplayEventEnd: defaultDisplayEventEnd }, getSegMeta(seg, todayRange)))));
  11783. }
  11784. }
  11785. return nodes;
  11786. };
  11787. TableRow.prototype.renderFillSegs = function (segs, fillType) {
  11788. var isRtl = this.context.isRtl;
  11789. var todayRange = this.props.todayRange;
  11790. var framePositions = this.state.framePositions;
  11791. var nodes = [];
  11792. if (framePositions) {
  11793. for (var _i = 0, segs_2 = segs; _i < segs_2.length; _i++) {
  11794. var seg = segs_2[_i];
  11795. var leftRightCss = isRtl ? {
  11796. right: 0,
  11797. left: framePositions.lefts[seg.lastCol] - framePositions.lefts[seg.firstCol]
  11798. } : {
  11799. left: 0,
  11800. right: framePositions.rights[seg.firstCol] - framePositions.rights[seg.lastCol],
  11801. };
  11802. nodes.push(createElement("div", { key: buildEventRangeKey(seg.eventRange), className: 'fc-daygrid-bg-harness', style: leftRightCss }, fillType === 'bg-event' ?
  11803. createElement(BgEvent, __assign({ seg: seg }, getSegMeta(seg, todayRange))) :
  11804. renderFill(fillType)));
  11805. }
  11806. }
  11807. return createElement.apply(void 0, __spreadArrays([Fragment, {}], nodes));
  11808. };
  11809. TableRow.prototype.updateSizing = function (isExternalSizingChange) {
  11810. var _a = this, props = _a.props, frameElRefs = _a.frameElRefs;
  11811. if (props.clientWidth !== null) { // positioning ready?
  11812. if (isExternalSizingChange) {
  11813. var frameEls = props.cells.map(function (cell) { return frameElRefs.currentMap[cell.key]; });
  11814. if (frameEls.length) {
  11815. var originEl = this.rootElRef.current;
  11816. this.setState({
  11817. framePositions: new PositionCache(originEl, frameEls, true, // isHorizontal
  11818. false)
  11819. });
  11820. }
  11821. }
  11822. var limitByContentHeight = props.dayMaxEvents === true || props.dayMaxEventRows === true;
  11823. this.setState({
  11824. segHeights: this.computeSegHeights(),
  11825. maxContentHeight: limitByContentHeight ? this.computeMaxContentHeight() : null
  11826. });
  11827. }
  11828. };
  11829. TableRow.prototype.computeSegHeights = function () {
  11830. return mapHash(this.segHarnessRefs.currentMap, function (eventHarnessEl) { return (eventHarnessEl.getBoundingClientRect().height); });
  11831. };
  11832. TableRow.prototype.computeMaxContentHeight = function () {
  11833. var firstKey = this.props.cells[0].key;
  11834. var cellEl = this.cellElRefs.currentMap[firstKey];
  11835. var fcContainerEl = this.fgElRefs.currentMap[firstKey];
  11836. return cellEl.getBoundingClientRect().bottom - fcContainerEl.getBoundingClientRect().top;
  11837. };
  11838. TableRow.prototype.getCellEls = function () {
  11839. var elMap = this.cellElRefs.currentMap;
  11840. return this.props.cells.map(function (cell) { return elMap[cell.key]; });
  11841. };
  11842. return TableRow;
  11843. }(DateComponent));
  11844. TableRow.addStateEquality({
  11845. segHeights: isPropsEqual
  11846. });
  11847. var PADDING_FROM_VIEWPORT = 10;
  11848. var SCROLL_DEBOUNCE = 10;
  11849. var Popover = /** @class */ (function (_super) {
  11850. __extends(Popover, _super);
  11851. function Popover() {
  11852. var _this = _super !== null && _super.apply(this, arguments) || this;
  11853. _this.repositioner = new DelayedRunner(_this.updateSize.bind(_this));
  11854. _this.handleRootEl = function (el) {
  11855. _this.rootEl = el;
  11856. if (_this.props.elRef) {
  11857. setRef(_this.props.elRef, el);
  11858. }
  11859. };
  11860. // Triggered when the user clicks *anywhere* in the document, for the autoHide feature
  11861. _this.handleDocumentMousedown = function (ev) {
  11862. var onClose = _this.props.onClose;
  11863. // only hide the popover if the click happened outside the popover
  11864. if (onClose && !_this.rootEl.contains(ev.target)) {
  11865. onClose();
  11866. }
  11867. };
  11868. _this.handleDocumentScroll = function () {
  11869. _this.repositioner.request(SCROLL_DEBOUNCE);
  11870. };
  11871. _this.handleCloseClick = function () {
  11872. var onClose = _this.props.onClose;
  11873. if (onClose) {
  11874. onClose();
  11875. }
  11876. };
  11877. return _this;
  11878. }
  11879. Popover.prototype.render = function () {
  11880. var theme = this.context.theme;
  11881. var props = this.props;
  11882. var classNames = [
  11883. 'fc-popover',
  11884. theme.getClass('popover')
  11885. ].concat(props.extraClassNames || []);
  11886. return (createElement("div", __assign({ className: classNames.join(' ') }, props.extraAttrs, { ref: this.handleRootEl }),
  11887. createElement("div", { className: 'fc-popover-header ' + theme.getClass('popoverHeader') },
  11888. createElement("span", { className: 'fc-popover-title' }, props.title),
  11889. createElement("span", { className: 'fc-popover-close ' + theme.getIconClass('close'), onClick: this.handleCloseClick })),
  11890. createElement("div", { className: 'fc-popover-body ' + theme.getClass('popoverContent') }, props.children)));
  11891. };
  11892. Popover.prototype.componentDidMount = function () {
  11893. document.addEventListener('mousedown', this.handleDocumentMousedown);
  11894. document.addEventListener('scroll', this.handleDocumentScroll);
  11895. this.updateSize();
  11896. };
  11897. Popover.prototype.componentWillUnmount = function () {
  11898. document.removeEventListener('mousedown', this.handleDocumentMousedown);
  11899. document.removeEventListener('scroll', this.handleDocumentScroll);
  11900. };
  11901. // TODO: adjust on window resize
  11902. /*
  11903. NOTE: the popover is position:fixed, so coordinates are relative to the viewport
  11904. NOTE: the PARENT calls this as well, on window resize. we would have wanted to use the repositioner,
  11905. but need to ensure that all other components have updated size first (for alignmentEl)
  11906. */
  11907. Popover.prototype.updateSize = function () {
  11908. var _a = this.props, alignmentEl = _a.alignmentEl, topAlignmentEl = _a.topAlignmentEl;
  11909. var rootEl = this.rootEl;
  11910. if (!rootEl) {
  11911. return; // not sure why this was null, but we shouldn't let external components call updateSize() anyway
  11912. }
  11913. var dims = rootEl.getBoundingClientRect(); // only used for width,height
  11914. var alignment = alignmentEl.getBoundingClientRect();
  11915. var top = topAlignmentEl ? topAlignmentEl.getBoundingClientRect().top : alignment.top;
  11916. top = Math.min(top, window.innerHeight - dims.height - PADDING_FROM_VIEWPORT);
  11917. top = Math.max(top, PADDING_FROM_VIEWPORT);
  11918. var left;
  11919. if (this.context.isRtl) {
  11920. left = alignment.right - dims.width;
  11921. }
  11922. else {
  11923. left = alignment.left;
  11924. }
  11925. left = Math.min(left, window.innerWidth - dims.width - PADDING_FROM_VIEWPORT);
  11926. left = Math.max(left, PADDING_FROM_VIEWPORT);
  11927. applyStyle(rootEl, { top: top, left: left });
  11928. };
  11929. return Popover;
  11930. }(BaseComponent));
  11931. var MorePopover = /** @class */ (function (_super) {
  11932. __extends(MorePopover, _super);
  11933. function MorePopover() {
  11934. var _this = _super !== null && _super.apply(this, arguments) || this;
  11935. _this.handlePopoverEl = function (popoverEl) {
  11936. _this.popoverEl = popoverEl;
  11937. if (popoverEl) {
  11938. _this.context.registerInteractiveComponent(_this, {
  11939. el: popoverEl,
  11940. useEventCenter: false
  11941. });
  11942. }
  11943. else {
  11944. _this.context.unregisterInteractiveComponent(_this);
  11945. }
  11946. };
  11947. return _this;
  11948. }
  11949. MorePopover.prototype.render = function () {
  11950. var _a = this.context, options = _a.options, dateEnv = _a.dateEnv;
  11951. var props = this.props;
  11952. var date = props.date, hiddenInstances = props.hiddenInstances, todayRange = props.todayRange, dateProfile = props.dateProfile, selectedInstanceId = props.selectedInstanceId;
  11953. var title = dateEnv.format(date, options.dayPopoverFormat);
  11954. return (createElement(DayCellRoot, { date: date, dateProfile: dateProfile, todayRange: todayRange, elRef: this.handlePopoverEl }, function (rootElRef, dayClassNames, dataAttrs) { return (createElement(Popover, { elRef: rootElRef, title: title, extraClassNames: ['fc-more-popover'].concat(dayClassNames), extraAttrs: dataAttrs, onClose: props.onCloseClick, alignmentEl: props.alignmentEl, topAlignmentEl: props.topAlignmentEl },
  11955. createElement(DayCellContent, { date: date, dateProfile: dateProfile, todayRange: todayRange }, function (innerElRef, innerContent) { return (innerContent &&
  11956. createElement("div", { className: 'fc-more-popover-misc', ref: innerElRef }, innerContent)); }),
  11957. props.segs.map(function (seg) {
  11958. var instanceId = seg.eventRange.instance.instanceId;
  11959. return (createElement("div", { className: 'fc-daygrid-event-harness', key: instanceId, style: {
  11960. visibility: hiddenInstances[instanceId] ? 'hidden' : ''
  11961. } }, hasListItemDisplay(seg) ?
  11962. createElement(TableListItemEvent, __assign({ seg: seg, isDragging: false, isSelected: instanceId === selectedInstanceId, defaultDisplayEventEnd: false }, getSegMeta(seg, todayRange))) :
  11963. createElement(TableBlockEvent, __assign({ seg: seg, isDragging: false, isResizing: false, isDateSelecting: false, isSelected: instanceId === selectedInstanceId, defaultDisplayEventEnd: false }, getSegMeta(seg, todayRange)))));
  11964. }))); }));
  11965. };
  11966. MorePopover.prototype.queryHit = function (positionLeft, positionTop, elWidth, elHeight) {
  11967. var date = this.props.date;
  11968. if (positionLeft < elWidth && positionTop < elHeight) {
  11969. return {
  11970. component: this,
  11971. dateSpan: {
  11972. allDay: true,
  11973. range: { start: date, end: addDays(date, 1) }
  11974. },
  11975. dayEl: this.popoverEl,
  11976. rect: {
  11977. left: 0,
  11978. top: 0,
  11979. right: elWidth,
  11980. bottom: elHeight
  11981. },
  11982. layer: 1
  11983. };
  11984. }
  11985. };
  11986. MorePopover.prototype.isPopover = function () {
  11987. return true; // gross
  11988. };
  11989. return MorePopover;
  11990. }(DateComponent));
  11991. var Table = /** @class */ (function (_super) {
  11992. __extends(Table, _super);
  11993. function Table() {
  11994. var _this = _super !== null && _super.apply(this, arguments) || this;
  11995. _this.splitBusinessHourSegs = memoize(splitSegsByRow);
  11996. _this.splitBgEventSegs = memoize(splitSegsByRow);
  11997. _this.splitFgEventSegs = memoize(splitSegsByRow);
  11998. _this.splitDateSelectionSegs = memoize(splitSegsByRow);
  11999. _this.splitEventDrag = memoize(splitInteractionByRow);
  12000. _this.splitEventResize = memoize(splitInteractionByRow);
  12001. _this.buildBuildMoreLinkText = memoize(buildBuildMoreLinkText);
  12002. _this.rowRefs = new RefMap();
  12003. _this.state = {
  12004. morePopoverState: null
  12005. };
  12006. _this.handleRootEl = function (rootEl) {
  12007. _this.rootEl = rootEl;
  12008. setRef(_this.props.elRef, rootEl);
  12009. };
  12010. _this.handleMoreLinkClick = function (arg) {
  12011. var context = _this.context;
  12012. var dateEnv = context.dateEnv;
  12013. var clickOption = context.options.moreLinkClick;
  12014. function segForPublic(seg) {
  12015. var _a = seg.eventRange, def = _a.def, instance = _a.instance, range = _a.range;
  12016. return {
  12017. event: new EventApi(context, def, instance),
  12018. start: dateEnv.toDate(range.start),
  12019. end: dateEnv.toDate(range.end),
  12020. isStart: seg.isStart,
  12021. isEnd: seg.isEnd
  12022. };
  12023. }
  12024. if (typeof clickOption === 'function') {
  12025. clickOption = clickOption({
  12026. date: dateEnv.toDate(arg.date),
  12027. allDay: true,
  12028. allSegs: arg.allSegs.map(segForPublic),
  12029. hiddenSegs: arg.hiddenSegs.map(segForPublic),
  12030. jsEvent: arg.ev,
  12031. view: context.viewApi
  12032. }); // hack to handle void
  12033. }
  12034. if (!clickOption || clickOption === 'popover') {
  12035. _this.setState({
  12036. morePopoverState: __assign(__assign({}, arg), { currentFgEventSegs: _this.props.fgEventSegs })
  12037. });
  12038. }
  12039. else if (typeof clickOption === 'string') { // a view name
  12040. context.calendarApi.zoomTo(arg.date, clickOption);
  12041. }
  12042. };
  12043. _this.handleMorePopoverClose = function () {
  12044. _this.setState({
  12045. morePopoverState: null
  12046. });
  12047. };
  12048. return _this;
  12049. }
  12050. Table.prototype.render = function () {
  12051. var _this = this;
  12052. var props = this.props;
  12053. var dateProfile = props.dateProfile, dayMaxEventRows = props.dayMaxEventRows, dayMaxEvents = props.dayMaxEvents, expandRows = props.expandRows;
  12054. var morePopoverState = this.state.morePopoverState;
  12055. var rowCnt = props.cells.length;
  12056. var businessHourSegsByRow = this.splitBusinessHourSegs(props.businessHourSegs, rowCnt);
  12057. var bgEventSegsByRow = this.splitBgEventSegs(props.bgEventSegs, rowCnt);
  12058. var fgEventSegsByRow = this.splitFgEventSegs(props.fgEventSegs, rowCnt);
  12059. var dateSelectionSegsByRow = this.splitDateSelectionSegs(props.dateSelectionSegs, rowCnt);
  12060. var eventDragByRow = this.splitEventDrag(props.eventDrag, rowCnt);
  12061. var eventResizeByRow = this.splitEventResize(props.eventResize, rowCnt);
  12062. var buildMoreLinkText = this.buildBuildMoreLinkText(this.context.options.moreLinkText);
  12063. var limitViaBalanced = dayMaxEvents === true || dayMaxEventRows === true;
  12064. // if rows can't expand to fill fixed height, can't do balanced-height event limit
  12065. // TODO: best place to normalize these options?
  12066. if (limitViaBalanced && !expandRows) {
  12067. limitViaBalanced = false;
  12068. dayMaxEventRows = null;
  12069. dayMaxEvents = null;
  12070. }
  12071. var classNames = [
  12072. 'fc-daygrid-body',
  12073. limitViaBalanced ? 'fc-daygrid-body-balanced' : 'fc-daygrid-body-unbalanced',
  12074. expandRows ? '' : 'fc-daygrid-body-natural' // will height of one row depend on the others?
  12075. ];
  12076. return (createElement("div", { className: classNames.join(' '), ref: this.handleRootEl, style: {
  12077. // these props are important to give this wrapper correct dimensions for interactions
  12078. // TODO: if we set it here, can we avoid giving to inner tables?
  12079. width: props.clientWidth,
  12080. minWidth: props.tableMinWidth
  12081. } },
  12082. createElement(NowTimer, { unit: 'day' }, function (nowDate, todayRange) { return (createElement(Fragment, null,
  12083. createElement("table", { className: 'fc-scrollgrid-sync-table', style: {
  12084. width: props.clientWidth,
  12085. minWidth: props.tableMinWidth,
  12086. height: expandRows ? props.clientHeight : ''
  12087. } },
  12088. props.colGroupNode,
  12089. createElement("tbody", null, props.cells.map(function (cells, row) { return (createElement(TableRow, { ref: _this.rowRefs.createRef(row), key: cells.length
  12090. ? cells[0].date.toISOString() /* best? or put key on cell? or use diff formatter? */
  12091. : row // in case there are no cells (like when resource view is loading)
  12092. , showDayNumbers: rowCnt > 1, showWeekNumbers: props.showWeekNumbers, todayRange: todayRange, dateProfile: dateProfile, cells: cells, renderIntro: props.renderRowIntro, businessHourSegs: businessHourSegsByRow[row], eventSelection: props.eventSelection, bgEventSegs: bgEventSegsByRow[row].filter(isSegAllDay) /* hack */, fgEventSegs: fgEventSegsByRow[row], dateSelectionSegs: dateSelectionSegsByRow[row], eventDrag: eventDragByRow[row], eventResize: eventResizeByRow[row], dayMaxEvents: dayMaxEvents, dayMaxEventRows: dayMaxEventRows, clientWidth: props.clientWidth, clientHeight: props.clientHeight, buildMoreLinkText: buildMoreLinkText, onMoreClick: _this.handleMoreLinkClick })); }))),
  12093. (!props.forPrint && morePopoverState && morePopoverState.currentFgEventSegs === props.fgEventSegs) && // clear popover on event mod
  12094. createElement(MorePopover, { date: morePopoverState.date, dateProfile: dateProfile, segs: morePopoverState.allSegs, alignmentEl: morePopoverState.dayEl, topAlignmentEl: rowCnt === 1 ? props.headerAlignElRef.current : null, onCloseClick: _this.handleMorePopoverClose, selectedInstanceId: props.eventSelection, hiddenInstances: // yuck
  12095. (props.eventDrag ? props.eventDrag.affectedInstances : null) ||
  12096. (props.eventResize ? props.eventResize.affectedInstances : null) ||
  12097. {}, todayRange: todayRange }))); })));
  12098. };
  12099. // Hit System
  12100. // ----------------------------------------------------------------------------------------------------
  12101. Table.prototype.prepareHits = function () {
  12102. this.rowPositions = new PositionCache(this.rootEl, this.rowRefs.collect().map(function (rowObj) { return rowObj.getCellEls()[0]; }), // first cell el in each row. TODO: not optimal
  12103. false, true // vertical
  12104. );
  12105. this.colPositions = new PositionCache(this.rootEl, this.rowRefs.currentMap[0].getCellEls(), // cell els in first row
  12106. true, // horizontal
  12107. false);
  12108. };
  12109. Table.prototype.positionToHit = function (leftPosition, topPosition) {
  12110. var _a = this, colPositions = _a.colPositions, rowPositions = _a.rowPositions;
  12111. var col = colPositions.leftToIndex(leftPosition);
  12112. var row = rowPositions.topToIndex(topPosition);
  12113. if (row != null && col != null) {
  12114. return {
  12115. row: row,
  12116. col: col,
  12117. dateSpan: {
  12118. range: this.getCellRange(row, col),
  12119. allDay: true
  12120. },
  12121. dayEl: this.getCellEl(row, col),
  12122. relativeRect: {
  12123. left: colPositions.lefts[col],
  12124. right: colPositions.rights[col],
  12125. top: rowPositions.tops[row],
  12126. bottom: rowPositions.bottoms[row]
  12127. }
  12128. };
  12129. }
  12130. };
  12131. Table.prototype.getCellEl = function (row, col) {
  12132. return this.rowRefs.currentMap[row].getCellEls()[col]; // TODO: not optimal
  12133. };
  12134. Table.prototype.getCellRange = function (row, col) {
  12135. var start = this.props.cells[row][col].date;
  12136. var end = addDays(start, 1);
  12137. return { start: start, end: end };
  12138. };
  12139. return Table;
  12140. }(DateComponent));
  12141. function buildBuildMoreLinkText(moreLinkTextInput) {
  12142. if (typeof moreLinkTextInput === 'function') {
  12143. return moreLinkTextInput;
  12144. }
  12145. else {
  12146. return function (num) {
  12147. return "+" + num + " " + moreLinkTextInput;
  12148. };
  12149. }
  12150. }
  12151. function isSegAllDay(seg) {
  12152. return seg.eventRange.def.allDay;
  12153. }
  12154. var DayTable = /** @class */ (function (_super) {
  12155. __extends(DayTable, _super);
  12156. function DayTable() {
  12157. var _this = _super !== null && _super.apply(this, arguments) || this;
  12158. _this.slicer = new DayTableSlicer();
  12159. _this.tableRef = createRef();
  12160. _this.handleRootEl = function (rootEl) {
  12161. if (rootEl) {
  12162. _this.context.registerInteractiveComponent(_this, { el: rootEl });
  12163. }
  12164. else {
  12165. _this.context.unregisterInteractiveComponent(_this);
  12166. }
  12167. };
  12168. return _this;
  12169. }
  12170. DayTable.prototype.render = function () {
  12171. var _a = this, props = _a.props, context = _a.context;
  12172. return (createElement(Table, __assign({ ref: this.tableRef, elRef: this.handleRootEl }, this.slicer.sliceProps(props, props.dateProfile, props.nextDayThreshold, context, props.dayTableModel), { dateProfile: props.dateProfile, cells: props.dayTableModel.cells, colGroupNode: props.colGroupNode, tableMinWidth: props.tableMinWidth, renderRowIntro: props.renderRowIntro, dayMaxEvents: props.dayMaxEvents, dayMaxEventRows: props.dayMaxEventRows, showWeekNumbers: props.showWeekNumbers, expandRows: props.expandRows, headerAlignElRef: props.headerAlignElRef, clientWidth: props.clientWidth, clientHeight: props.clientHeight, forPrint: props.forPrint })));
  12173. };
  12174. DayTable.prototype.prepareHits = function () {
  12175. this.tableRef.current.prepareHits();
  12176. };
  12177. DayTable.prototype.queryHit = function (positionLeft, positionTop) {
  12178. var rawHit = this.tableRef.current.positionToHit(positionLeft, positionTop);
  12179. if (rawHit) {
  12180. return {
  12181. component: this,
  12182. dateSpan: rawHit.dateSpan,
  12183. dayEl: rawHit.dayEl,
  12184. rect: {
  12185. left: rawHit.relativeRect.left,
  12186. right: rawHit.relativeRect.right,
  12187. top: rawHit.relativeRect.top,
  12188. bottom: rawHit.relativeRect.bottom
  12189. },
  12190. layer: 0
  12191. };
  12192. }
  12193. };
  12194. return DayTable;
  12195. }(DateComponent));
  12196. var DayTableSlicer = /** @class */ (function (_super) {
  12197. __extends(DayTableSlicer, _super);
  12198. function DayTableSlicer() {
  12199. var _this = _super !== null && _super.apply(this, arguments) || this;
  12200. _this.forceDayIfListItem = true;
  12201. return _this;
  12202. }
  12203. DayTableSlicer.prototype.sliceRange = function (dateRange, dayTableModel) {
  12204. return dayTableModel.sliceRange(dateRange);
  12205. };
  12206. return DayTableSlicer;
  12207. }(Slicer));
  12208. var DayTableView = /** @class */ (function (_super) {
  12209. __extends(DayTableView, _super);
  12210. function DayTableView() {
  12211. var _this = _super !== null && _super.apply(this, arguments) || this;
  12212. _this.buildDayTableModel = memoize(buildDayTableModel);
  12213. _this.headerRef = createRef();
  12214. _this.tableRef = createRef();
  12215. return _this;
  12216. }
  12217. DayTableView.prototype.render = function () {
  12218. var _this = this;
  12219. var _a = this.context, options = _a.options, dateProfileGenerator = _a.dateProfileGenerator;
  12220. var props = this.props;
  12221. var dayTableModel = this.buildDayTableModel(props.dateProfile, dateProfileGenerator);
  12222. var headerContent = options.dayHeaders &&
  12223. createElement(DayHeader, { ref: this.headerRef, dateProfile: props.dateProfile, dates: dayTableModel.headerDates, datesRepDistinctDays: dayTableModel.rowCnt === 1 });
  12224. var bodyContent = function (contentArg) { return (createElement(DayTable, { ref: _this.tableRef, dateProfile: props.dateProfile, dayTableModel: dayTableModel, businessHours: props.businessHours, dateSelection: props.dateSelection, eventStore: props.eventStore, eventUiBases: props.eventUiBases, eventSelection: props.eventSelection, eventDrag: props.eventDrag, eventResize: props.eventResize, nextDayThreshold: options.nextDayThreshold, colGroupNode: contentArg.tableColGroupNode, tableMinWidth: contentArg.tableMinWidth, dayMaxEvents: options.dayMaxEvents, dayMaxEventRows: options.dayMaxEventRows, showWeekNumbers: options.weekNumbers, expandRows: !props.isHeightAuto, headerAlignElRef: _this.headerElRef, clientWidth: contentArg.clientWidth, clientHeight: contentArg.clientHeight, forPrint: props.forPrint })); };
  12225. return options.dayMinWidth
  12226. ? this.renderHScrollLayout(headerContent, bodyContent, dayTableModel.colCnt, options.dayMinWidth)
  12227. : this.renderSimpleLayout(headerContent, bodyContent);
  12228. };
  12229. return DayTableView;
  12230. }(TableView));
  12231. function buildDayTableModel(dateProfile, dateProfileGenerator) {
  12232. var daySeries = new DaySeriesModel(dateProfile.renderRange, dateProfileGenerator);
  12233. return new DayTableModel(daySeries, /year|month|week/.test(dateProfile.currentRangeUnit));
  12234. }
  12235. var TableDateProfileGenerator = /** @class */ (function (_super) {
  12236. __extends(TableDateProfileGenerator, _super);
  12237. function TableDateProfileGenerator() {
  12238. return _super !== null && _super.apply(this, arguments) || this;
  12239. }
  12240. // Computes the date range that will be rendered.
  12241. TableDateProfileGenerator.prototype.buildRenderRange = function (currentRange, currentRangeUnit, isRangeAllDay) {
  12242. var dateEnv = this.props.dateEnv;
  12243. var renderRange = _super.prototype.buildRenderRange.call(this, currentRange, currentRangeUnit, isRangeAllDay);
  12244. var start = renderRange.start;
  12245. var end = renderRange.end;
  12246. var endOfWeek;
  12247. // year and month views should be aligned with weeks. this is already done for week
  12248. if (/^(year|month)$/.test(currentRangeUnit)) {
  12249. start = dateEnv.startOfWeek(start);
  12250. // make end-of-week if not already
  12251. endOfWeek = dateEnv.startOfWeek(end);
  12252. if (endOfWeek.valueOf() !== end.valueOf()) {
  12253. end = addWeeks(endOfWeek, 1);
  12254. }
  12255. }
  12256. // ensure 6 weeks
  12257. if (this.props.monthMode &&
  12258. this.props.fixedWeekCount) {
  12259. var rowCnt = Math.ceil(// could be partial weeks due to hiddenDays
  12260. diffWeeks(start, end));
  12261. end = addWeeks(end, 6 - rowCnt);
  12262. }
  12263. return { start: start, end: end };
  12264. };
  12265. return TableDateProfileGenerator;
  12266. }(DateProfileGenerator));
  12267. var OPTION_REFINERS = {
  12268. moreLinkClick: identity,
  12269. moreLinkClassNames: identity,
  12270. moreLinkContent: identity,
  12271. moreLinkDidMount: identity,
  12272. moreLinkWillUnmount: identity,
  12273. };
  12274. var dayGridPlugin = createPlugin({
  12275. initialView: 'dayGridMonth',
  12276. optionRefiners: OPTION_REFINERS,
  12277. views: {
  12278. dayGrid: {
  12279. component: DayTableView,
  12280. dateProfileGeneratorClass: TableDateProfileGenerator
  12281. },
  12282. dayGridDay: {
  12283. type: 'dayGrid',
  12284. duration: { days: 1 }
  12285. },
  12286. dayGridWeek: {
  12287. type: 'dayGrid',
  12288. duration: { weeks: 1 }
  12289. },
  12290. dayGridMonth: {
  12291. type: 'dayGrid',
  12292. duration: { months: 1 },
  12293. monthMode: true,
  12294. fixedWeekCount: true
  12295. }
  12296. }
  12297. });
  12298. var AllDaySplitter = /** @class */ (function (_super) {
  12299. __extends(AllDaySplitter, _super);
  12300. function AllDaySplitter() {
  12301. return _super !== null && _super.apply(this, arguments) || this;
  12302. }
  12303. AllDaySplitter.prototype.getKeyInfo = function () {
  12304. return {
  12305. allDay: {},
  12306. timed: {}
  12307. };
  12308. };
  12309. AllDaySplitter.prototype.getKeysForDateSpan = function (dateSpan) {
  12310. if (dateSpan.allDay) {
  12311. return ['allDay'];
  12312. }
  12313. else {
  12314. return ['timed'];
  12315. }
  12316. };
  12317. AllDaySplitter.prototype.getKeysForEventDef = function (eventDef) {
  12318. if (!eventDef.allDay) {
  12319. return ['timed'];
  12320. }
  12321. else if (hasBgRendering(eventDef)) {
  12322. return ['timed', 'allDay'];
  12323. }
  12324. else {
  12325. return ['allDay'];
  12326. }
  12327. };
  12328. return AllDaySplitter;
  12329. }(Splitter));
  12330. var TimeColsSlatsCoords = /** @class */ (function () {
  12331. function TimeColsSlatsCoords(positions, dateProfile, slatMetas) {
  12332. this.positions = positions;
  12333. this.dateProfile = dateProfile;
  12334. this.slatMetas = slatMetas;
  12335. }
  12336. TimeColsSlatsCoords.prototype.safeComputeTop = function (date) {
  12337. var dateProfile = this.dateProfile;
  12338. if (rangeContainsMarker(dateProfile.currentRange, date)) {
  12339. var startOfDayDate = startOfDay(date);
  12340. var timeMs = date.valueOf() - startOfDayDate.valueOf();
  12341. if (timeMs >= asRoughMs(dateProfile.slotMinTime) &&
  12342. timeMs < asRoughMs(dateProfile.slotMaxTime)) {
  12343. return this.computeTimeTop(createDuration(timeMs));
  12344. }
  12345. }
  12346. };
  12347. // Computes the top coordinate, relative to the bounds of the grid, of the given date.
  12348. // A `startOfDayDate` must be given for avoiding ambiguity over how to treat midnight.
  12349. TimeColsSlatsCoords.prototype.computeDateTop = function (when, startOfDayDate) {
  12350. if (!startOfDayDate) {
  12351. startOfDayDate = startOfDay(when);
  12352. }
  12353. return this.computeTimeTop(createDuration(when.valueOf() - startOfDayDate.valueOf()));
  12354. };
  12355. // Computes the top coordinate, relative to the bounds of the grid, of the given time (a Duration).
  12356. // This is a makeshify way to compute the time-top. Assumes all slatMetas dates are uniform.
  12357. // Eventually allow computation with arbirary slat dates.
  12358. TimeColsSlatsCoords.prototype.computeTimeTop = function (duration) {
  12359. var _a = this, positions = _a.positions, dateProfile = _a.dateProfile, slatMetas = _a.slatMetas;
  12360. var len = positions.els.length;
  12361. var slotDurationMs = slatMetas[1].date.valueOf() - slatMetas[0].date.valueOf(); // we assume dates are uniform
  12362. var slatCoverage = (duration.milliseconds - asRoughMs(dateProfile.slotMinTime)) / slotDurationMs; // floating-point value of # of slots covered
  12363. var slatIndex;
  12364. var slatRemainder;
  12365. // compute a floating-point number for how many slats should be progressed through.
  12366. // from 0 to number of slats (inclusive)
  12367. // constrained because slotMinTime/slotMaxTime might be customized.
  12368. slatCoverage = Math.max(0, slatCoverage);
  12369. slatCoverage = Math.min(len, slatCoverage);
  12370. // an integer index of the furthest whole slat
  12371. // from 0 to number slats (*exclusive*, so len-1)
  12372. slatIndex = Math.floor(slatCoverage);
  12373. slatIndex = Math.min(slatIndex, len - 1);
  12374. // how much further through the slatIndex slat (from 0.0-1.0) must be covered in addition.
  12375. // could be 1.0 if slatCoverage is covering *all* the slots
  12376. slatRemainder = slatCoverage - slatIndex;
  12377. return positions.tops[slatIndex] +
  12378. positions.getHeight(slatIndex) * slatRemainder;
  12379. };
  12380. return TimeColsSlatsCoords;
  12381. }());
  12382. // potential nice values for the slot-duration and interval-duration
  12383. // from largest to smallest
  12384. var STOCK_SUB_DURATIONS = [
  12385. { hours: 1 },
  12386. { minutes: 30 },
  12387. { minutes: 15 },
  12388. { seconds: 30 },
  12389. { seconds: 15 }
  12390. ];
  12391. /*
  12392. for the horizontal "slats" that run width-wise. Has a time axis on a side. Depends on RTL.
  12393. */
  12394. var TimeColsSlats = /** @class */ (function (_super) {
  12395. __extends(TimeColsSlats, _super);
  12396. function TimeColsSlats() {
  12397. var _this = _super !== null && _super.apply(this, arguments) || this;
  12398. _this.rootElRef = createRef();
  12399. _this.slatElRefs = new RefMap();
  12400. return _this;
  12401. }
  12402. TimeColsSlats.prototype.render = function () {
  12403. var _a = this, props = _a.props, context = _a.context;
  12404. return (createElement("div", { className: 'fc-timegrid-slots', ref: this.rootElRef },
  12405. createElement("table", { className: context.theme.getClass('table'), style: {
  12406. minWidth: props.tableMinWidth,
  12407. width: props.clientWidth,
  12408. height: props.minHeight
  12409. } },
  12410. props.tableColGroupNode /* relies on there only being a single <col> for the axis */,
  12411. createElement(TimeColsSlatsBody, { slatElRefs: this.slatElRefs, axis: props.axis, slatMetas: props.slatMetas }))));
  12412. };
  12413. TimeColsSlats.prototype.componentDidMount = function () {
  12414. this.updateSizing();
  12415. };
  12416. TimeColsSlats.prototype.componentDidUpdate = function () {
  12417. this.updateSizing();
  12418. };
  12419. TimeColsSlats.prototype.componentWillUnmount = function () {
  12420. if (this.props.onCoords) {
  12421. this.props.onCoords(null);
  12422. }
  12423. };
  12424. TimeColsSlats.prototype.updateSizing = function () {
  12425. var props = this.props;
  12426. if (props.onCoords &&
  12427. props.clientWidth !== null // means sizing has stabilized
  12428. ) {
  12429. var rootEl = this.rootElRef.current;
  12430. if (rootEl.offsetHeight) { // not hidden by css
  12431. props.onCoords(new TimeColsSlatsCoords(new PositionCache(this.rootElRef.current, collectSlatEls(this.slatElRefs.currentMap, props.slatMetas), false, true // vertical
  12432. ), this.props.dateProfile, props.slatMetas));
  12433. }
  12434. }
  12435. };
  12436. return TimeColsSlats;
  12437. }(BaseComponent));
  12438. function collectSlatEls(elMap, slatMetas) {
  12439. return slatMetas.map(function (slatMeta) { return elMap[slatMeta.key]; });
  12440. }
  12441. var TimeColsSlatsBody = /** @class */ (function (_super) {
  12442. __extends(TimeColsSlatsBody, _super);
  12443. function TimeColsSlatsBody() {
  12444. return _super !== null && _super.apply(this, arguments) || this;
  12445. }
  12446. TimeColsSlatsBody.prototype.render = function () {
  12447. var _a = this, props = _a.props, context = _a.context;
  12448. var options = context.options;
  12449. var slatElRefs = props.slatElRefs;
  12450. return (createElement("tbody", null, props.slatMetas.map(function (slatMeta, i) {
  12451. var hookProps = {
  12452. time: slatMeta.time,
  12453. date: context.dateEnv.toDate(slatMeta.date),
  12454. view: context.viewApi
  12455. };
  12456. var classNames = [
  12457. 'fc-timegrid-slot',
  12458. 'fc-timegrid-slot-lane',
  12459. slatMeta.isLabeled ? '' : 'fc-timegrid-slot-minor'
  12460. ];
  12461. return (createElement("tr", { key: slatMeta.key, ref: slatElRefs.createRef(slatMeta.key) },
  12462. props.axis &&
  12463. createElement(TimeColsAxisCell, __assign({}, slatMeta)),
  12464. createElement(RenderHook, { hookProps: hookProps, classNames: options.slotLaneClassNames, content: options.slotLaneContent, didMount: options.slotLaneDidMount, willUnmount: options.slotLaneWillUnmount }, function (rootElRef, customClassNames, innerElRef, innerContent) { return (createElement("td", { ref: rootElRef, className: classNames.concat(customClassNames).join(' '), "data-time": slatMeta.isoTimeStr }, innerContent)); })));
  12465. })));
  12466. };
  12467. return TimeColsSlatsBody;
  12468. }(BaseComponent));
  12469. var DEFAULT_SLAT_LABEL_FORMAT = createFormatter({
  12470. hour: 'numeric',
  12471. minute: '2-digit',
  12472. omitZeroMinute: true,
  12473. meridiem: 'short'
  12474. });
  12475. function TimeColsAxisCell(props) {
  12476. var classNames = [
  12477. 'fc-timegrid-slot',
  12478. 'fc-timegrid-slot-label',
  12479. props.isLabeled ? 'fc-scrollgrid-shrink' : 'fc-timegrid-slot-minor'
  12480. ];
  12481. return (createElement(ViewContextType.Consumer, null, function (context) {
  12482. if (!props.isLabeled) {
  12483. return (createElement("td", { className: classNames.join(' '), "data-time": props.isoTimeStr }));
  12484. }
  12485. else {
  12486. var dateEnv = context.dateEnv, options = context.options, viewApi = context.viewApi;
  12487. var labelFormat = // TODO: fully pre-parse
  12488. options.slotLabelFormat == null ? DEFAULT_SLAT_LABEL_FORMAT :
  12489. Array.isArray(options.slotLabelFormat) ? createFormatter(options.slotLabelFormat[0]) :
  12490. createFormatter(options.slotLabelFormat);
  12491. var hookProps = {
  12492. time: props.time,
  12493. date: dateEnv.toDate(props.date),
  12494. view: viewApi,
  12495. text: dateEnv.format(props.date, labelFormat)
  12496. };
  12497. return (createElement(RenderHook, { hookProps: hookProps, classNames: options.slotLabelClassNames, content: options.slotLabelContent, defaultContent: renderInnerContent$3, didMount: options.slotLabelDidMount, willUnmount: options.slotLabelWillUnmount }, function (rootElRef, customClassNames, innerElRef, innerContent) { return (createElement("td", { ref: rootElRef, className: classNames.concat(customClassNames).join(' '), "data-time": props.isoTimeStr },
  12498. createElement("div", { className: 'fc-timegrid-slot-label-frame fc-scrollgrid-shrink-frame' },
  12499. createElement("div", { className: 'fc-timegrid-slot-label-cushion fc-scrollgrid-shrink-cushion', ref: innerElRef }, innerContent)))); }));
  12500. }
  12501. }));
  12502. }
  12503. function renderInnerContent$3(props) {
  12504. return props.text;
  12505. }
  12506. function buildSlatMetas(slotMinTime, slotMaxTime, explicitLabelInterval, slotDuration, dateEnv) {
  12507. var dayStart = new Date(0);
  12508. var slatTime = slotMinTime;
  12509. var slatIterator = createDuration(0);
  12510. var labelInterval = explicitLabelInterval || computeLabelInterval(slotDuration);
  12511. var metas = [];
  12512. while (asRoughMs(slatTime) < asRoughMs(slotMaxTime)) {
  12513. var date = dateEnv.add(dayStart, slatTime);
  12514. var isLabeled = wholeDivideDurations(slatIterator, labelInterval) !== null;
  12515. metas.push({
  12516. date: date,
  12517. time: slatTime,
  12518. key: date.toISOString(),
  12519. isoTimeStr: formatIsoTimeString(date),
  12520. isLabeled: isLabeled
  12521. });
  12522. slatTime = addDurations(slatTime, slotDuration);
  12523. slatIterator = addDurations(slatIterator, slotDuration);
  12524. }
  12525. return metas;
  12526. }
  12527. // Computes an automatic value for slotLabelInterval
  12528. function computeLabelInterval(slotDuration) {
  12529. var i;
  12530. var labelInterval;
  12531. var slotsPerLabel;
  12532. // find the smallest stock label interval that results in more than one slots-per-label
  12533. for (i = STOCK_SUB_DURATIONS.length - 1; i >= 0; i--) {
  12534. labelInterval = createDuration(STOCK_SUB_DURATIONS[i]);
  12535. slotsPerLabel = wholeDivideDurations(labelInterval, slotDuration);
  12536. if (slotsPerLabel !== null && slotsPerLabel > 1) {
  12537. return labelInterval;
  12538. }
  12539. }
  12540. return slotDuration; // fall back
  12541. }
  12542. var DEFAULT_WEEK_NUM_FORMAT$1 = createFormatter({ week: 'short' });
  12543. var AUTO_ALL_DAY_MAX_EVENT_ROWS = 5;
  12544. var TimeColsView = /** @class */ (function (_super) {
  12545. __extends(TimeColsView, _super);
  12546. function TimeColsView() {
  12547. var _this = _super !== null && _super.apply(this, arguments) || this;
  12548. _this.allDaySplitter = new AllDaySplitter(); // for use by subclasses
  12549. _this.headerElRef = createRef();
  12550. _this.rootElRef = createRef();
  12551. _this.scrollerElRef = createRef();
  12552. _this.state = {
  12553. slatCoords: null
  12554. };
  12555. _this.handleScrollTopRequest = function (scrollTop) {
  12556. var scrollerEl = _this.scrollerElRef.current;
  12557. if (scrollerEl) { // TODO: not sure how this could ever be null. weirdness with the reducer
  12558. scrollerEl.scrollTop = scrollTop;
  12559. }
  12560. };
  12561. /* Header Render Methods
  12562. ------------------------------------------------------------------------------------------------------------------*/
  12563. _this.renderHeadAxis = function (frameHeight) {
  12564. if (frameHeight === void 0) { frameHeight = ''; }
  12565. var options = _this.context.options;
  12566. var dateProfile = _this.props.dateProfile;
  12567. var range = dateProfile.renderRange;
  12568. var dayCnt = diffDays(range.start, range.end);
  12569. var navLinkAttrs = (options.navLinks && dayCnt === 1) // only do in day views (to avoid doing in week views that dont need it)
  12570. ? { 'data-navlink': buildNavLinkData(range.start, 'week'), tabIndex: 0 }
  12571. : {};
  12572. if (options.weekNumbers) {
  12573. return (createElement(WeekNumberRoot, { date: range.start, defaultFormat: DEFAULT_WEEK_NUM_FORMAT$1 }, function (rootElRef, classNames, innerElRef, innerContent) { return (createElement("th", { ref: rootElRef, className: [
  12574. 'fc-timegrid-axis',
  12575. 'fc-scrollgrid-shrink'
  12576. ].concat(classNames).join(' ') },
  12577. createElement("div", { className: 'fc-timegrid-axis-frame fc-scrollgrid-shrink-frame fc-timegrid-axis-frame-liquid', style: { height: frameHeight } },
  12578. createElement("a", __assign({ ref: innerElRef, className: 'fc-timegrid-axis-cushion fc-scrollgrid-shrink-cushion' }, navLinkAttrs), innerContent)))); }));
  12579. }
  12580. return (createElement("th", { className: 'fc-timegrid-axis' },
  12581. createElement("div", { className: 'fc-timegrid-axis-frame', style: { height: frameHeight } })));
  12582. };
  12583. /* Table Component Render Methods
  12584. ------------------------------------------------------------------------------------------------------------------*/
  12585. // only a one-way height sync. we don't send the axis inner-content height to the DayGrid,
  12586. // but DayGrid still needs to have classNames on inner elements in order to measure.
  12587. _this.renderTableRowAxis = function (rowHeight) {
  12588. var _a = _this.context, options = _a.options, viewApi = _a.viewApi;
  12589. var hookProps = {
  12590. text: options.allDayText,
  12591. view: viewApi
  12592. };
  12593. return (
  12594. // TODO: make reusable hook. used in list view too
  12595. createElement(RenderHook, { hookProps: hookProps, classNames: options.allDayClassNames, content: options.allDayContent, defaultContent: renderAllDayInner, didMount: options.allDayDidMount, willUnmount: options.allDayWillUnmount }, function (rootElRef, classNames, innerElRef, innerContent) { return (createElement("td", { ref: rootElRef, className: [
  12596. 'fc-timegrid-axis',
  12597. 'fc-scrollgrid-shrink'
  12598. ].concat(classNames).join(' ') },
  12599. createElement("div", { className: 'fc-timegrid-axis-frame fc-scrollgrid-shrink-frame' + (rowHeight == null ? ' fc-timegrid-axis-frame-liquid' : ''), style: { height: rowHeight } },
  12600. createElement("span", { className: 'fc-timegrid-axis-cushion fc-scrollgrid-shrink-cushion', ref: innerElRef }, innerContent)))); }));
  12601. };
  12602. _this.handleSlatCoords = function (slatCoords) {
  12603. _this.setState({ slatCoords: slatCoords });
  12604. };
  12605. return _this;
  12606. }
  12607. // rendering
  12608. // ----------------------------------------------------------------------------------------------------
  12609. TimeColsView.prototype.renderSimpleLayout = function (headerRowContent, allDayContent, timeContent) {
  12610. var _a = this, context = _a.context, props = _a.props;
  12611. var sections = [];
  12612. var stickyHeaderDates = getStickyHeaderDates(context.options);
  12613. if (headerRowContent) {
  12614. sections.push({
  12615. type: 'header',
  12616. key: 'header',
  12617. isSticky: stickyHeaderDates,
  12618. chunk: {
  12619. elRef: this.headerElRef,
  12620. tableClassName: 'fc-col-header',
  12621. rowContent: headerRowContent
  12622. }
  12623. });
  12624. }
  12625. if (allDayContent) {
  12626. sections.push({
  12627. type: 'body',
  12628. key: 'all-day',
  12629. chunk: { content: allDayContent }
  12630. });
  12631. sections.push({
  12632. type: 'body',
  12633. key: 'all-day-divider',
  12634. outerContent: ( // TODO: rename to cellContent so don't need to define <tr>?
  12635. createElement("tr", { className: 'fc-scrollgrid-section' },
  12636. createElement("td", { className: 'fc-timegrid-divider ' + context.theme.getClass('tableCellShaded') })))
  12637. });
  12638. }
  12639. sections.push({
  12640. type: 'body',
  12641. key: 'body',
  12642. liquid: true,
  12643. expandRows: Boolean(context.options.expandRows),
  12644. chunk: {
  12645. scrollerElRef: this.scrollerElRef,
  12646. content: timeContent
  12647. }
  12648. });
  12649. return (createElement(ViewRoot, { viewSpec: context.viewSpec, elRef: this.rootElRef }, function (rootElRef, classNames) { return (createElement("div", { className: ['fc-timegrid'].concat(classNames).join(' '), ref: rootElRef },
  12650. createElement(SimpleScrollGrid, { liquid: !props.isHeightAuto && !props.forPrint, cols: [{ width: 'shrink' }], sections: sections }))); }));
  12651. };
  12652. TimeColsView.prototype.renderHScrollLayout = function (headerRowContent, allDayContent, timeContent, colCnt, dayMinWidth, slatMetas, slatCoords // yuck
  12653. ) {
  12654. var _this = this;
  12655. var ScrollGrid = this.context.pluginHooks.scrollGridImpl;
  12656. if (!ScrollGrid) {
  12657. throw new Error('No ScrollGrid implementation');
  12658. }
  12659. var _a = this, context = _a.context, props = _a.props;
  12660. var stickyHeaderDates = !props.forPrint && getStickyHeaderDates(context.options);
  12661. var stickyFooterScrollbar = !props.forPrint && getStickyFooterScrollbar(context.options);
  12662. var sections = [];
  12663. if (headerRowContent) {
  12664. sections.push({
  12665. type: 'header',
  12666. key: 'header',
  12667. isSticky: stickyHeaderDates,
  12668. syncRowHeights: true,
  12669. chunks: [
  12670. {
  12671. key: 'axis',
  12672. rowContent: function (arg) { return (createElement("tr", null, _this.renderHeadAxis(arg.rowSyncHeights[0]))); }
  12673. },
  12674. {
  12675. key: 'cols',
  12676. elRef: this.headerElRef,
  12677. tableClassName: 'fc-col-header',
  12678. rowContent: headerRowContent
  12679. }
  12680. ]
  12681. });
  12682. }
  12683. if (allDayContent) {
  12684. sections.push({
  12685. type: 'body',
  12686. key: 'all-day',
  12687. syncRowHeights: true,
  12688. chunks: [
  12689. {
  12690. key: 'axis',
  12691. rowContent: function (contentArg) { return (createElement("tr", null, _this.renderTableRowAxis(contentArg.rowSyncHeights[0]))); },
  12692. },
  12693. {
  12694. key: 'cols',
  12695. content: allDayContent
  12696. }
  12697. ]
  12698. });
  12699. sections.push({
  12700. key: 'all-day-divider',
  12701. type: 'body',
  12702. outerContent: ( // TODO: rename to cellContent so don't need to define <tr>?
  12703. createElement("tr", { className: 'fc-scrollgrid-section' },
  12704. createElement("td", { colSpan: 2, className: 'fc-timegrid-divider ' + context.theme.getClass('tableCellShaded') })))
  12705. });
  12706. }
  12707. var isNowIndicator = context.options.nowIndicator;
  12708. sections.push({
  12709. type: 'body',
  12710. key: 'body',
  12711. liquid: true,
  12712. expandRows: Boolean(context.options.expandRows),
  12713. chunks: [
  12714. {
  12715. key: 'axis',
  12716. content: function (arg) {
  12717. // TODO: make this now-indicator arrow more DRY with TimeColsContent
  12718. return (createElement("div", { className: 'fc-timegrid-axis-chunk' },
  12719. createElement("table", null,
  12720. arg.tableColGroupNode,
  12721. createElement("tbody", null,
  12722. createElement(TimeBodyAxis, { slatMetas: slatMetas }))),
  12723. createElement("div", { className: 'fc-timegrid-now-indicator-container' },
  12724. createElement(NowTimer, { unit: isNowIndicator ? 'minute' : 'day' /* hacky */ }, function (nowDate) {
  12725. var nowIndicatorTop = isNowIndicator &&
  12726. slatCoords &&
  12727. slatCoords.safeComputeTop(nowDate); // might return void
  12728. if (typeof nowIndicatorTop === 'number') {
  12729. return (createElement(NowIndicatorRoot, { isAxis: true, date: nowDate }, function (rootElRef, classNames, innerElRef, innerContent) { return (createElement("div", { ref: rootElRef, className: ['fc-timegrid-now-indicator-arrow'].concat(classNames).join(' '), style: { top: nowIndicatorTop } }, innerContent)); }));
  12730. }
  12731. }))));
  12732. }
  12733. },
  12734. {
  12735. key: 'cols',
  12736. scrollerElRef: this.scrollerElRef,
  12737. content: timeContent
  12738. }
  12739. ]
  12740. });
  12741. if (stickyFooterScrollbar) {
  12742. sections.push({
  12743. key: 'footer',
  12744. type: 'footer',
  12745. isSticky: true,
  12746. chunks: [
  12747. {
  12748. key: 'axis',
  12749. content: renderScrollShim
  12750. },
  12751. {
  12752. key: 'cols',
  12753. content: renderScrollShim
  12754. }
  12755. ]
  12756. });
  12757. }
  12758. return (createElement(ViewRoot, { viewSpec: context.viewSpec, elRef: this.rootElRef }, function (rootElRef, classNames) { return (createElement("div", { className: ['fc-timegrid'].concat(classNames).join(' '), ref: rootElRef },
  12759. createElement(ScrollGrid, { liquid: !props.isHeightAuto && !props.forPrint, colGroups: [
  12760. { width: 'shrink', cols: [{ width: 'shrink' }] },
  12761. { cols: [{ span: colCnt, minWidth: dayMinWidth }] }
  12762. ], sections: sections }))); }));
  12763. };
  12764. /* Dimensions
  12765. ------------------------------------------------------------------------------------------------------------------*/
  12766. TimeColsView.prototype.getAllDayMaxEventProps = function () {
  12767. var _a = this.context.options, dayMaxEvents = _a.dayMaxEvents, dayMaxEventRows = _a.dayMaxEventRows;
  12768. if (dayMaxEvents === true || dayMaxEventRows === true) { // is auto?
  12769. dayMaxEvents = undefined;
  12770. dayMaxEventRows = AUTO_ALL_DAY_MAX_EVENT_ROWS; // make sure "auto" goes to a real number
  12771. }
  12772. return { dayMaxEvents: dayMaxEvents, dayMaxEventRows: dayMaxEventRows };
  12773. };
  12774. return TimeColsView;
  12775. }(DateComponent));
  12776. function renderAllDayInner(hookProps) {
  12777. return hookProps.text;
  12778. }
  12779. var TimeBodyAxis = /** @class */ (function (_super) {
  12780. __extends(TimeBodyAxis, _super);
  12781. function TimeBodyAxis() {
  12782. return _super !== null && _super.apply(this, arguments) || this;
  12783. }
  12784. TimeBodyAxis.prototype.render = function () {
  12785. return this.props.slatMetas.map(function (slatMeta) { return (createElement("tr", { key: slatMeta.key },
  12786. createElement(TimeColsAxisCell, __assign({}, slatMeta)))); });
  12787. };
  12788. return TimeBodyAxis;
  12789. }(BaseComponent));
  12790. function splitSegsByCol(segs, colCnt) {
  12791. var segsByCol = [];
  12792. var i;
  12793. for (i = 0; i < colCnt; i++) {
  12794. segsByCol.push([]);
  12795. }
  12796. if (segs) {
  12797. for (i = 0; i < segs.length; i++) {
  12798. segsByCol[segs[i].col].push(segs[i]);
  12799. }
  12800. }
  12801. return segsByCol;
  12802. }
  12803. function splitInteractionByCol(ui, colCnt) {
  12804. var byRow = [];
  12805. if (!ui) {
  12806. for (var i = 0; i < colCnt; i++) {
  12807. byRow[i] = null;
  12808. }
  12809. }
  12810. else {
  12811. for (var i = 0; i < colCnt; i++) {
  12812. byRow[i] = {
  12813. affectedInstances: ui.affectedInstances,
  12814. isEvent: ui.isEvent,
  12815. segs: []
  12816. };
  12817. }
  12818. for (var _i = 0, _a = ui.segs; _i < _a.length; _i++) {
  12819. var seg = _a[_i];
  12820. byRow[seg.col].segs.push(seg);
  12821. }
  12822. }
  12823. return byRow;
  12824. }
  12825. // UNFORTUNATELY, assigns results to the top/bottom/level/forwardCoord/backwardCoord props of the actual segs.
  12826. // TODO: return hash (by instanceId) of results
  12827. function computeSegCoords(segs, dayDate, slatCoords, eventMinHeight, eventOrderSpecs) {
  12828. computeSegVerticals(segs, dayDate, slatCoords, eventMinHeight);
  12829. return computeSegHorizontals(segs, eventOrderSpecs); // requires top/bottom from computeSegVerticals
  12830. }
  12831. // For each segment in an array, computes and assigns its top and bottom properties
  12832. function computeSegVerticals(segs, dayDate, slatCoords, eventMinHeight) {
  12833. for (var _i = 0, segs_1 = segs; _i < segs_1.length; _i++) {
  12834. var seg = segs_1[_i];
  12835. seg.top = slatCoords.computeDateTop(seg.start, dayDate);
  12836. seg.bottom = Math.max(seg.top + (eventMinHeight || 0), // yuck
  12837. slatCoords.computeDateTop(seg.end, dayDate));
  12838. }
  12839. }
  12840. // Given an array of segments that are all in the same column, sets the backwardCoord and forwardCoord on each.
  12841. // Assumed the segs are already ordered.
  12842. // NOTE: Also reorders the given array by date!
  12843. function computeSegHorizontals(segs, eventOrderSpecs) {
  12844. // IMPORTANT TO CLEAR OLD RESULTS :(
  12845. for (var _i = 0, segs_2 = segs; _i < segs_2.length; _i++) {
  12846. var seg = segs_2[_i];
  12847. seg.level = null;
  12848. seg.forwardCoord = null;
  12849. seg.backwardCoord = null;
  12850. seg.forwardPressure = null;
  12851. }
  12852. segs = sortEventSegs(segs, eventOrderSpecs);
  12853. var level0;
  12854. var levels = buildSlotSegLevels(segs);
  12855. computeForwardSlotSegs(levels);
  12856. if ((level0 = levels[0])) {
  12857. for (var _a = 0, level0_1 = level0; _a < level0_1.length; _a++) {
  12858. var seg = level0_1[_a];
  12859. computeSlotSegPressures(seg);
  12860. }
  12861. for (var _b = 0, level0_2 = level0; _b < level0_2.length; _b++) {
  12862. var seg = level0_2[_b];
  12863. computeSegForwardBack(seg, 0, 0, eventOrderSpecs);
  12864. }
  12865. }
  12866. return segs;
  12867. }
  12868. // Builds an array of segments "levels". The first level will be the leftmost tier of segments if the calendar is
  12869. // left-to-right, or the rightmost if the calendar is right-to-left. Assumes the segments are already ordered by date.
  12870. function buildSlotSegLevels(segs) {
  12871. var levels = [];
  12872. var i;
  12873. var seg;
  12874. var j;
  12875. for (i = 0; i < segs.length; i++) {
  12876. seg = segs[i];
  12877. // go through all the levels and stop on the first level where there are no collisions
  12878. for (j = 0; j < levels.length; j++) {
  12879. if (!computeSlotSegCollisions(seg, levels[j]).length) {
  12880. break;
  12881. }
  12882. }
  12883. seg.level = j;
  12884. (levels[j] || (levels[j] = [])).push(seg);
  12885. }
  12886. return levels;
  12887. }
  12888. // Find all the segments in `otherSegs` that vertically collide with `seg`.
  12889. // Append into an optionally-supplied `results` array and return.
  12890. function computeSlotSegCollisions(seg, otherSegs, results) {
  12891. if (results === void 0) { results = []; }
  12892. for (var i = 0; i < otherSegs.length; i++) {
  12893. if (isSlotSegCollision(seg, otherSegs[i])) {
  12894. results.push(otherSegs[i]);
  12895. }
  12896. }
  12897. return results;
  12898. }
  12899. // Do these segments occupy the same vertical space?
  12900. function isSlotSegCollision(seg1, seg2) {
  12901. return seg1.bottom > seg2.top && seg1.top < seg2.bottom;
  12902. }
  12903. // For every segment, figure out the other segments that are in subsequent
  12904. // levels that also occupy the same vertical space. Accumulate in seg.forwardSegs
  12905. function computeForwardSlotSegs(levels) {
  12906. var i;
  12907. var level;
  12908. var j;
  12909. var seg;
  12910. var k;
  12911. for (i = 0; i < levels.length; i++) {
  12912. level = levels[i];
  12913. for (j = 0; j < level.length; j++) {
  12914. seg = level[j];
  12915. seg.forwardSegs = [];
  12916. for (k = i + 1; k < levels.length; k++) {
  12917. computeSlotSegCollisions(seg, levels[k], seg.forwardSegs);
  12918. }
  12919. }
  12920. }
  12921. }
  12922. // Figure out which path forward (via seg.forwardSegs) results in the longest path until
  12923. // the furthest edge is reached. The number of segments in this path will be seg.forwardPressure
  12924. function computeSlotSegPressures(seg) {
  12925. var forwardSegs = seg.forwardSegs;
  12926. var forwardPressure = 0;
  12927. var i;
  12928. var forwardSeg;
  12929. if (seg.forwardPressure == null) { // not already computed
  12930. for (i = 0; i < forwardSegs.length; i++) {
  12931. forwardSeg = forwardSegs[i];
  12932. // figure out the child's maximum forward path
  12933. computeSlotSegPressures(forwardSeg);
  12934. // either use the existing maximum, or use the child's forward pressure
  12935. // plus one (for the forwardSeg itself)
  12936. forwardPressure = Math.max(forwardPressure, 1 + forwardSeg.forwardPressure);
  12937. }
  12938. seg.forwardPressure = forwardPressure;
  12939. }
  12940. }
  12941. // Calculate seg.forwardCoord and seg.backwardCoord for the segment, where both values range
  12942. // from 0 to 1. If the calendar is left-to-right, the seg.backwardCoord maps to "left" and
  12943. // seg.forwardCoord maps to "right" (via percentage). Vice-versa if the calendar is right-to-left.
  12944. //
  12945. // The segment might be part of a "series", which means consecutive segments with the same pressure
  12946. // who's width is unknown until an edge has been hit. `seriesBackwardPressure` is the number of
  12947. // segments behind this one in the current series, and `seriesBackwardCoord` is the starting
  12948. // coordinate of the first segment in the series.
  12949. function computeSegForwardBack(seg, seriesBackwardPressure, seriesBackwardCoord, eventOrderSpecs) {
  12950. var forwardSegs = seg.forwardSegs;
  12951. var i;
  12952. if (seg.forwardCoord == null) { // not already computed
  12953. if (!forwardSegs.length) {
  12954. // if there are no forward segments, this segment should butt up against the edge
  12955. seg.forwardCoord = 1;
  12956. }
  12957. else {
  12958. // sort highest pressure first
  12959. sortForwardSegs(forwardSegs, eventOrderSpecs);
  12960. // this segment's forwardCoord will be calculated from the backwardCoord of the
  12961. // highest-pressure forward segment.
  12962. computeSegForwardBack(forwardSegs[0], seriesBackwardPressure + 1, seriesBackwardCoord, eventOrderSpecs);
  12963. seg.forwardCoord = forwardSegs[0].backwardCoord;
  12964. }
  12965. // calculate the backwardCoord from the forwardCoord. consider the series
  12966. seg.backwardCoord = seg.forwardCoord -
  12967. (seg.forwardCoord - seriesBackwardCoord) / // available width for series
  12968. (seriesBackwardPressure + 1); // # of segments in the series
  12969. // use this segment's coordinates to computed the coordinates of the less-pressurized
  12970. // forward segments
  12971. for (i = 0; i < forwardSegs.length; i++) {
  12972. computeSegForwardBack(forwardSegs[i], 0, seg.forwardCoord, eventOrderSpecs);
  12973. }
  12974. }
  12975. }
  12976. function sortForwardSegs(forwardSegs, eventOrderSpecs) {
  12977. var objs = forwardSegs.map(buildTimeGridSegCompareObj);
  12978. var specs = [
  12979. // put higher-pressure first
  12980. { field: 'forwardPressure', order: -1 },
  12981. // put segments that are closer to initial edge first (and favor ones with no coords yet)
  12982. { field: 'backwardCoord', order: 1 }
  12983. ].concat(eventOrderSpecs);
  12984. objs.sort(function (obj0, obj1) {
  12985. return compareByFieldSpecs(obj0, obj1, specs);
  12986. });
  12987. return objs.map(function (c) {
  12988. return c._seg;
  12989. });
  12990. }
  12991. function buildTimeGridSegCompareObj(seg) {
  12992. var obj = buildSegCompareObj(seg);
  12993. obj.forwardPressure = seg.forwardPressure;
  12994. obj.backwardCoord = seg.backwardCoord;
  12995. return obj;
  12996. }
  12997. var DEFAULT_TIME_FORMAT = createFormatter({
  12998. hour: 'numeric',
  12999. minute: '2-digit',
  13000. meridiem: false
  13001. });
  13002. var TimeColEvent = /** @class */ (function (_super) {
  13003. __extends(TimeColEvent, _super);
  13004. function TimeColEvent() {
  13005. return _super !== null && _super.apply(this, arguments) || this;
  13006. }
  13007. TimeColEvent.prototype.render = function () {
  13008. var classNames = [
  13009. 'fc-timegrid-event',
  13010. 'fc-v-event'
  13011. ];
  13012. if (this.props.isCondensed) {
  13013. classNames.push('fc-timegrid-event-condensed');
  13014. }
  13015. return (createElement(StandardEvent, __assign({}, this.props, { defaultTimeFormat: DEFAULT_TIME_FORMAT, extraClassNames: classNames })));
  13016. };
  13017. return TimeColEvent;
  13018. }(BaseComponent));
  13019. config.timeGridEventCondensedHeight = 30;
  13020. var TimeCol = /** @class */ (function (_super) {
  13021. __extends(TimeCol, _super);
  13022. function TimeCol() {
  13023. return _super !== null && _super.apply(this, arguments) || this;
  13024. }
  13025. TimeCol.prototype.render = function () {
  13026. var _this = this;
  13027. var _a = this, props = _a.props, context = _a.context;
  13028. var isSelectMirror = context.options.selectMirror;
  13029. var mirrorSegs = (props.eventDrag && props.eventDrag.segs) ||
  13030. (props.eventResize && props.eventResize.segs) ||
  13031. (isSelectMirror && props.dateSelectionSegs) ||
  13032. [];
  13033. var interactionAffectedInstances = // TODO: messy way to compute this
  13034. (props.eventDrag && props.eventDrag.affectedInstances) ||
  13035. (props.eventResize && props.eventResize.affectedInstances) ||
  13036. {};
  13037. return (createElement(DayCellRoot, { elRef: props.elRef, date: props.date, dateProfile: props.dateProfile, todayRange: props.todayRange, extraHookProps: props.extraHookProps }, function (rootElRef, classNames, dataAttrs) { return (createElement("td", __assign({ ref: rootElRef, className: ['fc-timegrid-col'].concat(classNames, props.extraClassNames || []).join(' ') }, dataAttrs, props.extraDataAttrs),
  13038. createElement("div", { className: 'fc-timegrid-col-frame' },
  13039. createElement("div", { className: 'fc-timegrid-col-bg' },
  13040. _this.renderFillSegs(props.businessHourSegs, 'non-business'),
  13041. _this.renderFillSegs(props.bgEventSegs, 'bg-event'),
  13042. _this.renderFillSegs(props.dateSelectionSegs, 'highlight')),
  13043. createElement("div", { className: 'fc-timegrid-col-events' }, _this.renderFgSegs(props.fgEventSegs, interactionAffectedInstances)),
  13044. createElement("div", { className: 'fc-timegrid-col-events' }, _this.renderFgSegs(mirrorSegs, {}, Boolean(props.eventDrag), Boolean(props.eventResize), Boolean(isSelectMirror)
  13045. // TODO: pass in left/right instead of using only computeSegTopBottomCss
  13046. )),
  13047. createElement("div", { className: 'fc-timegrid-now-indicator-container' }, _this.renderNowIndicator(props.nowIndicatorSegs)),
  13048. createElement(TimeColMisc, { date: props.date, dateProfile: props.dateProfile, todayRange: props.todayRange, extraHookProps: props.extraHookProps })))); }));
  13049. };
  13050. TimeCol.prototype.renderFgSegs = function (segs, segIsInvisible, isDragging, isResizing, isDateSelecting) {
  13051. var props = this.props;
  13052. if (props.forPrint) {
  13053. return this.renderPrintFgSegs(segs);
  13054. }
  13055. else if (props.slatCoords) {
  13056. return this.renderPositionedFgSegs(segs, segIsInvisible, isDragging, isResizing, isDateSelecting);
  13057. }
  13058. };
  13059. TimeCol.prototype.renderPrintFgSegs = function (segs) {
  13060. var props = this.props;
  13061. return segs.map(function (seg) { return (createElement("div", { className: 'fc-timegrid-event-harness', key: seg.eventRange.instance.instanceId },
  13062. createElement(TimeColEvent, __assign({ seg: seg, isDragging: false, isResizing: false, isDateSelecting: false, isSelected: false, isCondensed: false }, getSegMeta(seg, props.todayRange, props.nowDate))))); });
  13063. };
  13064. TimeCol.prototype.renderPositionedFgSegs = function (segs, segIsInvisible, isDragging, isResizing, isDateSelecting) {
  13065. var _this = this;
  13066. var _a = this, context = _a.context, props = _a.props;
  13067. // assigns TO THE SEGS THEMSELVES
  13068. // also, receives resorted array
  13069. segs = computeSegCoords(segs, props.date, props.slatCoords, context.options.eventMinHeight, context.options.eventOrder);
  13070. return segs.map(function (seg) {
  13071. var instanceId = seg.eventRange.instance.instanceId;
  13072. var isMirror = isDragging || isResizing || isDateSelecting;
  13073. var positionCss = isMirror ? __assign({ left: 0, right: 0 }, _this.computeSegTopBottomCss(seg)) :
  13074. _this.computeFgSegPositionCss(seg);
  13075. return (createElement("div", { className: 'fc-timegrid-event-harness' + (seg.level > 0 ? ' fc-timegrid-event-harness-inset' : ''), key: instanceId, style: __assign({ visibility: segIsInvisible[instanceId] ? 'hidden' : '' }, positionCss) },
  13076. createElement(TimeColEvent, __assign({ seg: seg, isDragging: isDragging, isResizing: isResizing, isDateSelecting: isDateSelecting, isSelected: instanceId === props.eventSelection, isCondensed: (seg.bottom - seg.top) < config.timeGridEventCondensedHeight }, getSegMeta(seg, props.todayRange, props.nowDate)))));
  13077. });
  13078. };
  13079. TimeCol.prototype.renderFillSegs = function (segs, fillType) {
  13080. var _this = this;
  13081. var _a = this, context = _a.context, props = _a.props;
  13082. if (!props.slatCoords) {
  13083. return;
  13084. }
  13085. // BAD: assigns TO THE SEGS THEMSELVES
  13086. computeSegVerticals(segs, props.date, props.slatCoords, context.options.eventMinHeight);
  13087. var children = segs.map(function (seg) { return (createElement("div", { key: buildEventRangeKey(seg.eventRange), className: 'fc-timegrid-bg-harness', style: _this.computeSegTopBottomCss(seg) }, fillType === 'bg-event' ?
  13088. createElement(BgEvent, __assign({ seg: seg }, getSegMeta(seg, props.todayRange, props.nowDate))) :
  13089. renderFill(fillType))); });
  13090. return createElement(Fragment, null, children);
  13091. };
  13092. TimeCol.prototype.renderNowIndicator = function (segs) {
  13093. var _a = this.props, slatCoords = _a.slatCoords, date = _a.date;
  13094. if (!slatCoords) {
  13095. return;
  13096. }
  13097. return segs.map(function (seg, i) { return (createElement(NowIndicatorRoot, { isAxis: false, date: date, key: i /* key doesn't matter. will only ever be one */ }, function (rootElRef, classNames, innerElRef, innerContent) { return (createElement("div", { ref: rootElRef, className: ['fc-timegrid-now-indicator-line'].concat(classNames).join(' '), style: { top: slatCoords.computeDateTop(seg.start, date) } }, innerContent)); })); });
  13098. };
  13099. TimeCol.prototype.computeFgSegPositionCss = function (seg) {
  13100. var _a = this.context, isRtl = _a.isRtl, options = _a.options;
  13101. var shouldOverlap = options.slotEventOverlap;
  13102. var backwardCoord = seg.backwardCoord; // the left side if LTR. the right side if RTL. floating-point
  13103. var forwardCoord = seg.forwardCoord; // the right side if LTR. the left side if RTL. floating-point
  13104. var left; // amount of space from left edge, a fraction of the total width
  13105. var right; // amount of space from right edge, a fraction of the total width
  13106. if (shouldOverlap) {
  13107. // double the width, but don't go beyond the maximum forward coordinate (1.0)
  13108. forwardCoord = Math.min(1, backwardCoord + (forwardCoord - backwardCoord) * 2);
  13109. }
  13110. if (isRtl) {
  13111. left = 1 - forwardCoord;
  13112. right = backwardCoord;
  13113. }
  13114. else {
  13115. left = backwardCoord;
  13116. right = 1 - forwardCoord;
  13117. }
  13118. var props = {
  13119. zIndex: seg.level + 1,
  13120. left: left * 100 + '%',
  13121. right: right * 100 + '%'
  13122. };
  13123. if (shouldOverlap && seg.forwardPressure) {
  13124. // add padding to the edge so that forward stacked events don't cover the resizer's icon
  13125. props[isRtl ? 'marginLeft' : 'marginRight'] = 10 * 2; // 10 is a guesstimate of the icon's width
  13126. }
  13127. return __assign(__assign({}, props), this.computeSegTopBottomCss(seg));
  13128. };
  13129. TimeCol.prototype.computeSegTopBottomCss = function (seg) {
  13130. return {
  13131. top: seg.top,
  13132. bottom: -seg.bottom
  13133. };
  13134. };
  13135. return TimeCol;
  13136. }(BaseComponent));
  13137. var TimeColMisc = /** @class */ (function (_super) {
  13138. __extends(TimeColMisc, _super);
  13139. function TimeColMisc() {
  13140. return _super !== null && _super.apply(this, arguments) || this;
  13141. }
  13142. TimeColMisc.prototype.render = function () {
  13143. var props = this.props;
  13144. return (createElement(DayCellContent, { date: props.date, dateProfile: props.dateProfile, todayRange: props.todayRange, extraHookProps: props.extraHookProps }, function (innerElRef, innerContent) { return (innerContent &&
  13145. createElement("div", { className: 'fc-timegrid-col-misc', ref: innerElRef }, innerContent)); }));
  13146. };
  13147. return TimeColMisc;
  13148. }(BaseComponent));
  13149. var TimeColsContent = /** @class */ (function (_super) {
  13150. __extends(TimeColsContent, _super);
  13151. function TimeColsContent() {
  13152. var _this = _super !== null && _super.apply(this, arguments) || this;
  13153. _this.splitFgEventSegs = memoize(splitSegsByCol);
  13154. _this.splitBgEventSegs = memoize(splitSegsByCol);
  13155. _this.splitBusinessHourSegs = memoize(splitSegsByCol);
  13156. _this.splitNowIndicatorSegs = memoize(splitSegsByCol);
  13157. _this.splitDateSelectionSegs = memoize(splitSegsByCol);
  13158. _this.splitEventDrag = memoize(splitInteractionByCol);
  13159. _this.splitEventResize = memoize(splitInteractionByCol);
  13160. _this.rootElRef = createRef();
  13161. _this.cellElRefs = new RefMap();
  13162. return _this;
  13163. }
  13164. TimeColsContent.prototype.render = function () {
  13165. var _this = this;
  13166. var _a = this, props = _a.props, context = _a.context;
  13167. var nowIndicatorTop = context.options.nowIndicator &&
  13168. props.slatCoords &&
  13169. props.slatCoords.safeComputeTop(props.nowDate); // might return void
  13170. var colCnt = props.cells.length;
  13171. var fgEventSegsByRow = this.splitFgEventSegs(props.fgEventSegs, colCnt);
  13172. var bgEventSegsByRow = this.splitBgEventSegs(props.bgEventSegs, colCnt);
  13173. var businessHourSegsByRow = this.splitBusinessHourSegs(props.businessHourSegs, colCnt);
  13174. var nowIndicatorSegsByRow = this.splitNowIndicatorSegs(props.nowIndicatorSegs, colCnt);
  13175. var dateSelectionSegsByRow = this.splitDateSelectionSegs(props.dateSelectionSegs, colCnt);
  13176. var eventDragByRow = this.splitEventDrag(props.eventDrag, colCnt);
  13177. var eventResizeByRow = this.splitEventResize(props.eventResize, colCnt);
  13178. return (createElement("div", { className: 'fc-timegrid-cols', ref: this.rootElRef },
  13179. createElement("table", { style: {
  13180. minWidth: props.tableMinWidth,
  13181. width: props.clientWidth
  13182. } },
  13183. props.tableColGroupNode,
  13184. createElement("tbody", null,
  13185. createElement("tr", null,
  13186. props.axis &&
  13187. createElement("td", { className: 'fc-timegrid-col fc-timegrid-axis' },
  13188. createElement("div", { className: 'fc-timegrid-col-frame' },
  13189. createElement("div", { className: 'fc-timegrid-now-indicator-container' }, typeof nowIndicatorTop === 'number' &&
  13190. createElement(NowIndicatorRoot, { isAxis: true, date: props.nowDate }, function (rootElRef, classNames, innerElRef, innerContent) { return (createElement("div", { ref: rootElRef, className: ['fc-timegrid-now-indicator-arrow'].concat(classNames).join(' '), style: { top: nowIndicatorTop } }, innerContent)); })))),
  13191. props.cells.map(function (cell, i) { return (createElement(TimeCol, { key: cell.key, elRef: _this.cellElRefs.createRef(cell.key), dateProfile: props.dateProfile, date: cell.date, nowDate: props.nowDate, todayRange: props.todayRange, extraHookProps: cell.extraHookProps, extraDataAttrs: cell.extraDataAttrs, extraClassNames: cell.extraClassNames, fgEventSegs: fgEventSegsByRow[i], bgEventSegs: bgEventSegsByRow[i], businessHourSegs: businessHourSegsByRow[i], nowIndicatorSegs: nowIndicatorSegsByRow[i], dateSelectionSegs: dateSelectionSegsByRow[i], eventDrag: eventDragByRow[i], eventResize: eventResizeByRow[i], slatCoords: props.slatCoords, eventSelection: props.eventSelection, forPrint: props.forPrint })); }))))));
  13192. };
  13193. TimeColsContent.prototype.componentDidMount = function () {
  13194. this.updateCoords();
  13195. };
  13196. TimeColsContent.prototype.componentDidUpdate = function () {
  13197. this.updateCoords();
  13198. };
  13199. TimeColsContent.prototype.updateCoords = function () {
  13200. var props = this.props;
  13201. if (props.onColCoords &&
  13202. props.clientWidth !== null // means sizing has stabilized
  13203. ) {
  13204. props.onColCoords(new PositionCache(this.rootElRef.current, collectCellEls(this.cellElRefs.currentMap, props.cells), true, // horizontal
  13205. false));
  13206. }
  13207. };
  13208. return TimeColsContent;
  13209. }(BaseComponent));
  13210. function collectCellEls(elMap, cells) {
  13211. return cells.map(function (cell) { return elMap[cell.key]; });
  13212. }
  13213. /* A component that renders one or more columns of vertical time slots
  13214. ----------------------------------------------------------------------------------------------------------------------*/
  13215. var TimeCols = /** @class */ (function (_super) {
  13216. __extends(TimeCols, _super);
  13217. function TimeCols() {
  13218. var _this = _super !== null && _super.apply(this, arguments) || this;
  13219. _this.processSlotOptions = memoize(processSlotOptions);
  13220. _this.state = {
  13221. slatCoords: null
  13222. };
  13223. _this.handleScrollRequest = function (request) {
  13224. var onScrollTopRequest = _this.props.onScrollTopRequest;
  13225. var slatCoords = _this.state.slatCoords;
  13226. if (onScrollTopRequest && slatCoords) {
  13227. if (request.time) {
  13228. var top_1 = slatCoords.computeTimeTop(request.time);
  13229. top_1 = Math.ceil(top_1); // zoom can give weird floating-point values. rather scroll a little bit further
  13230. if (top_1) {
  13231. top_1++;
  13232. } // to overcome top border that slots beyond the first have. looks better
  13233. onScrollTopRequest(top_1);
  13234. }
  13235. return true;
  13236. }
  13237. };
  13238. _this.handleColCoords = function (colCoords) {
  13239. _this.colCoords = colCoords;
  13240. };
  13241. _this.handleSlatCoords = function (slatCoords) {
  13242. _this.setState({ slatCoords: slatCoords });
  13243. if (_this.props.onSlatCoords) {
  13244. _this.props.onSlatCoords(slatCoords);
  13245. }
  13246. };
  13247. return _this;
  13248. }
  13249. TimeCols.prototype.render = function () {
  13250. var _a = this, props = _a.props, state = _a.state;
  13251. return (createElement("div", { className: 'fc-timegrid-body', ref: props.rootElRef, style: {
  13252. // these props are important to give this wrapper correct dimensions for interactions
  13253. // TODO: if we set it here, can we avoid giving to inner tables?
  13254. width: props.clientWidth,
  13255. minWidth: props.tableMinWidth
  13256. } },
  13257. createElement(TimeColsSlats, { axis: props.axis, dateProfile: props.dateProfile, slatMetas: props.slatMetas, clientWidth: props.clientWidth, minHeight: props.expandRows ? props.clientHeight : '', tableMinWidth: props.tableMinWidth, tableColGroupNode: props.axis ? props.tableColGroupNode : null /* axis depends on the colgroup's shrinking */, onCoords: this.handleSlatCoords }),
  13258. createElement(TimeColsContent, { cells: props.cells, axis: props.axis, dateProfile: props.dateProfile, businessHourSegs: props.businessHourSegs, bgEventSegs: props.bgEventSegs, fgEventSegs: props.fgEventSegs, dateSelectionSegs: props.dateSelectionSegs, eventSelection: props.eventSelection, eventDrag: props.eventDrag, eventResize: props.eventResize, todayRange: props.todayRange, nowDate: props.nowDate, nowIndicatorSegs: props.nowIndicatorSegs, clientWidth: props.clientWidth, tableMinWidth: props.tableMinWidth, tableColGroupNode: props.tableColGroupNode, slatCoords: state.slatCoords, onColCoords: this.handleColCoords, forPrint: props.forPrint })));
  13259. };
  13260. TimeCols.prototype.componentDidMount = function () {
  13261. this.scrollResponder = this.context.createScrollResponder(this.handleScrollRequest);
  13262. };
  13263. TimeCols.prototype.componentDidUpdate = function (prevProps) {
  13264. this.scrollResponder.update(prevProps.dateProfile !== this.props.dateProfile);
  13265. };
  13266. TimeCols.prototype.componentWillUnmount = function () {
  13267. this.scrollResponder.detach();
  13268. };
  13269. TimeCols.prototype.positionToHit = function (positionLeft, positionTop) {
  13270. var _a = this.context, dateEnv = _a.dateEnv, options = _a.options;
  13271. var colCoords = this.colCoords;
  13272. var dateProfile = this.props.dateProfile;
  13273. var slatCoords = this.state.slatCoords;
  13274. var _b = this.processSlotOptions(this.props.slotDuration, options.snapDuration), snapDuration = _b.snapDuration, snapsPerSlot = _b.snapsPerSlot;
  13275. var colIndex = colCoords.leftToIndex(positionLeft);
  13276. var slatIndex = slatCoords.positions.topToIndex(positionTop);
  13277. if (colIndex != null && slatIndex != null) {
  13278. var slatTop = slatCoords.positions.tops[slatIndex];
  13279. var slatHeight = slatCoords.positions.getHeight(slatIndex);
  13280. var partial = (positionTop - slatTop) / slatHeight; // floating point number between 0 and 1
  13281. var localSnapIndex = Math.floor(partial * snapsPerSlot); // the snap # relative to start of slat
  13282. var snapIndex = slatIndex * snapsPerSlot + localSnapIndex;
  13283. var dayDate = this.props.cells[colIndex].date;
  13284. var time = addDurations(dateProfile.slotMinTime, multiplyDuration(snapDuration, snapIndex));
  13285. var start = dateEnv.add(dayDate, time);
  13286. var end = dateEnv.add(start, snapDuration);
  13287. return {
  13288. col: colIndex,
  13289. dateSpan: {
  13290. range: { start: start, end: end },
  13291. allDay: false
  13292. },
  13293. dayEl: colCoords.els[colIndex],
  13294. relativeRect: {
  13295. left: colCoords.lefts[colIndex],
  13296. right: colCoords.rights[colIndex],
  13297. top: slatTop,
  13298. bottom: slatTop + slatHeight
  13299. }
  13300. };
  13301. }
  13302. };
  13303. return TimeCols;
  13304. }(BaseComponent));
  13305. function processSlotOptions(slotDuration, snapDurationOverride) {
  13306. var snapDuration = snapDurationOverride || slotDuration;
  13307. var snapsPerSlot = wholeDivideDurations(slotDuration, snapDuration);
  13308. if (snapsPerSlot === null) {
  13309. snapDuration = slotDuration;
  13310. snapsPerSlot = 1;
  13311. // TODO: say warning?
  13312. }
  13313. return { snapDuration: snapDuration, snapsPerSlot: snapsPerSlot };
  13314. }
  13315. var DayTimeCols = /** @class */ (function (_super) {
  13316. __extends(DayTimeCols, _super);
  13317. function DayTimeCols() {
  13318. var _this = _super !== null && _super.apply(this, arguments) || this;
  13319. _this.buildDayRanges = memoize(buildDayRanges);
  13320. _this.slicer = new DayTimeColsSlicer();
  13321. _this.timeColsRef = createRef();
  13322. _this.handleRootEl = function (rootEl) {
  13323. if (rootEl) {
  13324. _this.context.registerInteractiveComponent(_this, { el: rootEl });
  13325. }
  13326. else {
  13327. _this.context.unregisterInteractiveComponent(_this);
  13328. }
  13329. };
  13330. return _this;
  13331. }
  13332. DayTimeCols.prototype.render = function () {
  13333. var _this = this;
  13334. var _a = this, props = _a.props, context = _a.context;
  13335. var dateProfile = props.dateProfile, dayTableModel = props.dayTableModel;
  13336. var isNowIndicator = context.options.nowIndicator;
  13337. var dayRanges = this.buildDayRanges(dayTableModel, dateProfile, context.dateEnv);
  13338. // give it the first row of cells
  13339. // TODO: would move this further down hierarchy, but sliceNowDate needs it
  13340. return (createElement(NowTimer, { unit: isNowIndicator ? 'minute' : 'day' }, function (nowDate, todayRange) { return (createElement(TimeCols, __assign({ ref: _this.timeColsRef, rootElRef: _this.handleRootEl }, _this.slicer.sliceProps(props, dateProfile, null, context, dayRanges), { forPrint: props.forPrint, axis: props.axis, dateProfile: dateProfile, slatMetas: props.slatMetas, slotDuration: props.slotDuration, cells: dayTableModel.cells[0], tableColGroupNode: props.tableColGroupNode, tableMinWidth: props.tableMinWidth, clientWidth: props.clientWidth, clientHeight: props.clientHeight, expandRows: props.expandRows, nowDate: nowDate, nowIndicatorSegs: isNowIndicator && _this.slicer.sliceNowDate(nowDate, context, dayRanges), todayRange: todayRange, onScrollTopRequest: props.onScrollTopRequest, onSlatCoords: props.onSlatCoords }))); }));
  13341. };
  13342. DayTimeCols.prototype.queryHit = function (positionLeft, positionTop) {
  13343. var rawHit = this.timeColsRef.current.positionToHit(positionLeft, positionTop);
  13344. if (rawHit) {
  13345. return {
  13346. component: this,
  13347. dateSpan: rawHit.dateSpan,
  13348. dayEl: rawHit.dayEl,
  13349. rect: {
  13350. left: rawHit.relativeRect.left,
  13351. right: rawHit.relativeRect.right,
  13352. top: rawHit.relativeRect.top,
  13353. bottom: rawHit.relativeRect.bottom
  13354. },
  13355. layer: 0
  13356. };
  13357. }
  13358. };
  13359. return DayTimeCols;
  13360. }(DateComponent));
  13361. function buildDayRanges(dayTableModel, dateProfile, dateEnv) {
  13362. var ranges = [];
  13363. for (var _i = 0, _a = dayTableModel.headerDates; _i < _a.length; _i++) {
  13364. var date = _a[_i];
  13365. ranges.push({
  13366. start: dateEnv.add(date, dateProfile.slotMinTime),
  13367. end: dateEnv.add(date, dateProfile.slotMaxTime)
  13368. });
  13369. }
  13370. return ranges;
  13371. }
  13372. var DayTimeColsSlicer = /** @class */ (function (_super) {
  13373. __extends(DayTimeColsSlicer, _super);
  13374. function DayTimeColsSlicer() {
  13375. return _super !== null && _super.apply(this, arguments) || this;
  13376. }
  13377. DayTimeColsSlicer.prototype.sliceRange = function (range, dayRanges) {
  13378. var segs = [];
  13379. for (var col = 0; col < dayRanges.length; col++) {
  13380. var segRange = intersectRanges(range, dayRanges[col]);
  13381. if (segRange) {
  13382. segs.push({
  13383. start: segRange.start,
  13384. end: segRange.end,
  13385. isStart: segRange.start.valueOf() === range.start.valueOf(),
  13386. isEnd: segRange.end.valueOf() === range.end.valueOf(),
  13387. col: col
  13388. });
  13389. }
  13390. }
  13391. return segs;
  13392. };
  13393. return DayTimeColsSlicer;
  13394. }(Slicer));
  13395. var DayTimeColsView = /** @class */ (function (_super) {
  13396. __extends(DayTimeColsView, _super);
  13397. function DayTimeColsView() {
  13398. var _this = _super !== null && _super.apply(this, arguments) || this;
  13399. _this.buildTimeColsModel = memoize(buildTimeColsModel);
  13400. _this.buildSlatMetas = memoize(buildSlatMetas);
  13401. return _this;
  13402. }
  13403. DayTimeColsView.prototype.render = function () {
  13404. var _this = this;
  13405. var _a = this.context, options = _a.options, dateEnv = _a.dateEnv, dateProfileGenerator = _a.dateProfileGenerator;
  13406. var props = this.props;
  13407. var dateProfile = props.dateProfile;
  13408. var dayTableModel = this.buildTimeColsModel(dateProfile, dateProfileGenerator);
  13409. var splitProps = this.allDaySplitter.splitProps(props);
  13410. var slatMetas = this.buildSlatMetas(dateProfile.slotMinTime, dateProfile.slotMaxTime, options.slotLabelInterval, options.slotDuration, dateEnv);
  13411. var dayMinWidth = options.dayMinWidth;
  13412. var hasAttachedAxis = !dayMinWidth;
  13413. var hasDetachedAxis = dayMinWidth;
  13414. var headerContent = options.dayHeaders &&
  13415. createElement(DayHeader, { dates: dayTableModel.headerDates, dateProfile: dateProfile, datesRepDistinctDays: true, renderIntro: hasAttachedAxis ? this.renderHeadAxis : null });
  13416. var allDayContent = (options.allDaySlot !== false) && (function (contentArg) { return (createElement(DayTable, __assign({}, splitProps['allDay'], { dateProfile: dateProfile, dayTableModel: dayTableModel, nextDayThreshold: options.nextDayThreshold, tableMinWidth: contentArg.tableMinWidth, colGroupNode: contentArg.tableColGroupNode, renderRowIntro: hasAttachedAxis ? _this.renderTableRowAxis : null, showWeekNumbers: false, expandRows: false, headerAlignElRef: _this.headerElRef, clientWidth: contentArg.clientWidth, clientHeight: contentArg.clientHeight, forPrint: props.forPrint }, _this.getAllDayMaxEventProps()))); });
  13417. var timeGridContent = function (contentArg) { return (createElement(DayTimeCols, __assign({}, splitProps['timed'], { dayTableModel: dayTableModel, dateProfile: dateProfile, axis: hasAttachedAxis, slotDuration: options.slotDuration, slatMetas: slatMetas, forPrint: props.forPrint, tableColGroupNode: contentArg.tableColGroupNode, tableMinWidth: contentArg.tableMinWidth, clientWidth: contentArg.clientWidth, clientHeight: contentArg.clientHeight, onSlatCoords: _this.handleSlatCoords, expandRows: contentArg.expandRows, onScrollTopRequest: _this.handleScrollTopRequest }))); };
  13418. return hasDetachedAxis
  13419. ? this.renderHScrollLayout(headerContent, allDayContent, timeGridContent, dayTableModel.colCnt, dayMinWidth, slatMetas, this.state.slatCoords)
  13420. : this.renderSimpleLayout(headerContent, allDayContent, timeGridContent);
  13421. };
  13422. return DayTimeColsView;
  13423. }(TimeColsView));
  13424. function buildTimeColsModel(dateProfile, dateProfileGenerator) {
  13425. var daySeries = new DaySeriesModel(dateProfile.renderRange, dateProfileGenerator);
  13426. return new DayTableModel(daySeries, false);
  13427. }
  13428. var OPTION_REFINERS$1 = {
  13429. allDaySlot: Boolean
  13430. };
  13431. var timeGridPlugin = createPlugin({
  13432. initialView: 'timeGridWeek',
  13433. optionRefiners: OPTION_REFINERS$1,
  13434. views: {
  13435. timeGrid: {
  13436. component: DayTimeColsView,
  13437. usesMinMaxTime: true,
  13438. allDaySlot: true,
  13439. slotDuration: '00:30:00',
  13440. slotEventOverlap: true // a bad name. confused with overlap/constraint system
  13441. },
  13442. timeGridDay: {
  13443. type: 'timeGrid',
  13444. duration: { days: 1 }
  13445. },
  13446. timeGridWeek: {
  13447. type: 'timeGrid',
  13448. duration: { weeks: 1 }
  13449. }
  13450. }
  13451. });
  13452. var ListViewHeaderRow = /** @class */ (function (_super) {
  13453. __extends(ListViewHeaderRow, _super);
  13454. function ListViewHeaderRow() {
  13455. return _super !== null && _super.apply(this, arguments) || this;
  13456. }
  13457. ListViewHeaderRow.prototype.render = function () {
  13458. var _a = this.props, dayDate = _a.dayDate, todayRange = _a.todayRange;
  13459. var _b = this.context, theme = _b.theme, dateEnv = _b.dateEnv, options = _b.options, viewApi = _b.viewApi;
  13460. var dayMeta = getDateMeta(dayDate, todayRange);
  13461. var text = options.listDayFormat ? dateEnv.format(dayDate, options.listDayFormat) : ''; // will ever be falsy?
  13462. var sideText = options.listDaySideFormat ? dateEnv.format(dayDate, options.listDaySideFormat) : ''; // will ever be falsy? also, BAD NAME "alt"
  13463. var navLinkData = options.navLinks
  13464. ? buildNavLinkData(dayDate)
  13465. : null;
  13466. var hookProps = __assign({ date: dateEnv.toDate(dayDate), view: viewApi, text: text,
  13467. sideText: sideText,
  13468. navLinkData: navLinkData }, dayMeta);
  13469. var classNames = ['fc-list-day'].concat(getDayClassNames(dayMeta, theme));
  13470. // TODO: make a reusable HOC for dayHeader (used in daygrid/timegrid too)
  13471. return (createElement(RenderHook, { hookProps: hookProps, classNames: options.dayHeaderClassNames, content: options.dayHeaderContent, defaultContent: renderInnerContent$4, didMount: options.dayHeaderDidMount, willUnmount: options.dayHeaderWillUnmount }, function (rootElRef, customClassNames, innerElRef, innerContent) { return (createElement("tr", { ref: rootElRef, className: classNames.concat(customClassNames).join(' '), "data-date": formatDayString(dayDate) },
  13472. createElement("th", { colSpan: 3 },
  13473. createElement("div", { className: 'fc-list-day-cushion ' + theme.getClass('tableCellShaded'), ref: innerElRef }, innerContent)))); }));
  13474. };
  13475. return ListViewHeaderRow;
  13476. }(BaseComponent));
  13477. function renderInnerContent$4(props) {
  13478. var navLinkAttrs = props.navLinkData // is there a type for this?
  13479. ? { 'data-navlink': props.navLinkData, tabIndex: 0 }
  13480. : {};
  13481. return (createElement(Fragment, null,
  13482. props.text &&
  13483. createElement("a", __assign({ className: 'fc-list-day-text' }, navLinkAttrs), props.text),
  13484. props.sideText &&
  13485. createElement("a", __assign({ className: 'fc-list-day-side-text' }, navLinkAttrs), props.sideText)));
  13486. }
  13487. var DEFAULT_TIME_FORMAT$1 = createFormatter({
  13488. hour: 'numeric',
  13489. minute: '2-digit',
  13490. meridiem: 'short'
  13491. });
  13492. var ListViewEventRow = /** @class */ (function (_super) {
  13493. __extends(ListViewEventRow, _super);
  13494. function ListViewEventRow() {
  13495. return _super !== null && _super.apply(this, arguments) || this;
  13496. }
  13497. ListViewEventRow.prototype.render = function () {
  13498. var _a = this, props = _a.props, context = _a.context;
  13499. var seg = props.seg;
  13500. var timeFormat = context.options.eventTimeFormat || DEFAULT_TIME_FORMAT$1;
  13501. return (createElement(EventRoot, { seg: seg, timeText: '' /* BAD. because of all-day content */, disableDragging: true, disableResizing: true, defaultContent: renderEventInnerContent, isPast: props.isPast, isFuture: props.isFuture, isToday: props.isToday, isSelected: props.isSelected, isDragging: props.isDragging, isResizing: props.isResizing, isDateSelecting: props.isDateSelecting }, function (rootElRef, classNames, innerElRef, innerContent, hookProps) { return (createElement("tr", { className: ['fc-list-event', hookProps.event.url ? 'fc-event-forced-url' : ''].concat(classNames).join(' '), ref: rootElRef },
  13502. buildTimeContent(seg, timeFormat, context),
  13503. createElement("td", { className: 'fc-list-event-graphic' },
  13504. createElement("span", { className: 'fc-list-event-dot', style: { borderColor: hookProps.borderColor || hookProps.backgroundColor } })),
  13505. createElement("td", { className: 'fc-list-event-title', ref: innerElRef }, innerContent))); }));
  13506. };
  13507. return ListViewEventRow;
  13508. }(BaseComponent));
  13509. function renderEventInnerContent(props) {
  13510. var event = props.event;
  13511. var url = event.url;
  13512. var anchorAttrs = url ? { href: url } : {};
  13513. return (createElement("a", __assign({}, anchorAttrs), event.title));
  13514. }
  13515. function buildTimeContent(seg, timeFormat, context) {
  13516. var options = context.options;
  13517. if (options.displayEventTime !== false) {
  13518. var eventDef = seg.eventRange.def;
  13519. var eventInstance = seg.eventRange.instance;
  13520. var doAllDay = false;
  13521. var timeText = void 0;
  13522. if (eventDef.allDay) {
  13523. doAllDay = true;
  13524. }
  13525. else if (isMultiDayRange(seg.eventRange.range)) { // TODO: use (!isStart || !isEnd) instead?
  13526. if (seg.isStart) {
  13527. timeText = buildSegTimeText(seg, timeFormat, context, null, null, eventInstance.range.start, seg.end);
  13528. }
  13529. else if (seg.isEnd) {
  13530. timeText = buildSegTimeText(seg, timeFormat, context, null, null, seg.start, eventInstance.range.end);
  13531. }
  13532. else {
  13533. doAllDay = true;
  13534. }
  13535. }
  13536. else {
  13537. timeText = buildSegTimeText(seg, timeFormat, context);
  13538. }
  13539. if (doAllDay) {
  13540. var hookProps = {
  13541. text: context.options.allDayText,
  13542. view: context.viewApi
  13543. };
  13544. return (createElement(RenderHook, { hookProps: hookProps, classNames: options.allDayClassNames, content: options.allDayContent, defaultContent: renderAllDayInner$1, didMount: options.allDayDidMount, willUnmount: options.allDayWillUnmount }, function (rootElRef, classNames, innerElRef, innerContent) { return (createElement("td", { className: ['fc-list-event-time'].concat(classNames).join(' '), ref: rootElRef }, innerContent)); }));
  13545. }
  13546. else {
  13547. return (createElement("td", { className: 'fc-list-event-time' }, timeText));
  13548. }
  13549. }
  13550. return null;
  13551. }
  13552. function renderAllDayInner$1(hookProps) {
  13553. return hookProps.text;
  13554. }
  13555. /*
  13556. Responsible for the scroller, and forwarding event-related actions into the "grid".
  13557. */
  13558. var ListView = /** @class */ (function (_super) {
  13559. __extends(ListView, _super);
  13560. function ListView() {
  13561. var _this = _super !== null && _super.apply(this, arguments) || this;
  13562. _this.computeDateVars = memoize(computeDateVars);
  13563. _this.eventStoreToSegs = memoize(_this._eventStoreToSegs);
  13564. _this.setRootEl = function (rootEl) {
  13565. if (rootEl) {
  13566. _this.context.registerInteractiveComponent(_this, {
  13567. el: rootEl
  13568. });
  13569. }
  13570. else {
  13571. _this.context.unregisterInteractiveComponent(_this);
  13572. }
  13573. };
  13574. return _this;
  13575. }
  13576. ListView.prototype.render = function () {
  13577. var _this = this;
  13578. var _a = this, props = _a.props, context = _a.context;
  13579. var extraClassNames = [
  13580. 'fc-list',
  13581. context.theme.getClass('table'),
  13582. context.options.stickyHeaderDates !== false ? 'fc-list-sticky' : ''
  13583. ];
  13584. var _b = this.computeDateVars(props.dateProfile), dayDates = _b.dayDates, dayRanges = _b.dayRanges;
  13585. var eventSegs = this.eventStoreToSegs(props.eventStore, props.eventUiBases, dayRanges);
  13586. return (createElement(ViewRoot, { viewSpec: context.viewSpec, elRef: this.setRootEl }, function (rootElRef, classNames) { return (createElement("div", { ref: rootElRef, className: extraClassNames.concat(classNames).join(' ') },
  13587. createElement(Scroller, { liquid: !props.isHeightAuto, overflowX: props.isHeightAuto ? 'visible' : 'hidden', overflowY: props.isHeightAuto ? 'visible' : 'auto' }, eventSegs.length > 0 ?
  13588. _this.renderSegList(eventSegs, dayDates) :
  13589. _this.renderEmptyMessage()))); }));
  13590. };
  13591. ListView.prototype.renderEmptyMessage = function () {
  13592. var _a = this.context, options = _a.options, viewApi = _a.viewApi;
  13593. var hookProps = {
  13594. text: options.noEventsText,
  13595. view: viewApi
  13596. };
  13597. return (createElement(RenderHook, { hookProps: hookProps, classNames: options.noEventsClassNames, content: options.noEventsContent, defaultContent: renderNoEventsInner, didMount: options.noEventsDidMount, willUnmount: options.noEventsWillUnmount }, function (rootElRef, classNames, innerElRef, innerContent) { return (createElement("div", { className: ['fc-list-empty'].concat(classNames).join(' '), ref: rootElRef },
  13598. createElement("div", { className: 'fc-list-empty-cushion', ref: innerElRef }, innerContent))); }));
  13599. };
  13600. ListView.prototype.renderSegList = function (allSegs, dayDates) {
  13601. var _a = this.context, theme = _a.theme, options = _a.options;
  13602. var segsByDay = groupSegsByDay(allSegs); // sparse array
  13603. return (createElement(NowTimer, { unit: 'day' }, function (nowDate, todayRange) {
  13604. var innerNodes = [];
  13605. for (var dayIndex = 0; dayIndex < segsByDay.length; dayIndex++) {
  13606. var daySegs = segsByDay[dayIndex];
  13607. if (daySegs) { // sparse array, so might be undefined
  13608. var dayStr = dayDates[dayIndex].toISOString();
  13609. // append a day header
  13610. innerNodes.push(createElement(ListViewHeaderRow, { key: dayStr, dayDate: dayDates[dayIndex], todayRange: todayRange }));
  13611. daySegs = sortEventSegs(daySegs, options.eventOrder);
  13612. for (var _i = 0, daySegs_1 = daySegs; _i < daySegs_1.length; _i++) {
  13613. var seg = daySegs_1[_i];
  13614. innerNodes.push(createElement(ListViewEventRow, __assign({ key: dayStr + ':' + seg.eventRange.instance.instanceId /* are multiple segs for an instanceId */, seg: seg, isDragging: false, isResizing: false, isDateSelecting: false, isSelected: false }, getSegMeta(seg, todayRange, nowDate))));
  13615. }
  13616. }
  13617. }
  13618. return (createElement("table", { className: 'fc-list-table ' + theme.getClass('table') },
  13619. createElement("tbody", null, innerNodes)));
  13620. }));
  13621. };
  13622. ListView.prototype._eventStoreToSegs = function (eventStore, eventUiBases, dayRanges) {
  13623. return this.eventRangesToSegs(sliceEventStore(eventStore, eventUiBases, this.props.dateProfile.activeRange, this.context.options.nextDayThreshold).fg, dayRanges);
  13624. };
  13625. ListView.prototype.eventRangesToSegs = function (eventRanges, dayRanges) {
  13626. var segs = [];
  13627. for (var _i = 0, eventRanges_1 = eventRanges; _i < eventRanges_1.length; _i++) {
  13628. var eventRange = eventRanges_1[_i];
  13629. segs.push.apply(segs, this.eventRangeToSegs(eventRange, dayRanges));
  13630. }
  13631. return segs;
  13632. };
  13633. ListView.prototype.eventRangeToSegs = function (eventRange, dayRanges) {
  13634. var dateEnv = this.context.dateEnv;
  13635. var nextDayThreshold = this.context.options.nextDayThreshold;
  13636. var range = eventRange.range;
  13637. var allDay = eventRange.def.allDay;
  13638. var dayIndex;
  13639. var segRange;
  13640. var seg;
  13641. var segs = [];
  13642. for (dayIndex = 0; dayIndex < dayRanges.length; dayIndex++) {
  13643. segRange = intersectRanges(range, dayRanges[dayIndex]);
  13644. if (segRange) {
  13645. seg = {
  13646. component: this,
  13647. eventRange: eventRange,
  13648. start: segRange.start,
  13649. end: segRange.end,
  13650. isStart: eventRange.isStart && segRange.start.valueOf() === range.start.valueOf(),
  13651. isEnd: eventRange.isEnd && segRange.end.valueOf() === range.end.valueOf(),
  13652. dayIndex: dayIndex
  13653. };
  13654. segs.push(seg);
  13655. // detect when range won't go fully into the next day,
  13656. // and mutate the latest seg to the be the end.
  13657. if (!seg.isEnd && !allDay &&
  13658. dayIndex + 1 < dayRanges.length &&
  13659. range.end <
  13660. dateEnv.add(dayRanges[dayIndex + 1].start, nextDayThreshold)) {
  13661. seg.end = range.end;
  13662. seg.isEnd = true;
  13663. break;
  13664. }
  13665. }
  13666. }
  13667. return segs;
  13668. };
  13669. return ListView;
  13670. }(DateComponent));
  13671. function renderNoEventsInner(hookProps) {
  13672. return hookProps.text;
  13673. }
  13674. function computeDateVars(dateProfile) {
  13675. var dayStart = startOfDay(dateProfile.renderRange.start);
  13676. var viewEnd = dateProfile.renderRange.end;
  13677. var dayDates = [];
  13678. var dayRanges = [];
  13679. while (dayStart < viewEnd) {
  13680. dayDates.push(dayStart);
  13681. dayRanges.push({
  13682. start: dayStart,
  13683. end: addDays(dayStart, 1)
  13684. });
  13685. dayStart = addDays(dayStart, 1);
  13686. }
  13687. return { dayDates: dayDates, dayRanges: dayRanges };
  13688. }
  13689. // Returns a sparse array of arrays, segs grouped by their dayIndex
  13690. function groupSegsByDay(segs) {
  13691. var segsByDay = []; // sparse array
  13692. var i;
  13693. var seg;
  13694. for (i = 0; i < segs.length; i++) {
  13695. seg = segs[i];
  13696. (segsByDay[seg.dayIndex] || (segsByDay[seg.dayIndex] = []))
  13697. .push(seg);
  13698. }
  13699. return segsByDay;
  13700. }
  13701. var OPTION_REFINERS$2 = {
  13702. listDayFormat: createFalsableFormatter,
  13703. listDaySideFormat: createFalsableFormatter,
  13704. noEventsClassNames: identity,
  13705. noEventsContent: identity,
  13706. noEventsDidMount: identity,
  13707. noEventsWillUnmount: identity
  13708. // noEventsText is defined in base options
  13709. };
  13710. function createFalsableFormatter(input) {
  13711. return input === false ? null : createFormatter(input);
  13712. }
  13713. var listPlugin = createPlugin({
  13714. optionRefiners: OPTION_REFINERS$2,
  13715. views: {
  13716. list: {
  13717. component: ListView,
  13718. buttonTextKey: 'list',
  13719. listDayFormat: { month: 'long', day: 'numeric', year: 'numeric' } // like "January 1, 2016"
  13720. },
  13721. listDay: {
  13722. type: 'list',
  13723. duration: { days: 1 },
  13724. listDayFormat: { weekday: 'long' } // day-of-week is all we need. full date is probably in headerToolbar
  13725. },
  13726. listWeek: {
  13727. type: 'list',
  13728. duration: { weeks: 1 },
  13729. listDayFormat: { weekday: 'long' },
  13730. listDaySideFormat: { month: 'long', day: 'numeric', year: 'numeric' }
  13731. },
  13732. listMonth: {
  13733. type: 'list',
  13734. duration: { month: 1 },
  13735. listDaySideFormat: { weekday: 'long' } // day-of-week is nice-to-have
  13736. },
  13737. listYear: {
  13738. type: 'list',
  13739. duration: { year: 1 },
  13740. listDaySideFormat: { weekday: 'long' } // day-of-week is nice-to-have
  13741. }
  13742. }
  13743. });
  13744. var BootstrapTheme = /** @class */ (function (_super) {
  13745. __extends(BootstrapTheme, _super);
  13746. function BootstrapTheme() {
  13747. return _super !== null && _super.apply(this, arguments) || this;
  13748. }
  13749. return BootstrapTheme;
  13750. }(Theme));
  13751. BootstrapTheme.prototype.classes = {
  13752. root: 'fc-theme-bootstrap',
  13753. table: 'table-bordered',
  13754. tableCellShaded: 'table-active',
  13755. buttonGroup: 'btn-group',
  13756. button: 'btn btn-primary',
  13757. buttonActive: 'active',
  13758. popover: 'popover',
  13759. popoverHeader: 'popover-header',
  13760. popoverContent: 'popover-body'
  13761. };
  13762. BootstrapTheme.prototype.baseIconClass = 'fa';
  13763. BootstrapTheme.prototype.iconClasses = {
  13764. close: 'fa-times',
  13765. prev: 'fa-chevron-left',
  13766. next: 'fa-chevron-right',
  13767. prevYear: 'fa-angle-double-left',
  13768. nextYear: 'fa-angle-double-right'
  13769. };
  13770. BootstrapTheme.prototype.rtlIconClasses = {
  13771. prev: 'fa-chevron-right',
  13772. next: 'fa-chevron-left',
  13773. prevYear: 'fa-angle-double-right',
  13774. nextYear: 'fa-angle-double-left'
  13775. };
  13776. BootstrapTheme.prototype.iconOverrideOption = 'bootstrapFontAwesome'; // TODO: make TS-friendly. move the option-processing into this plugin
  13777. BootstrapTheme.prototype.iconOverrideCustomButtonOption = 'bootstrapFontAwesome';
  13778. BootstrapTheme.prototype.iconOverridePrefix = 'fa-';
  13779. var plugin = createPlugin({
  13780. themeClasses: {
  13781. bootstrap: BootstrapTheme
  13782. }
  13783. });
  13784. // rename this file to options.ts like other packages?
  13785. var OPTION_REFINERS$3 = {
  13786. googleCalendarApiKey: String
  13787. };
  13788. var EVENT_SOURCE_REFINERS$1 = {
  13789. googleCalendarApiKey: String,
  13790. googleCalendarId: String,
  13791. googleCalendarApiBase: String,
  13792. extraParams: identity
  13793. };
  13794. // TODO: expose somehow
  13795. var API_BASE = 'https://www.googleapis.com/calendar/v3/calendars';
  13796. var eventSourceDef$3 = {
  13797. parseMeta: function (refined) {
  13798. var googleCalendarId = refined.googleCalendarId;
  13799. if (!googleCalendarId && refined.url) {
  13800. googleCalendarId = parseGoogleCalendarId(refined.url);
  13801. }
  13802. if (googleCalendarId) {
  13803. return {
  13804. googleCalendarId: googleCalendarId,
  13805. googleCalendarApiKey: refined.googleCalendarApiKey,
  13806. googleCalendarApiBase: refined.googleCalendarApiBase,
  13807. extraParams: refined.extraParams
  13808. };
  13809. }
  13810. return null;
  13811. },
  13812. fetch: function (arg, onSuccess, onFailure) {
  13813. var _a = arg.context, dateEnv = _a.dateEnv, options = _a.options;
  13814. var meta = arg.eventSource.meta;
  13815. var apiKey = meta.googleCalendarApiKey || options.googleCalendarApiKey;
  13816. if (!apiKey) {
  13817. onFailure({
  13818. message: 'Specify a googleCalendarApiKey. See http://fullcalendar.io/docs/google_calendar/'
  13819. });
  13820. }
  13821. else {
  13822. var url = buildUrl(meta);
  13823. // TODO: make DRY with json-feed-event-source
  13824. var extraParams = meta.extraParams;
  13825. var extraParamsObj = typeof extraParams === 'function' ? extraParams() : extraParams;
  13826. var requestParams_1 = buildRequestParams$1(arg.range, apiKey, extraParamsObj, dateEnv);
  13827. requestJson('GET', url, requestParams_1, function (body, xhr) {
  13828. if (body.error) {
  13829. onFailure({
  13830. message: 'Google Calendar API: ' + body.error.message,
  13831. errors: body.error.errors,
  13832. xhr: xhr
  13833. });
  13834. }
  13835. else {
  13836. onSuccess({
  13837. rawEvents: gcalItemsToRawEventDefs(body.items, requestParams_1.timeZone),
  13838. xhr: xhr
  13839. });
  13840. }
  13841. }, function (message, xhr) {
  13842. onFailure({ message: message, xhr: xhr });
  13843. });
  13844. }
  13845. }
  13846. };
  13847. function parseGoogleCalendarId(url) {
  13848. var match;
  13849. // detect if the ID was specified as a single string.
  13850. // will match calendars like "asdf1234@calendar.google.com" in addition to person email calendars.
  13851. if (/^[^/]+@([^/.]+\.)*(google|googlemail|gmail)\.com$/.test(url)) {
  13852. return url;
  13853. }
  13854. else if ((match = /^https:\/\/www.googleapis.com\/calendar\/v3\/calendars\/([^/]*)/.exec(url)) ||
  13855. (match = /^https?:\/\/www.google.com\/calendar\/feeds\/([^/]*)/.exec(url))) {
  13856. return decodeURIComponent(match[1]);
  13857. }
  13858. }
  13859. function buildUrl(meta) {
  13860. var apiBase = meta.googleCalendarApiBase;
  13861. if (!apiBase) {
  13862. apiBase = API_BASE;
  13863. }
  13864. return apiBase + '/' + encodeURIComponent(meta.googleCalendarId) + '/events';
  13865. }
  13866. function buildRequestParams$1(range, apiKey, extraParams, dateEnv) {
  13867. var params;
  13868. var startStr;
  13869. var endStr;
  13870. if (dateEnv.canComputeOffset) {
  13871. // strings will naturally have offsets, which GCal needs
  13872. startStr = dateEnv.formatIso(range.start);
  13873. endStr = dateEnv.formatIso(range.end);
  13874. }
  13875. else {
  13876. // when timezone isn't known, we don't know what the UTC offset should be, so ask for +/- 1 day
  13877. // from the UTC day-start to guarantee we're getting all the events
  13878. // (start/end will be UTC-coerced dates, so toISOString is okay)
  13879. startStr = addDays(range.start, -1).toISOString();
  13880. endStr = addDays(range.end, 1).toISOString();
  13881. }
  13882. params = __assign(__assign({}, (extraParams || {})), { key: apiKey, timeMin: startStr, timeMax: endStr, singleEvents: true, maxResults: 9999 });
  13883. if (dateEnv.timeZone !== 'local') {
  13884. params.timeZone = dateEnv.timeZone;
  13885. }
  13886. return params;
  13887. }
  13888. function gcalItemsToRawEventDefs(items, gcalTimezone) {
  13889. return items.map(function (item) {
  13890. return gcalItemToRawEventDef(item, gcalTimezone);
  13891. });
  13892. }
  13893. function gcalItemToRawEventDef(item, gcalTimezone) {
  13894. var url = item.htmlLink || null;
  13895. // make the URLs for each event show times in the correct timezone
  13896. if (url && gcalTimezone) {
  13897. url = injectQsComponent(url, 'ctz=' + gcalTimezone);
  13898. }
  13899. return {
  13900. id: item.id,
  13901. title: item.summary,
  13902. start: item.start.dateTime || item.start.date,
  13903. end: item.end.dateTime || item.end.date,
  13904. url: url,
  13905. location: item.location,
  13906. description: item.description
  13907. };
  13908. }
  13909. // Injects a string like "arg=value" into the querystring of a URL
  13910. // TODO: move to a general util file?
  13911. function injectQsComponent(url, component) {
  13912. // inject it after the querystring but before the fragment
  13913. return url.replace(/(\?.*?)?(#|$)/, function (whole, qs, hash) {
  13914. return (qs ? qs + '&' : '?') + component + hash;
  13915. });
  13916. }
  13917. var googleCalendarPlugin = createPlugin({
  13918. eventSourceDefs: [eventSourceDef$3],
  13919. optionRefiners: OPTION_REFINERS$3,
  13920. eventSourceRefiners: EVENT_SOURCE_REFINERS$1
  13921. });
  13922. globalPlugins.push(interactionPlugin, dayGridPlugin, timeGridPlugin, listPlugin, plugin, googleCalendarPlugin);
  13923. exports.BASE_OPTION_DEFAULTS = BASE_OPTION_DEFAULTS;
  13924. exports.BASE_OPTION_REFINERS = BASE_OPTION_REFINERS;
  13925. exports.BaseComponent = BaseComponent;
  13926. exports.BgEvent = BgEvent;
  13927. exports.BootstrapTheme = BootstrapTheme;
  13928. exports.Calendar = Calendar;
  13929. exports.CalendarApi = CalendarApi;
  13930. exports.CalendarContent = CalendarContent;
  13931. exports.CalendarDataManager = CalendarDataManager;
  13932. exports.CalendarDataProvider = CalendarDataProvider;
  13933. exports.CalendarRoot = CalendarRoot;
  13934. exports.Component = Component;
  13935. exports.ContentHook = ContentHook;
  13936. exports.CustomContentRenderContext = CustomContentRenderContext;
  13937. exports.DateComponent = DateComponent;
  13938. exports.DateEnv = DateEnv;
  13939. exports.DateProfileGenerator = DateProfileGenerator;
  13940. exports.DayCellContent = DayCellContent;
  13941. exports.DayCellRoot = DayCellRoot;
  13942. exports.DayGridView = DayTableView;
  13943. exports.DayHeader = DayHeader;
  13944. exports.DaySeriesModel = DaySeriesModel;
  13945. exports.DayTable = DayTable;
  13946. exports.DayTableModel = DayTableModel;
  13947. exports.DayTableSlicer = DayTableSlicer;
  13948. exports.DayTimeCols = DayTimeCols;
  13949. exports.DayTimeColsSlicer = DayTimeColsSlicer;
  13950. exports.DayTimeColsView = DayTimeColsView;
  13951. exports.DelayedRunner = DelayedRunner;
  13952. exports.Draggable = ExternalDraggable;
  13953. exports.ElementDragging = ElementDragging;
  13954. exports.ElementScrollController = ElementScrollController;
  13955. exports.Emitter = Emitter;
  13956. exports.EventApi = EventApi;
  13957. exports.EventRoot = EventRoot;
  13958. exports.EventSourceApi = EventSourceApi;
  13959. exports.FeaturefulElementDragging = FeaturefulElementDragging;
  13960. exports.Fragment = Fragment;
  13961. exports.Interaction = Interaction;
  13962. exports.ListView = ListView;
  13963. exports.MountHook = MountHook;
  13964. exports.NamedTimeZoneImpl = NamedTimeZoneImpl;
  13965. exports.NowIndicatorRoot = NowIndicatorRoot;
  13966. exports.NowTimer = NowTimer;
  13967. exports.PointerDragging = PointerDragging;
  13968. exports.PositionCache = PositionCache;
  13969. exports.RefMap = RefMap;
  13970. exports.RenderHook = RenderHook;
  13971. exports.ScrollController = ScrollController;
  13972. exports.ScrollResponder = ScrollResponder;
  13973. exports.Scroller = Scroller;
  13974. exports.SimpleScrollGrid = SimpleScrollGrid;
  13975. exports.Slicer = Slicer;
  13976. exports.Splitter = Splitter;
  13977. exports.StandardEvent = StandardEvent;
  13978. exports.Table = Table;
  13979. exports.TableDateCell = TableDateCell;
  13980. exports.TableDowCell = TableDowCell;
  13981. exports.TableView = TableView;
  13982. exports.Theme = Theme;
  13983. exports.ThirdPartyDraggable = ThirdPartyDraggable;
  13984. exports.TimeCols = TimeCols;
  13985. exports.TimeColsSlatsCoords = TimeColsSlatsCoords;
  13986. exports.TimeColsView = TimeColsView;
  13987. exports.ViewApi = ViewApi;
  13988. exports.ViewContextType = ViewContextType;
  13989. exports.ViewRoot = ViewRoot;
  13990. exports.WeekNumberRoot = WeekNumberRoot;
  13991. exports.WindowScrollController = WindowScrollController;
  13992. exports.addDays = addDays;
  13993. exports.addDurations = addDurations;
  13994. exports.addMs = addMs;
  13995. exports.addWeeks = addWeeks;
  13996. exports.allowContextMenu = allowContextMenu;
  13997. exports.allowSelection = allowSelection;
  13998. exports.applyMutationToEventStore = applyMutationToEventStore;
  13999. exports.applyStyle = applyStyle;
  14000. exports.applyStyleProp = applyStyleProp;
  14001. exports.asRoughMinutes = asRoughMinutes;
  14002. exports.asRoughMs = asRoughMs;
  14003. exports.asRoughSeconds = asRoughSeconds;
  14004. exports.buildClassNameNormalizer = buildClassNameNormalizer;
  14005. exports.buildDayRanges = buildDayRanges;
  14006. exports.buildDayTableModel = buildDayTableModel;
  14007. exports.buildEventApis = buildEventApis;
  14008. exports.buildEventRangeKey = buildEventRangeKey;
  14009. exports.buildHashFromArray = buildHashFromArray;
  14010. exports.buildNavLinkData = buildNavLinkData;
  14011. exports.buildSegCompareObj = buildSegCompareObj;
  14012. exports.buildSegTimeText = buildSegTimeText;
  14013. exports.buildSlatMetas = buildSlatMetas;
  14014. exports.buildTimeColsModel = buildTimeColsModel;
  14015. exports.collectFromHash = collectFromHash;
  14016. exports.combineEventUis = combineEventUis;
  14017. exports.compareByFieldSpec = compareByFieldSpec;
  14018. exports.compareByFieldSpecs = compareByFieldSpecs;
  14019. exports.compareNumbers = compareNumbers;
  14020. exports.compareObjs = compareObjs;
  14021. exports.computeEdges = computeEdges;
  14022. exports.computeFallbackHeaderFormat = computeFallbackHeaderFormat;
  14023. exports.computeHeightAndMargins = computeHeightAndMargins;
  14024. exports.computeInnerRect = computeInnerRect;
  14025. exports.computeRect = computeRect;
  14026. exports.computeSegDraggable = computeSegDraggable;
  14027. exports.computeSegEndResizable = computeSegEndResizable;
  14028. exports.computeSegStartResizable = computeSegStartResizable;
  14029. exports.computeShrinkWidth = computeShrinkWidth;
  14030. exports.computeSmallestCellWidth = computeSmallestCellWidth;
  14031. exports.computeVisibleDayRange = computeVisibleDayRange;
  14032. exports.config = config;
  14033. exports.constrainPoint = constrainPoint;
  14034. exports.createContext = createContext$1;
  14035. exports.createDuration = createDuration;
  14036. exports.createElement = createElement;
  14037. exports.createEmptyEventStore = createEmptyEventStore;
  14038. exports.createEventInstance = createEventInstance;
  14039. exports.createEventUi = createEventUi;
  14040. exports.createFormatter = createFormatter;
  14041. exports.createPlugin = createPlugin;
  14042. exports.createRef = createRef;
  14043. exports.diffDates = diffDates;
  14044. exports.diffDayAndTime = diffDayAndTime;
  14045. exports.diffDays = diffDays;
  14046. exports.diffPoints = diffPoints;
  14047. exports.diffWeeks = diffWeeks;
  14048. exports.diffWholeDays = diffWholeDays;
  14049. exports.diffWholeWeeks = diffWholeWeeks;
  14050. exports.disableCursor = disableCursor;
  14051. exports.elementClosest = elementClosest;
  14052. exports.elementMatches = elementMatches;
  14053. exports.enableCursor = enableCursor;
  14054. exports.eventTupleToStore = eventTupleToStore;
  14055. exports.filterEventStoreDefs = filterEventStoreDefs;
  14056. exports.filterHash = filterHash;
  14057. exports.findDirectChildren = findDirectChildren;
  14058. exports.findElements = findElements;
  14059. exports.flexibleCompare = flexibleCompare;
  14060. exports.flushToDom = flushToDom$1;
  14061. exports.formatDate = formatDate;
  14062. exports.formatDayString = formatDayString;
  14063. exports.formatIsoTimeString = formatIsoTimeString;
  14064. exports.formatRange = formatRange;
  14065. exports.getAllowYScrolling = getAllowYScrolling;
  14066. exports.getClippingParents = getClippingParents;
  14067. exports.getDateMeta = getDateMeta;
  14068. exports.getDayClassNames = getDayClassNames;
  14069. exports.getDefaultEventEnd = getDefaultEventEnd;
  14070. exports.getElSeg = getElSeg;
  14071. exports.getEventClassNames = getEventClassNames;
  14072. exports.getIsRtlScrollbarOnLeft = getIsRtlScrollbarOnLeft;
  14073. exports.getRectCenter = getRectCenter;
  14074. exports.getRelevantEvents = getRelevantEvents;
  14075. exports.getScrollGridClassNames = getScrollGridClassNames;
  14076. exports.getScrollbarWidths = getScrollbarWidths;
  14077. exports.getSectionClassNames = getSectionClassNames;
  14078. exports.getSectionHasLiquidHeight = getSectionHasLiquidHeight;
  14079. exports.getSegMeta = getSegMeta;
  14080. exports.getSlotClassNames = getSlotClassNames;
  14081. exports.getStickyFooterScrollbar = getStickyFooterScrollbar;
  14082. exports.getStickyHeaderDates = getStickyHeaderDates;
  14083. exports.getUnequalProps = getUnequalProps;
  14084. exports.globalLocales = globalLocales;
  14085. exports.globalPlugins = globalPlugins;
  14086. exports.greatestDurationDenominator = greatestDurationDenominator;
  14087. exports.guid = guid;
  14088. exports.hasBgRendering = hasBgRendering;
  14089. exports.hasShrinkWidth = hasShrinkWidth;
  14090. exports.htmlToElement = htmlToElement;
  14091. exports.identity = identity;
  14092. exports.interactionSettingsStore = interactionSettingsStore;
  14093. exports.interactionSettingsToStore = interactionSettingsToStore;
  14094. exports.intersectRanges = intersectRanges;
  14095. exports.intersectRects = intersectRects;
  14096. exports.isArraysEqual = isArraysEqual;
  14097. exports.isColPropsEqual = isColPropsEqual;
  14098. exports.isDateSpansEqual = isDateSpansEqual;
  14099. exports.isInt = isInt;
  14100. exports.isInteractionValid = isInteractionValid;
  14101. exports.isMultiDayRange = isMultiDayRange;
  14102. exports.isPropsEqual = isPropsEqual;
  14103. exports.isPropsValid = isPropsValid;
  14104. exports.isSingleDay = isSingleDay;
  14105. exports.isValidDate = isValidDate;
  14106. exports.listenBySelector = listenBySelector;
  14107. exports.mapHash = mapHash;
  14108. exports.memoize = memoize;
  14109. exports.memoizeArraylike = memoizeArraylike;
  14110. exports.memoizeHashlike = memoizeHashlike;
  14111. exports.memoizeObjArg = memoizeObjArg;
  14112. exports.mergeEventStores = mergeEventStores;
  14113. exports.multiplyDuration = multiplyDuration;
  14114. exports.padStart = padStart;
  14115. exports.parseBusinessHours = parseBusinessHours;
  14116. exports.parseClassNames = parseClassNames;
  14117. exports.parseDragMeta = parseDragMeta;
  14118. exports.parseEventDef = parseEventDef;
  14119. exports.parseFieldSpecs = parseFieldSpecs;
  14120. exports.parseMarker = parse;
  14121. exports.pointInsideRect = pointInsideRect;
  14122. exports.preventContextMenu = preventContextMenu;
  14123. exports.preventDefault = preventDefault;
  14124. exports.preventSelection = preventSelection;
  14125. exports.rangeContainsMarker = rangeContainsMarker;
  14126. exports.rangeContainsRange = rangeContainsRange;
  14127. exports.rangesEqual = rangesEqual;
  14128. exports.rangesIntersect = rangesIntersect;
  14129. exports.refineEventDef = refineEventDef;
  14130. exports.refineProps = refineProps;
  14131. exports.removeElement = removeElement;
  14132. exports.removeExact = removeExact;
  14133. exports.render = render;
  14134. exports.renderChunkContent = renderChunkContent;
  14135. exports.renderFill = renderFill;
  14136. exports.renderMicroColGroup = renderMicroColGroup;
  14137. exports.renderScrollShim = renderScrollShim;
  14138. exports.requestJson = requestJson;
  14139. exports.sanitizeShrinkWidth = sanitizeShrinkWidth;
  14140. exports.setElSeg = setElSeg;
  14141. exports.setRef = setRef;
  14142. exports.sliceEventStore = sliceEventStore;
  14143. exports.sliceEvents = sliceEvents;
  14144. exports.sortEventSegs = sortEventSegs;
  14145. exports.startOfDay = startOfDay;
  14146. exports.translateRect = translateRect;
  14147. exports.triggerDateSelect = triggerDateSelect;
  14148. exports.unpromisify = unpromisify;
  14149. exports.version = version;
  14150. exports.whenTransitionDone = whenTransitionDone;
  14151. exports.wholeDivideDurations = wholeDivideDurations;
  14152. return exports;
  14153. }({}));