v4-fullcalendar.js 702 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018
  1. /*!
  2. FullCalendar v5.11.3
  3. Docs & License: https://fullcalendar.io/
  4. (c) 2022 Adam Shaw
  5. */
  6. var FullCalendar = (function (exports) {
  7. 'use strict';
  8. /*! *****************************************************************************
  9. Copyright (c) Microsoft Corporation.
  10. Permission to use, copy, modify, and/or distribute this software for any
  11. purpose with or without fee is hereby granted.
  12. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
  13. REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
  14. AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
  15. INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  16. LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
  17. OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  18. PERFORMANCE OF THIS SOFTWARE.
  19. ***************************************************************************** */
  20. /* global Reflect, Promise */
  21. var extendStatics = function(d, b) {
  22. extendStatics = Object.setPrototypeOf ||
  23. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  24. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  25. return extendStatics(d, b);
  26. };
  27. function __extends(d, b) {
  28. if (typeof b !== "function" && b !== null)
  29. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  30. extendStatics(d, b);
  31. function __() { this.constructor = d; }
  32. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  33. }
  34. var __assign = function() {
  35. __assign = Object.assign || function __assign(t) {
  36. for (var s, i = 1, n = arguments.length; i < n; i++) {
  37. s = arguments[i];
  38. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  39. }
  40. return t;
  41. };
  42. return __assign.apply(this, arguments);
  43. };
  44. function __spreadArray(to, from, pack) {
  45. if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
  46. if (ar || !(i in from)) {
  47. if (!ar) ar = Array.prototype.slice.call(from, 0, i);
  48. ar[i] = from[i];
  49. }
  50. }
  51. return to.concat(ar || from);
  52. }
  53. var n,u,i$1,t,o,r$1={},f$1=[],e$1=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i;function c$1(n,l){for(var u in l)n[u]=l[u];return n}function s(n){var l=n.parentNode;l&&l.removeChild(n);}function a$1(n,l,u){var i,t,o,r=arguments,f={};for(o in l)"key"==o?i=l[o]:"ref"==o?t=l[o]:f[o]=l[o];if(arguments.length>3)for(u=[u],o=3;o<arguments.length;o++)u.push(r[o]);if(null!=u&&(f.children=u),"function"==typeof n&&null!=n.defaultProps)for(o in n.defaultProps)void 0===f[o]&&(f[o]=n.defaultProps[o]);return v$1(n,f,i,t,null)}function v$1(l,u,i,t,o){var r={type:l,props:u,key:i,ref:t,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,__h:null,constructor:void 0,__v:null==o?++n.__v:o};return null!=n.vnode&&n.vnode(r),r}function h(){return {current:null}}function y(n){return n.children}function p(n,l){this.props=n,this.context=l;}function d(n,l){if(null==l)return n.__?d(n.__,n.__.__k.indexOf(n)+1):null;for(var u;l<n.__k.length;l++)if(null!=(u=n.__k[l])&&null!=u.__e)return u.__e;return "function"==typeof n.type?d(n):null}function _(n){var l,u;if(null!=(n=n.__)&&null!=n.__c){for(n.__e=n.__c.base=null,l=0;l<n.__k.length;l++)if(null!=(u=n.__k[l])&&null!=u.__e){n.__e=n.__c.base=u.__e;break}return _(n)}}function k(l){(!l.__d&&(l.__d=!0)&&u.push(l)&&!b$1.__r++||t!==n.debounceRendering)&&((t=n.debounceRendering)||i$1)(b$1);}function b$1(){for(var n;b$1.__r=u.length;)n=u.sort(function(n,l){return n.__v.__b-l.__v.__b}),u=[],n.some(function(n){var l,u,i,t,o,r;n.__d&&(o=(t=(l=n).__v).__e,(r=l.__P)&&(u=[],(i=c$1({},t)).__v=t.__v+1,I$1(r,t,i,l.__n,void 0!==r.ownerSVGElement,null!=t.__h?[o]:null,u,null==o?d(t):o,t.__h),T$1(u,t),t.__e!=o&&_(t)));});}function m(n,l,u,i,t,o,e,c,s,a){var h,p,_,k,b,m,w,A=i&&i.__k||f$1,P=A.length;for(u.__k=[],h=0;h<l.length;h++)if(null!=(k=u.__k[h]=null==(k=l[h])||"boolean"==typeof k?null:"string"==typeof k||"number"==typeof k||"bigint"==typeof k?v$1(null,k,null,null,k):Array.isArray(k)?v$1(y,{children:k},null,null,null):k.__b>0?v$1(k.type,k.props,k.key,null,k.__v):k)){if(k.__=u,k.__b=u.__b+1,null===(_=A[h])||_&&k.key==_.key&&k.type===_.type)A[h]=void 0;else for(p=0;p<P;p++){if((_=A[p])&&k.key==_.key&&k.type===_.type){A[p]=void 0;break}_=null;}I$1(n,k,_=_||r$1,t,o,e,c,s,a),b=k.__e,(p=k.ref)&&_.ref!=p&&(w||(w=[]),_.ref&&w.push(_.ref,null,k),w.push(p,k.__c||b,k)),null!=b?(null==m&&(m=b),"function"==typeof k.type&&null!=k.__k&&k.__k===_.__k?k.__d=s=g$1(k,s,n):s=x$1(n,k,_,A,b,s),a||"option"!==u.type?"function"==typeof u.type&&(u.__d=s):n.value=""):s&&_.__e==s&&s.parentNode!=n&&(s=d(_));}for(u.__e=m,h=P;h--;)null!=A[h]&&("function"==typeof u.type&&null!=A[h].__e&&A[h].__e==u.__d&&(u.__d=d(i,h+1)),L$1(A[h],A[h]));if(w)for(h=0;h<w.length;h++)z(w[h],w[++h],w[++h]);}function g$1(n,l,u){var i,t;for(i=0;i<n.__k.length;i++)(t=n.__k[i])&&(t.__=n,l="function"==typeof t.type?g$1(t,l,u):x$1(u,t,t,n.__k,t.__e,l));return l}function w$1(n,l){return l=l||[],null==n||"boolean"==typeof n||(Array.isArray(n)?n.some(function(n){w$1(n,l);}):l.push(n)),l}function x$1(n,l,u,i,t,o){var r,f,e;if(void 0!==l.__d)r=l.__d,l.__d=void 0;else if(null==u||t!=o||null==t.parentNode)n:if(null==o||o.parentNode!==n)n.appendChild(t),r=null;else {for(f=o,e=0;(f=f.nextSibling)&&e<i.length;e+=2)if(f==t)break n;n.insertBefore(t,o),r=o;}return void 0!==r?r:t.nextSibling}function A$1(n,l,u,i,t){var o;for(o in u)"children"===o||"key"===o||o in l||C$1(n,o,null,u[o],i);for(o in l)t&&"function"!=typeof l[o]||"children"===o||"key"===o||"value"===o||"checked"===o||u[o]===l[o]||C$1(n,o,l[o],u[o],i);}function P$1(n,l,u){"-"===l[0]?n.setProperty(l,u):n[l]=null==u?"":"number"!=typeof u||e$1.test(l)?u:u+"px";}function C$1(n,l,u,i,t){var o;n:if("style"===l)if("string"==typeof u)n.style.cssText=u;else {if("string"==typeof i&&(n.style.cssText=i=""),i)for(l in i)u&&l in u||P$1(n.style,l,"");if(u)for(l in u)i&&u[l]===i[l]||P$1(n.style,l,u[l]);}else if("o"===l[0]&&"n"===l[1])o=l!==(l=l.replace(/Capture$/,"")),l=l.toLowerCase()in n?l.toLowerCase().slice(2):l.slice(2),n.l||(n.l={}),n.l[l+o]=u,u?i||n.addEventListener(l,o?H$1:$$1,o):n.removeEventListener(l,o?H$1:$$1,o);else if("dangerouslySetInnerHTML"!==l){if(t)l=l.replace(/xlink[H:h]/,"h").replace(/sName$/,"s");else if("href"!==l&&"list"!==l&&"form"!==l&&"tabIndex"!==l&&"download"!==l&&l in n)try{n[l]=null==u?"":u;break n}catch(n){}"function"==typeof u||(null!=u&&(!1!==u||"a"===l[0]&&"r"===l[1])?n.setAttribute(l,u):n.removeAttribute(l));}}function $$1(l){this.l[l.type+!1](n.event?n.event(l):l);}function H$1(l){this.l[l.type+!0](n.event?n.event(l):l);}function I$1(l,u,i,t,o,r,f,e,s){var a,v,h,d,_,k,b,g,w,x,A,P=u.type;if(void 0!==u.constructor)return null;null!=i.__h&&(s=i.__h,e=u.__e=i.__e,u.__h=null,r=[e]),(a=n.__b)&&a(u);try{n:if("function"==typeof P){if(g=u.props,w=(a=P.contextType)&&t[a.__c],x=a?w?w.props.value:a.__:t,i.__c?b=(v=u.__c=i.__c).__=v.__E:("prototype"in P&&P.prototype.render?u.__c=v=new P(g,x):(u.__c=v=new p(g,x),v.constructor=P,v.render=M$1),w&&w.sub(v),v.props=g,v.state||(v.state={}),v.context=x,v.__n=t,h=v.__d=!0,v.__h=[]),null==v.__s&&(v.__s=v.state),null!=P.getDerivedStateFromProps&&(v.__s==v.state&&(v.__s=c$1({},v.__s)),c$1(v.__s,P.getDerivedStateFromProps(g,v.__s))),d=v.props,_=v.state,h)null==P.getDerivedStateFromProps&&null!=v.componentWillMount&&v.componentWillMount(),null!=v.componentDidMount&&v.__h.push(v.componentDidMount);else {if(null==P.getDerivedStateFromProps&&g!==d&&null!=v.componentWillReceiveProps&&v.componentWillReceiveProps(g,x),!v.__e&&null!=v.shouldComponentUpdate&&!1===v.shouldComponentUpdate(g,v.__s,x)||u.__v===i.__v){v.props=g,v.state=v.__s,u.__v!==i.__v&&(v.__d=!1),v.__v=u,u.__e=i.__e,u.__k=i.__k,u.__k.forEach(function(n){n&&(n.__=u);}),v.__h.length&&f.push(v);break n}null!=v.componentWillUpdate&&v.componentWillUpdate(g,v.__s,x),null!=v.componentDidUpdate&&v.__h.push(function(){v.componentDidUpdate(d,_,k);});}v.context=x,v.props=g,v.state=v.__s,(a=n.__r)&&a(u),v.__d=!1,v.__v=u,v.__P=l,a=v.render(v.props,v.state,v.context),v.state=v.__s,null!=v.getChildContext&&(t=c$1(c$1({},t),v.getChildContext())),h||null==v.getSnapshotBeforeUpdate||(k=v.getSnapshotBeforeUpdate(d,_)),A=null!=a&&a.type===y&&null==a.key?a.props.children:a,m(l,Array.isArray(A)?A:[A],u,i,t,o,r,f,e,s),v.base=u.__e,u.__h=null,v.__h.length&&f.push(v),b&&(v.__E=v.__=null),v.__e=!1;}else null==r&&u.__v===i.__v?(u.__k=i.__k,u.__e=i.__e):u.__e=j$2(i.__e,u,i,t,o,r,f,s);(a=n.diffed)&&a(u);}catch(l){u.__v=null,(s||null!=r)&&(u.__e=e,u.__h=!!s,r[r.indexOf(e)]=null),n.__e(l,u,i);}}function T$1(l,u){n.__c&&n.__c(u,l),l.some(function(u){try{l=u.__h,u.__h=[],l.some(function(n){n.call(u);});}catch(l){n.__e(l,u.__v);}});}function j$2(n,l,u,i,t,o,e,c){var a,v,h,y,p=u.props,d=l.props,_=l.type,k=0;if("svg"===_&&(t=!0),null!=o)for(;k<o.length;k++)if((a=o[k])&&(a===n||(_?a.localName==_:3==a.nodeType))){n=a,o[k]=null;break}if(null==n){if(null===_)return document.createTextNode(d);n=t?document.createElementNS("http://www.w3.org/2000/svg",_):document.createElement(_,d.is&&d),o=null,c=!1;}if(null===_)p===d||c&&n.data===d||(n.data=d);else {if(o=o&&f$1.slice.call(n.childNodes),v=(p=u.props||r$1).dangerouslySetInnerHTML,h=d.dangerouslySetInnerHTML,!c){if(null!=o)for(p={},y=0;y<n.attributes.length;y++)p[n.attributes[y].name]=n.attributes[y].value;(h||v)&&(h&&(v&&h.__html==v.__html||h.__html===n.innerHTML)||(n.innerHTML=h&&h.__html||""));}if(A$1(n,d,p,t,c),h)l.__k=[];else if(k=l.props.children,m(n,Array.isArray(k)?k:[k],l,u,i,t&&"foreignObject"!==_,o,e,n.firstChild,c),null!=o)for(k=o.length;k--;)null!=o[k]&&s(o[k]);c||("value"in d&&void 0!==(k=d.value)&&(k!==n.value||"progress"===_&&!k)&&C$1(n,"value",k,p.value,!1),"checked"in d&&void 0!==(k=d.checked)&&k!==n.checked&&C$1(n,"checked",k,p.checked,!1));}return n}function z(l,u,i){try{"function"==typeof l?l(u):l.current=u;}catch(l){n.__e(l,i);}}function L$1(l,u,i){var t,o,r;if(n.unmount&&n.unmount(l),(t=l.ref)&&(t.current&&t.current!==l.__e||z(t,null,u)),i||"function"==typeof l.type||(i=null!=(o=l.__e)),l.__e=l.__d=void 0,null!=(t=l.__c)){if(t.componentWillUnmount)try{t.componentWillUnmount();}catch(l){n.__e(l,u);}t.base=t.__P=null;}if(t=l.__k)for(r=0;r<t.length;r++)t[r]&&L$1(t[r],u,i);null!=o&&s(o);}function M$1(n,l,u){return this.constructor(n,u)}function N(l,u,i){var t,o,e;n.__&&n.__(l,u),o=(t="function"==typeof i)?null:i&&i.__k||u.__k,e=[],I$1(u,l=(!t&&i||u).__k=a$1(y,null,[l]),o||r$1,r$1,void 0!==u.ownerSVGElement,!t&&i?[i]:o?null:u.firstChild?f$1.slice.call(u.childNodes):null,e,!t&&i?i:o?o.__e:u.firstChild,t),T$1(e,l);}function q(n,l){var u={__c:l="__cC"+o++,__:n,Consumer:function(n,l){return n.children(l)},Provider:function(n){var u,i;return this.getChildContext||(u=[],(i={})[l]=this,this.getChildContext=function(){return i},this.shouldComponentUpdate=function(n){this.props.value!==n.value&&u.some(k);},this.sub=function(n){u.push(n);var l=n.componentWillUnmount;n.componentWillUnmount=function(){u.splice(u.indexOf(n),1),l&&l.call(n);};}),n.children}};return u.Provider.__=u.Consumer.contextType=u}n={__e:function(n,l){for(var u,i,t;l=l.__;)if((u=l.__c)&&!u.__)try{if((i=u.constructor)&&null!=i.getDerivedStateFromError&&(u.setState(i.getDerivedStateFromError(n)),t=u.__d),null!=u.componentDidCatch&&(u.componentDidCatch(n),t=u.__d),t)return u.__E=u}catch(l){n=l;}throw n},__v:0},p.prototype.setState=function(n,l){var u;u=null!=this.__s&&this.__s!==this.state?this.__s:this.__s=c$1({},this.state),"function"==typeof n&&(n=n(c$1({},u),this.props)),n&&c$1(u,n),null!=n&&this.__v&&(l&&this.__h.push(l),k(this));},p.prototype.forceUpdate=function(n){this.__v&&(this.__e=!0,n&&this.__h.push(n),k(this));},p.prototype.render=y,u=[],i$1="function"==typeof Promise?Promise.prototype.then.bind(Promise.resolve()):setTimeout,b$1.__r=0,o=0;
  54. var r,i=[],c=n.__b,f=n.__r,e=n.diffed,a=n.__c,v=n.unmount;function x(){i.forEach(function(t){if(t.__P)try{t.__H.__h.forEach(g),t.__H.__h.forEach(j$1),t.__H.__h=[];}catch(u){t.__H.__h=[],n.__e(u,t.__v);}}),i=[];}n.__b=function(n){c&&c(n);},n.__r=function(n){f&&f(n);var r=(n.__c).__H;r&&(r.__h.forEach(g),r.__h.forEach(j$1),r.__h=[]);},n.diffed=function(t){e&&e(t);var o=t.__c;o&&o.__H&&o.__H.__h.length&&(1!==i.push(o)&&r===n.requestAnimationFrame||((r=n.requestAnimationFrame)||function(n){var t,u=function(){clearTimeout(r),b&&cancelAnimationFrame(t),setTimeout(n);},r=setTimeout(u,100);b&&(t=requestAnimationFrame(u));})(x));},n.__c=function(t,u){u.some(function(t){try{t.__h.forEach(g),t.__h=t.__h.filter(function(n){return !n.__||j$1(n)});}catch(r){u.some(function(n){n.__h&&(n.__h=[]);}),u=[],n.__e(r,t.__v);}}),a&&a(t,u);},n.unmount=function(t){v&&v(t);var u=t.__c;if(u&&u.__H)try{u.__H.__.forEach(g);}catch(t){n.__e(t,u.__v);}};var b="function"==typeof requestAnimationFrame;function g(n){"function"==typeof n.__c&&n.__c();}function j$1(n){n.__c=n.__();}
  55. function C(n,t){for(var e in t)n[e]=t[e];return n}function S(n,t){for(var e in n)if("__source"!==e&&!(e in t))return !0;for(var r in t)if("__source"!==r&&n[r]!==t[r])return !0;return !1}function E(n){this.props=n;}(E.prototype=new p).isPureReactComponent=!0,E.prototype.shouldComponentUpdate=function(n,t){return S(this.props,n)||S(this.state,t)};var w=n.__b;n.__b=function(n){n.type&&n.type.__f&&n.ref&&(n.props.ref=n.ref,n.ref=null),w&&w(n);};var A=n.__e;n.__e=function(n,t,e){if(n.then)for(var r,u=t;u=u.__;)if((r=u.__c)&&r.__c)return null==t.__e&&(t.__e=e.__e,t.__k=e.__k),r.__c(n,t);A(n,t,e);};var O=n.unmount;function L(){this.__u=0,this.t=null,this.__b=null;}function U(n){var t=n.__.__c;return t&&t.__e&&t.__e(n)}function F(){this.u=null,this.o=null;}n.unmount=function(n){var t=n.__c;t&&t.__R&&t.__R(),t&&!0===n.__h&&(n.type=null),O&&O(n);},(L.prototype=new p).__c=function(n,t){var e=t.__c,r=this;null==r.t&&(r.t=[]),r.t.push(e);var u=U(r.__v),o=!1,i=function(){o||(o=!0,e.__R=null,u?u(l):l());};e.__R=i;var l=function(){if(!--r.__u){if(r.state.__e){var n=r.state.__e;r.__v.__k[0]=function n(t,e,r){return t&&(t.__v=null,t.__k=t.__k&&t.__k.map(function(t){return n(t,e,r)}),t.__c&&t.__c.__P===e&&(t.__e&&r.insertBefore(t.__e,t.__d),t.__c.__e=!0,t.__c.__P=r)),t}(n,n.__c.__P,n.__c.__O);}var t;for(r.setState({__e:r.__b=null});t=r.t.pop();)t.forceUpdate();}},f=!0===t.__h;r.__u++||f||r.setState({__e:r.__b=r.__v.__k[0]}),n.then(i,i);},L.prototype.componentWillUnmount=function(){this.t=[];},L.prototype.render=function(n,t){if(this.__b){if(this.__v.__k){var e=document.createElement("div"),r=this.__v.__k[0].__c;this.__v.__k[0]=function n(t,e,r){return t&&(t.__c&&t.__c.__H&&(t.__c.__H.__.forEach(function(n){"function"==typeof n.__c&&n.__c();}),t.__c.__H=null),null!=(t=C({},t)).__c&&(t.__c.__P===r&&(t.__c.__P=e),t.__c=null),t.__k=t.__k&&t.__k.map(function(t){return n(t,e,r)})),t}(this.__b,e,r.__O=r.__P);}this.__b=null;}var u=t.__e&&a$1(y,null,n.fallback);return u&&(u.__h=null),[a$1(y,null,t.__e?null:n.children),u]};var M=function(n,t,e){if(++e[1]===e[0]&&n.o.delete(t),n.props.revealOrder&&("t"!==n.props.revealOrder[0]||!n.o.size))for(e=n.u;e;){for(;e.length>3;)e.pop()();if(e[1]<e[0])break;n.u=e=e[2];}};function T(n){return this.getChildContext=function(){return n.context},n.children}function j(n){var t=this,e=n.i;t.componentWillUnmount=function(){N(null,t.l),t.l=null,t.i=null;},t.i&&t.i!==e&&t.componentWillUnmount(),n.__v?(t.l||(t.i=e,t.l={nodeType:1,parentNode:e,childNodes:[],appendChild:function(n){this.childNodes.push(n),t.i.appendChild(n);},insertBefore:function(n,e){this.childNodes.push(n),t.i.appendChild(n);},removeChild:function(n){this.childNodes.splice(this.childNodes.indexOf(n)>>>1,1),t.i.removeChild(n);}}),N(a$1(T,{context:t.context},n.__v),t.l)):t.l&&t.componentWillUnmount();}function I(n,t){return a$1(j,{__v:n,i:t})}(F.prototype=new p).__e=function(n){var t=this,e=U(t.__v),r=t.o.get(n);return r[0]++,function(u){var o=function(){t.props.revealOrder?(r.push(u),M(t,n,r)):u();};e?e(o):o();}},F.prototype.render=function(n){this.u=null,this.o=new Map;var t=w$1(n.children);n.revealOrder&&"b"===n.revealOrder[0]&&t.reverse();for(var e=t.length;e--;)this.o.set(t[e],this.u=[1,0,this.u]);return n.children},F.prototype.componentDidUpdate=F.prototype.componentDidMount=function(){var n=this;this.o.forEach(function(t,e){M(n,e,t);});};var W="undefined"!=typeof Symbol&&Symbol.for&&Symbol.for("react.element")||60103,P=/^(?:accent|alignment|arabic|baseline|cap|clip(?!PathU)|color|fill|flood|font|glyph(?!R)|horiz|marker(?!H|W|U)|overline|paint|stop|strikethrough|stroke|text(?!L)|underline|unicode|units|v|vector|vert|word|writing|x(?!C))[A-Z]/,V=function(n){return ("undefined"!=typeof Symbol&&"symbol"==typeof Symbol()?/fil|che|rad/i:/fil|che|ra/i).test(n)};p.prototype.isReactComponent={},["componentWillMount","componentWillReceiveProps","componentWillUpdate"].forEach(function(n){Object.defineProperty(p.prototype,n,{configurable:!0,get:function(){return this["UNSAFE_"+n]},set:function(t){Object.defineProperty(this,n,{configurable:!0,writable:!0,value:t});}});});var H=n.event;function Z(){}function Y(){return this.cancelBubble}function $(){return this.defaultPrevented}n.event=function(n){return H&&(n=H(n)),n.persist=Z,n.isPropagationStopped=Y,n.isDefaultPrevented=$,n.nativeEvent=n};var G={configurable:!0,get:function(){return this.class}},J=n.vnode;n.vnode=function(n){var t=n.type,e=n.props,r=e;if("string"==typeof t){for(var u in r={},e){var o=e[u];"value"===u&&"defaultValue"in e&&null==o||("defaultValue"===u&&"value"in e&&null==e.value?u="value":"download"===u&&!0===o?o="":/ondoubleclick/i.test(u)?u="ondblclick":/^onchange(textarea|input)/i.test(u+t)&&!V(e.type)?u="oninput":/^on(Ani|Tra|Tou|BeforeInp)/.test(u)?u=u.toLowerCase():P.test(u)?u=u.replace(/[A-Z0-9]/,"-$&").toLowerCase():null===o&&(o=void 0),r[u]=o);}"select"==t&&r.multiple&&Array.isArray(r.value)&&(r.value=w$1(e.children).forEach(function(n){n.props.selected=-1!=r.value.indexOf(n.props.value);})),"select"==t&&null!=r.defaultValue&&(r.value=w$1(e.children).forEach(function(n){n.props.selected=r.multiple?-1!=r.defaultValue.indexOf(n.props.value):r.defaultValue==n.props.value;})),n.props=r;}t&&e.class!=e.className&&(G.enumerable="className"in e,null!=e.className&&(r.class=e.className),Object.defineProperty(r,"className",G)),n.$$typeof=W,J&&J(n);};var K=n.__r;n.__r=function(n){K&&K(n);};"object"==typeof performance&&"function"==typeof performance.now?performance.now.bind(performance):function(){return Date.now()};
  56. var globalObj = typeof globalThis !== 'undefined' ? globalThis : window; // // TODO: streamline when killing IE11 support
  57. if (globalObj.FullCalendarVDom) {
  58. console.warn('FullCalendar VDOM already loaded');
  59. }
  60. else {
  61. globalObj.FullCalendarVDom = {
  62. Component: p,
  63. createElement: a$1,
  64. render: N,
  65. createRef: h,
  66. Fragment: y,
  67. createContext: createContext$1,
  68. createPortal: I,
  69. flushSync: flushSync$1,
  70. unmountComponentAtNode: unmountComponentAtNode$1,
  71. };
  72. }
  73. // HACKS...
  74. // TODO: lock version
  75. // TODO: link gh issues
  76. function flushSync$1(runBeforeFlush) {
  77. runBeforeFlush();
  78. var oldDebounceRendering = n.debounceRendering; // orig
  79. var callbackQ = [];
  80. function execCallbackSync(callback) {
  81. callbackQ.push(callback);
  82. }
  83. n.debounceRendering = execCallbackSync;
  84. N(a$1(FakeComponent, {}), document.createElement('div'));
  85. while (callbackQ.length) {
  86. callbackQ.shift()();
  87. }
  88. n.debounceRendering = oldDebounceRendering;
  89. }
  90. var FakeComponent = /** @class */ (function (_super) {
  91. __extends(FakeComponent, _super);
  92. function FakeComponent() {
  93. return _super !== null && _super.apply(this, arguments) || this;
  94. }
  95. FakeComponent.prototype.render = function () { return a$1('div', {}); };
  96. FakeComponent.prototype.componentDidMount = function () { this.setState({}); };
  97. return FakeComponent;
  98. }(p));
  99. function createContext$1(defaultValue) {
  100. var ContextType = q(defaultValue);
  101. var origProvider = ContextType.Provider;
  102. ContextType.Provider = function () {
  103. var _this = this;
  104. var isNew = !this.getChildContext;
  105. var children = origProvider.apply(this, arguments); // eslint-disable-line prefer-rest-params
  106. if (isNew) {
  107. var subs_1 = [];
  108. this.shouldComponentUpdate = function (_props) {
  109. if (_this.props.value !== _props.value) {
  110. subs_1.forEach(function (c) {
  111. c.context = _props.value;
  112. c.forceUpdate();
  113. });
  114. }
  115. };
  116. this.sub = function (c) {
  117. subs_1.push(c);
  118. var old = c.componentWillUnmount;
  119. c.componentWillUnmount = function () {
  120. subs_1.splice(subs_1.indexOf(c), 1);
  121. old && old.call(c);
  122. };
  123. };
  124. }
  125. return children;
  126. };
  127. return ContextType;
  128. }
  129. function unmountComponentAtNode$1(node) {
  130. N(null, node);
  131. }
  132. // no public types yet. when there are, export from:
  133. // import {} from './api-type-deps'
  134. var EventSourceApi = /** @class */ (function () {
  135. function EventSourceApi(context, internalEventSource) {
  136. this.context = context;
  137. this.internalEventSource = internalEventSource;
  138. }
  139. EventSourceApi.prototype.remove = function () {
  140. this.context.dispatch({
  141. type: 'REMOVE_EVENT_SOURCE',
  142. sourceId: this.internalEventSource.sourceId,
  143. });
  144. };
  145. EventSourceApi.prototype.refetch = function () {
  146. this.context.dispatch({
  147. type: 'FETCH_EVENT_SOURCES',
  148. sourceIds: [this.internalEventSource.sourceId],
  149. isRefetch: true,
  150. });
  151. };
  152. Object.defineProperty(EventSourceApi.prototype, "id", {
  153. get: function () {
  154. return this.internalEventSource.publicId;
  155. },
  156. enumerable: false,
  157. configurable: true
  158. });
  159. Object.defineProperty(EventSourceApi.prototype, "url", {
  160. get: function () {
  161. return this.internalEventSource.meta.url;
  162. },
  163. enumerable: false,
  164. configurable: true
  165. });
  166. Object.defineProperty(EventSourceApi.prototype, "format", {
  167. get: function () {
  168. return this.internalEventSource.meta.format; // TODO: bad. not guaranteed
  169. },
  170. enumerable: false,
  171. configurable: true
  172. });
  173. return EventSourceApi;
  174. }());
  175. function removeElement(el) {
  176. if (el.parentNode) {
  177. el.parentNode.removeChild(el);
  178. }
  179. }
  180. // Querying
  181. // ----------------------------------------------------------------------------------------------------------------
  182. function elementClosest(el, selector) {
  183. if (el.closest) {
  184. return el.closest(selector);
  185. // really bad fallback for IE
  186. // from https://developer.mozilla.org/en-US/docs/Web/API/Element/closest
  187. }
  188. if (!document.documentElement.contains(el)) {
  189. return null;
  190. }
  191. do {
  192. if (elementMatches(el, selector)) {
  193. return el;
  194. }
  195. el = (el.parentElement || el.parentNode);
  196. } while (el !== null && el.nodeType === 1);
  197. return null;
  198. }
  199. function elementMatches(el, selector) {
  200. var method = el.matches || el.matchesSelector || el.msMatchesSelector;
  201. return method.call(el, selector);
  202. }
  203. // accepts multiple subject els
  204. // returns a real array. good for methods like forEach
  205. // TODO: accept the document
  206. function findElements(container, selector) {
  207. var containers = container instanceof HTMLElement ? [container] : container;
  208. var allMatches = [];
  209. for (var i = 0; i < containers.length; i += 1) {
  210. var matches = containers[i].querySelectorAll(selector);
  211. for (var j = 0; j < matches.length; j += 1) {
  212. allMatches.push(matches[j]);
  213. }
  214. }
  215. return allMatches;
  216. }
  217. // accepts multiple subject els
  218. // only queries direct child elements // TODO: rename to findDirectChildren!
  219. function findDirectChildren(parent, selector) {
  220. var parents = parent instanceof HTMLElement ? [parent] : parent;
  221. var allMatches = [];
  222. for (var i = 0; i < parents.length; i += 1) {
  223. var childNodes = parents[i].children; // only ever elements
  224. for (var j = 0; j < childNodes.length; j += 1) {
  225. var childNode = childNodes[j];
  226. if (!selector || elementMatches(childNode, selector)) {
  227. allMatches.push(childNode);
  228. }
  229. }
  230. }
  231. return allMatches;
  232. }
  233. // Style
  234. // ----------------------------------------------------------------------------------------------------------------
  235. var PIXEL_PROP_RE = /(top|left|right|bottom|width|height)$/i;
  236. function applyStyle(el, props) {
  237. for (var propName in props) {
  238. applyStyleProp(el, propName, props[propName]);
  239. }
  240. }
  241. function applyStyleProp(el, name, val) {
  242. if (val == null) {
  243. el.style[name] = '';
  244. }
  245. else if (typeof val === 'number' && PIXEL_PROP_RE.test(name)) {
  246. el.style[name] = val + "px";
  247. }
  248. else {
  249. el.style[name] = val;
  250. }
  251. }
  252. // Event Handling
  253. // ----------------------------------------------------------------------------------------------------------------
  254. // if intercepting bubbled events at the document/window/body level,
  255. // and want to see originating element (the 'target'), use this util instead
  256. // of `ev.target` because it goes within web-component boundaries.
  257. function getEventTargetViaRoot(ev) {
  258. var _a, _b;
  259. return (_b = (_a = ev.composedPath) === null || _a === void 0 ? void 0 : _a.call(ev)[0]) !== null && _b !== void 0 ? _b : ev.target;
  260. }
  261. // Shadow DOM consuderations
  262. // ----------------------------------------------------------------------------------------------------------------
  263. function getElRoot(el) {
  264. return el.getRootNode ? el.getRootNode() : document;
  265. }
  266. // Unique ID for DOM attribute
  267. var guid$1 = 0;
  268. function getUniqueDomId() {
  269. guid$1 += 1;
  270. return 'fc-dom-' + guid$1;
  271. }
  272. // Stops a mouse/touch event from doing it's native browser action
  273. function preventDefault(ev) {
  274. ev.preventDefault();
  275. }
  276. // Event Delegation
  277. // ----------------------------------------------------------------------------------------------------------------
  278. function buildDelegationHandler(selector, handler) {
  279. return function (ev) {
  280. var matchedChild = elementClosest(ev.target, selector);
  281. if (matchedChild) {
  282. handler.call(matchedChild, ev, matchedChild);
  283. }
  284. };
  285. }
  286. function listenBySelector(container, eventType, selector, handler) {
  287. var attachedHandler = buildDelegationHandler(selector, handler);
  288. container.addEventListener(eventType, attachedHandler);
  289. return function () {
  290. container.removeEventListener(eventType, attachedHandler);
  291. };
  292. }
  293. function listenToHoverBySelector(container, selector, onMouseEnter, onMouseLeave) {
  294. var currentMatchedChild;
  295. return listenBySelector(container, 'mouseover', selector, function (mouseOverEv, matchedChild) {
  296. if (matchedChild !== currentMatchedChild) {
  297. currentMatchedChild = matchedChild;
  298. onMouseEnter(mouseOverEv, matchedChild);
  299. var realOnMouseLeave_1 = function (mouseLeaveEv) {
  300. currentMatchedChild = null;
  301. onMouseLeave(mouseLeaveEv, matchedChild);
  302. matchedChild.removeEventListener('mouseleave', realOnMouseLeave_1);
  303. };
  304. // listen to the next mouseleave, and then unattach
  305. matchedChild.addEventListener('mouseleave', realOnMouseLeave_1);
  306. }
  307. });
  308. }
  309. // Animation
  310. // ----------------------------------------------------------------------------------------------------------------
  311. var transitionEventNames = [
  312. 'webkitTransitionEnd',
  313. 'otransitionend',
  314. 'oTransitionEnd',
  315. 'msTransitionEnd',
  316. 'transitionend',
  317. ];
  318. // triggered only when the next single subsequent transition finishes
  319. function whenTransitionDone(el, callback) {
  320. var realCallback = function (ev) {
  321. callback(ev);
  322. transitionEventNames.forEach(function (eventName) {
  323. el.removeEventListener(eventName, realCallback);
  324. });
  325. };
  326. transitionEventNames.forEach(function (eventName) {
  327. el.addEventListener(eventName, realCallback); // cross-browser way to determine when the transition finishes
  328. });
  329. }
  330. // ARIA workarounds
  331. // ----------------------------------------------------------------------------------------------------------------
  332. function createAriaClickAttrs(handler) {
  333. return __assign({ onClick: handler }, createAriaKeyboardAttrs(handler));
  334. }
  335. function createAriaKeyboardAttrs(handler) {
  336. return {
  337. tabIndex: 0,
  338. onKeyDown: function (ev) {
  339. if (ev.key === 'Enter' || ev.key === ' ') {
  340. handler(ev);
  341. ev.preventDefault(); // if space, don't scroll down page
  342. }
  343. },
  344. };
  345. }
  346. var guidNumber = 0;
  347. function guid() {
  348. guidNumber += 1;
  349. return String(guidNumber);
  350. }
  351. /* FullCalendar-specific DOM Utilities
  352. ----------------------------------------------------------------------------------------------------------------------*/
  353. // Make the mouse cursor express that an event is not allowed in the current area
  354. function disableCursor() {
  355. document.body.classList.add('fc-not-allowed');
  356. }
  357. // Returns the mouse cursor to its original look
  358. function enableCursor() {
  359. document.body.classList.remove('fc-not-allowed');
  360. }
  361. /* Selection
  362. ----------------------------------------------------------------------------------------------------------------------*/
  363. function preventSelection(el) {
  364. el.classList.add('fc-unselectable');
  365. el.addEventListener('selectstart', preventDefault);
  366. }
  367. function allowSelection(el) {
  368. el.classList.remove('fc-unselectable');
  369. el.removeEventListener('selectstart', preventDefault);
  370. }
  371. /* Context Menu
  372. ----------------------------------------------------------------------------------------------------------------------*/
  373. function preventContextMenu(el) {
  374. el.addEventListener('contextmenu', preventDefault);
  375. }
  376. function allowContextMenu(el) {
  377. el.removeEventListener('contextmenu', preventDefault);
  378. }
  379. function parseFieldSpecs(input) {
  380. var specs = [];
  381. var tokens = [];
  382. var i;
  383. var token;
  384. if (typeof input === 'string') {
  385. tokens = input.split(/\s*,\s*/);
  386. }
  387. else if (typeof input === 'function') {
  388. tokens = [input];
  389. }
  390. else if (Array.isArray(input)) {
  391. tokens = input;
  392. }
  393. for (i = 0; i < tokens.length; i += 1) {
  394. token = tokens[i];
  395. if (typeof token === 'string') {
  396. specs.push(token.charAt(0) === '-' ?
  397. { field: token.substring(1), order: -1 } :
  398. { field: token, order: 1 });
  399. }
  400. else if (typeof token === 'function') {
  401. specs.push({ func: token });
  402. }
  403. }
  404. return specs;
  405. }
  406. function compareByFieldSpecs(obj0, obj1, fieldSpecs) {
  407. var i;
  408. var cmp;
  409. for (i = 0; i < fieldSpecs.length; i += 1) {
  410. cmp = compareByFieldSpec(obj0, obj1, fieldSpecs[i]);
  411. if (cmp) {
  412. return cmp;
  413. }
  414. }
  415. return 0;
  416. }
  417. function compareByFieldSpec(obj0, obj1, fieldSpec) {
  418. if (fieldSpec.func) {
  419. return fieldSpec.func(obj0, obj1);
  420. }
  421. return flexibleCompare(obj0[fieldSpec.field], obj1[fieldSpec.field])
  422. * (fieldSpec.order || 1);
  423. }
  424. function flexibleCompare(a, b) {
  425. if (!a && !b) {
  426. return 0;
  427. }
  428. if (b == null) {
  429. return -1;
  430. }
  431. if (a == null) {
  432. return 1;
  433. }
  434. if (typeof a === 'string' || typeof b === 'string') {
  435. return String(a).localeCompare(String(b));
  436. }
  437. return a - b;
  438. }
  439. /* String Utilities
  440. ----------------------------------------------------------------------------------------------------------------------*/
  441. function padStart(val, len) {
  442. var s = String(val);
  443. return '000'.substr(0, len - s.length) + s;
  444. }
  445. function formatWithOrdinals(formatter, args, fallbackText) {
  446. if (typeof formatter === 'function') {
  447. return formatter.apply(void 0, args);
  448. }
  449. if (typeof formatter === 'string') { // non-blank string
  450. return args.reduce(function (str, arg, index) { return (str.replace('$' + index, arg || '')); }, formatter);
  451. }
  452. return fallbackText;
  453. }
  454. /* Number Utilities
  455. ----------------------------------------------------------------------------------------------------------------------*/
  456. function compareNumbers(a, b) {
  457. return a - b;
  458. }
  459. function isInt(n) {
  460. return n % 1 === 0;
  461. }
  462. /* FC-specific DOM dimension stuff
  463. ----------------------------------------------------------------------------------------------------------------------*/
  464. function computeSmallestCellWidth(cellEl) {
  465. var allWidthEl = cellEl.querySelector('.fc-scrollgrid-shrink-frame');
  466. var contentWidthEl = cellEl.querySelector('.fc-scrollgrid-shrink-cushion');
  467. if (!allWidthEl) {
  468. throw new Error('needs fc-scrollgrid-shrink-frame className'); // TODO: use const
  469. }
  470. if (!contentWidthEl) {
  471. throw new Error('needs fc-scrollgrid-shrink-cushion className');
  472. }
  473. return cellEl.getBoundingClientRect().width - allWidthEl.getBoundingClientRect().width + // the cell padding+border
  474. contentWidthEl.getBoundingClientRect().width;
  475. }
  476. var DAY_IDS = ['sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat'];
  477. // Adding
  478. function addWeeks(m, n) {
  479. var a = dateToUtcArray(m);
  480. a[2] += n * 7;
  481. return arrayToUtcDate(a);
  482. }
  483. function addDays(m, n) {
  484. var a = dateToUtcArray(m);
  485. a[2] += n;
  486. return arrayToUtcDate(a);
  487. }
  488. function addMs(m, n) {
  489. var a = dateToUtcArray(m);
  490. a[6] += n;
  491. return arrayToUtcDate(a);
  492. }
  493. // Diffing (all return floats)
  494. // TODO: why not use ranges?
  495. function diffWeeks(m0, m1) {
  496. return diffDays(m0, m1) / 7;
  497. }
  498. function diffDays(m0, m1) {
  499. return (m1.valueOf() - m0.valueOf()) / (1000 * 60 * 60 * 24);
  500. }
  501. function diffHours(m0, m1) {
  502. return (m1.valueOf() - m0.valueOf()) / (1000 * 60 * 60);
  503. }
  504. function diffMinutes(m0, m1) {
  505. return (m1.valueOf() - m0.valueOf()) / (1000 * 60);
  506. }
  507. function diffSeconds(m0, m1) {
  508. return (m1.valueOf() - m0.valueOf()) / 1000;
  509. }
  510. function diffDayAndTime(m0, m1) {
  511. var m0day = startOfDay(m0);
  512. var m1day = startOfDay(m1);
  513. return {
  514. years: 0,
  515. months: 0,
  516. days: Math.round(diffDays(m0day, m1day)),
  517. milliseconds: (m1.valueOf() - m1day.valueOf()) - (m0.valueOf() - m0day.valueOf()),
  518. };
  519. }
  520. // Diffing Whole Units
  521. function diffWholeWeeks(m0, m1) {
  522. var d = diffWholeDays(m0, m1);
  523. if (d !== null && d % 7 === 0) {
  524. return d / 7;
  525. }
  526. return null;
  527. }
  528. function diffWholeDays(m0, m1) {
  529. if (timeAsMs(m0) === timeAsMs(m1)) {
  530. return Math.round(diffDays(m0, m1));
  531. }
  532. return null;
  533. }
  534. // Start-Of
  535. function startOfDay(m) {
  536. return arrayToUtcDate([
  537. m.getUTCFullYear(),
  538. m.getUTCMonth(),
  539. m.getUTCDate(),
  540. ]);
  541. }
  542. function startOfHour(m) {
  543. return arrayToUtcDate([
  544. m.getUTCFullYear(),
  545. m.getUTCMonth(),
  546. m.getUTCDate(),
  547. m.getUTCHours(),
  548. ]);
  549. }
  550. function startOfMinute(m) {
  551. return arrayToUtcDate([
  552. m.getUTCFullYear(),
  553. m.getUTCMonth(),
  554. m.getUTCDate(),
  555. m.getUTCHours(),
  556. m.getUTCMinutes(),
  557. ]);
  558. }
  559. function startOfSecond(m) {
  560. return arrayToUtcDate([
  561. m.getUTCFullYear(),
  562. m.getUTCMonth(),
  563. m.getUTCDate(),
  564. m.getUTCHours(),
  565. m.getUTCMinutes(),
  566. m.getUTCSeconds(),
  567. ]);
  568. }
  569. // Week Computation
  570. function weekOfYear(marker, dow, doy) {
  571. var y = marker.getUTCFullYear();
  572. var w = weekOfGivenYear(marker, y, dow, doy);
  573. if (w < 1) {
  574. return weekOfGivenYear(marker, y - 1, dow, doy);
  575. }
  576. var nextW = weekOfGivenYear(marker, y + 1, dow, doy);
  577. if (nextW >= 1) {
  578. return Math.min(w, nextW);
  579. }
  580. return w;
  581. }
  582. function weekOfGivenYear(marker, year, dow, doy) {
  583. var firstWeekStart = arrayToUtcDate([year, 0, 1 + firstWeekOffset(year, dow, doy)]);
  584. var dayStart = startOfDay(marker);
  585. var days = Math.round(diffDays(firstWeekStart, dayStart));
  586. return Math.floor(days / 7) + 1; // zero-indexed
  587. }
  588. // start-of-first-week - start-of-year
  589. function firstWeekOffset(year, dow, doy) {
  590. // first-week day -- which january is always in the first week (4 for iso, 1 for other)
  591. var fwd = 7 + dow - doy;
  592. // first-week day local weekday -- which local weekday is fwd
  593. var fwdlw = (7 + arrayToUtcDate([year, 0, fwd]).getUTCDay() - dow) % 7;
  594. return -fwdlw + fwd - 1;
  595. }
  596. // Array Conversion
  597. function dateToLocalArray(date) {
  598. return [
  599. date.getFullYear(),
  600. date.getMonth(),
  601. date.getDate(),
  602. date.getHours(),
  603. date.getMinutes(),
  604. date.getSeconds(),
  605. date.getMilliseconds(),
  606. ];
  607. }
  608. function arrayToLocalDate(a) {
  609. return new Date(a[0], a[1] || 0, a[2] == null ? 1 : a[2], // day of month
  610. a[3] || 0, a[4] || 0, a[5] || 0);
  611. }
  612. function dateToUtcArray(date) {
  613. return [
  614. date.getUTCFullYear(),
  615. date.getUTCMonth(),
  616. date.getUTCDate(),
  617. date.getUTCHours(),
  618. date.getUTCMinutes(),
  619. date.getUTCSeconds(),
  620. date.getUTCMilliseconds(),
  621. ];
  622. }
  623. function arrayToUtcDate(a) {
  624. // according to web standards (and Safari), a month index is required.
  625. // massage if only given a year.
  626. if (a.length === 1) {
  627. a = a.concat([0]);
  628. }
  629. return new Date(Date.UTC.apply(Date, a));
  630. }
  631. // Other Utils
  632. function isValidDate(m) {
  633. return !isNaN(m.valueOf());
  634. }
  635. function timeAsMs(m) {
  636. return m.getUTCHours() * 1000 * 60 * 60 +
  637. m.getUTCMinutes() * 1000 * 60 +
  638. m.getUTCSeconds() * 1000 +
  639. m.getUTCMilliseconds();
  640. }
  641. function createEventInstance(defId, range, forcedStartTzo, forcedEndTzo) {
  642. return {
  643. instanceId: guid(),
  644. defId: defId,
  645. range: range,
  646. forcedStartTzo: forcedStartTzo == null ? null : forcedStartTzo,
  647. forcedEndTzo: forcedEndTzo == null ? null : forcedEndTzo,
  648. };
  649. }
  650. var hasOwnProperty = Object.prototype.hasOwnProperty;
  651. // Merges an array of objects into a single object.
  652. // The second argument allows for an array of property names who's object values will be merged together.
  653. function mergeProps(propObjs, complexPropsMap) {
  654. var dest = {};
  655. if (complexPropsMap) {
  656. for (var name_1 in complexPropsMap) {
  657. var complexObjs = [];
  658. // collect the trailing object values, stopping when a non-object is discovered
  659. for (var i = propObjs.length - 1; i >= 0; i -= 1) {
  660. var val = propObjs[i][name_1];
  661. if (typeof val === 'object' && val) { // non-null object
  662. complexObjs.unshift(val);
  663. }
  664. else if (val !== undefined) {
  665. dest[name_1] = val; // if there were no objects, this value will be used
  666. break;
  667. }
  668. }
  669. // if the trailing values were objects, use the merged value
  670. if (complexObjs.length) {
  671. dest[name_1] = mergeProps(complexObjs);
  672. }
  673. }
  674. }
  675. // copy values into the destination, going from last to first
  676. for (var i = propObjs.length - 1; i >= 0; i -= 1) {
  677. var props = propObjs[i];
  678. for (var name_2 in props) {
  679. if (!(name_2 in dest)) { // if already assigned by previous props or complex props, don't reassign
  680. dest[name_2] = props[name_2];
  681. }
  682. }
  683. }
  684. return dest;
  685. }
  686. function filterHash(hash, func) {
  687. var filtered = {};
  688. for (var key in hash) {
  689. if (func(hash[key], key)) {
  690. filtered[key] = hash[key];
  691. }
  692. }
  693. return filtered;
  694. }
  695. function mapHash(hash, func) {
  696. var newHash = {};
  697. for (var key in hash) {
  698. newHash[key] = func(hash[key], key);
  699. }
  700. return newHash;
  701. }
  702. function arrayToHash(a) {
  703. var hash = {};
  704. for (var _i = 0, a_1 = a; _i < a_1.length; _i++) {
  705. var item = a_1[_i];
  706. hash[item] = true;
  707. }
  708. return hash;
  709. }
  710. function buildHashFromArray(a, func) {
  711. var hash = {};
  712. for (var i = 0; i < a.length; i += 1) {
  713. var tuple = func(a[i], i);
  714. hash[tuple[0]] = tuple[1];
  715. }
  716. return hash;
  717. }
  718. function hashValuesToArray(obj) {
  719. var a = [];
  720. for (var key in obj) {
  721. a.push(obj[key]);
  722. }
  723. return a;
  724. }
  725. function isPropsEqual(obj0, obj1) {
  726. if (obj0 === obj1) {
  727. return true;
  728. }
  729. for (var key in obj0) {
  730. if (hasOwnProperty.call(obj0, key)) {
  731. if (!(key in obj1)) {
  732. return false;
  733. }
  734. }
  735. }
  736. for (var key in obj1) {
  737. if (hasOwnProperty.call(obj1, key)) {
  738. if (obj0[key] !== obj1[key]) {
  739. return false;
  740. }
  741. }
  742. }
  743. return true;
  744. }
  745. function getUnequalProps(obj0, obj1) {
  746. var keys = [];
  747. for (var key in obj0) {
  748. if (hasOwnProperty.call(obj0, key)) {
  749. if (!(key in obj1)) {
  750. keys.push(key);
  751. }
  752. }
  753. }
  754. for (var key in obj1) {
  755. if (hasOwnProperty.call(obj1, key)) {
  756. if (obj0[key] !== obj1[key]) {
  757. keys.push(key);
  758. }
  759. }
  760. }
  761. return keys;
  762. }
  763. function compareObjs(oldProps, newProps, equalityFuncs) {
  764. if (equalityFuncs === void 0) { equalityFuncs = {}; }
  765. if (oldProps === newProps) {
  766. return true;
  767. }
  768. for (var key in newProps) {
  769. if (key in oldProps && isObjValsEqual(oldProps[key], newProps[key], equalityFuncs[key])) ;
  770. else {
  771. return false;
  772. }
  773. }
  774. // check for props that were omitted in the new
  775. for (var key in oldProps) {
  776. if (!(key in newProps)) {
  777. return false;
  778. }
  779. }
  780. return true;
  781. }
  782. /*
  783. assumed "true" equality for handler names like "onReceiveSomething"
  784. */
  785. function isObjValsEqual(val0, val1, comparator) {
  786. if (val0 === val1 || comparator === true) {
  787. return true;
  788. }
  789. if (comparator) {
  790. return comparator(val0, val1);
  791. }
  792. return false;
  793. }
  794. function collectFromHash(hash, startIndex, endIndex, step) {
  795. if (startIndex === void 0) { startIndex = 0; }
  796. if (step === void 0) { step = 1; }
  797. var res = [];
  798. if (endIndex == null) {
  799. endIndex = Object.keys(hash).length;
  800. }
  801. for (var i = startIndex; i < endIndex; i += step) {
  802. var val = hash[i];
  803. if (val !== undefined) { // will disregard undefined for sparse arrays
  804. res.push(val);
  805. }
  806. }
  807. return res;
  808. }
  809. function parseRecurring(refined, defaultAllDay, dateEnv, recurringTypes) {
  810. for (var i = 0; i < recurringTypes.length; i += 1) {
  811. var parsed = recurringTypes[i].parse(refined, dateEnv);
  812. if (parsed) {
  813. var allDay = refined.allDay;
  814. if (allDay == null) {
  815. allDay = defaultAllDay;
  816. if (allDay == null) {
  817. allDay = parsed.allDayGuess;
  818. if (allDay == null) {
  819. allDay = false;
  820. }
  821. }
  822. }
  823. return {
  824. allDay: allDay,
  825. duration: parsed.duration,
  826. typeData: parsed.typeData,
  827. typeId: i,
  828. };
  829. }
  830. }
  831. return null;
  832. }
  833. function expandRecurring(eventStore, framingRange, context) {
  834. var dateEnv = context.dateEnv, pluginHooks = context.pluginHooks, options = context.options;
  835. var defs = eventStore.defs, instances = eventStore.instances;
  836. // remove existing recurring instances
  837. // TODO: bad. always expand events as a second step
  838. instances = filterHash(instances, function (instance) { return !defs[instance.defId].recurringDef; });
  839. for (var defId in defs) {
  840. var def = defs[defId];
  841. if (def.recurringDef) {
  842. var duration = def.recurringDef.duration;
  843. if (!duration) {
  844. duration = def.allDay ?
  845. options.defaultAllDayEventDuration :
  846. options.defaultTimedEventDuration;
  847. }
  848. var starts = expandRecurringRanges(def, duration, framingRange, dateEnv, pluginHooks.recurringTypes);
  849. for (var _i = 0, starts_1 = starts; _i < starts_1.length; _i++) {
  850. var start = starts_1[_i];
  851. var instance = createEventInstance(defId, {
  852. start: start,
  853. end: dateEnv.add(start, duration),
  854. });
  855. instances[instance.instanceId] = instance;
  856. }
  857. }
  858. }
  859. return { defs: defs, instances: instances };
  860. }
  861. /*
  862. Event MUST have a recurringDef
  863. */
  864. function expandRecurringRanges(eventDef, duration, framingRange, dateEnv, recurringTypes) {
  865. var typeDef = recurringTypes[eventDef.recurringDef.typeId];
  866. var markers = typeDef.expand(eventDef.recurringDef.typeData, {
  867. start: dateEnv.subtract(framingRange.start, duration),
  868. end: framingRange.end,
  869. }, dateEnv);
  870. // the recurrence plugins don't guarantee that all-day events are start-of-day, so we have to
  871. if (eventDef.allDay) {
  872. markers = markers.map(startOfDay);
  873. }
  874. return markers;
  875. }
  876. var INTERNAL_UNITS = ['years', 'months', 'days', 'milliseconds'];
  877. var PARSE_RE = /^(-?)(?:(\d+)\.)?(\d+):(\d\d)(?::(\d\d)(?:\.(\d\d\d))?)?/;
  878. // Parsing and Creation
  879. function createDuration(input, unit) {
  880. var _a;
  881. if (typeof input === 'string') {
  882. return parseString(input);
  883. }
  884. if (typeof input === 'object' && input) { // non-null object
  885. return parseObject(input);
  886. }
  887. if (typeof input === 'number') {
  888. return parseObject((_a = {}, _a[unit || 'milliseconds'] = input, _a));
  889. }
  890. return null;
  891. }
  892. function parseString(s) {
  893. var m = PARSE_RE.exec(s);
  894. if (m) {
  895. var sign = m[1] ? -1 : 1;
  896. return {
  897. years: 0,
  898. months: 0,
  899. days: sign * (m[2] ? parseInt(m[2], 10) : 0),
  900. milliseconds: sign * ((m[3] ? parseInt(m[3], 10) : 0) * 60 * 60 * 1000 + // hours
  901. (m[4] ? parseInt(m[4], 10) : 0) * 60 * 1000 + // minutes
  902. (m[5] ? parseInt(m[5], 10) : 0) * 1000 + // seconds
  903. (m[6] ? parseInt(m[6], 10) : 0) // ms
  904. ),
  905. };
  906. }
  907. return null;
  908. }
  909. function parseObject(obj) {
  910. var duration = {
  911. years: obj.years || obj.year || 0,
  912. months: obj.months || obj.month || 0,
  913. days: obj.days || obj.day || 0,
  914. milliseconds: (obj.hours || obj.hour || 0) * 60 * 60 * 1000 + // hours
  915. (obj.minutes || obj.minute || 0) * 60 * 1000 + // minutes
  916. (obj.seconds || obj.second || 0) * 1000 + // seconds
  917. (obj.milliseconds || obj.millisecond || obj.ms || 0), // ms
  918. };
  919. var weeks = obj.weeks || obj.week;
  920. if (weeks) {
  921. duration.days += weeks * 7;
  922. duration.specifiedWeeks = true;
  923. }
  924. return duration;
  925. }
  926. // Equality
  927. function durationsEqual(d0, d1) {
  928. return d0.years === d1.years &&
  929. d0.months === d1.months &&
  930. d0.days === d1.days &&
  931. d0.milliseconds === d1.milliseconds;
  932. }
  933. function asCleanDays(dur) {
  934. if (!dur.years && !dur.months && !dur.milliseconds) {
  935. return dur.days;
  936. }
  937. return 0;
  938. }
  939. // Simple Math
  940. function addDurations(d0, d1) {
  941. return {
  942. years: d0.years + d1.years,
  943. months: d0.months + d1.months,
  944. days: d0.days + d1.days,
  945. milliseconds: d0.milliseconds + d1.milliseconds,
  946. };
  947. }
  948. function subtractDurations(d1, d0) {
  949. return {
  950. years: d1.years - d0.years,
  951. months: d1.months - d0.months,
  952. days: d1.days - d0.days,
  953. milliseconds: d1.milliseconds - d0.milliseconds,
  954. };
  955. }
  956. function multiplyDuration(d, n) {
  957. return {
  958. years: d.years * n,
  959. months: d.months * n,
  960. days: d.days * n,
  961. milliseconds: d.milliseconds * n,
  962. };
  963. }
  964. // Conversions
  965. // "Rough" because they are based on average-case Gregorian months/years
  966. function asRoughYears(dur) {
  967. return asRoughDays(dur) / 365;
  968. }
  969. function asRoughMonths(dur) {
  970. return asRoughDays(dur) / 30;
  971. }
  972. function asRoughDays(dur) {
  973. return asRoughMs(dur) / 864e5;
  974. }
  975. function asRoughMinutes(dur) {
  976. return asRoughMs(dur) / (1000 * 60);
  977. }
  978. function asRoughSeconds(dur) {
  979. return asRoughMs(dur) / 1000;
  980. }
  981. function asRoughMs(dur) {
  982. return dur.years * (365 * 864e5) +
  983. dur.months * (30 * 864e5) +
  984. dur.days * 864e5 +
  985. dur.milliseconds;
  986. }
  987. // Advanced Math
  988. function wholeDivideDurations(numerator, denominator) {
  989. var res = null;
  990. for (var i = 0; i < INTERNAL_UNITS.length; i += 1) {
  991. var unit = INTERNAL_UNITS[i];
  992. if (denominator[unit]) {
  993. var localRes = numerator[unit] / denominator[unit];
  994. if (!isInt(localRes) || (res !== null && res !== localRes)) {
  995. return null;
  996. }
  997. res = localRes;
  998. }
  999. else if (numerator[unit]) {
  1000. // needs to divide by something but can't!
  1001. return null;
  1002. }
  1003. }
  1004. return res;
  1005. }
  1006. function greatestDurationDenominator(dur) {
  1007. var ms = dur.milliseconds;
  1008. if (ms) {
  1009. if (ms % 1000 !== 0) {
  1010. return { unit: 'millisecond', value: ms };
  1011. }
  1012. if (ms % (1000 * 60) !== 0) {
  1013. return { unit: 'second', value: ms / 1000 };
  1014. }
  1015. if (ms % (1000 * 60 * 60) !== 0) {
  1016. return { unit: 'minute', value: ms / (1000 * 60) };
  1017. }
  1018. if (ms) {
  1019. return { unit: 'hour', value: ms / (1000 * 60 * 60) };
  1020. }
  1021. }
  1022. if (dur.days) {
  1023. if (dur.specifiedWeeks && dur.days % 7 === 0) {
  1024. return { unit: 'week', value: dur.days / 7 };
  1025. }
  1026. return { unit: 'day', value: dur.days };
  1027. }
  1028. if (dur.months) {
  1029. return { unit: 'month', value: dur.months };
  1030. }
  1031. if (dur.years) {
  1032. return { unit: 'year', value: dur.years };
  1033. }
  1034. return { unit: 'millisecond', value: 0 };
  1035. }
  1036. // timeZoneOffset is in minutes
  1037. function buildIsoString(marker, timeZoneOffset, stripZeroTime) {
  1038. if (stripZeroTime === void 0) { stripZeroTime = false; }
  1039. var s = marker.toISOString();
  1040. s = s.replace('.000', '');
  1041. if (stripZeroTime) {
  1042. s = s.replace('T00:00:00Z', '');
  1043. }
  1044. if (s.length > 10) { // time part wasn't stripped, can add timezone info
  1045. if (timeZoneOffset == null) {
  1046. s = s.replace('Z', '');
  1047. }
  1048. else if (timeZoneOffset !== 0) {
  1049. s = s.replace('Z', formatTimeZoneOffset(timeZoneOffset, true));
  1050. }
  1051. // otherwise, its UTC-0 and we want to keep the Z
  1052. }
  1053. return s;
  1054. }
  1055. // formats the date, but with no time part
  1056. // TODO: somehow merge with buildIsoString and stripZeroTime
  1057. // TODO: rename. omit "string"
  1058. function formatDayString(marker) {
  1059. return marker.toISOString().replace(/T.*$/, '');
  1060. }
  1061. // TODO: use Date::toISOString and use everything after the T?
  1062. function formatIsoTimeString(marker) {
  1063. return padStart(marker.getUTCHours(), 2) + ':' +
  1064. padStart(marker.getUTCMinutes(), 2) + ':' +
  1065. padStart(marker.getUTCSeconds(), 2);
  1066. }
  1067. function formatTimeZoneOffset(minutes, doIso) {
  1068. if (doIso === void 0) { doIso = false; }
  1069. var sign = minutes < 0 ? '-' : '+';
  1070. var abs = Math.abs(minutes);
  1071. var hours = Math.floor(abs / 60);
  1072. var mins = Math.round(abs % 60);
  1073. if (doIso) {
  1074. return sign + padStart(hours, 2) + ":" + padStart(mins, 2);
  1075. }
  1076. return "GMT" + sign + hours + (mins ? ":" + padStart(mins, 2) : '');
  1077. }
  1078. // TODO: new util arrayify?
  1079. function removeExact(array, exactVal) {
  1080. var removeCnt = 0;
  1081. var i = 0;
  1082. while (i < array.length) {
  1083. if (array[i] === exactVal) {
  1084. array.splice(i, 1);
  1085. removeCnt += 1;
  1086. }
  1087. else {
  1088. i += 1;
  1089. }
  1090. }
  1091. return removeCnt;
  1092. }
  1093. function isArraysEqual(a0, a1, equalityFunc) {
  1094. if (a0 === a1) {
  1095. return true;
  1096. }
  1097. var len = a0.length;
  1098. var i;
  1099. if (len !== a1.length) { // not array? or not same length?
  1100. return false;
  1101. }
  1102. for (i = 0; i < len; i += 1) {
  1103. if (!(equalityFunc ? equalityFunc(a0[i], a1[i]) : a0[i] === a1[i])) {
  1104. return false;
  1105. }
  1106. }
  1107. return true;
  1108. }
  1109. function memoize(workerFunc, resEquality, teardownFunc) {
  1110. var currentArgs;
  1111. var currentRes;
  1112. return function () {
  1113. var newArgs = [];
  1114. for (var _i = 0; _i < arguments.length; _i++) {
  1115. newArgs[_i] = arguments[_i];
  1116. }
  1117. if (!currentArgs) {
  1118. currentRes = workerFunc.apply(this, newArgs);
  1119. }
  1120. else if (!isArraysEqual(currentArgs, newArgs)) {
  1121. if (teardownFunc) {
  1122. teardownFunc(currentRes);
  1123. }
  1124. var res = workerFunc.apply(this, newArgs);
  1125. if (!resEquality || !resEquality(res, currentRes)) {
  1126. currentRes = res;
  1127. }
  1128. }
  1129. currentArgs = newArgs;
  1130. return currentRes;
  1131. };
  1132. }
  1133. function memoizeObjArg(workerFunc, resEquality, teardownFunc) {
  1134. var _this = this;
  1135. var currentArg;
  1136. var currentRes;
  1137. return function (newArg) {
  1138. if (!currentArg) {
  1139. currentRes = workerFunc.call(_this, newArg);
  1140. }
  1141. else if (!isPropsEqual(currentArg, newArg)) {
  1142. if (teardownFunc) {
  1143. teardownFunc(currentRes);
  1144. }
  1145. var res = workerFunc.call(_this, newArg);
  1146. if (!resEquality || !resEquality(res, currentRes)) {
  1147. currentRes = res;
  1148. }
  1149. }
  1150. currentArg = newArg;
  1151. return currentRes;
  1152. };
  1153. }
  1154. function memoizeArraylike(// used at all?
  1155. workerFunc, resEquality, teardownFunc) {
  1156. var _this = this;
  1157. var currentArgSets = [];
  1158. var currentResults = [];
  1159. return function (newArgSets) {
  1160. var currentLen = currentArgSets.length;
  1161. var newLen = newArgSets.length;
  1162. var i = 0;
  1163. for (; i < currentLen; i += 1) {
  1164. if (!newArgSets[i]) { // one of the old sets no longer exists
  1165. if (teardownFunc) {
  1166. teardownFunc(currentResults[i]);
  1167. }
  1168. }
  1169. else if (!isArraysEqual(currentArgSets[i], newArgSets[i])) {
  1170. if (teardownFunc) {
  1171. teardownFunc(currentResults[i]);
  1172. }
  1173. var res = workerFunc.apply(_this, newArgSets[i]);
  1174. if (!resEquality || !resEquality(res, currentResults[i])) {
  1175. currentResults[i] = res;
  1176. }
  1177. }
  1178. }
  1179. for (; i < newLen; i += 1) {
  1180. currentResults[i] = workerFunc.apply(_this, newArgSets[i]);
  1181. }
  1182. currentArgSets = newArgSets;
  1183. currentResults.splice(newLen); // remove excess
  1184. return currentResults;
  1185. };
  1186. }
  1187. function memoizeHashlike(workerFunc, resEquality, teardownFunc) {
  1188. var _this = this;
  1189. var currentArgHash = {};
  1190. var currentResHash = {};
  1191. return function (newArgHash) {
  1192. var newResHash = {};
  1193. for (var key in newArgHash) {
  1194. if (!currentResHash[key]) {
  1195. newResHash[key] = workerFunc.apply(_this, newArgHash[key]);
  1196. }
  1197. else if (!isArraysEqual(currentArgHash[key], newArgHash[key])) {
  1198. if (teardownFunc) {
  1199. teardownFunc(currentResHash[key]);
  1200. }
  1201. var res = workerFunc.apply(_this, newArgHash[key]);
  1202. newResHash[key] = (resEquality && resEquality(res, currentResHash[key]))
  1203. ? currentResHash[key]
  1204. : res;
  1205. }
  1206. else {
  1207. newResHash[key] = currentResHash[key];
  1208. }
  1209. }
  1210. currentArgHash = newArgHash;
  1211. currentResHash = newResHash;
  1212. return newResHash;
  1213. };
  1214. }
  1215. var EXTENDED_SETTINGS_AND_SEVERITIES = {
  1216. week: 3,
  1217. separator: 0,
  1218. omitZeroMinute: 0,
  1219. meridiem: 0,
  1220. omitCommas: 0,
  1221. };
  1222. var STANDARD_DATE_PROP_SEVERITIES = {
  1223. timeZoneName: 7,
  1224. era: 6,
  1225. year: 5,
  1226. month: 4,
  1227. day: 2,
  1228. weekday: 2,
  1229. hour: 1,
  1230. minute: 1,
  1231. second: 1,
  1232. };
  1233. var MERIDIEM_RE = /\s*([ap])\.?m\.?/i; // eats up leading spaces too
  1234. var COMMA_RE = /,/g; // we need re for globalness
  1235. var MULTI_SPACE_RE = /\s+/g;
  1236. var LTR_RE = /\u200e/g; // control character
  1237. var UTC_RE = /UTC|GMT/;
  1238. var NativeFormatter = /** @class */ (function () {
  1239. function NativeFormatter(formatSettings) {
  1240. var standardDateProps = {};
  1241. var extendedSettings = {};
  1242. var severity = 0;
  1243. for (var name_1 in formatSettings) {
  1244. if (name_1 in EXTENDED_SETTINGS_AND_SEVERITIES) {
  1245. extendedSettings[name_1] = formatSettings[name_1];
  1246. severity = Math.max(EXTENDED_SETTINGS_AND_SEVERITIES[name_1], severity);
  1247. }
  1248. else {
  1249. standardDateProps[name_1] = formatSettings[name_1];
  1250. if (name_1 in STANDARD_DATE_PROP_SEVERITIES) { // TODO: what about hour12? no severity
  1251. severity = Math.max(STANDARD_DATE_PROP_SEVERITIES[name_1], severity);
  1252. }
  1253. }
  1254. }
  1255. this.standardDateProps = standardDateProps;
  1256. this.extendedSettings = extendedSettings;
  1257. this.severity = severity;
  1258. this.buildFormattingFunc = memoize(buildFormattingFunc);
  1259. }
  1260. NativeFormatter.prototype.format = function (date, context) {
  1261. return this.buildFormattingFunc(this.standardDateProps, this.extendedSettings, context)(date);
  1262. };
  1263. NativeFormatter.prototype.formatRange = function (start, end, context, betterDefaultSeparator) {
  1264. var _a = this, standardDateProps = _a.standardDateProps, extendedSettings = _a.extendedSettings;
  1265. var diffSeverity = computeMarkerDiffSeverity(start.marker, end.marker, context.calendarSystem);
  1266. if (!diffSeverity) {
  1267. return this.format(start, context);
  1268. }
  1269. var biggestUnitForPartial = diffSeverity;
  1270. if (biggestUnitForPartial > 1 && // the two dates are different in a way that's larger scale than time
  1271. (standardDateProps.year === 'numeric' || standardDateProps.year === '2-digit') &&
  1272. (standardDateProps.month === 'numeric' || standardDateProps.month === '2-digit') &&
  1273. (standardDateProps.day === 'numeric' || standardDateProps.day === '2-digit')) {
  1274. biggestUnitForPartial = 1; // make it look like the dates are only different in terms of time
  1275. }
  1276. var full0 = this.format(start, context);
  1277. var full1 = this.format(end, context);
  1278. if (full0 === full1) {
  1279. return full0;
  1280. }
  1281. var partialDateProps = computePartialFormattingOptions(standardDateProps, biggestUnitForPartial);
  1282. var partialFormattingFunc = buildFormattingFunc(partialDateProps, extendedSettings, context);
  1283. var partial0 = partialFormattingFunc(start);
  1284. var partial1 = partialFormattingFunc(end);
  1285. var insertion = findCommonInsertion(full0, partial0, full1, partial1);
  1286. var separator = extendedSettings.separator || betterDefaultSeparator || context.defaultSeparator || '';
  1287. if (insertion) {
  1288. return insertion.before + partial0 + separator + partial1 + insertion.after;
  1289. }
  1290. return full0 + separator + full1;
  1291. };
  1292. NativeFormatter.prototype.getLargestUnit = function () {
  1293. switch (this.severity) {
  1294. case 7:
  1295. case 6:
  1296. case 5:
  1297. return 'year';
  1298. case 4:
  1299. return 'month';
  1300. case 3:
  1301. return 'week';
  1302. case 2:
  1303. return 'day';
  1304. default:
  1305. return 'time'; // really?
  1306. }
  1307. };
  1308. return NativeFormatter;
  1309. }());
  1310. function buildFormattingFunc(standardDateProps, extendedSettings, context) {
  1311. var standardDatePropCnt = Object.keys(standardDateProps).length;
  1312. if (standardDatePropCnt === 1 && standardDateProps.timeZoneName === 'short') {
  1313. return function (date) { return (formatTimeZoneOffset(date.timeZoneOffset)); };
  1314. }
  1315. if (standardDatePropCnt === 0 && extendedSettings.week) {
  1316. return function (date) { return (formatWeekNumber(context.computeWeekNumber(date.marker), context.weekText, context.weekTextLong, context.locale, extendedSettings.week)); };
  1317. }
  1318. return buildNativeFormattingFunc(standardDateProps, extendedSettings, context);
  1319. }
  1320. function buildNativeFormattingFunc(standardDateProps, extendedSettings, context) {
  1321. standardDateProps = __assign({}, standardDateProps); // copy
  1322. extendedSettings = __assign({}, extendedSettings); // copy
  1323. sanitizeSettings(standardDateProps, extendedSettings);
  1324. standardDateProps.timeZone = 'UTC'; // we leverage the only guaranteed timeZone for our UTC markers
  1325. var normalFormat = new Intl.DateTimeFormat(context.locale.codes, standardDateProps);
  1326. var zeroFormat; // needed?
  1327. if (extendedSettings.omitZeroMinute) {
  1328. var zeroProps = __assign({}, standardDateProps);
  1329. delete zeroProps.minute; // seconds and ms were already considered in sanitizeSettings
  1330. zeroFormat = new Intl.DateTimeFormat(context.locale.codes, zeroProps);
  1331. }
  1332. return function (date) {
  1333. var marker = date.marker;
  1334. var format;
  1335. if (zeroFormat && !marker.getUTCMinutes()) {
  1336. format = zeroFormat;
  1337. }
  1338. else {
  1339. format = normalFormat;
  1340. }
  1341. var s = format.format(marker);
  1342. return postProcess(s, date, standardDateProps, extendedSettings, context);
  1343. };
  1344. }
  1345. function sanitizeSettings(standardDateProps, extendedSettings) {
  1346. // deal with a browser inconsistency where formatting the timezone
  1347. // requires that the hour/minute be present.
  1348. if (standardDateProps.timeZoneName) {
  1349. if (!standardDateProps.hour) {
  1350. standardDateProps.hour = '2-digit';
  1351. }
  1352. if (!standardDateProps.minute) {
  1353. standardDateProps.minute = '2-digit';
  1354. }
  1355. }
  1356. // only support short timezone names
  1357. if (standardDateProps.timeZoneName === 'long') {
  1358. standardDateProps.timeZoneName = 'short';
  1359. }
  1360. // if requesting to display seconds, MUST display minutes
  1361. if (extendedSettings.omitZeroMinute && (standardDateProps.second || standardDateProps.millisecond)) {
  1362. delete extendedSettings.omitZeroMinute;
  1363. }
  1364. }
  1365. function postProcess(s, date, standardDateProps, extendedSettings, context) {
  1366. s = s.replace(LTR_RE, ''); // remove left-to-right control chars. do first. good for other regexes
  1367. if (standardDateProps.timeZoneName === 'short') {
  1368. s = injectTzoStr(s, (context.timeZone === 'UTC' || date.timeZoneOffset == null) ?
  1369. 'UTC' : // important to normalize for IE, which does "GMT"
  1370. formatTimeZoneOffset(date.timeZoneOffset));
  1371. }
  1372. if (extendedSettings.omitCommas) {
  1373. s = s.replace(COMMA_RE, '').trim();
  1374. }
  1375. if (extendedSettings.omitZeroMinute) {
  1376. s = s.replace(':00', ''); // zeroFormat doesn't always achieve this
  1377. }
  1378. // ^ do anything that might create adjacent spaces before this point,
  1379. // because MERIDIEM_RE likes to eat up loading spaces
  1380. if (extendedSettings.meridiem === false) {
  1381. s = s.replace(MERIDIEM_RE, '').trim();
  1382. }
  1383. else if (extendedSettings.meridiem === 'narrow') { // a/p
  1384. s = s.replace(MERIDIEM_RE, function (m0, m1) { return m1.toLocaleLowerCase(); });
  1385. }
  1386. else if (extendedSettings.meridiem === 'short') { // am/pm
  1387. s = s.replace(MERIDIEM_RE, function (m0, m1) { return m1.toLocaleLowerCase() + "m"; });
  1388. }
  1389. else if (extendedSettings.meridiem === 'lowercase') { // other meridiem transformers already converted to lowercase
  1390. s = s.replace(MERIDIEM_RE, function (m0) { return m0.toLocaleLowerCase(); });
  1391. }
  1392. s = s.replace(MULTI_SPACE_RE, ' ');
  1393. s = s.trim();
  1394. return s;
  1395. }
  1396. function injectTzoStr(s, tzoStr) {
  1397. var replaced = false;
  1398. s = s.replace(UTC_RE, function () {
  1399. replaced = true;
  1400. return tzoStr;
  1401. });
  1402. // IE11 doesn't include UTC/GMT in the original string, so append to end
  1403. if (!replaced) {
  1404. s += " " + tzoStr;
  1405. }
  1406. return s;
  1407. }
  1408. function formatWeekNumber(num, weekText, weekTextLong, locale, display) {
  1409. var parts = [];
  1410. if (display === 'long') {
  1411. parts.push(weekTextLong);
  1412. }
  1413. else if (display === 'short' || display === 'narrow') {
  1414. parts.push(weekText);
  1415. }
  1416. if (display === 'long' || display === 'short') {
  1417. parts.push(' ');
  1418. }
  1419. parts.push(locale.simpleNumberFormat.format(num));
  1420. if (locale.options.direction === 'rtl') { // TODO: use control characters instead?
  1421. parts.reverse();
  1422. }
  1423. return parts.join('');
  1424. }
  1425. // Range Formatting Utils
  1426. // 0 = exactly the same
  1427. // 1 = different by time
  1428. // and bigger
  1429. function computeMarkerDiffSeverity(d0, d1, ca) {
  1430. if (ca.getMarkerYear(d0) !== ca.getMarkerYear(d1)) {
  1431. return 5;
  1432. }
  1433. if (ca.getMarkerMonth(d0) !== ca.getMarkerMonth(d1)) {
  1434. return 4;
  1435. }
  1436. if (ca.getMarkerDay(d0) !== ca.getMarkerDay(d1)) {
  1437. return 2;
  1438. }
  1439. if (timeAsMs(d0) !== timeAsMs(d1)) {
  1440. return 1;
  1441. }
  1442. return 0;
  1443. }
  1444. function computePartialFormattingOptions(options, biggestUnit) {
  1445. var partialOptions = {};
  1446. for (var name_2 in options) {
  1447. if (!(name_2 in STANDARD_DATE_PROP_SEVERITIES) || // not a date part prop (like timeZone)
  1448. STANDARD_DATE_PROP_SEVERITIES[name_2] <= biggestUnit) {
  1449. partialOptions[name_2] = options[name_2];
  1450. }
  1451. }
  1452. return partialOptions;
  1453. }
  1454. function findCommonInsertion(full0, partial0, full1, partial1) {
  1455. var i0 = 0;
  1456. while (i0 < full0.length) {
  1457. var found0 = full0.indexOf(partial0, i0);
  1458. if (found0 === -1) {
  1459. break;
  1460. }
  1461. var before0 = full0.substr(0, found0);
  1462. i0 = found0 + partial0.length;
  1463. var after0 = full0.substr(i0);
  1464. var i1 = 0;
  1465. while (i1 < full1.length) {
  1466. var found1 = full1.indexOf(partial1, i1);
  1467. if (found1 === -1) {
  1468. break;
  1469. }
  1470. var before1 = full1.substr(0, found1);
  1471. i1 = found1 + partial1.length;
  1472. var after1 = full1.substr(i1);
  1473. if (before0 === before1 && after0 === after1) {
  1474. return {
  1475. before: before0,
  1476. after: after0,
  1477. };
  1478. }
  1479. }
  1480. }
  1481. return null;
  1482. }
  1483. function expandZonedMarker(dateInfo, calendarSystem) {
  1484. var a = calendarSystem.markerToArray(dateInfo.marker);
  1485. return {
  1486. marker: dateInfo.marker,
  1487. timeZoneOffset: dateInfo.timeZoneOffset,
  1488. array: a,
  1489. year: a[0],
  1490. month: a[1],
  1491. day: a[2],
  1492. hour: a[3],
  1493. minute: a[4],
  1494. second: a[5],
  1495. millisecond: a[6],
  1496. };
  1497. }
  1498. function createVerboseFormattingArg(start, end, context, betterDefaultSeparator) {
  1499. var startInfo = expandZonedMarker(start, context.calendarSystem);
  1500. var endInfo = end ? expandZonedMarker(end, context.calendarSystem) : null;
  1501. return {
  1502. date: startInfo,
  1503. start: startInfo,
  1504. end: endInfo,
  1505. timeZone: context.timeZone,
  1506. localeCodes: context.locale.codes,
  1507. defaultSeparator: betterDefaultSeparator || context.defaultSeparator,
  1508. };
  1509. }
  1510. /*
  1511. TODO: fix the terminology of "formatter" vs "formatting func"
  1512. */
  1513. /*
  1514. At the time of instantiation, this object does not know which cmd-formatting system it will use.
  1515. It receives this at the time of formatting, as a setting.
  1516. */
  1517. var CmdFormatter = /** @class */ (function () {
  1518. function CmdFormatter(cmdStr) {
  1519. this.cmdStr = cmdStr;
  1520. }
  1521. CmdFormatter.prototype.format = function (date, context, betterDefaultSeparator) {
  1522. return context.cmdFormatter(this.cmdStr, createVerboseFormattingArg(date, null, context, betterDefaultSeparator));
  1523. };
  1524. CmdFormatter.prototype.formatRange = function (start, end, context, betterDefaultSeparator) {
  1525. return context.cmdFormatter(this.cmdStr, createVerboseFormattingArg(start, end, context, betterDefaultSeparator));
  1526. };
  1527. return CmdFormatter;
  1528. }());
  1529. var FuncFormatter = /** @class */ (function () {
  1530. function FuncFormatter(func) {
  1531. this.func = func;
  1532. }
  1533. FuncFormatter.prototype.format = function (date, context, betterDefaultSeparator) {
  1534. return this.func(createVerboseFormattingArg(date, null, context, betterDefaultSeparator));
  1535. };
  1536. FuncFormatter.prototype.formatRange = function (start, end, context, betterDefaultSeparator) {
  1537. return this.func(createVerboseFormattingArg(start, end, context, betterDefaultSeparator));
  1538. };
  1539. return FuncFormatter;
  1540. }());
  1541. function createFormatter(input) {
  1542. if (typeof input === 'object' && input) { // non-null object
  1543. return new NativeFormatter(input);
  1544. }
  1545. if (typeof input === 'string') {
  1546. return new CmdFormatter(input);
  1547. }
  1548. if (typeof input === 'function') {
  1549. return new FuncFormatter(input);
  1550. }
  1551. return null;
  1552. }
  1553. // base options
  1554. // ------------
  1555. var BASE_OPTION_REFINERS = {
  1556. navLinkDayClick: identity,
  1557. navLinkWeekClick: identity,
  1558. duration: createDuration,
  1559. bootstrapFontAwesome: identity,
  1560. buttonIcons: identity,
  1561. customButtons: identity,
  1562. defaultAllDayEventDuration: createDuration,
  1563. defaultTimedEventDuration: createDuration,
  1564. nextDayThreshold: createDuration,
  1565. scrollTime: createDuration,
  1566. scrollTimeReset: Boolean,
  1567. slotMinTime: createDuration,
  1568. slotMaxTime: createDuration,
  1569. dayPopoverFormat: createFormatter,
  1570. slotDuration: createDuration,
  1571. snapDuration: createDuration,
  1572. headerToolbar: identity,
  1573. footerToolbar: identity,
  1574. defaultRangeSeparator: String,
  1575. titleRangeSeparator: String,
  1576. forceEventDuration: Boolean,
  1577. dayHeaders: Boolean,
  1578. dayHeaderFormat: createFormatter,
  1579. dayHeaderClassNames: identity,
  1580. dayHeaderContent: identity,
  1581. dayHeaderDidMount: identity,
  1582. dayHeaderWillUnmount: identity,
  1583. dayCellClassNames: identity,
  1584. dayCellContent: identity,
  1585. dayCellDidMount: identity,
  1586. dayCellWillUnmount: identity,
  1587. initialView: String,
  1588. aspectRatio: Number,
  1589. weekends: Boolean,
  1590. weekNumberCalculation: identity,
  1591. weekNumbers: Boolean,
  1592. weekNumberClassNames: identity,
  1593. weekNumberContent: identity,
  1594. weekNumberDidMount: identity,
  1595. weekNumberWillUnmount: identity,
  1596. editable: Boolean,
  1597. viewClassNames: identity,
  1598. viewDidMount: identity,
  1599. viewWillUnmount: identity,
  1600. nowIndicator: Boolean,
  1601. nowIndicatorClassNames: identity,
  1602. nowIndicatorContent: identity,
  1603. nowIndicatorDidMount: identity,
  1604. nowIndicatorWillUnmount: identity,
  1605. showNonCurrentDates: Boolean,
  1606. lazyFetching: Boolean,
  1607. startParam: String,
  1608. endParam: String,
  1609. timeZoneParam: String,
  1610. timeZone: String,
  1611. locales: identity,
  1612. locale: identity,
  1613. themeSystem: String,
  1614. dragRevertDuration: Number,
  1615. dragScroll: Boolean,
  1616. allDayMaintainDuration: Boolean,
  1617. unselectAuto: Boolean,
  1618. dropAccept: identity,
  1619. eventOrder: parseFieldSpecs,
  1620. eventOrderStrict: Boolean,
  1621. handleWindowResize: Boolean,
  1622. windowResizeDelay: Number,
  1623. longPressDelay: Number,
  1624. eventDragMinDistance: Number,
  1625. expandRows: Boolean,
  1626. height: identity,
  1627. contentHeight: identity,
  1628. direction: String,
  1629. weekNumberFormat: createFormatter,
  1630. eventResizableFromStart: Boolean,
  1631. displayEventTime: Boolean,
  1632. displayEventEnd: Boolean,
  1633. weekText: String,
  1634. weekTextLong: String,
  1635. progressiveEventRendering: Boolean,
  1636. businessHours: identity,
  1637. initialDate: identity,
  1638. now: identity,
  1639. eventDataTransform: identity,
  1640. stickyHeaderDates: identity,
  1641. stickyFooterScrollbar: identity,
  1642. viewHeight: identity,
  1643. defaultAllDay: Boolean,
  1644. eventSourceFailure: identity,
  1645. eventSourceSuccess: identity,
  1646. eventDisplay: String,
  1647. eventStartEditable: Boolean,
  1648. eventDurationEditable: Boolean,
  1649. eventOverlap: identity,
  1650. eventConstraint: identity,
  1651. eventAllow: identity,
  1652. eventBackgroundColor: String,
  1653. eventBorderColor: String,
  1654. eventTextColor: String,
  1655. eventColor: String,
  1656. eventClassNames: identity,
  1657. eventContent: identity,
  1658. eventDidMount: identity,
  1659. eventWillUnmount: identity,
  1660. selectConstraint: identity,
  1661. selectOverlap: identity,
  1662. selectAllow: identity,
  1663. droppable: Boolean,
  1664. unselectCancel: String,
  1665. slotLabelFormat: identity,
  1666. slotLaneClassNames: identity,
  1667. slotLaneContent: identity,
  1668. slotLaneDidMount: identity,
  1669. slotLaneWillUnmount: identity,
  1670. slotLabelClassNames: identity,
  1671. slotLabelContent: identity,
  1672. slotLabelDidMount: identity,
  1673. slotLabelWillUnmount: identity,
  1674. dayMaxEvents: identity,
  1675. dayMaxEventRows: identity,
  1676. dayMinWidth: Number,
  1677. slotLabelInterval: createDuration,
  1678. allDayText: String,
  1679. allDayClassNames: identity,
  1680. allDayContent: identity,
  1681. allDayDidMount: identity,
  1682. allDayWillUnmount: identity,
  1683. slotMinWidth: Number,
  1684. navLinks: Boolean,
  1685. eventTimeFormat: createFormatter,
  1686. rerenderDelay: Number,
  1687. moreLinkText: identity,
  1688. moreLinkHint: identity,
  1689. selectMinDistance: Number,
  1690. selectable: Boolean,
  1691. selectLongPressDelay: Number,
  1692. eventLongPressDelay: Number,
  1693. selectMirror: Boolean,
  1694. eventMaxStack: Number,
  1695. eventMinHeight: Number,
  1696. eventMinWidth: Number,
  1697. eventShortHeight: Number,
  1698. slotEventOverlap: Boolean,
  1699. plugins: identity,
  1700. firstDay: Number,
  1701. dayCount: Number,
  1702. dateAlignment: String,
  1703. dateIncrement: createDuration,
  1704. hiddenDays: identity,
  1705. monthMode: Boolean,
  1706. fixedWeekCount: Boolean,
  1707. validRange: identity,
  1708. visibleRange: identity,
  1709. titleFormat: identity,
  1710. eventInteractive: Boolean,
  1711. // only used by list-view, but languages define the value, so we need it in base options
  1712. noEventsText: String,
  1713. viewHint: identity,
  1714. navLinkHint: identity,
  1715. closeHint: String,
  1716. timeHint: String,
  1717. eventHint: String,
  1718. moreLinkClick: identity,
  1719. moreLinkClassNames: identity,
  1720. moreLinkContent: identity,
  1721. moreLinkDidMount: identity,
  1722. moreLinkWillUnmount: identity,
  1723. };
  1724. // do NOT give a type here. need `typeof BASE_OPTION_DEFAULTS` to give real results.
  1725. // raw values.
  1726. var BASE_OPTION_DEFAULTS = {
  1727. eventDisplay: 'auto',
  1728. defaultRangeSeparator: ' - ',
  1729. titleRangeSeparator: ' \u2013 ',
  1730. defaultTimedEventDuration: '01:00:00',
  1731. defaultAllDayEventDuration: { day: 1 },
  1732. forceEventDuration: false,
  1733. nextDayThreshold: '00:00:00',
  1734. dayHeaders: true,
  1735. initialView: '',
  1736. aspectRatio: 1.35,
  1737. headerToolbar: {
  1738. start: 'title',
  1739. center: '',
  1740. end: 'today prev,next',
  1741. },
  1742. weekends: true,
  1743. weekNumbers: false,
  1744. weekNumberCalculation: 'local',
  1745. editable: false,
  1746. nowIndicator: false,
  1747. scrollTime: '06:00:00',
  1748. scrollTimeReset: true,
  1749. slotMinTime: '00:00:00',
  1750. slotMaxTime: '24:00:00',
  1751. showNonCurrentDates: true,
  1752. lazyFetching: true,
  1753. startParam: 'start',
  1754. endParam: 'end',
  1755. timeZoneParam: 'timeZone',
  1756. timeZone: 'local',
  1757. locales: [],
  1758. locale: '',
  1759. themeSystem: 'standard',
  1760. dragRevertDuration: 500,
  1761. dragScroll: true,
  1762. allDayMaintainDuration: false,
  1763. unselectAuto: true,
  1764. dropAccept: '*',
  1765. eventOrder: 'start,-duration,allDay,title',
  1766. dayPopoverFormat: { month: 'long', day: 'numeric', year: 'numeric' },
  1767. handleWindowResize: true,
  1768. windowResizeDelay: 100,
  1769. longPressDelay: 1000,
  1770. eventDragMinDistance: 5,
  1771. expandRows: false,
  1772. navLinks: false,
  1773. selectable: false,
  1774. eventMinHeight: 15,
  1775. eventMinWidth: 30,
  1776. eventShortHeight: 30,
  1777. };
  1778. // calendar listeners
  1779. // ------------------
  1780. var CALENDAR_LISTENER_REFINERS = {
  1781. datesSet: identity,
  1782. eventsSet: identity,
  1783. eventAdd: identity,
  1784. eventChange: identity,
  1785. eventRemove: identity,
  1786. windowResize: identity,
  1787. eventClick: identity,
  1788. eventMouseEnter: identity,
  1789. eventMouseLeave: identity,
  1790. select: identity,
  1791. unselect: identity,
  1792. loading: identity,
  1793. // internal
  1794. _unmount: identity,
  1795. _beforeprint: identity,
  1796. _afterprint: identity,
  1797. _noEventDrop: identity,
  1798. _noEventResize: identity,
  1799. _resize: identity,
  1800. _scrollRequest: identity,
  1801. };
  1802. // calendar-specific options
  1803. // -------------------------
  1804. var CALENDAR_OPTION_REFINERS = {
  1805. buttonText: identity,
  1806. buttonHints: identity,
  1807. views: identity,
  1808. plugins: identity,
  1809. initialEvents: identity,
  1810. events: identity,
  1811. eventSources: identity,
  1812. };
  1813. var COMPLEX_OPTION_COMPARATORS = {
  1814. headerToolbar: isMaybeObjectsEqual,
  1815. footerToolbar: isMaybeObjectsEqual,
  1816. buttonText: isMaybeObjectsEqual,
  1817. buttonHints: isMaybeObjectsEqual,
  1818. buttonIcons: isMaybeObjectsEqual,
  1819. dateIncrement: isMaybeObjectsEqual,
  1820. };
  1821. function isMaybeObjectsEqual(a, b) {
  1822. if (typeof a === 'object' && typeof b === 'object' && a && b) { // both non-null objects
  1823. return isPropsEqual(a, b);
  1824. }
  1825. return a === b;
  1826. }
  1827. // view-specific options
  1828. // ---------------------
  1829. var VIEW_OPTION_REFINERS = {
  1830. type: String,
  1831. component: identity,
  1832. buttonText: String,
  1833. buttonTextKey: String,
  1834. dateProfileGeneratorClass: identity,
  1835. usesMinMaxTime: Boolean,
  1836. classNames: identity,
  1837. content: identity,
  1838. didMount: identity,
  1839. willUnmount: identity,
  1840. };
  1841. // util funcs
  1842. // ----------------------------------------------------------------------------------------------------
  1843. function mergeRawOptions(optionSets) {
  1844. return mergeProps(optionSets, COMPLEX_OPTION_COMPARATORS);
  1845. }
  1846. function refineProps(input, refiners) {
  1847. var refined = {};
  1848. var extra = {};
  1849. for (var propName in refiners) {
  1850. if (propName in input) {
  1851. refined[propName] = refiners[propName](input[propName]);
  1852. }
  1853. }
  1854. for (var propName in input) {
  1855. if (!(propName in refiners)) {
  1856. extra[propName] = input[propName];
  1857. }
  1858. }
  1859. return { refined: refined, extra: extra };
  1860. }
  1861. function identity(raw) {
  1862. return raw;
  1863. }
  1864. function parseEvents(rawEvents, eventSource, context, allowOpenRange) {
  1865. var eventStore = createEmptyEventStore();
  1866. var eventRefiners = buildEventRefiners(context);
  1867. for (var _i = 0, rawEvents_1 = rawEvents; _i < rawEvents_1.length; _i++) {
  1868. var rawEvent = rawEvents_1[_i];
  1869. var tuple = parseEvent(rawEvent, eventSource, context, allowOpenRange, eventRefiners);
  1870. if (tuple) {
  1871. eventTupleToStore(tuple, eventStore);
  1872. }
  1873. }
  1874. return eventStore;
  1875. }
  1876. function eventTupleToStore(tuple, eventStore) {
  1877. if (eventStore === void 0) { eventStore = createEmptyEventStore(); }
  1878. eventStore.defs[tuple.def.defId] = tuple.def;
  1879. if (tuple.instance) {
  1880. eventStore.instances[tuple.instance.instanceId] = tuple.instance;
  1881. }
  1882. return eventStore;
  1883. }
  1884. // retrieves events that have the same groupId as the instance specified by `instanceId`
  1885. // or they are the same as the instance.
  1886. // why might instanceId not be in the store? an event from another calendar?
  1887. function getRelevantEvents(eventStore, instanceId) {
  1888. var instance = eventStore.instances[instanceId];
  1889. if (instance) {
  1890. var def_1 = eventStore.defs[instance.defId];
  1891. // get events/instances with same group
  1892. var newStore = filterEventStoreDefs(eventStore, function (lookDef) { return isEventDefsGrouped(def_1, lookDef); });
  1893. // add the original
  1894. // TODO: wish we could use eventTupleToStore or something like it
  1895. newStore.defs[def_1.defId] = def_1;
  1896. newStore.instances[instance.instanceId] = instance;
  1897. return newStore;
  1898. }
  1899. return createEmptyEventStore();
  1900. }
  1901. function isEventDefsGrouped(def0, def1) {
  1902. return Boolean(def0.groupId && def0.groupId === def1.groupId);
  1903. }
  1904. function createEmptyEventStore() {
  1905. return { defs: {}, instances: {} };
  1906. }
  1907. function mergeEventStores(store0, store1) {
  1908. return {
  1909. defs: __assign(__assign({}, store0.defs), store1.defs),
  1910. instances: __assign(__assign({}, store0.instances), store1.instances),
  1911. };
  1912. }
  1913. function filterEventStoreDefs(eventStore, filterFunc) {
  1914. var defs = filterHash(eventStore.defs, filterFunc);
  1915. var instances = filterHash(eventStore.instances, function (instance) { return (defs[instance.defId] // still exists?
  1916. ); });
  1917. return { defs: defs, instances: instances };
  1918. }
  1919. function excludeSubEventStore(master, sub) {
  1920. var defs = master.defs, instances = master.instances;
  1921. var filteredDefs = {};
  1922. var filteredInstances = {};
  1923. for (var defId in defs) {
  1924. if (!sub.defs[defId]) { // not explicitly excluded
  1925. filteredDefs[defId] = defs[defId];
  1926. }
  1927. }
  1928. for (var instanceId in instances) {
  1929. if (!sub.instances[instanceId] && // not explicitly excluded
  1930. filteredDefs[instances[instanceId].defId] // def wasn't filtered away
  1931. ) {
  1932. filteredInstances[instanceId] = instances[instanceId];
  1933. }
  1934. }
  1935. return {
  1936. defs: filteredDefs,
  1937. instances: filteredInstances,
  1938. };
  1939. }
  1940. function normalizeConstraint(input, context) {
  1941. if (Array.isArray(input)) {
  1942. return parseEvents(input, null, context, true); // allowOpenRange=true
  1943. }
  1944. if (typeof input === 'object' && input) { // non-null object
  1945. return parseEvents([input], null, context, true); // allowOpenRange=true
  1946. }
  1947. if (input != null) {
  1948. return String(input);
  1949. }
  1950. return null;
  1951. }
  1952. function parseClassNames(raw) {
  1953. if (Array.isArray(raw)) {
  1954. return raw;
  1955. }
  1956. if (typeof raw === 'string') {
  1957. return raw.split(/\s+/);
  1958. }
  1959. return [];
  1960. }
  1961. // TODO: better called "EventSettings" or "EventConfig"
  1962. // TODO: move this file into structs
  1963. // TODO: separate constraint/overlap/allow, because selection uses only that, not other props
  1964. var EVENT_UI_REFINERS = {
  1965. display: String,
  1966. editable: Boolean,
  1967. startEditable: Boolean,
  1968. durationEditable: Boolean,
  1969. constraint: identity,
  1970. overlap: identity,
  1971. allow: identity,
  1972. className: parseClassNames,
  1973. classNames: parseClassNames,
  1974. color: String,
  1975. backgroundColor: String,
  1976. borderColor: String,
  1977. textColor: String,
  1978. };
  1979. var EMPTY_EVENT_UI = {
  1980. display: null,
  1981. startEditable: null,
  1982. durationEditable: null,
  1983. constraints: [],
  1984. overlap: null,
  1985. allows: [],
  1986. backgroundColor: '',
  1987. borderColor: '',
  1988. textColor: '',
  1989. classNames: [],
  1990. };
  1991. function createEventUi(refined, context) {
  1992. var constraint = normalizeConstraint(refined.constraint, context);
  1993. return {
  1994. display: refined.display || null,
  1995. startEditable: refined.startEditable != null ? refined.startEditable : refined.editable,
  1996. durationEditable: refined.durationEditable != null ? refined.durationEditable : refined.editable,
  1997. constraints: constraint != null ? [constraint] : [],
  1998. overlap: refined.overlap != null ? refined.overlap : null,
  1999. allows: refined.allow != null ? [refined.allow] : [],
  2000. backgroundColor: refined.backgroundColor || refined.color || '',
  2001. borderColor: refined.borderColor || refined.color || '',
  2002. textColor: refined.textColor || '',
  2003. classNames: (refined.className || []).concat(refined.classNames || []), // join singular and plural
  2004. };
  2005. }
  2006. // TODO: prevent against problems with <2 args!
  2007. function combineEventUis(uis) {
  2008. return uis.reduce(combineTwoEventUis, EMPTY_EVENT_UI);
  2009. }
  2010. function combineTwoEventUis(item0, item1) {
  2011. return {
  2012. display: item1.display != null ? item1.display : item0.display,
  2013. startEditable: item1.startEditable != null ? item1.startEditable : item0.startEditable,
  2014. durationEditable: item1.durationEditable != null ? item1.durationEditable : item0.durationEditable,
  2015. constraints: item0.constraints.concat(item1.constraints),
  2016. overlap: typeof item1.overlap === 'boolean' ? item1.overlap : item0.overlap,
  2017. allows: item0.allows.concat(item1.allows),
  2018. backgroundColor: item1.backgroundColor || item0.backgroundColor,
  2019. borderColor: item1.borderColor || item0.borderColor,
  2020. textColor: item1.textColor || item0.textColor,
  2021. classNames: item0.classNames.concat(item1.classNames),
  2022. };
  2023. }
  2024. var EVENT_NON_DATE_REFINERS = {
  2025. id: String,
  2026. groupId: String,
  2027. title: String,
  2028. url: String,
  2029. interactive: Boolean,
  2030. };
  2031. var EVENT_DATE_REFINERS = {
  2032. start: identity,
  2033. end: identity,
  2034. date: identity,
  2035. allDay: Boolean,
  2036. };
  2037. var EVENT_REFINERS = __assign(__assign(__assign({}, EVENT_NON_DATE_REFINERS), EVENT_DATE_REFINERS), { extendedProps: identity });
  2038. function parseEvent(raw, eventSource, context, allowOpenRange, refiners) {
  2039. if (refiners === void 0) { refiners = buildEventRefiners(context); }
  2040. var _a = refineEventDef(raw, context, refiners), refined = _a.refined, extra = _a.extra;
  2041. var defaultAllDay = computeIsDefaultAllDay(eventSource, context);
  2042. var recurringRes = parseRecurring(refined, defaultAllDay, context.dateEnv, context.pluginHooks.recurringTypes);
  2043. if (recurringRes) {
  2044. var def = parseEventDef(refined, extra, eventSource ? eventSource.sourceId : '', recurringRes.allDay, Boolean(recurringRes.duration), context);
  2045. def.recurringDef = {
  2046. typeId: recurringRes.typeId,
  2047. typeData: recurringRes.typeData,
  2048. duration: recurringRes.duration,
  2049. };
  2050. return { def: def, instance: null };
  2051. }
  2052. var singleRes = parseSingle(refined, defaultAllDay, context, allowOpenRange);
  2053. if (singleRes) {
  2054. var def = parseEventDef(refined, extra, eventSource ? eventSource.sourceId : '', singleRes.allDay, singleRes.hasEnd, context);
  2055. var instance = createEventInstance(def.defId, singleRes.range, singleRes.forcedStartTzo, singleRes.forcedEndTzo);
  2056. return { def: def, instance: instance };
  2057. }
  2058. return null;
  2059. }
  2060. function refineEventDef(raw, context, refiners) {
  2061. if (refiners === void 0) { refiners = buildEventRefiners(context); }
  2062. return refineProps(raw, refiners);
  2063. }
  2064. function buildEventRefiners(context) {
  2065. return __assign(__assign(__assign({}, EVENT_UI_REFINERS), EVENT_REFINERS), context.pluginHooks.eventRefiners);
  2066. }
  2067. /*
  2068. Will NOT populate extendedProps with the leftover properties.
  2069. Will NOT populate date-related props.
  2070. */
  2071. function parseEventDef(refined, extra, sourceId, allDay, hasEnd, context) {
  2072. var def = {
  2073. title: refined.title || '',
  2074. groupId: refined.groupId || '',
  2075. publicId: refined.id || '',
  2076. url: refined.url || '',
  2077. recurringDef: null,
  2078. defId: guid(),
  2079. sourceId: sourceId,
  2080. allDay: allDay,
  2081. hasEnd: hasEnd,
  2082. interactive: refined.interactive,
  2083. ui: createEventUi(refined, context),
  2084. extendedProps: __assign(__assign({}, (refined.extendedProps || {})), extra),
  2085. };
  2086. for (var _i = 0, _a = context.pluginHooks.eventDefMemberAdders; _i < _a.length; _i++) {
  2087. var memberAdder = _a[_i];
  2088. __assign(def, memberAdder(refined));
  2089. }
  2090. // help out EventApi from having user modify props
  2091. Object.freeze(def.ui.classNames);
  2092. Object.freeze(def.extendedProps);
  2093. return def;
  2094. }
  2095. function parseSingle(refined, defaultAllDay, context, allowOpenRange) {
  2096. var allDay = refined.allDay;
  2097. var startMeta;
  2098. var startMarker = null;
  2099. var hasEnd = false;
  2100. var endMeta;
  2101. var endMarker = null;
  2102. var startInput = refined.start != null ? refined.start : refined.date;
  2103. startMeta = context.dateEnv.createMarkerMeta(startInput);
  2104. if (startMeta) {
  2105. startMarker = startMeta.marker;
  2106. }
  2107. else if (!allowOpenRange) {
  2108. return null;
  2109. }
  2110. if (refined.end != null) {
  2111. endMeta = context.dateEnv.createMarkerMeta(refined.end);
  2112. }
  2113. if (allDay == null) {
  2114. if (defaultAllDay != null) {
  2115. allDay = defaultAllDay;
  2116. }
  2117. else {
  2118. // fall back to the date props LAST
  2119. allDay = (!startMeta || startMeta.isTimeUnspecified) &&
  2120. (!endMeta || endMeta.isTimeUnspecified);
  2121. }
  2122. }
  2123. if (allDay && startMarker) {
  2124. startMarker = startOfDay(startMarker);
  2125. }
  2126. if (endMeta) {
  2127. endMarker = endMeta.marker;
  2128. if (allDay) {
  2129. endMarker = startOfDay(endMarker);
  2130. }
  2131. if (startMarker && endMarker <= startMarker) {
  2132. endMarker = null;
  2133. }
  2134. }
  2135. if (endMarker) {
  2136. hasEnd = true;
  2137. }
  2138. else if (!allowOpenRange) {
  2139. hasEnd = context.options.forceEventDuration || false;
  2140. endMarker = context.dateEnv.add(startMarker, allDay ?
  2141. context.options.defaultAllDayEventDuration :
  2142. context.options.defaultTimedEventDuration);
  2143. }
  2144. return {
  2145. allDay: allDay,
  2146. hasEnd: hasEnd,
  2147. range: { start: startMarker, end: endMarker },
  2148. forcedStartTzo: startMeta ? startMeta.forcedTzo : null,
  2149. forcedEndTzo: endMeta ? endMeta.forcedTzo : null,
  2150. };
  2151. }
  2152. function computeIsDefaultAllDay(eventSource, context) {
  2153. var res = null;
  2154. if (eventSource) {
  2155. res = eventSource.defaultAllDay;
  2156. }
  2157. if (res == null) {
  2158. res = context.options.defaultAllDay;
  2159. }
  2160. return res;
  2161. }
  2162. /* Date stuff that doesn't belong in datelib core
  2163. ----------------------------------------------------------------------------------------------------------------------*/
  2164. // given a timed range, computes an all-day range that has the same exact duration,
  2165. // but whose start time is aligned with the start of the day.
  2166. function computeAlignedDayRange(timedRange) {
  2167. var dayCnt = Math.floor(diffDays(timedRange.start, timedRange.end)) || 1;
  2168. var start = startOfDay(timedRange.start);
  2169. var end = addDays(start, dayCnt);
  2170. return { start: start, end: end };
  2171. }
  2172. // given a timed range, computes an all-day range based on how for the end date bleeds into the next day
  2173. // TODO: give nextDayThreshold a default arg
  2174. function computeVisibleDayRange(timedRange, nextDayThreshold) {
  2175. if (nextDayThreshold === void 0) { nextDayThreshold = createDuration(0); }
  2176. var startDay = null;
  2177. var endDay = null;
  2178. if (timedRange.end) {
  2179. endDay = startOfDay(timedRange.end);
  2180. var endTimeMS = timedRange.end.valueOf() - endDay.valueOf(); // # of milliseconds into `endDay`
  2181. // If the end time is actually inclusively part of the next day and is equal to or
  2182. // beyond the next day threshold, adjust the end to be the exclusive end of `endDay`.
  2183. // Otherwise, leaving it as inclusive will cause it to exclude `endDay`.
  2184. if (endTimeMS && endTimeMS >= asRoughMs(nextDayThreshold)) {
  2185. endDay = addDays(endDay, 1);
  2186. }
  2187. }
  2188. if (timedRange.start) {
  2189. startDay = startOfDay(timedRange.start); // the beginning of the day the range starts
  2190. // If end is within `startDay` but not past nextDayThreshold, assign the default duration of one day.
  2191. if (endDay && endDay <= startDay) {
  2192. endDay = addDays(startDay, 1);
  2193. }
  2194. }
  2195. return { start: startDay, end: endDay };
  2196. }
  2197. // spans from one day into another?
  2198. function isMultiDayRange(range) {
  2199. var visibleRange = computeVisibleDayRange(range);
  2200. return diffDays(visibleRange.start, visibleRange.end) > 1;
  2201. }
  2202. function diffDates(date0, date1, dateEnv, largeUnit) {
  2203. if (largeUnit === 'year') {
  2204. return createDuration(dateEnv.diffWholeYears(date0, date1), 'year');
  2205. }
  2206. if (largeUnit === 'month') {
  2207. return createDuration(dateEnv.diffWholeMonths(date0, date1), 'month');
  2208. }
  2209. return diffDayAndTime(date0, date1); // returns a duration
  2210. }
  2211. function parseRange(input, dateEnv) {
  2212. var start = null;
  2213. var end = null;
  2214. if (input.start) {
  2215. start = dateEnv.createMarker(input.start);
  2216. }
  2217. if (input.end) {
  2218. end = dateEnv.createMarker(input.end);
  2219. }
  2220. if (!start && !end) {
  2221. return null;
  2222. }
  2223. if (start && end && end < start) {
  2224. return null;
  2225. }
  2226. return { start: start, end: end };
  2227. }
  2228. // SIDE-EFFECT: will mutate ranges.
  2229. // Will return a new array result.
  2230. function invertRanges(ranges, constraintRange) {
  2231. var invertedRanges = [];
  2232. var start = constraintRange.start; // the end of the previous range. the start of the new range
  2233. var i;
  2234. var dateRange;
  2235. // ranges need to be in order. required for our date-walking algorithm
  2236. ranges.sort(compareRanges);
  2237. for (i = 0; i < ranges.length; i += 1) {
  2238. dateRange = ranges[i];
  2239. // add the span of time before the event (if there is any)
  2240. if (dateRange.start > start) { // compare millisecond time (skip any ambig logic)
  2241. invertedRanges.push({ start: start, end: dateRange.start });
  2242. }
  2243. if (dateRange.end > start) {
  2244. start = dateRange.end;
  2245. }
  2246. }
  2247. // add the span of time after the last event (if there is any)
  2248. if (start < constraintRange.end) { // compare millisecond time (skip any ambig logic)
  2249. invertedRanges.push({ start: start, end: constraintRange.end });
  2250. }
  2251. return invertedRanges;
  2252. }
  2253. function compareRanges(range0, range1) {
  2254. return range0.start.valueOf() - range1.start.valueOf(); // earlier ranges go first
  2255. }
  2256. function intersectRanges(range0, range1) {
  2257. var start = range0.start, end = range0.end;
  2258. var newRange = null;
  2259. if (range1.start !== null) {
  2260. if (start === null) {
  2261. start = range1.start;
  2262. }
  2263. else {
  2264. start = new Date(Math.max(start.valueOf(), range1.start.valueOf()));
  2265. }
  2266. }
  2267. if (range1.end != null) {
  2268. if (end === null) {
  2269. end = range1.end;
  2270. }
  2271. else {
  2272. end = new Date(Math.min(end.valueOf(), range1.end.valueOf()));
  2273. }
  2274. }
  2275. if (start === null || end === null || start < end) {
  2276. newRange = { start: start, end: end };
  2277. }
  2278. return newRange;
  2279. }
  2280. function rangesEqual(range0, range1) {
  2281. return (range0.start === null ? null : range0.start.valueOf()) === (range1.start === null ? null : range1.start.valueOf()) &&
  2282. (range0.end === null ? null : range0.end.valueOf()) === (range1.end === null ? null : range1.end.valueOf());
  2283. }
  2284. function rangesIntersect(range0, range1) {
  2285. return (range0.end === null || range1.start === null || range0.end > range1.start) &&
  2286. (range0.start === null || range1.end === null || range0.start < range1.end);
  2287. }
  2288. function rangeContainsRange(outerRange, innerRange) {
  2289. return (outerRange.start === null || (innerRange.start !== null && innerRange.start >= outerRange.start)) &&
  2290. (outerRange.end === null || (innerRange.end !== null && innerRange.end <= outerRange.end));
  2291. }
  2292. function rangeContainsMarker(range, date) {
  2293. return (range.start === null || date >= range.start) &&
  2294. (range.end === null || date < range.end);
  2295. }
  2296. // If the given date is not within the given range, move it inside.
  2297. // (If it's past the end, make it one millisecond before the end).
  2298. function constrainMarkerToRange(date, range) {
  2299. if (range.start != null && date < range.start) {
  2300. return range.start;
  2301. }
  2302. if (range.end != null && date >= range.end) {
  2303. return new Date(range.end.valueOf() - 1);
  2304. }
  2305. return date;
  2306. }
  2307. /*
  2308. Specifying nextDayThreshold signals that all-day ranges should be sliced.
  2309. */
  2310. function sliceEventStore(eventStore, eventUiBases, framingRange, nextDayThreshold) {
  2311. var inverseBgByGroupId = {};
  2312. var inverseBgByDefId = {};
  2313. var defByGroupId = {};
  2314. var bgRanges = [];
  2315. var fgRanges = [];
  2316. var eventUis = compileEventUis(eventStore.defs, eventUiBases);
  2317. for (var defId in eventStore.defs) {
  2318. var def = eventStore.defs[defId];
  2319. var ui = eventUis[def.defId];
  2320. if (ui.display === 'inverse-background') {
  2321. if (def.groupId) {
  2322. inverseBgByGroupId[def.groupId] = [];
  2323. if (!defByGroupId[def.groupId]) {
  2324. defByGroupId[def.groupId] = def;
  2325. }
  2326. }
  2327. else {
  2328. inverseBgByDefId[defId] = [];
  2329. }
  2330. }
  2331. }
  2332. for (var instanceId in eventStore.instances) {
  2333. var instance = eventStore.instances[instanceId];
  2334. var def = eventStore.defs[instance.defId];
  2335. var ui = eventUis[def.defId];
  2336. var origRange = instance.range;
  2337. var normalRange = (!def.allDay && nextDayThreshold) ?
  2338. computeVisibleDayRange(origRange, nextDayThreshold) :
  2339. origRange;
  2340. var slicedRange = intersectRanges(normalRange, framingRange);
  2341. if (slicedRange) {
  2342. if (ui.display === 'inverse-background') {
  2343. if (def.groupId) {
  2344. inverseBgByGroupId[def.groupId].push(slicedRange);
  2345. }
  2346. else {
  2347. inverseBgByDefId[instance.defId].push(slicedRange);
  2348. }
  2349. }
  2350. else if (ui.display !== 'none') {
  2351. (ui.display === 'background' ? bgRanges : fgRanges).push({
  2352. def: def,
  2353. ui: ui,
  2354. instance: instance,
  2355. range: slicedRange,
  2356. isStart: normalRange.start && normalRange.start.valueOf() === slicedRange.start.valueOf(),
  2357. isEnd: normalRange.end && normalRange.end.valueOf() === slicedRange.end.valueOf(),
  2358. });
  2359. }
  2360. }
  2361. }
  2362. for (var groupId in inverseBgByGroupId) { // BY GROUP
  2363. var ranges = inverseBgByGroupId[groupId];
  2364. var invertedRanges = invertRanges(ranges, framingRange);
  2365. for (var _i = 0, invertedRanges_1 = invertedRanges; _i < invertedRanges_1.length; _i++) {
  2366. var invertedRange = invertedRanges_1[_i];
  2367. var def = defByGroupId[groupId];
  2368. var ui = eventUis[def.defId];
  2369. bgRanges.push({
  2370. def: def,
  2371. ui: ui,
  2372. instance: null,
  2373. range: invertedRange,
  2374. isStart: false,
  2375. isEnd: false,
  2376. });
  2377. }
  2378. }
  2379. for (var defId in inverseBgByDefId) {
  2380. var ranges = inverseBgByDefId[defId];
  2381. var invertedRanges = invertRanges(ranges, framingRange);
  2382. for (var _a = 0, invertedRanges_2 = invertedRanges; _a < invertedRanges_2.length; _a++) {
  2383. var invertedRange = invertedRanges_2[_a];
  2384. bgRanges.push({
  2385. def: eventStore.defs[defId],
  2386. ui: eventUis[defId],
  2387. instance: null,
  2388. range: invertedRange,
  2389. isStart: false,
  2390. isEnd: false,
  2391. });
  2392. }
  2393. }
  2394. return { bg: bgRanges, fg: fgRanges };
  2395. }
  2396. function hasBgRendering(def) {
  2397. return def.ui.display === 'background' || def.ui.display === 'inverse-background';
  2398. }
  2399. function setElSeg(el, seg) {
  2400. el.fcSeg = seg;
  2401. }
  2402. function getElSeg(el) {
  2403. return el.fcSeg ||
  2404. el.parentNode.fcSeg || // for the harness
  2405. null;
  2406. }
  2407. // event ui computation
  2408. function compileEventUis(eventDefs, eventUiBases) {
  2409. return mapHash(eventDefs, function (eventDef) { return compileEventUi(eventDef, eventUiBases); });
  2410. }
  2411. function compileEventUi(eventDef, eventUiBases) {
  2412. var uis = [];
  2413. if (eventUiBases['']) {
  2414. uis.push(eventUiBases['']);
  2415. }
  2416. if (eventUiBases[eventDef.defId]) {
  2417. uis.push(eventUiBases[eventDef.defId]);
  2418. }
  2419. uis.push(eventDef.ui);
  2420. return combineEventUis(uis);
  2421. }
  2422. function sortEventSegs(segs, eventOrderSpecs) {
  2423. var objs = segs.map(buildSegCompareObj);
  2424. objs.sort(function (obj0, obj1) { return compareByFieldSpecs(obj0, obj1, eventOrderSpecs); });
  2425. return objs.map(function (c) { return c._seg; });
  2426. }
  2427. // returns a object with all primitive props that can be compared
  2428. function buildSegCompareObj(seg) {
  2429. var eventRange = seg.eventRange;
  2430. var eventDef = eventRange.def;
  2431. var range = eventRange.instance ? eventRange.instance.range : eventRange.range;
  2432. var start = range.start ? range.start.valueOf() : 0; // TODO: better support for open-range events
  2433. var end = range.end ? range.end.valueOf() : 0; // "
  2434. return __assign(__assign(__assign({}, eventDef.extendedProps), eventDef), { id: eventDef.publicId, start: start,
  2435. end: end, duration: end - start, allDay: Number(eventDef.allDay), _seg: seg });
  2436. }
  2437. function computeSegDraggable(seg, context) {
  2438. var pluginHooks = context.pluginHooks;
  2439. var transformers = pluginHooks.isDraggableTransformers;
  2440. var _a = seg.eventRange, def = _a.def, ui = _a.ui;
  2441. var val = ui.startEditable;
  2442. for (var _i = 0, transformers_1 = transformers; _i < transformers_1.length; _i++) {
  2443. var transformer = transformers_1[_i];
  2444. val = transformer(val, def, ui, context);
  2445. }
  2446. return val;
  2447. }
  2448. function computeSegStartResizable(seg, context) {
  2449. return seg.isStart && seg.eventRange.ui.durationEditable && context.options.eventResizableFromStart;
  2450. }
  2451. function computeSegEndResizable(seg, context) {
  2452. return seg.isEnd && seg.eventRange.ui.durationEditable;
  2453. }
  2454. function buildSegTimeText(seg, timeFormat, context, defaultDisplayEventTime, // defaults to true
  2455. defaultDisplayEventEnd, // defaults to true
  2456. startOverride, endOverride) {
  2457. var dateEnv = context.dateEnv, options = context.options;
  2458. var displayEventTime = options.displayEventTime, displayEventEnd = options.displayEventEnd;
  2459. var eventDef = seg.eventRange.def;
  2460. var eventInstance = seg.eventRange.instance;
  2461. if (displayEventTime == null) {
  2462. displayEventTime = defaultDisplayEventTime !== false;
  2463. }
  2464. if (displayEventEnd == null) {
  2465. displayEventEnd = defaultDisplayEventEnd !== false;
  2466. }
  2467. var wholeEventStart = eventInstance.range.start;
  2468. var wholeEventEnd = eventInstance.range.end;
  2469. var segStart = startOverride || seg.start || seg.eventRange.range.start;
  2470. var segEnd = endOverride || seg.end || seg.eventRange.range.end;
  2471. var isStartDay = startOfDay(wholeEventStart).valueOf() === startOfDay(segStart).valueOf();
  2472. var isEndDay = startOfDay(addMs(wholeEventEnd, -1)).valueOf() === startOfDay(addMs(segEnd, -1)).valueOf();
  2473. if (displayEventTime && !eventDef.allDay && (isStartDay || isEndDay)) {
  2474. segStart = isStartDay ? wholeEventStart : segStart;
  2475. segEnd = isEndDay ? wholeEventEnd : segEnd;
  2476. if (displayEventEnd && eventDef.hasEnd) {
  2477. return dateEnv.formatRange(segStart, segEnd, timeFormat, {
  2478. forcedStartTzo: startOverride ? null : eventInstance.forcedStartTzo,
  2479. forcedEndTzo: endOverride ? null : eventInstance.forcedEndTzo,
  2480. });
  2481. }
  2482. return dateEnv.format(segStart, timeFormat, {
  2483. forcedTzo: startOverride ? null : eventInstance.forcedStartTzo, // nooooo, same
  2484. });
  2485. }
  2486. return '';
  2487. }
  2488. function getSegMeta(seg, todayRange, nowDate) {
  2489. var segRange = seg.eventRange.range;
  2490. return {
  2491. isPast: segRange.end < (nowDate || todayRange.start),
  2492. isFuture: segRange.start >= (nowDate || todayRange.end),
  2493. isToday: todayRange && rangeContainsMarker(todayRange, segRange.start),
  2494. };
  2495. }
  2496. function getEventClassNames(props) {
  2497. var classNames = ['fc-event'];
  2498. if (props.isMirror) {
  2499. classNames.push('fc-event-mirror');
  2500. }
  2501. if (props.isDraggable) {
  2502. classNames.push('fc-event-draggable');
  2503. }
  2504. if (props.isStartResizable || props.isEndResizable) {
  2505. classNames.push('fc-event-resizable');
  2506. }
  2507. if (props.isDragging) {
  2508. classNames.push('fc-event-dragging');
  2509. }
  2510. if (props.isResizing) {
  2511. classNames.push('fc-event-resizing');
  2512. }
  2513. if (props.isSelected) {
  2514. classNames.push('fc-event-selected');
  2515. }
  2516. if (props.isStart) {
  2517. classNames.push('fc-event-start');
  2518. }
  2519. if (props.isEnd) {
  2520. classNames.push('fc-event-end');
  2521. }
  2522. if (props.isPast) {
  2523. classNames.push('fc-event-past');
  2524. }
  2525. if (props.isToday) {
  2526. classNames.push('fc-event-today');
  2527. }
  2528. if (props.isFuture) {
  2529. classNames.push('fc-event-future');
  2530. }
  2531. return classNames;
  2532. }
  2533. function buildEventRangeKey(eventRange) {
  2534. return eventRange.instance
  2535. ? eventRange.instance.instanceId
  2536. : eventRange.def.defId + ":" + eventRange.range.start.toISOString();
  2537. // inverse-background events don't have specific instances. TODO: better solution
  2538. }
  2539. function getSegAnchorAttrs(seg, context) {
  2540. var _a = seg.eventRange, def = _a.def, instance = _a.instance;
  2541. var url = def.url;
  2542. if (url) {
  2543. return { href: url };
  2544. }
  2545. var emitter = context.emitter, options = context.options;
  2546. var eventInteractive = options.eventInteractive;
  2547. if (eventInteractive == null) {
  2548. eventInteractive = def.interactive;
  2549. if (eventInteractive == null) {
  2550. eventInteractive = Boolean(emitter.hasHandlers('eventClick'));
  2551. }
  2552. }
  2553. // mock what happens in EventClicking
  2554. if (eventInteractive) {
  2555. // only attach keyboard-related handlers because click handler is already done in EventClicking
  2556. return createAriaKeyboardAttrs(function (ev) {
  2557. emitter.trigger('eventClick', {
  2558. el: ev.target,
  2559. event: new EventApi(context, def, instance),
  2560. jsEvent: ev,
  2561. view: context.viewApi,
  2562. });
  2563. });
  2564. }
  2565. return {};
  2566. }
  2567. var STANDARD_PROPS = {
  2568. start: identity,
  2569. end: identity,
  2570. allDay: Boolean,
  2571. };
  2572. function parseDateSpan(raw, dateEnv, defaultDuration) {
  2573. var span = parseOpenDateSpan(raw, dateEnv);
  2574. var range = span.range;
  2575. if (!range.start) {
  2576. return null;
  2577. }
  2578. if (!range.end) {
  2579. if (defaultDuration == null) {
  2580. return null;
  2581. }
  2582. range.end = dateEnv.add(range.start, defaultDuration);
  2583. }
  2584. return span;
  2585. }
  2586. /*
  2587. TODO: somehow combine with parseRange?
  2588. Will return null if the start/end props were present but parsed invalidly.
  2589. */
  2590. function parseOpenDateSpan(raw, dateEnv) {
  2591. var _a = refineProps(raw, STANDARD_PROPS), standardProps = _a.refined, extra = _a.extra;
  2592. var startMeta = standardProps.start ? dateEnv.createMarkerMeta(standardProps.start) : null;
  2593. var endMeta = standardProps.end ? dateEnv.createMarkerMeta(standardProps.end) : null;
  2594. var allDay = standardProps.allDay;
  2595. if (allDay == null) {
  2596. allDay = (startMeta && startMeta.isTimeUnspecified) &&
  2597. (!endMeta || endMeta.isTimeUnspecified);
  2598. }
  2599. return __assign({ range: {
  2600. start: startMeta ? startMeta.marker : null,
  2601. end: endMeta ? endMeta.marker : null,
  2602. }, allDay: allDay }, extra);
  2603. }
  2604. function isDateSpansEqual(span0, span1) {
  2605. return rangesEqual(span0.range, span1.range) &&
  2606. span0.allDay === span1.allDay &&
  2607. isSpanPropsEqual(span0, span1);
  2608. }
  2609. // the NON-DATE-RELATED props
  2610. function isSpanPropsEqual(span0, span1) {
  2611. for (var propName in span1) {
  2612. if (propName !== 'range' && propName !== 'allDay') {
  2613. if (span0[propName] !== span1[propName]) {
  2614. return false;
  2615. }
  2616. }
  2617. }
  2618. // are there any props that span0 has that span1 DOESN'T have?
  2619. // both have range/allDay, so no need to special-case.
  2620. for (var propName in span0) {
  2621. if (!(propName in span1)) {
  2622. return false;
  2623. }
  2624. }
  2625. return true;
  2626. }
  2627. function buildDateSpanApi(span, dateEnv) {
  2628. return __assign(__assign({}, buildRangeApi(span.range, dateEnv, span.allDay)), { allDay: span.allDay });
  2629. }
  2630. function buildRangeApiWithTimeZone(range, dateEnv, omitTime) {
  2631. return __assign(__assign({}, buildRangeApi(range, dateEnv, omitTime)), { timeZone: dateEnv.timeZone });
  2632. }
  2633. function buildRangeApi(range, dateEnv, omitTime) {
  2634. return {
  2635. start: dateEnv.toDate(range.start),
  2636. end: dateEnv.toDate(range.end),
  2637. startStr: dateEnv.formatIso(range.start, { omitTime: omitTime }),
  2638. endStr: dateEnv.formatIso(range.end, { omitTime: omitTime }),
  2639. };
  2640. }
  2641. function fabricateEventRange(dateSpan, eventUiBases, context) {
  2642. var res = refineEventDef({ editable: false }, context);
  2643. var def = parseEventDef(res.refined, res.extra, '', // sourceId
  2644. dateSpan.allDay, true, // hasEnd
  2645. context);
  2646. return {
  2647. def: def,
  2648. ui: compileEventUi(def, eventUiBases),
  2649. instance: createEventInstance(def.defId, dateSpan.range),
  2650. range: dateSpan.range,
  2651. isStart: true,
  2652. isEnd: true,
  2653. };
  2654. }
  2655. function triggerDateSelect(selection, pev, context) {
  2656. context.emitter.trigger('select', __assign(__assign({}, buildDateSpanApiWithContext(selection, context)), { jsEvent: pev ? pev.origEvent : null, view: context.viewApi || context.calendarApi.view }));
  2657. }
  2658. function triggerDateUnselect(pev, context) {
  2659. context.emitter.trigger('unselect', {
  2660. jsEvent: pev ? pev.origEvent : null,
  2661. view: context.viewApi || context.calendarApi.view,
  2662. });
  2663. }
  2664. function buildDateSpanApiWithContext(dateSpan, context) {
  2665. var props = {};
  2666. for (var _i = 0, _a = context.pluginHooks.dateSpanTransforms; _i < _a.length; _i++) {
  2667. var transform = _a[_i];
  2668. __assign(props, transform(dateSpan, context));
  2669. }
  2670. __assign(props, buildDateSpanApi(dateSpan, context.dateEnv));
  2671. return props;
  2672. }
  2673. // Given an event's allDay status and start date, return what its fallback end date should be.
  2674. // TODO: rename to computeDefaultEventEnd
  2675. function getDefaultEventEnd(allDay, marker, context) {
  2676. var dateEnv = context.dateEnv, options = context.options;
  2677. var end = marker;
  2678. if (allDay) {
  2679. end = startOfDay(end);
  2680. end = dateEnv.add(end, options.defaultAllDayEventDuration);
  2681. }
  2682. else {
  2683. end = dateEnv.add(end, options.defaultTimedEventDuration);
  2684. }
  2685. return end;
  2686. }
  2687. // applies the mutation to ALL defs/instances within the event store
  2688. function applyMutationToEventStore(eventStore, eventConfigBase, mutation, context) {
  2689. var eventConfigs = compileEventUis(eventStore.defs, eventConfigBase);
  2690. var dest = createEmptyEventStore();
  2691. for (var defId in eventStore.defs) {
  2692. var def = eventStore.defs[defId];
  2693. dest.defs[defId] = applyMutationToEventDef(def, eventConfigs[defId], mutation, context);
  2694. }
  2695. for (var instanceId in eventStore.instances) {
  2696. var instance = eventStore.instances[instanceId];
  2697. var def = dest.defs[instance.defId]; // important to grab the newly modified def
  2698. dest.instances[instanceId] = applyMutationToEventInstance(instance, def, eventConfigs[instance.defId], mutation, context);
  2699. }
  2700. return dest;
  2701. }
  2702. function applyMutationToEventDef(eventDef, eventConfig, mutation, context) {
  2703. var standardProps = mutation.standardProps || {};
  2704. // if hasEnd has not been specified, guess a good value based on deltas.
  2705. // if duration will change, there's no way the default duration will persist,
  2706. // and thus, we need to mark the event as having a real end
  2707. if (standardProps.hasEnd == null &&
  2708. eventConfig.durationEditable &&
  2709. (mutation.startDelta || mutation.endDelta)) {
  2710. standardProps.hasEnd = true; // TODO: is this mutation okay?
  2711. }
  2712. var copy = __assign(__assign(__assign({}, eventDef), standardProps), { ui: __assign(__assign({}, eventDef.ui), standardProps.ui) });
  2713. if (mutation.extendedProps) {
  2714. copy.extendedProps = __assign(__assign({}, copy.extendedProps), mutation.extendedProps);
  2715. }
  2716. for (var _i = 0, _a = context.pluginHooks.eventDefMutationAppliers; _i < _a.length; _i++) {
  2717. var applier = _a[_i];
  2718. applier(copy, mutation, context);
  2719. }
  2720. if (!copy.hasEnd && context.options.forceEventDuration) {
  2721. copy.hasEnd = true;
  2722. }
  2723. return copy;
  2724. }
  2725. function applyMutationToEventInstance(eventInstance, eventDef, // must first be modified by applyMutationToEventDef
  2726. eventConfig, mutation, context) {
  2727. var dateEnv = context.dateEnv;
  2728. var forceAllDay = mutation.standardProps && mutation.standardProps.allDay === true;
  2729. var clearEnd = mutation.standardProps && mutation.standardProps.hasEnd === false;
  2730. var copy = __assign({}, eventInstance);
  2731. if (forceAllDay) {
  2732. copy.range = computeAlignedDayRange(copy.range);
  2733. }
  2734. if (mutation.datesDelta && eventConfig.startEditable) {
  2735. copy.range = {
  2736. start: dateEnv.add(copy.range.start, mutation.datesDelta),
  2737. end: dateEnv.add(copy.range.end, mutation.datesDelta),
  2738. };
  2739. }
  2740. if (mutation.startDelta && eventConfig.durationEditable) {
  2741. copy.range = {
  2742. start: dateEnv.add(copy.range.start, mutation.startDelta),
  2743. end: copy.range.end,
  2744. };
  2745. }
  2746. if (mutation.endDelta && eventConfig.durationEditable) {
  2747. copy.range = {
  2748. start: copy.range.start,
  2749. end: dateEnv.add(copy.range.end, mutation.endDelta),
  2750. };
  2751. }
  2752. if (clearEnd) {
  2753. copy.range = {
  2754. start: copy.range.start,
  2755. end: getDefaultEventEnd(eventDef.allDay, copy.range.start, context),
  2756. };
  2757. }
  2758. // in case event was all-day but the supplied deltas were not
  2759. // better util for this?
  2760. if (eventDef.allDay) {
  2761. copy.range = {
  2762. start: startOfDay(copy.range.start),
  2763. end: startOfDay(copy.range.end),
  2764. };
  2765. }
  2766. // handle invalid durations
  2767. if (copy.range.end < copy.range.start) {
  2768. copy.range.end = getDefaultEventEnd(eventDef.allDay, copy.range.start, context);
  2769. }
  2770. return copy;
  2771. }
  2772. // no public types yet. when there are, export from:
  2773. // import {} from './api-type-deps'
  2774. var ViewApi = /** @class */ (function () {
  2775. function ViewApi(type, getCurrentData, dateEnv) {
  2776. this.type = type;
  2777. this.getCurrentData = getCurrentData;
  2778. this.dateEnv = dateEnv;
  2779. }
  2780. Object.defineProperty(ViewApi.prototype, "calendar", {
  2781. get: function () {
  2782. return this.getCurrentData().calendarApi;
  2783. },
  2784. enumerable: false,
  2785. configurable: true
  2786. });
  2787. Object.defineProperty(ViewApi.prototype, "title", {
  2788. get: function () {
  2789. return this.getCurrentData().viewTitle;
  2790. },
  2791. enumerable: false,
  2792. configurable: true
  2793. });
  2794. Object.defineProperty(ViewApi.prototype, "activeStart", {
  2795. get: function () {
  2796. return this.dateEnv.toDate(this.getCurrentData().dateProfile.activeRange.start);
  2797. },
  2798. enumerable: false,
  2799. configurable: true
  2800. });
  2801. Object.defineProperty(ViewApi.prototype, "activeEnd", {
  2802. get: function () {
  2803. return this.dateEnv.toDate(this.getCurrentData().dateProfile.activeRange.end);
  2804. },
  2805. enumerable: false,
  2806. configurable: true
  2807. });
  2808. Object.defineProperty(ViewApi.prototype, "currentStart", {
  2809. get: function () {
  2810. return this.dateEnv.toDate(this.getCurrentData().dateProfile.currentRange.start);
  2811. },
  2812. enumerable: false,
  2813. configurable: true
  2814. });
  2815. Object.defineProperty(ViewApi.prototype, "currentEnd", {
  2816. get: function () {
  2817. return this.dateEnv.toDate(this.getCurrentData().dateProfile.currentRange.end);
  2818. },
  2819. enumerable: false,
  2820. configurable: true
  2821. });
  2822. ViewApi.prototype.getOption = function (name) {
  2823. return this.getCurrentData().options[name]; // are the view-specific options
  2824. };
  2825. return ViewApi;
  2826. }());
  2827. var EVENT_SOURCE_REFINERS$1 = {
  2828. id: String,
  2829. defaultAllDay: Boolean,
  2830. url: String,
  2831. format: String,
  2832. events: identity,
  2833. eventDataTransform: identity,
  2834. // for any network-related sources
  2835. success: identity,
  2836. failure: identity,
  2837. };
  2838. function parseEventSource(raw, context, refiners) {
  2839. if (refiners === void 0) { refiners = buildEventSourceRefiners(context); }
  2840. var rawObj;
  2841. if (typeof raw === 'string') {
  2842. rawObj = { url: raw };
  2843. }
  2844. else if (typeof raw === 'function' || Array.isArray(raw)) {
  2845. rawObj = { events: raw };
  2846. }
  2847. else if (typeof raw === 'object' && raw) { // not null
  2848. rawObj = raw;
  2849. }
  2850. if (rawObj) {
  2851. var _a = refineProps(rawObj, refiners), refined = _a.refined, extra = _a.extra;
  2852. var metaRes = buildEventSourceMeta(refined, context);
  2853. if (metaRes) {
  2854. return {
  2855. _raw: raw,
  2856. isFetching: false,
  2857. latestFetchId: '',
  2858. fetchRange: null,
  2859. defaultAllDay: refined.defaultAllDay,
  2860. eventDataTransform: refined.eventDataTransform,
  2861. success: refined.success,
  2862. failure: refined.failure,
  2863. publicId: refined.id || '',
  2864. sourceId: guid(),
  2865. sourceDefId: metaRes.sourceDefId,
  2866. meta: metaRes.meta,
  2867. ui: createEventUi(refined, context),
  2868. extendedProps: extra,
  2869. };
  2870. }
  2871. }
  2872. return null;
  2873. }
  2874. function buildEventSourceRefiners(context) {
  2875. return __assign(__assign(__assign({}, EVENT_UI_REFINERS), EVENT_SOURCE_REFINERS$1), context.pluginHooks.eventSourceRefiners);
  2876. }
  2877. function buildEventSourceMeta(raw, context) {
  2878. var defs = context.pluginHooks.eventSourceDefs;
  2879. for (var i = defs.length - 1; i >= 0; i -= 1) { // later-added plugins take precedence
  2880. var def = defs[i];
  2881. var meta = def.parseMeta(raw);
  2882. if (meta) {
  2883. return { sourceDefId: i, meta: meta };
  2884. }
  2885. }
  2886. return null;
  2887. }
  2888. function reduceCurrentDate(currentDate, action) {
  2889. switch (action.type) {
  2890. case 'CHANGE_DATE':
  2891. return action.dateMarker;
  2892. default:
  2893. return currentDate;
  2894. }
  2895. }
  2896. function getInitialDate(options, dateEnv) {
  2897. var initialDateInput = options.initialDate;
  2898. // compute the initial ambig-timezone date
  2899. if (initialDateInput != null) {
  2900. return dateEnv.createMarker(initialDateInput);
  2901. }
  2902. return getNow(options.now, dateEnv); // getNow already returns unzoned
  2903. }
  2904. function getNow(nowInput, dateEnv) {
  2905. if (typeof nowInput === 'function') {
  2906. nowInput = nowInput();
  2907. }
  2908. if (nowInput == null) {
  2909. return dateEnv.createNowMarker();
  2910. }
  2911. return dateEnv.createMarker(nowInput);
  2912. }
  2913. var CalendarApi = /** @class */ (function () {
  2914. function CalendarApi() {
  2915. }
  2916. CalendarApi.prototype.getCurrentData = function () {
  2917. return this.currentDataManager.getCurrentData();
  2918. };
  2919. CalendarApi.prototype.dispatch = function (action) {
  2920. return this.currentDataManager.dispatch(action);
  2921. };
  2922. Object.defineProperty(CalendarApi.prototype, "view", {
  2923. get: function () { return this.getCurrentData().viewApi; } // for public API
  2924. ,
  2925. enumerable: false,
  2926. configurable: true
  2927. });
  2928. CalendarApi.prototype.batchRendering = function (callback) {
  2929. callback();
  2930. };
  2931. CalendarApi.prototype.updateSize = function () {
  2932. this.trigger('_resize', true);
  2933. };
  2934. // Options
  2935. // -----------------------------------------------------------------------------------------------------------------
  2936. CalendarApi.prototype.setOption = function (name, val) {
  2937. this.dispatch({
  2938. type: 'SET_OPTION',
  2939. optionName: name,
  2940. rawOptionValue: val,
  2941. });
  2942. };
  2943. CalendarApi.prototype.getOption = function (name) {
  2944. return this.currentDataManager.currentCalendarOptionsInput[name];
  2945. };
  2946. CalendarApi.prototype.getAvailableLocaleCodes = function () {
  2947. return Object.keys(this.getCurrentData().availableRawLocales);
  2948. };
  2949. // Trigger
  2950. // -----------------------------------------------------------------------------------------------------------------
  2951. CalendarApi.prototype.on = function (handlerName, handler) {
  2952. var currentDataManager = this.currentDataManager;
  2953. if (currentDataManager.currentCalendarOptionsRefiners[handlerName]) {
  2954. currentDataManager.emitter.on(handlerName, handler);
  2955. }
  2956. else {
  2957. console.warn("Unknown listener name '" + handlerName + "'");
  2958. }
  2959. };
  2960. CalendarApi.prototype.off = function (handlerName, handler) {
  2961. this.currentDataManager.emitter.off(handlerName, handler);
  2962. };
  2963. // not meant for public use
  2964. CalendarApi.prototype.trigger = function (handlerName) {
  2965. var _a;
  2966. var args = [];
  2967. for (var _i = 1; _i < arguments.length; _i++) {
  2968. args[_i - 1] = arguments[_i];
  2969. }
  2970. (_a = this.currentDataManager.emitter).trigger.apply(_a, __spreadArray([handlerName], args));
  2971. };
  2972. // View
  2973. // -----------------------------------------------------------------------------------------------------------------
  2974. CalendarApi.prototype.changeView = function (viewType, dateOrRange) {
  2975. var _this = this;
  2976. this.batchRendering(function () {
  2977. _this.unselect();
  2978. if (dateOrRange) {
  2979. if (dateOrRange.start && dateOrRange.end) { // a range
  2980. _this.dispatch({
  2981. type: 'CHANGE_VIEW_TYPE',
  2982. viewType: viewType,
  2983. });
  2984. _this.dispatch({
  2985. type: 'SET_OPTION',
  2986. optionName: 'visibleRange',
  2987. rawOptionValue: dateOrRange,
  2988. });
  2989. }
  2990. else {
  2991. var dateEnv = _this.getCurrentData().dateEnv;
  2992. _this.dispatch({
  2993. type: 'CHANGE_VIEW_TYPE',
  2994. viewType: viewType,
  2995. dateMarker: dateEnv.createMarker(dateOrRange),
  2996. });
  2997. }
  2998. }
  2999. else {
  3000. _this.dispatch({
  3001. type: 'CHANGE_VIEW_TYPE',
  3002. viewType: viewType,
  3003. });
  3004. }
  3005. });
  3006. };
  3007. // Forces navigation to a view for the given date.
  3008. // `viewType` can be a specific view name or a generic one like "week" or "day".
  3009. // needs to change
  3010. CalendarApi.prototype.zoomTo = function (dateMarker, viewType) {
  3011. var state = this.getCurrentData();
  3012. var spec;
  3013. viewType = viewType || 'day'; // day is default zoom
  3014. spec = state.viewSpecs[viewType] || this.getUnitViewSpec(viewType);
  3015. this.unselect();
  3016. if (spec) {
  3017. this.dispatch({
  3018. type: 'CHANGE_VIEW_TYPE',
  3019. viewType: spec.type,
  3020. dateMarker: dateMarker,
  3021. });
  3022. }
  3023. else {
  3024. this.dispatch({
  3025. type: 'CHANGE_DATE',
  3026. dateMarker: dateMarker,
  3027. });
  3028. }
  3029. };
  3030. // Given a duration singular unit, like "week" or "day", finds a matching view spec.
  3031. // Preference is given to views that have corresponding buttons.
  3032. CalendarApi.prototype.getUnitViewSpec = function (unit) {
  3033. var _a = this.getCurrentData(), viewSpecs = _a.viewSpecs, toolbarConfig = _a.toolbarConfig;
  3034. var viewTypes = [].concat(toolbarConfig.header ? toolbarConfig.header.viewsWithButtons : [], toolbarConfig.footer ? toolbarConfig.footer.viewsWithButtons : []);
  3035. var i;
  3036. var spec;
  3037. for (var viewType in viewSpecs) {
  3038. viewTypes.push(viewType);
  3039. }
  3040. for (i = 0; i < viewTypes.length; i += 1) {
  3041. spec = viewSpecs[viewTypes[i]];
  3042. if (spec) {
  3043. if (spec.singleUnit === unit) {
  3044. return spec;
  3045. }
  3046. }
  3047. }
  3048. return null;
  3049. };
  3050. // Current Date
  3051. // -----------------------------------------------------------------------------------------------------------------
  3052. CalendarApi.prototype.prev = function () {
  3053. this.unselect();
  3054. this.dispatch({ type: 'PREV' });
  3055. };
  3056. CalendarApi.prototype.next = function () {
  3057. this.unselect();
  3058. this.dispatch({ type: 'NEXT' });
  3059. };
  3060. CalendarApi.prototype.prevYear = function () {
  3061. var state = this.getCurrentData();
  3062. this.unselect();
  3063. this.dispatch({
  3064. type: 'CHANGE_DATE',
  3065. dateMarker: state.dateEnv.addYears(state.currentDate, -1),
  3066. });
  3067. };
  3068. CalendarApi.prototype.nextYear = function () {
  3069. var state = this.getCurrentData();
  3070. this.unselect();
  3071. this.dispatch({
  3072. type: 'CHANGE_DATE',
  3073. dateMarker: state.dateEnv.addYears(state.currentDate, 1),
  3074. });
  3075. };
  3076. CalendarApi.prototype.today = function () {
  3077. var state = this.getCurrentData();
  3078. this.unselect();
  3079. this.dispatch({
  3080. type: 'CHANGE_DATE',
  3081. dateMarker: getNow(state.calendarOptions.now, state.dateEnv),
  3082. });
  3083. };
  3084. CalendarApi.prototype.gotoDate = function (zonedDateInput) {
  3085. var state = this.getCurrentData();
  3086. this.unselect();
  3087. this.dispatch({
  3088. type: 'CHANGE_DATE',
  3089. dateMarker: state.dateEnv.createMarker(zonedDateInput),
  3090. });
  3091. };
  3092. CalendarApi.prototype.incrementDate = function (deltaInput) {
  3093. var state = this.getCurrentData();
  3094. var delta = createDuration(deltaInput);
  3095. if (delta) { // else, warn about invalid input?
  3096. this.unselect();
  3097. this.dispatch({
  3098. type: 'CHANGE_DATE',
  3099. dateMarker: state.dateEnv.add(state.currentDate, delta),
  3100. });
  3101. }
  3102. };
  3103. // for external API
  3104. CalendarApi.prototype.getDate = function () {
  3105. var state = this.getCurrentData();
  3106. return state.dateEnv.toDate(state.currentDate);
  3107. };
  3108. // Date Formatting Utils
  3109. // -----------------------------------------------------------------------------------------------------------------
  3110. CalendarApi.prototype.formatDate = function (d, formatter) {
  3111. var dateEnv = this.getCurrentData().dateEnv;
  3112. return dateEnv.format(dateEnv.createMarker(d), createFormatter(formatter));
  3113. };
  3114. // `settings` is for formatter AND isEndExclusive
  3115. CalendarApi.prototype.formatRange = function (d0, d1, settings) {
  3116. var dateEnv = this.getCurrentData().dateEnv;
  3117. return dateEnv.formatRange(dateEnv.createMarker(d0), dateEnv.createMarker(d1), createFormatter(settings), settings);
  3118. };
  3119. CalendarApi.prototype.formatIso = function (d, omitTime) {
  3120. var dateEnv = this.getCurrentData().dateEnv;
  3121. return dateEnv.formatIso(dateEnv.createMarker(d), { omitTime: omitTime });
  3122. };
  3123. // Date Selection / Event Selection / DayClick
  3124. // -----------------------------------------------------------------------------------------------------------------
  3125. // this public method receives start/end dates in any format, with any timezone
  3126. // NOTE: args were changed from v3
  3127. CalendarApi.prototype.select = function (dateOrObj, endDate) {
  3128. var selectionInput;
  3129. if (endDate == null) {
  3130. if (dateOrObj.start != null) {
  3131. selectionInput = dateOrObj;
  3132. }
  3133. else {
  3134. selectionInput = {
  3135. start: dateOrObj,
  3136. end: null,
  3137. };
  3138. }
  3139. }
  3140. else {
  3141. selectionInput = {
  3142. start: dateOrObj,
  3143. end: endDate,
  3144. };
  3145. }
  3146. var state = this.getCurrentData();
  3147. var selection = parseDateSpan(selectionInput, state.dateEnv, createDuration({ days: 1 }));
  3148. if (selection) { // throw parse error otherwise?
  3149. this.dispatch({ type: 'SELECT_DATES', selection: selection });
  3150. triggerDateSelect(selection, null, state);
  3151. }
  3152. };
  3153. // public method
  3154. CalendarApi.prototype.unselect = function (pev) {
  3155. var state = this.getCurrentData();
  3156. if (state.dateSelection) {
  3157. this.dispatch({ type: 'UNSELECT_DATES' });
  3158. triggerDateUnselect(pev, state);
  3159. }
  3160. };
  3161. // Public Events API
  3162. // -----------------------------------------------------------------------------------------------------------------
  3163. CalendarApi.prototype.addEvent = function (eventInput, sourceInput) {
  3164. if (eventInput instanceof EventApi) {
  3165. var def = eventInput._def;
  3166. var instance = eventInput._instance;
  3167. var currentData = this.getCurrentData();
  3168. // not already present? don't want to add an old snapshot
  3169. if (!currentData.eventStore.defs[def.defId]) {
  3170. this.dispatch({
  3171. type: 'ADD_EVENTS',
  3172. eventStore: eventTupleToStore({ def: def, instance: instance }), // TODO: better util for two args?
  3173. });
  3174. this.triggerEventAdd(eventInput);
  3175. }
  3176. return eventInput;
  3177. }
  3178. var state = this.getCurrentData();
  3179. var eventSource;
  3180. if (sourceInput instanceof EventSourceApi) {
  3181. eventSource = sourceInput.internalEventSource;
  3182. }
  3183. else if (typeof sourceInput === 'boolean') {
  3184. if (sourceInput) { // true. part of the first event source
  3185. eventSource = hashValuesToArray(state.eventSources)[0];
  3186. }
  3187. }
  3188. else if (sourceInput != null) { // an ID. accepts a number too
  3189. var sourceApi = this.getEventSourceById(sourceInput); // TODO: use an internal function
  3190. if (!sourceApi) {
  3191. console.warn("Could not find an event source with ID \"" + sourceInput + "\""); // TODO: test
  3192. return null;
  3193. }
  3194. eventSource = sourceApi.internalEventSource;
  3195. }
  3196. var tuple = parseEvent(eventInput, eventSource, state, false);
  3197. if (tuple) {
  3198. var newEventApi = new EventApi(state, tuple.def, tuple.def.recurringDef ? null : tuple.instance);
  3199. this.dispatch({
  3200. type: 'ADD_EVENTS',
  3201. eventStore: eventTupleToStore(tuple),
  3202. });
  3203. this.triggerEventAdd(newEventApi);
  3204. return newEventApi;
  3205. }
  3206. return null;
  3207. };
  3208. CalendarApi.prototype.triggerEventAdd = function (eventApi) {
  3209. var _this = this;
  3210. var emitter = this.getCurrentData().emitter;
  3211. emitter.trigger('eventAdd', {
  3212. event: eventApi,
  3213. relatedEvents: [],
  3214. revert: function () {
  3215. _this.dispatch({
  3216. type: 'REMOVE_EVENTS',
  3217. eventStore: eventApiToStore(eventApi),
  3218. });
  3219. },
  3220. });
  3221. };
  3222. // TODO: optimize
  3223. CalendarApi.prototype.getEventById = function (id) {
  3224. var state = this.getCurrentData();
  3225. var _a = state.eventStore, defs = _a.defs, instances = _a.instances;
  3226. id = String(id);
  3227. for (var defId in defs) {
  3228. var def = defs[defId];
  3229. if (def.publicId === id) {
  3230. if (def.recurringDef) {
  3231. return new EventApi(state, def, null);
  3232. }
  3233. for (var instanceId in instances) {
  3234. var instance = instances[instanceId];
  3235. if (instance.defId === def.defId) {
  3236. return new EventApi(state, def, instance);
  3237. }
  3238. }
  3239. }
  3240. }
  3241. return null;
  3242. };
  3243. CalendarApi.prototype.getEvents = function () {
  3244. var currentData = this.getCurrentData();
  3245. return buildEventApis(currentData.eventStore, currentData);
  3246. };
  3247. CalendarApi.prototype.removeAllEvents = function () {
  3248. this.dispatch({ type: 'REMOVE_ALL_EVENTS' });
  3249. };
  3250. // Public Event Sources API
  3251. // -----------------------------------------------------------------------------------------------------------------
  3252. CalendarApi.prototype.getEventSources = function () {
  3253. var state = this.getCurrentData();
  3254. var sourceHash = state.eventSources;
  3255. var sourceApis = [];
  3256. for (var internalId in sourceHash) {
  3257. sourceApis.push(new EventSourceApi(state, sourceHash[internalId]));
  3258. }
  3259. return sourceApis;
  3260. };
  3261. CalendarApi.prototype.getEventSourceById = function (id) {
  3262. var state = this.getCurrentData();
  3263. var sourceHash = state.eventSources;
  3264. id = String(id);
  3265. for (var sourceId in sourceHash) {
  3266. if (sourceHash[sourceId].publicId === id) {
  3267. return new EventSourceApi(state, sourceHash[sourceId]);
  3268. }
  3269. }
  3270. return null;
  3271. };
  3272. CalendarApi.prototype.addEventSource = function (sourceInput) {
  3273. var state = this.getCurrentData();
  3274. if (sourceInput instanceof EventSourceApi) {
  3275. // not already present? don't want to add an old snapshot
  3276. if (!state.eventSources[sourceInput.internalEventSource.sourceId]) {
  3277. this.dispatch({
  3278. type: 'ADD_EVENT_SOURCES',
  3279. sources: [sourceInput.internalEventSource],
  3280. });
  3281. }
  3282. return sourceInput;
  3283. }
  3284. var eventSource = parseEventSource(sourceInput, state);
  3285. if (eventSource) { // TODO: error otherwise?
  3286. this.dispatch({ type: 'ADD_EVENT_SOURCES', sources: [eventSource] });
  3287. return new EventSourceApi(state, eventSource);
  3288. }
  3289. return null;
  3290. };
  3291. CalendarApi.prototype.removeAllEventSources = function () {
  3292. this.dispatch({ type: 'REMOVE_ALL_EVENT_SOURCES' });
  3293. };
  3294. CalendarApi.prototype.refetchEvents = function () {
  3295. this.dispatch({ type: 'FETCH_EVENT_SOURCES', isRefetch: true });
  3296. };
  3297. // Scroll
  3298. // -----------------------------------------------------------------------------------------------------------------
  3299. CalendarApi.prototype.scrollToTime = function (timeInput) {
  3300. var time = createDuration(timeInput);
  3301. if (time) {
  3302. this.trigger('_scrollRequest', { time: time });
  3303. }
  3304. };
  3305. return CalendarApi;
  3306. }());
  3307. var EventApi = /** @class */ (function () {
  3308. // instance will be null if expressing a recurring event that has no current instances,
  3309. // OR if trying to validate an incoming external event that has no dates assigned
  3310. function EventApi(context, def, instance) {
  3311. this._context = context;
  3312. this._def = def;
  3313. this._instance = instance || null;
  3314. }
  3315. /*
  3316. TODO: make event struct more responsible for this
  3317. */
  3318. EventApi.prototype.setProp = function (name, val) {
  3319. var _a, _b;
  3320. if (name in EVENT_DATE_REFINERS) {
  3321. console.warn('Could not set date-related prop \'name\'. Use one of the date-related methods instead.');
  3322. // TODO: make proper aliasing system?
  3323. }
  3324. else if (name === 'id') {
  3325. val = EVENT_NON_DATE_REFINERS[name](val);
  3326. this.mutate({
  3327. standardProps: { publicId: val }, // hardcoded internal name
  3328. });
  3329. }
  3330. else if (name in EVENT_NON_DATE_REFINERS) {
  3331. val = EVENT_NON_DATE_REFINERS[name](val);
  3332. this.mutate({
  3333. standardProps: (_a = {}, _a[name] = val, _a),
  3334. });
  3335. }
  3336. else if (name in EVENT_UI_REFINERS) {
  3337. var ui = EVENT_UI_REFINERS[name](val);
  3338. if (name === 'color') {
  3339. ui = { backgroundColor: val, borderColor: val };
  3340. }
  3341. else if (name === 'editable') {
  3342. ui = { startEditable: val, durationEditable: val };
  3343. }
  3344. else {
  3345. ui = (_b = {}, _b[name] = val, _b);
  3346. }
  3347. this.mutate({
  3348. standardProps: { ui: ui },
  3349. });
  3350. }
  3351. else {
  3352. console.warn("Could not set prop '" + name + "'. Use setExtendedProp instead.");
  3353. }
  3354. };
  3355. EventApi.prototype.setExtendedProp = function (name, val) {
  3356. var _a;
  3357. this.mutate({
  3358. extendedProps: (_a = {}, _a[name] = val, _a),
  3359. });
  3360. };
  3361. EventApi.prototype.setStart = function (startInput, options) {
  3362. if (options === void 0) { options = {}; }
  3363. var dateEnv = this._context.dateEnv;
  3364. var start = dateEnv.createMarker(startInput);
  3365. if (start && this._instance) { // TODO: warning if parsed bad
  3366. var instanceRange = this._instance.range;
  3367. var startDelta = diffDates(instanceRange.start, start, dateEnv, options.granularity); // what if parsed bad!?
  3368. if (options.maintainDuration) {
  3369. this.mutate({ datesDelta: startDelta });
  3370. }
  3371. else {
  3372. this.mutate({ startDelta: startDelta });
  3373. }
  3374. }
  3375. };
  3376. EventApi.prototype.setEnd = function (endInput, options) {
  3377. if (options === void 0) { options = {}; }
  3378. var dateEnv = this._context.dateEnv;
  3379. var end;
  3380. if (endInput != null) {
  3381. end = dateEnv.createMarker(endInput);
  3382. if (!end) {
  3383. return; // TODO: warning if parsed bad
  3384. }
  3385. }
  3386. if (this._instance) {
  3387. if (end) {
  3388. var endDelta = diffDates(this._instance.range.end, end, dateEnv, options.granularity);
  3389. this.mutate({ endDelta: endDelta });
  3390. }
  3391. else {
  3392. this.mutate({ standardProps: { hasEnd: false } });
  3393. }
  3394. }
  3395. };
  3396. EventApi.prototype.setDates = function (startInput, endInput, options) {
  3397. if (options === void 0) { options = {}; }
  3398. var dateEnv = this._context.dateEnv;
  3399. var standardProps = { allDay: options.allDay };
  3400. var start = dateEnv.createMarker(startInput);
  3401. var end;
  3402. if (!start) {
  3403. return; // TODO: warning if parsed bad
  3404. }
  3405. if (endInput != null) {
  3406. end = dateEnv.createMarker(endInput);
  3407. if (!end) { // TODO: warning if parsed bad
  3408. return;
  3409. }
  3410. }
  3411. if (this._instance) {
  3412. var instanceRange = this._instance.range;
  3413. // when computing the diff for an event being converted to all-day,
  3414. // compute diff off of the all-day values the way event-mutation does.
  3415. if (options.allDay === true) {
  3416. instanceRange = computeAlignedDayRange(instanceRange);
  3417. }
  3418. var startDelta = diffDates(instanceRange.start, start, dateEnv, options.granularity);
  3419. if (end) {
  3420. var endDelta = diffDates(instanceRange.end, end, dateEnv, options.granularity);
  3421. if (durationsEqual(startDelta, endDelta)) {
  3422. this.mutate({ datesDelta: startDelta, standardProps: standardProps });
  3423. }
  3424. else {
  3425. this.mutate({ startDelta: startDelta, endDelta: endDelta, standardProps: standardProps });
  3426. }
  3427. }
  3428. else { // means "clear the end"
  3429. standardProps.hasEnd = false;
  3430. this.mutate({ datesDelta: startDelta, standardProps: standardProps });
  3431. }
  3432. }
  3433. };
  3434. EventApi.prototype.moveStart = function (deltaInput) {
  3435. var delta = createDuration(deltaInput);
  3436. if (delta) { // TODO: warning if parsed bad
  3437. this.mutate({ startDelta: delta });
  3438. }
  3439. };
  3440. EventApi.prototype.moveEnd = function (deltaInput) {
  3441. var delta = createDuration(deltaInput);
  3442. if (delta) { // TODO: warning if parsed bad
  3443. this.mutate({ endDelta: delta });
  3444. }
  3445. };
  3446. EventApi.prototype.moveDates = function (deltaInput) {
  3447. var delta = createDuration(deltaInput);
  3448. if (delta) { // TODO: warning if parsed bad
  3449. this.mutate({ datesDelta: delta });
  3450. }
  3451. };
  3452. EventApi.prototype.setAllDay = function (allDay, options) {
  3453. if (options === void 0) { options = {}; }
  3454. var standardProps = { allDay: allDay };
  3455. var maintainDuration = options.maintainDuration;
  3456. if (maintainDuration == null) {
  3457. maintainDuration = this._context.options.allDayMaintainDuration;
  3458. }
  3459. if (this._def.allDay !== allDay) {
  3460. standardProps.hasEnd = maintainDuration;
  3461. }
  3462. this.mutate({ standardProps: standardProps });
  3463. };
  3464. EventApi.prototype.formatRange = function (formatInput) {
  3465. var dateEnv = this._context.dateEnv;
  3466. var instance = this._instance;
  3467. var formatter = createFormatter(formatInput);
  3468. if (this._def.hasEnd) {
  3469. return dateEnv.formatRange(instance.range.start, instance.range.end, formatter, {
  3470. forcedStartTzo: instance.forcedStartTzo,
  3471. forcedEndTzo: instance.forcedEndTzo,
  3472. });
  3473. }
  3474. return dateEnv.format(instance.range.start, formatter, {
  3475. forcedTzo: instance.forcedStartTzo,
  3476. });
  3477. };
  3478. EventApi.prototype.mutate = function (mutation) {
  3479. var instance = this._instance;
  3480. if (instance) {
  3481. var def = this._def;
  3482. var context_1 = this._context;
  3483. var eventStore_1 = context_1.getCurrentData().eventStore;
  3484. var relevantEvents = getRelevantEvents(eventStore_1, instance.instanceId);
  3485. var eventConfigBase = {
  3486. '': {
  3487. display: '',
  3488. startEditable: true,
  3489. durationEditable: true,
  3490. constraints: [],
  3491. overlap: null,
  3492. allows: [],
  3493. backgroundColor: '',
  3494. borderColor: '',
  3495. textColor: '',
  3496. classNames: [],
  3497. },
  3498. };
  3499. relevantEvents = applyMutationToEventStore(relevantEvents, eventConfigBase, mutation, context_1);
  3500. var oldEvent = new EventApi(context_1, def, instance); // snapshot
  3501. this._def = relevantEvents.defs[def.defId];
  3502. this._instance = relevantEvents.instances[instance.instanceId];
  3503. context_1.dispatch({
  3504. type: 'MERGE_EVENTS',
  3505. eventStore: relevantEvents,
  3506. });
  3507. context_1.emitter.trigger('eventChange', {
  3508. oldEvent: oldEvent,
  3509. event: this,
  3510. relatedEvents: buildEventApis(relevantEvents, context_1, instance),
  3511. revert: function () {
  3512. context_1.dispatch({
  3513. type: 'RESET_EVENTS',
  3514. eventStore: eventStore_1,
  3515. });
  3516. },
  3517. });
  3518. }
  3519. };
  3520. EventApi.prototype.remove = function () {
  3521. var context = this._context;
  3522. var asStore = eventApiToStore(this);
  3523. context.dispatch({
  3524. type: 'REMOVE_EVENTS',
  3525. eventStore: asStore,
  3526. });
  3527. context.emitter.trigger('eventRemove', {
  3528. event: this,
  3529. relatedEvents: [],
  3530. revert: function () {
  3531. context.dispatch({
  3532. type: 'MERGE_EVENTS',
  3533. eventStore: asStore,
  3534. });
  3535. },
  3536. });
  3537. };
  3538. Object.defineProperty(EventApi.prototype, "source", {
  3539. get: function () {
  3540. var sourceId = this._def.sourceId;
  3541. if (sourceId) {
  3542. return new EventSourceApi(this._context, this._context.getCurrentData().eventSources[sourceId]);
  3543. }
  3544. return null;
  3545. },
  3546. enumerable: false,
  3547. configurable: true
  3548. });
  3549. Object.defineProperty(EventApi.prototype, "start", {
  3550. get: function () {
  3551. return this._instance ?
  3552. this._context.dateEnv.toDate(this._instance.range.start) :
  3553. null;
  3554. },
  3555. enumerable: false,
  3556. configurable: true
  3557. });
  3558. Object.defineProperty(EventApi.prototype, "end", {
  3559. get: function () {
  3560. return (this._instance && this._def.hasEnd) ?
  3561. this._context.dateEnv.toDate(this._instance.range.end) :
  3562. null;
  3563. },
  3564. enumerable: false,
  3565. configurable: true
  3566. });
  3567. Object.defineProperty(EventApi.prototype, "startStr", {
  3568. get: function () {
  3569. var instance = this._instance;
  3570. if (instance) {
  3571. return this._context.dateEnv.formatIso(instance.range.start, {
  3572. omitTime: this._def.allDay,
  3573. forcedTzo: instance.forcedStartTzo,
  3574. });
  3575. }
  3576. return '';
  3577. },
  3578. enumerable: false,
  3579. configurable: true
  3580. });
  3581. Object.defineProperty(EventApi.prototype, "endStr", {
  3582. get: function () {
  3583. var instance = this._instance;
  3584. if (instance && this._def.hasEnd) {
  3585. return this._context.dateEnv.formatIso(instance.range.end, {
  3586. omitTime: this._def.allDay,
  3587. forcedTzo: instance.forcedEndTzo,
  3588. });
  3589. }
  3590. return '';
  3591. },
  3592. enumerable: false,
  3593. configurable: true
  3594. });
  3595. Object.defineProperty(EventApi.prototype, "id", {
  3596. // computable props that all access the def
  3597. // TODO: find a TypeScript-compatible way to do this at scale
  3598. get: function () { return this._def.publicId; },
  3599. enumerable: false,
  3600. configurable: true
  3601. });
  3602. Object.defineProperty(EventApi.prototype, "groupId", {
  3603. get: function () { return this._def.groupId; },
  3604. enumerable: false,
  3605. configurable: true
  3606. });
  3607. Object.defineProperty(EventApi.prototype, "allDay", {
  3608. get: function () { return this._def.allDay; },
  3609. enumerable: false,
  3610. configurable: true
  3611. });
  3612. Object.defineProperty(EventApi.prototype, "title", {
  3613. get: function () { return this._def.title; },
  3614. enumerable: false,
  3615. configurable: true
  3616. });
  3617. Object.defineProperty(EventApi.prototype, "url", {
  3618. get: function () { return this._def.url; },
  3619. enumerable: false,
  3620. configurable: true
  3621. });
  3622. Object.defineProperty(EventApi.prototype, "display", {
  3623. get: function () { return this._def.ui.display || 'auto'; } // bad. just normalize the type earlier
  3624. ,
  3625. enumerable: false,
  3626. configurable: true
  3627. });
  3628. Object.defineProperty(EventApi.prototype, "startEditable", {
  3629. get: function () { return this._def.ui.startEditable; },
  3630. enumerable: false,
  3631. configurable: true
  3632. });
  3633. Object.defineProperty(EventApi.prototype, "durationEditable", {
  3634. get: function () { return this._def.ui.durationEditable; },
  3635. enumerable: false,
  3636. configurable: true
  3637. });
  3638. Object.defineProperty(EventApi.prototype, "constraint", {
  3639. get: function () { return this._def.ui.constraints[0] || null; },
  3640. enumerable: false,
  3641. configurable: true
  3642. });
  3643. Object.defineProperty(EventApi.prototype, "overlap", {
  3644. get: function () { return this._def.ui.overlap; },
  3645. enumerable: false,
  3646. configurable: true
  3647. });
  3648. Object.defineProperty(EventApi.prototype, "allow", {
  3649. get: function () { return this._def.ui.allows[0] || null; },
  3650. enumerable: false,
  3651. configurable: true
  3652. });
  3653. Object.defineProperty(EventApi.prototype, "backgroundColor", {
  3654. get: function () { return this._def.ui.backgroundColor; },
  3655. enumerable: false,
  3656. configurable: true
  3657. });
  3658. Object.defineProperty(EventApi.prototype, "borderColor", {
  3659. get: function () { return this._def.ui.borderColor; },
  3660. enumerable: false,
  3661. configurable: true
  3662. });
  3663. Object.defineProperty(EventApi.prototype, "textColor", {
  3664. get: function () { return this._def.ui.textColor; },
  3665. enumerable: false,
  3666. configurable: true
  3667. });
  3668. Object.defineProperty(EventApi.prototype, "classNames", {
  3669. // NOTE: user can't modify these because Object.freeze was called in event-def parsing
  3670. get: function () { return this._def.ui.classNames; },
  3671. enumerable: false,
  3672. configurable: true
  3673. });
  3674. Object.defineProperty(EventApi.prototype, "extendedProps", {
  3675. get: function () { return this._def.extendedProps; },
  3676. enumerable: false,
  3677. configurable: true
  3678. });
  3679. EventApi.prototype.toPlainObject = function (settings) {
  3680. if (settings === void 0) { settings = {}; }
  3681. var def = this._def;
  3682. var ui = def.ui;
  3683. var _a = this, startStr = _a.startStr, endStr = _a.endStr;
  3684. var res = {};
  3685. if (def.title) {
  3686. res.title = def.title;
  3687. }
  3688. if (startStr) {
  3689. res.start = startStr;
  3690. }
  3691. if (endStr) {
  3692. res.end = endStr;
  3693. }
  3694. if (def.publicId) {
  3695. res.id = def.publicId;
  3696. }
  3697. if (def.groupId) {
  3698. res.groupId = def.groupId;
  3699. }
  3700. if (def.url) {
  3701. res.url = def.url;
  3702. }
  3703. if (ui.display && ui.display !== 'auto') {
  3704. res.display = ui.display;
  3705. }
  3706. // TODO: what about recurring-event properties???
  3707. // TODO: include startEditable/durationEditable/constraint/overlap/allow
  3708. if (settings.collapseColor && ui.backgroundColor && ui.backgroundColor === ui.borderColor) {
  3709. res.color = ui.backgroundColor;
  3710. }
  3711. else {
  3712. if (ui.backgroundColor) {
  3713. res.backgroundColor = ui.backgroundColor;
  3714. }
  3715. if (ui.borderColor) {
  3716. res.borderColor = ui.borderColor;
  3717. }
  3718. }
  3719. if (ui.textColor) {
  3720. res.textColor = ui.textColor;
  3721. }
  3722. if (ui.classNames.length) {
  3723. res.classNames = ui.classNames;
  3724. }
  3725. if (Object.keys(def.extendedProps).length) {
  3726. if (settings.collapseExtendedProps) {
  3727. __assign(res, def.extendedProps);
  3728. }
  3729. else {
  3730. res.extendedProps = def.extendedProps;
  3731. }
  3732. }
  3733. return res;
  3734. };
  3735. EventApi.prototype.toJSON = function () {
  3736. return this.toPlainObject();
  3737. };
  3738. return EventApi;
  3739. }());
  3740. function eventApiToStore(eventApi) {
  3741. var _a, _b;
  3742. var def = eventApi._def;
  3743. var instance = eventApi._instance;
  3744. return {
  3745. defs: (_a = {}, _a[def.defId] = def, _a),
  3746. instances: instance
  3747. ? (_b = {}, _b[instance.instanceId] = instance, _b) : {},
  3748. };
  3749. }
  3750. function buildEventApis(eventStore, context, excludeInstance) {
  3751. var defs = eventStore.defs, instances = eventStore.instances;
  3752. var eventApis = [];
  3753. var excludeInstanceId = excludeInstance ? excludeInstance.instanceId : '';
  3754. for (var id in instances) {
  3755. var instance = instances[id];
  3756. var def = defs[instance.defId];
  3757. if (instance.instanceId !== excludeInstanceId) {
  3758. eventApis.push(new EventApi(context, def, instance));
  3759. }
  3760. }
  3761. return eventApis;
  3762. }
  3763. var calendarSystemClassMap = {};
  3764. function registerCalendarSystem(name, theClass) {
  3765. calendarSystemClassMap[name] = theClass;
  3766. }
  3767. function createCalendarSystem(name) {
  3768. return new calendarSystemClassMap[name]();
  3769. }
  3770. var GregorianCalendarSystem = /** @class */ (function () {
  3771. function GregorianCalendarSystem() {
  3772. }
  3773. GregorianCalendarSystem.prototype.getMarkerYear = function (d) {
  3774. return d.getUTCFullYear();
  3775. };
  3776. GregorianCalendarSystem.prototype.getMarkerMonth = function (d) {
  3777. return d.getUTCMonth();
  3778. };
  3779. GregorianCalendarSystem.prototype.getMarkerDay = function (d) {
  3780. return d.getUTCDate();
  3781. };
  3782. GregorianCalendarSystem.prototype.arrayToMarker = function (arr) {
  3783. return arrayToUtcDate(arr);
  3784. };
  3785. GregorianCalendarSystem.prototype.markerToArray = function (marker) {
  3786. return dateToUtcArray(marker);
  3787. };
  3788. return GregorianCalendarSystem;
  3789. }());
  3790. registerCalendarSystem('gregory', GregorianCalendarSystem);
  3791. var ISO_RE = /^\s*(\d{4})(-?(\d{2})(-?(\d{2})([T ](\d{2}):?(\d{2})(:?(\d{2})(\.(\d+))?)?(Z|(([-+])(\d{2})(:?(\d{2}))?))?)?)?)?$/;
  3792. function parse(str) {
  3793. var m = ISO_RE.exec(str);
  3794. if (m) {
  3795. 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));
  3796. if (isValidDate(marker)) {
  3797. var timeZoneOffset = null;
  3798. if (m[13]) {
  3799. timeZoneOffset = (m[15] === '-' ? -1 : 1) * (Number(m[16] || 0) * 60 +
  3800. Number(m[18] || 0));
  3801. }
  3802. return {
  3803. marker: marker,
  3804. isTimeUnspecified: !m[6],
  3805. timeZoneOffset: timeZoneOffset,
  3806. };
  3807. }
  3808. }
  3809. return null;
  3810. }
  3811. var DateEnv = /** @class */ (function () {
  3812. function DateEnv(settings) {
  3813. var timeZone = this.timeZone = settings.timeZone;
  3814. var isNamedTimeZone = timeZone !== 'local' && timeZone !== 'UTC';
  3815. if (settings.namedTimeZoneImpl && isNamedTimeZone) {
  3816. this.namedTimeZoneImpl = new settings.namedTimeZoneImpl(timeZone);
  3817. }
  3818. this.canComputeOffset = Boolean(!isNamedTimeZone || this.namedTimeZoneImpl);
  3819. this.calendarSystem = createCalendarSystem(settings.calendarSystem);
  3820. this.locale = settings.locale;
  3821. this.weekDow = settings.locale.week.dow;
  3822. this.weekDoy = settings.locale.week.doy;
  3823. if (settings.weekNumberCalculation === 'ISO') {
  3824. this.weekDow = 1;
  3825. this.weekDoy = 4;
  3826. }
  3827. if (typeof settings.firstDay === 'number') {
  3828. this.weekDow = settings.firstDay;
  3829. }
  3830. if (typeof settings.weekNumberCalculation === 'function') {
  3831. this.weekNumberFunc = settings.weekNumberCalculation;
  3832. }
  3833. this.weekText = settings.weekText != null ? settings.weekText : settings.locale.options.weekText;
  3834. this.weekTextLong = (settings.weekTextLong != null ? settings.weekTextLong : settings.locale.options.weekTextLong) || this.weekText;
  3835. this.cmdFormatter = settings.cmdFormatter;
  3836. this.defaultSeparator = settings.defaultSeparator;
  3837. }
  3838. // Creating / Parsing
  3839. DateEnv.prototype.createMarker = function (input) {
  3840. var meta = this.createMarkerMeta(input);
  3841. if (meta === null) {
  3842. return null;
  3843. }
  3844. return meta.marker;
  3845. };
  3846. DateEnv.prototype.createNowMarker = function () {
  3847. if (this.canComputeOffset) {
  3848. return this.timestampToMarker(new Date().valueOf());
  3849. }
  3850. // if we can't compute the current date val for a timezone,
  3851. // better to give the current local date vals than UTC
  3852. return arrayToUtcDate(dateToLocalArray(new Date()));
  3853. };
  3854. DateEnv.prototype.createMarkerMeta = function (input) {
  3855. if (typeof input === 'string') {
  3856. return this.parse(input);
  3857. }
  3858. var marker = null;
  3859. if (typeof input === 'number') {
  3860. marker = this.timestampToMarker(input);
  3861. }
  3862. else if (input instanceof Date) {
  3863. input = input.valueOf();
  3864. if (!isNaN(input)) {
  3865. marker = this.timestampToMarker(input);
  3866. }
  3867. }
  3868. else if (Array.isArray(input)) {
  3869. marker = arrayToUtcDate(input);
  3870. }
  3871. if (marker === null || !isValidDate(marker)) {
  3872. return null;
  3873. }
  3874. return { marker: marker, isTimeUnspecified: false, forcedTzo: null };
  3875. };
  3876. DateEnv.prototype.parse = function (s) {
  3877. var parts = parse(s);
  3878. if (parts === null) {
  3879. return null;
  3880. }
  3881. var marker = parts.marker;
  3882. var forcedTzo = null;
  3883. if (parts.timeZoneOffset !== null) {
  3884. if (this.canComputeOffset) {
  3885. marker = this.timestampToMarker(marker.valueOf() - parts.timeZoneOffset * 60 * 1000);
  3886. }
  3887. else {
  3888. forcedTzo = parts.timeZoneOffset;
  3889. }
  3890. }
  3891. return { marker: marker, isTimeUnspecified: parts.isTimeUnspecified, forcedTzo: forcedTzo };
  3892. };
  3893. // Accessors
  3894. DateEnv.prototype.getYear = function (marker) {
  3895. return this.calendarSystem.getMarkerYear(marker);
  3896. };
  3897. DateEnv.prototype.getMonth = function (marker) {
  3898. return this.calendarSystem.getMarkerMonth(marker);
  3899. };
  3900. // Adding / Subtracting
  3901. DateEnv.prototype.add = function (marker, dur) {
  3902. var a = this.calendarSystem.markerToArray(marker);
  3903. a[0] += dur.years;
  3904. a[1] += dur.months;
  3905. a[2] += dur.days;
  3906. a[6] += dur.milliseconds;
  3907. return this.calendarSystem.arrayToMarker(a);
  3908. };
  3909. DateEnv.prototype.subtract = function (marker, dur) {
  3910. var a = this.calendarSystem.markerToArray(marker);
  3911. a[0] -= dur.years;
  3912. a[1] -= dur.months;
  3913. a[2] -= dur.days;
  3914. a[6] -= dur.milliseconds;
  3915. return this.calendarSystem.arrayToMarker(a);
  3916. };
  3917. DateEnv.prototype.addYears = function (marker, n) {
  3918. var a = this.calendarSystem.markerToArray(marker);
  3919. a[0] += n;
  3920. return this.calendarSystem.arrayToMarker(a);
  3921. };
  3922. DateEnv.prototype.addMonths = function (marker, n) {
  3923. var a = this.calendarSystem.markerToArray(marker);
  3924. a[1] += n;
  3925. return this.calendarSystem.arrayToMarker(a);
  3926. };
  3927. // Diffing Whole Units
  3928. DateEnv.prototype.diffWholeYears = function (m0, m1) {
  3929. var calendarSystem = this.calendarSystem;
  3930. if (timeAsMs(m0) === timeAsMs(m1) &&
  3931. calendarSystem.getMarkerDay(m0) === calendarSystem.getMarkerDay(m1) &&
  3932. calendarSystem.getMarkerMonth(m0) === calendarSystem.getMarkerMonth(m1)) {
  3933. return calendarSystem.getMarkerYear(m1) - calendarSystem.getMarkerYear(m0);
  3934. }
  3935. return null;
  3936. };
  3937. DateEnv.prototype.diffWholeMonths = function (m0, m1) {
  3938. var calendarSystem = this.calendarSystem;
  3939. if (timeAsMs(m0) === timeAsMs(m1) &&
  3940. calendarSystem.getMarkerDay(m0) === calendarSystem.getMarkerDay(m1)) {
  3941. return (calendarSystem.getMarkerMonth(m1) - calendarSystem.getMarkerMonth(m0)) +
  3942. (calendarSystem.getMarkerYear(m1) - calendarSystem.getMarkerYear(m0)) * 12;
  3943. }
  3944. return null;
  3945. };
  3946. // Range / Duration
  3947. DateEnv.prototype.greatestWholeUnit = function (m0, m1) {
  3948. var n = this.diffWholeYears(m0, m1);
  3949. if (n !== null) {
  3950. return { unit: 'year', value: n };
  3951. }
  3952. n = this.diffWholeMonths(m0, m1);
  3953. if (n !== null) {
  3954. return { unit: 'month', value: n };
  3955. }
  3956. n = diffWholeWeeks(m0, m1);
  3957. if (n !== null) {
  3958. return { unit: 'week', value: n };
  3959. }
  3960. n = diffWholeDays(m0, m1);
  3961. if (n !== null) {
  3962. return { unit: 'day', value: n };
  3963. }
  3964. n = diffHours(m0, m1);
  3965. if (isInt(n)) {
  3966. return { unit: 'hour', value: n };
  3967. }
  3968. n = diffMinutes(m0, m1);
  3969. if (isInt(n)) {
  3970. return { unit: 'minute', value: n };
  3971. }
  3972. n = diffSeconds(m0, m1);
  3973. if (isInt(n)) {
  3974. return { unit: 'second', value: n };
  3975. }
  3976. return { unit: 'millisecond', value: m1.valueOf() - m0.valueOf() };
  3977. };
  3978. DateEnv.prototype.countDurationsBetween = function (m0, m1, d) {
  3979. // TODO: can use greatestWholeUnit
  3980. var diff;
  3981. if (d.years) {
  3982. diff = this.diffWholeYears(m0, m1);
  3983. if (diff !== null) {
  3984. return diff / asRoughYears(d);
  3985. }
  3986. }
  3987. if (d.months) {
  3988. diff = this.diffWholeMonths(m0, m1);
  3989. if (diff !== null) {
  3990. return diff / asRoughMonths(d);
  3991. }
  3992. }
  3993. if (d.days) {
  3994. diff = diffWholeDays(m0, m1);
  3995. if (diff !== null) {
  3996. return diff / asRoughDays(d);
  3997. }
  3998. }
  3999. return (m1.valueOf() - m0.valueOf()) / asRoughMs(d);
  4000. };
  4001. // Start-Of
  4002. // these DON'T return zoned-dates. only UTC start-of dates
  4003. DateEnv.prototype.startOf = function (m, unit) {
  4004. if (unit === 'year') {
  4005. return this.startOfYear(m);
  4006. }
  4007. if (unit === 'month') {
  4008. return this.startOfMonth(m);
  4009. }
  4010. if (unit === 'week') {
  4011. return this.startOfWeek(m);
  4012. }
  4013. if (unit === 'day') {
  4014. return startOfDay(m);
  4015. }
  4016. if (unit === 'hour') {
  4017. return startOfHour(m);
  4018. }
  4019. if (unit === 'minute') {
  4020. return startOfMinute(m);
  4021. }
  4022. if (unit === 'second') {
  4023. return startOfSecond(m);
  4024. }
  4025. return null;
  4026. };
  4027. DateEnv.prototype.startOfYear = function (m) {
  4028. return this.calendarSystem.arrayToMarker([
  4029. this.calendarSystem.getMarkerYear(m),
  4030. ]);
  4031. };
  4032. DateEnv.prototype.startOfMonth = function (m) {
  4033. return this.calendarSystem.arrayToMarker([
  4034. this.calendarSystem.getMarkerYear(m),
  4035. this.calendarSystem.getMarkerMonth(m),
  4036. ]);
  4037. };
  4038. DateEnv.prototype.startOfWeek = function (m) {
  4039. return this.calendarSystem.arrayToMarker([
  4040. this.calendarSystem.getMarkerYear(m),
  4041. this.calendarSystem.getMarkerMonth(m),
  4042. m.getUTCDate() - ((m.getUTCDay() - this.weekDow + 7) % 7),
  4043. ]);
  4044. };
  4045. // Week Number
  4046. DateEnv.prototype.computeWeekNumber = function (marker) {
  4047. if (this.weekNumberFunc) {
  4048. return this.weekNumberFunc(this.toDate(marker));
  4049. }
  4050. return weekOfYear(marker, this.weekDow, this.weekDoy);
  4051. };
  4052. // TODO: choke on timeZoneName: long
  4053. DateEnv.prototype.format = function (marker, formatter, dateOptions) {
  4054. if (dateOptions === void 0) { dateOptions = {}; }
  4055. return formatter.format({
  4056. marker: marker,
  4057. timeZoneOffset: dateOptions.forcedTzo != null ?
  4058. dateOptions.forcedTzo :
  4059. this.offsetForMarker(marker),
  4060. }, this);
  4061. };
  4062. DateEnv.prototype.formatRange = function (start, end, formatter, dateOptions) {
  4063. if (dateOptions === void 0) { dateOptions = {}; }
  4064. if (dateOptions.isEndExclusive) {
  4065. end = addMs(end, -1);
  4066. }
  4067. return formatter.formatRange({
  4068. marker: start,
  4069. timeZoneOffset: dateOptions.forcedStartTzo != null ?
  4070. dateOptions.forcedStartTzo :
  4071. this.offsetForMarker(start),
  4072. }, {
  4073. marker: end,
  4074. timeZoneOffset: dateOptions.forcedEndTzo != null ?
  4075. dateOptions.forcedEndTzo :
  4076. this.offsetForMarker(end),
  4077. }, this, dateOptions.defaultSeparator);
  4078. };
  4079. /*
  4080. DUMB: the omitTime arg is dumb. if we omit the time, we want to omit the timezone offset. and if we do that,
  4081. might as well use buildIsoString or some other util directly
  4082. */
  4083. DateEnv.prototype.formatIso = function (marker, extraOptions) {
  4084. if (extraOptions === void 0) { extraOptions = {}; }
  4085. var timeZoneOffset = null;
  4086. if (!extraOptions.omitTimeZoneOffset) {
  4087. if (extraOptions.forcedTzo != null) {
  4088. timeZoneOffset = extraOptions.forcedTzo;
  4089. }
  4090. else {
  4091. timeZoneOffset = this.offsetForMarker(marker);
  4092. }
  4093. }
  4094. return buildIsoString(marker, timeZoneOffset, extraOptions.omitTime);
  4095. };
  4096. // TimeZone
  4097. DateEnv.prototype.timestampToMarker = function (ms) {
  4098. if (this.timeZone === 'local') {
  4099. return arrayToUtcDate(dateToLocalArray(new Date(ms)));
  4100. }
  4101. if (this.timeZone === 'UTC' || !this.namedTimeZoneImpl) {
  4102. return new Date(ms);
  4103. }
  4104. return arrayToUtcDate(this.namedTimeZoneImpl.timestampToArray(ms));
  4105. };
  4106. DateEnv.prototype.offsetForMarker = function (m) {
  4107. if (this.timeZone === 'local') {
  4108. return -arrayToLocalDate(dateToUtcArray(m)).getTimezoneOffset(); // convert "inverse" offset to "normal" offset
  4109. }
  4110. if (this.timeZone === 'UTC') {
  4111. return 0;
  4112. }
  4113. if (this.namedTimeZoneImpl) {
  4114. return this.namedTimeZoneImpl.offsetForArray(dateToUtcArray(m));
  4115. }
  4116. return null;
  4117. };
  4118. // Conversion
  4119. DateEnv.prototype.toDate = function (m, forcedTzo) {
  4120. if (this.timeZone === 'local') {
  4121. return arrayToLocalDate(dateToUtcArray(m));
  4122. }
  4123. if (this.timeZone === 'UTC') {
  4124. return new Date(m.valueOf()); // make sure it's a copy
  4125. }
  4126. if (!this.namedTimeZoneImpl) {
  4127. return new Date(m.valueOf() - (forcedTzo || 0));
  4128. }
  4129. return new Date(m.valueOf() -
  4130. this.namedTimeZoneImpl.offsetForArray(dateToUtcArray(m)) * 1000 * 60);
  4131. };
  4132. return DateEnv;
  4133. }());
  4134. var globalLocales = [];
  4135. var MINIMAL_RAW_EN_LOCALE = {
  4136. code: 'en',
  4137. week: {
  4138. dow: 0,
  4139. doy: 4, // 4 days need to be within the year to be considered the first week
  4140. },
  4141. direction: 'ltr',
  4142. buttonText: {
  4143. prev: 'prev',
  4144. next: 'next',
  4145. prevYear: 'prev year',
  4146. nextYear: 'next year',
  4147. year: 'year',
  4148. today: 'today',
  4149. month: 'month',
  4150. week: 'week',
  4151. day: 'day',
  4152. list: 'list',
  4153. },
  4154. weekText: 'W',
  4155. weekTextLong: 'Week',
  4156. closeHint: 'Close',
  4157. timeHint: 'Time',
  4158. eventHint: 'Event',
  4159. allDayText: 'all-day',
  4160. moreLinkText: 'more',
  4161. noEventsText: 'No events to display',
  4162. };
  4163. var RAW_EN_LOCALE = __assign(__assign({}, MINIMAL_RAW_EN_LOCALE), {
  4164. // Includes things we don't want other locales to inherit,
  4165. // things that derive from other translatable strings.
  4166. buttonHints: {
  4167. prev: 'Previous $0',
  4168. next: 'Next $0',
  4169. today: function (buttonText, unit) {
  4170. return (unit === 'day')
  4171. ? 'Today'
  4172. : "This " + buttonText;
  4173. },
  4174. }, viewHint: '$0 view', navLinkHint: 'Go to $0', moreLinkHint: function (eventCnt) {
  4175. return "Show " + eventCnt + " more event" + (eventCnt === 1 ? '' : 's');
  4176. } });
  4177. function organizeRawLocales(explicitRawLocales) {
  4178. var defaultCode = explicitRawLocales.length > 0 ? explicitRawLocales[0].code : 'en';
  4179. var allRawLocales = globalLocales.concat(explicitRawLocales);
  4180. var rawLocaleMap = {
  4181. en: RAW_EN_LOCALE,
  4182. };
  4183. for (var _i = 0, allRawLocales_1 = allRawLocales; _i < allRawLocales_1.length; _i++) {
  4184. var rawLocale = allRawLocales_1[_i];
  4185. rawLocaleMap[rawLocale.code] = rawLocale;
  4186. }
  4187. return {
  4188. map: rawLocaleMap,
  4189. defaultCode: defaultCode,
  4190. };
  4191. }
  4192. function buildLocale(inputSingular, available) {
  4193. if (typeof inputSingular === 'object' && !Array.isArray(inputSingular)) {
  4194. return parseLocale(inputSingular.code, [inputSingular.code], inputSingular);
  4195. }
  4196. return queryLocale(inputSingular, available);
  4197. }
  4198. function queryLocale(codeArg, available) {
  4199. var codes = [].concat(codeArg || []); // will convert to array
  4200. var raw = queryRawLocale(codes, available) || RAW_EN_LOCALE;
  4201. return parseLocale(codeArg, codes, raw);
  4202. }
  4203. function queryRawLocale(codes, available) {
  4204. for (var i = 0; i < codes.length; i += 1) {
  4205. var parts = codes[i].toLocaleLowerCase().split('-');
  4206. for (var j = parts.length; j > 0; j -= 1) {
  4207. var simpleId = parts.slice(0, j).join('-');
  4208. if (available[simpleId]) {
  4209. return available[simpleId];
  4210. }
  4211. }
  4212. }
  4213. return null;
  4214. }
  4215. function parseLocale(codeArg, codes, raw) {
  4216. var merged = mergeProps([MINIMAL_RAW_EN_LOCALE, raw], ['buttonText']);
  4217. delete merged.code; // don't want this part of the options
  4218. var week = merged.week;
  4219. delete merged.week;
  4220. return {
  4221. codeArg: codeArg,
  4222. codes: codes,
  4223. week: week,
  4224. simpleNumberFormat: new Intl.NumberFormat(codeArg),
  4225. options: merged,
  4226. };
  4227. }
  4228. function formatDate(dateInput, options) {
  4229. if (options === void 0) { options = {}; }
  4230. var dateEnv = buildDateEnv$1(options);
  4231. var formatter = createFormatter(options);
  4232. var dateMeta = dateEnv.createMarkerMeta(dateInput);
  4233. if (!dateMeta) { // TODO: warning?
  4234. return '';
  4235. }
  4236. return dateEnv.format(dateMeta.marker, formatter, {
  4237. forcedTzo: dateMeta.forcedTzo,
  4238. });
  4239. }
  4240. function formatRange(startInput, endInput, options) {
  4241. var dateEnv = buildDateEnv$1(typeof options === 'object' && options ? options : {}); // pass in if non-null object
  4242. var formatter = createFormatter(options);
  4243. var startMeta = dateEnv.createMarkerMeta(startInput);
  4244. var endMeta = dateEnv.createMarkerMeta(endInput);
  4245. if (!startMeta || !endMeta) { // TODO: warning?
  4246. return '';
  4247. }
  4248. return dateEnv.formatRange(startMeta.marker, endMeta.marker, formatter, {
  4249. forcedStartTzo: startMeta.forcedTzo,
  4250. forcedEndTzo: endMeta.forcedTzo,
  4251. isEndExclusive: options.isEndExclusive,
  4252. defaultSeparator: BASE_OPTION_DEFAULTS.defaultRangeSeparator,
  4253. });
  4254. }
  4255. // TODO: more DRY and optimized
  4256. function buildDateEnv$1(settings) {
  4257. var locale = buildLocale(settings.locale || 'en', organizeRawLocales([]).map); // TODO: don't hardcode 'en' everywhere
  4258. return new DateEnv(__assign(__assign({ timeZone: BASE_OPTION_DEFAULTS.timeZone, calendarSystem: 'gregory' }, settings), { locale: locale }));
  4259. }
  4260. var DEF_DEFAULTS = {
  4261. startTime: '09:00',
  4262. endTime: '17:00',
  4263. daysOfWeek: [1, 2, 3, 4, 5],
  4264. display: 'inverse-background',
  4265. classNames: 'fc-non-business',
  4266. groupId: '_businessHours', // so multiple defs get grouped
  4267. };
  4268. /*
  4269. TODO: pass around as EventDefHash!!!
  4270. */
  4271. function parseBusinessHours(input, context) {
  4272. return parseEvents(refineInputs(input), null, context);
  4273. }
  4274. function refineInputs(input) {
  4275. var rawDefs;
  4276. if (input === true) {
  4277. rawDefs = [{}]; // will get DEF_DEFAULTS verbatim
  4278. }
  4279. else if (Array.isArray(input)) {
  4280. // if specifying an array, every sub-definition NEEDS a day-of-week
  4281. rawDefs = input.filter(function (rawDef) { return rawDef.daysOfWeek; });
  4282. }
  4283. else if (typeof input === 'object' && input) { // non-null object
  4284. rawDefs = [input];
  4285. }
  4286. else { // is probably false
  4287. rawDefs = [];
  4288. }
  4289. rawDefs = rawDefs.map(function (rawDef) { return (__assign(__assign({}, DEF_DEFAULTS), rawDef)); });
  4290. return rawDefs;
  4291. }
  4292. function pointInsideRect(point, rect) {
  4293. return point.left >= rect.left &&
  4294. point.left < rect.right &&
  4295. point.top >= rect.top &&
  4296. point.top < rect.bottom;
  4297. }
  4298. // Returns a new rectangle that is the intersection of the two rectangles. If they don't intersect, returns false
  4299. function intersectRects(rect1, rect2) {
  4300. var res = {
  4301. left: Math.max(rect1.left, rect2.left),
  4302. right: Math.min(rect1.right, rect2.right),
  4303. top: Math.max(rect1.top, rect2.top),
  4304. bottom: Math.min(rect1.bottom, rect2.bottom),
  4305. };
  4306. if (res.left < res.right && res.top < res.bottom) {
  4307. return res;
  4308. }
  4309. return false;
  4310. }
  4311. function translateRect(rect, deltaX, deltaY) {
  4312. return {
  4313. left: rect.left + deltaX,
  4314. right: rect.right + deltaX,
  4315. top: rect.top + deltaY,
  4316. bottom: rect.bottom + deltaY,
  4317. };
  4318. }
  4319. // Returns a new point that will have been moved to reside within the given rectangle
  4320. function constrainPoint(point, rect) {
  4321. return {
  4322. left: Math.min(Math.max(point.left, rect.left), rect.right),
  4323. top: Math.min(Math.max(point.top, rect.top), rect.bottom),
  4324. };
  4325. }
  4326. // Returns a point that is the center of the given rectangle
  4327. function getRectCenter(rect) {
  4328. return {
  4329. left: (rect.left + rect.right) / 2,
  4330. top: (rect.top + rect.bottom) / 2,
  4331. };
  4332. }
  4333. // Subtracts point2's coordinates from point1's coordinates, returning a delta
  4334. function diffPoints(point1, point2) {
  4335. return {
  4336. left: point1.left - point2.left,
  4337. top: point1.top - point2.top,
  4338. };
  4339. }
  4340. var canVGrowWithinCell;
  4341. function getCanVGrowWithinCell() {
  4342. if (canVGrowWithinCell == null) {
  4343. canVGrowWithinCell = computeCanVGrowWithinCell();
  4344. }
  4345. return canVGrowWithinCell;
  4346. }
  4347. function computeCanVGrowWithinCell() {
  4348. // for SSR, because this function is call immediately at top-level
  4349. // TODO: just make this logic execute top-level, immediately, instead of doing lazily
  4350. if (typeof document === 'undefined') {
  4351. return true;
  4352. }
  4353. var el = document.createElement('div');
  4354. el.style.position = 'absolute';
  4355. el.style.top = '0px';
  4356. el.style.left = '0px';
  4357. el.innerHTML = '<table><tr><td><div></div></td></tr></table>';
  4358. el.querySelector('table').style.height = '100px';
  4359. el.querySelector('div').style.height = '100%';
  4360. document.body.appendChild(el);
  4361. var div = el.querySelector('div');
  4362. var possible = div.offsetHeight > 0;
  4363. document.body.removeChild(el);
  4364. return possible;
  4365. }
  4366. var EMPTY_EVENT_STORE = createEmptyEventStore(); // for purecomponents. TODO: keep elsewhere
  4367. var Splitter = /** @class */ (function () {
  4368. function Splitter() {
  4369. this.getKeysForEventDefs = memoize(this._getKeysForEventDefs);
  4370. this.splitDateSelection = memoize(this._splitDateSpan);
  4371. this.splitEventStore = memoize(this._splitEventStore);
  4372. this.splitIndividualUi = memoize(this._splitIndividualUi);
  4373. this.splitEventDrag = memoize(this._splitInteraction);
  4374. this.splitEventResize = memoize(this._splitInteraction);
  4375. this.eventUiBuilders = {}; // TODO: typescript protection
  4376. }
  4377. Splitter.prototype.splitProps = function (props) {
  4378. var _this = this;
  4379. var keyInfos = this.getKeyInfo(props);
  4380. var defKeys = this.getKeysForEventDefs(props.eventStore);
  4381. var dateSelections = this.splitDateSelection(props.dateSelection);
  4382. var individualUi = this.splitIndividualUi(props.eventUiBases, defKeys); // the individual *bases*
  4383. var eventStores = this.splitEventStore(props.eventStore, defKeys);
  4384. var eventDrags = this.splitEventDrag(props.eventDrag);
  4385. var eventResizes = this.splitEventResize(props.eventResize);
  4386. var splitProps = {};
  4387. this.eventUiBuilders = mapHash(keyInfos, function (info, key) { return _this.eventUiBuilders[key] || memoize(buildEventUiForKey); });
  4388. for (var key in keyInfos) {
  4389. var keyInfo = keyInfos[key];
  4390. var eventStore = eventStores[key] || EMPTY_EVENT_STORE;
  4391. var buildEventUi = this.eventUiBuilders[key];
  4392. splitProps[key] = {
  4393. businessHours: keyInfo.businessHours || props.businessHours,
  4394. dateSelection: dateSelections[key] || null,
  4395. eventStore: eventStore,
  4396. eventUiBases: buildEventUi(props.eventUiBases[''], keyInfo.ui, individualUi[key]),
  4397. eventSelection: eventStore.instances[props.eventSelection] ? props.eventSelection : '',
  4398. eventDrag: eventDrags[key] || null,
  4399. eventResize: eventResizes[key] || null,
  4400. };
  4401. }
  4402. return splitProps;
  4403. };
  4404. Splitter.prototype._splitDateSpan = function (dateSpan) {
  4405. var dateSpans = {};
  4406. if (dateSpan) {
  4407. var keys = this.getKeysForDateSpan(dateSpan);
  4408. for (var _i = 0, keys_1 = keys; _i < keys_1.length; _i++) {
  4409. var key = keys_1[_i];
  4410. dateSpans[key] = dateSpan;
  4411. }
  4412. }
  4413. return dateSpans;
  4414. };
  4415. Splitter.prototype._getKeysForEventDefs = function (eventStore) {
  4416. var _this = this;
  4417. return mapHash(eventStore.defs, function (eventDef) { return _this.getKeysForEventDef(eventDef); });
  4418. };
  4419. Splitter.prototype._splitEventStore = function (eventStore, defKeys) {
  4420. var defs = eventStore.defs, instances = eventStore.instances;
  4421. var splitStores = {};
  4422. for (var defId in defs) {
  4423. for (var _i = 0, _a = defKeys[defId]; _i < _a.length; _i++) {
  4424. var key = _a[_i];
  4425. if (!splitStores[key]) {
  4426. splitStores[key] = createEmptyEventStore();
  4427. }
  4428. splitStores[key].defs[defId] = defs[defId];
  4429. }
  4430. }
  4431. for (var instanceId in instances) {
  4432. var instance = instances[instanceId];
  4433. for (var _b = 0, _c = defKeys[instance.defId]; _b < _c.length; _b++) {
  4434. var key = _c[_b];
  4435. if (splitStores[key]) { // must have already been created
  4436. splitStores[key].instances[instanceId] = instance;
  4437. }
  4438. }
  4439. }
  4440. return splitStores;
  4441. };
  4442. Splitter.prototype._splitIndividualUi = function (eventUiBases, defKeys) {
  4443. var splitHashes = {};
  4444. for (var defId in eventUiBases) {
  4445. if (defId) { // not the '' key
  4446. for (var _i = 0, _a = defKeys[defId]; _i < _a.length; _i++) {
  4447. var key = _a[_i];
  4448. if (!splitHashes[key]) {
  4449. splitHashes[key] = {};
  4450. }
  4451. splitHashes[key][defId] = eventUiBases[defId];
  4452. }
  4453. }
  4454. }
  4455. return splitHashes;
  4456. };
  4457. Splitter.prototype._splitInteraction = function (interaction) {
  4458. var splitStates = {};
  4459. if (interaction) {
  4460. var affectedStores_1 = this._splitEventStore(interaction.affectedEvents, this._getKeysForEventDefs(interaction.affectedEvents));
  4461. // can't rely on defKeys because event data is mutated
  4462. var mutatedKeysByDefId = this._getKeysForEventDefs(interaction.mutatedEvents);
  4463. var mutatedStores_1 = this._splitEventStore(interaction.mutatedEvents, mutatedKeysByDefId);
  4464. var populate = function (key) {
  4465. if (!splitStates[key]) {
  4466. splitStates[key] = {
  4467. affectedEvents: affectedStores_1[key] || EMPTY_EVENT_STORE,
  4468. mutatedEvents: mutatedStores_1[key] || EMPTY_EVENT_STORE,
  4469. isEvent: interaction.isEvent,
  4470. };
  4471. }
  4472. };
  4473. for (var key in affectedStores_1) {
  4474. populate(key);
  4475. }
  4476. for (var key in mutatedStores_1) {
  4477. populate(key);
  4478. }
  4479. }
  4480. return splitStates;
  4481. };
  4482. return Splitter;
  4483. }());
  4484. function buildEventUiForKey(allUi, eventUiForKey, individualUi) {
  4485. var baseParts = [];
  4486. if (allUi) {
  4487. baseParts.push(allUi);
  4488. }
  4489. if (eventUiForKey) {
  4490. baseParts.push(eventUiForKey);
  4491. }
  4492. var stuff = {
  4493. '': combineEventUis(baseParts),
  4494. };
  4495. if (individualUi) {
  4496. __assign(stuff, individualUi);
  4497. }
  4498. return stuff;
  4499. }
  4500. function getDateMeta(date, todayRange, nowDate, dateProfile) {
  4501. return {
  4502. dow: date.getUTCDay(),
  4503. isDisabled: Boolean(dateProfile && !rangeContainsMarker(dateProfile.activeRange, date)),
  4504. isOther: Boolean(dateProfile && !rangeContainsMarker(dateProfile.currentRange, date)),
  4505. isToday: Boolean(todayRange && rangeContainsMarker(todayRange, date)),
  4506. isPast: Boolean(nowDate ? (date < nowDate) : todayRange ? (date < todayRange.start) : false),
  4507. isFuture: Boolean(nowDate ? (date > nowDate) : todayRange ? (date >= todayRange.end) : false),
  4508. };
  4509. }
  4510. function getDayClassNames(meta, theme) {
  4511. var classNames = [
  4512. 'fc-day',
  4513. "fc-day-" + DAY_IDS[meta.dow],
  4514. ];
  4515. if (meta.isDisabled) {
  4516. classNames.push('fc-day-disabled');
  4517. }
  4518. else {
  4519. if (meta.isToday) {
  4520. classNames.push('fc-day-today');
  4521. classNames.push(theme.getClass('today'));
  4522. }
  4523. if (meta.isPast) {
  4524. classNames.push('fc-day-past');
  4525. }
  4526. if (meta.isFuture) {
  4527. classNames.push('fc-day-future');
  4528. }
  4529. if (meta.isOther) {
  4530. classNames.push('fc-day-other');
  4531. }
  4532. }
  4533. return classNames;
  4534. }
  4535. function getSlotClassNames(meta, theme) {
  4536. var classNames = [
  4537. 'fc-slot',
  4538. "fc-slot-" + DAY_IDS[meta.dow],
  4539. ];
  4540. if (meta.isDisabled) {
  4541. classNames.push('fc-slot-disabled');
  4542. }
  4543. else {
  4544. if (meta.isToday) {
  4545. classNames.push('fc-slot-today');
  4546. classNames.push(theme.getClass('today'));
  4547. }
  4548. if (meta.isPast) {
  4549. classNames.push('fc-slot-past');
  4550. }
  4551. if (meta.isFuture) {
  4552. classNames.push('fc-slot-future');
  4553. }
  4554. }
  4555. return classNames;
  4556. }
  4557. var DAY_FORMAT = createFormatter({ year: 'numeric', month: 'long', day: 'numeric' });
  4558. var WEEK_FORMAT = createFormatter({ week: 'long' });
  4559. function buildNavLinkAttrs(context, dateMarker, viewType, isTabbable) {
  4560. if (viewType === void 0) { viewType = 'day'; }
  4561. if (isTabbable === void 0) { isTabbable = true; }
  4562. var dateEnv = context.dateEnv, options = context.options, calendarApi = context.calendarApi;
  4563. var dateStr = dateEnv.format(dateMarker, viewType === 'week' ? WEEK_FORMAT : DAY_FORMAT);
  4564. if (options.navLinks) {
  4565. var zonedDate = dateEnv.toDate(dateMarker);
  4566. var handleInteraction = function (ev) {
  4567. var customAction = viewType === 'day' ? options.navLinkDayClick :
  4568. viewType === 'week' ? options.navLinkWeekClick : null;
  4569. if (typeof customAction === 'function') {
  4570. customAction.call(calendarApi, dateEnv.toDate(dateMarker), ev);
  4571. }
  4572. else {
  4573. if (typeof customAction === 'string') {
  4574. viewType = customAction;
  4575. }
  4576. calendarApi.zoomTo(dateMarker, viewType);
  4577. }
  4578. };
  4579. return __assign({ title: formatWithOrdinals(options.navLinkHint, [dateStr, zonedDate], dateStr), 'data-navlink': '' }, (isTabbable
  4580. ? createAriaClickAttrs(handleInteraction)
  4581. : { onClick: handleInteraction }));
  4582. }
  4583. return { 'aria-label': dateStr };
  4584. }
  4585. var _isRtlScrollbarOnLeft = null;
  4586. function getIsRtlScrollbarOnLeft() {
  4587. if (_isRtlScrollbarOnLeft === null) {
  4588. _isRtlScrollbarOnLeft = computeIsRtlScrollbarOnLeft();
  4589. }
  4590. return _isRtlScrollbarOnLeft;
  4591. }
  4592. function computeIsRtlScrollbarOnLeft() {
  4593. var outerEl = document.createElement('div');
  4594. applyStyle(outerEl, {
  4595. position: 'absolute',
  4596. top: -1000,
  4597. left: 0,
  4598. border: 0,
  4599. padding: 0,
  4600. overflow: 'scroll',
  4601. direction: 'rtl',
  4602. });
  4603. outerEl.innerHTML = '<div></div>';
  4604. document.body.appendChild(outerEl);
  4605. var innerEl = outerEl.firstChild;
  4606. var res = innerEl.getBoundingClientRect().left > outerEl.getBoundingClientRect().left;
  4607. removeElement(outerEl);
  4608. return res;
  4609. }
  4610. var _scrollbarWidths;
  4611. function getScrollbarWidths() {
  4612. if (!_scrollbarWidths) {
  4613. _scrollbarWidths = computeScrollbarWidths();
  4614. }
  4615. return _scrollbarWidths;
  4616. }
  4617. function computeScrollbarWidths() {
  4618. var el = document.createElement('div');
  4619. el.style.overflow = 'scroll';
  4620. el.style.position = 'absolute';
  4621. el.style.top = '-9999px';
  4622. el.style.left = '-9999px';
  4623. document.body.appendChild(el);
  4624. var res = computeScrollbarWidthsForEl(el);
  4625. document.body.removeChild(el);
  4626. return res;
  4627. }
  4628. // WARNING: will include border
  4629. function computeScrollbarWidthsForEl(el) {
  4630. return {
  4631. x: el.offsetHeight - el.clientHeight,
  4632. y: el.offsetWidth - el.clientWidth,
  4633. };
  4634. }
  4635. function computeEdges(el, getPadding) {
  4636. if (getPadding === void 0) { getPadding = false; }
  4637. var computedStyle = window.getComputedStyle(el);
  4638. var borderLeft = parseInt(computedStyle.borderLeftWidth, 10) || 0;
  4639. var borderRight = parseInt(computedStyle.borderRightWidth, 10) || 0;
  4640. var borderTop = parseInt(computedStyle.borderTopWidth, 10) || 0;
  4641. var borderBottom = parseInt(computedStyle.borderBottomWidth, 10) || 0;
  4642. var badScrollbarWidths = computeScrollbarWidthsForEl(el); // includes border!
  4643. var scrollbarLeftRight = badScrollbarWidths.y - borderLeft - borderRight;
  4644. var scrollbarBottom = badScrollbarWidths.x - borderTop - borderBottom;
  4645. var res = {
  4646. borderLeft: borderLeft,
  4647. borderRight: borderRight,
  4648. borderTop: borderTop,
  4649. borderBottom: borderBottom,
  4650. scrollbarBottom: scrollbarBottom,
  4651. scrollbarLeft: 0,
  4652. scrollbarRight: 0,
  4653. };
  4654. if (getIsRtlScrollbarOnLeft() && computedStyle.direction === 'rtl') { // is the scrollbar on the left side?
  4655. res.scrollbarLeft = scrollbarLeftRight;
  4656. }
  4657. else {
  4658. res.scrollbarRight = scrollbarLeftRight;
  4659. }
  4660. if (getPadding) {
  4661. res.paddingLeft = parseInt(computedStyle.paddingLeft, 10) || 0;
  4662. res.paddingRight = parseInt(computedStyle.paddingRight, 10) || 0;
  4663. res.paddingTop = parseInt(computedStyle.paddingTop, 10) || 0;
  4664. res.paddingBottom = parseInt(computedStyle.paddingBottom, 10) || 0;
  4665. }
  4666. return res;
  4667. }
  4668. function computeInnerRect(el, goWithinPadding, doFromWindowViewport) {
  4669. if (goWithinPadding === void 0) { goWithinPadding = false; }
  4670. var outerRect = doFromWindowViewport ? el.getBoundingClientRect() : computeRect(el);
  4671. var edges = computeEdges(el, goWithinPadding);
  4672. var res = {
  4673. left: outerRect.left + edges.borderLeft + edges.scrollbarLeft,
  4674. right: outerRect.right - edges.borderRight - edges.scrollbarRight,
  4675. top: outerRect.top + edges.borderTop,
  4676. bottom: outerRect.bottom - edges.borderBottom - edges.scrollbarBottom,
  4677. };
  4678. if (goWithinPadding) {
  4679. res.left += edges.paddingLeft;
  4680. res.right -= edges.paddingRight;
  4681. res.top += edges.paddingTop;
  4682. res.bottom -= edges.paddingBottom;
  4683. }
  4684. return res;
  4685. }
  4686. function computeRect(el) {
  4687. var rect = el.getBoundingClientRect();
  4688. return {
  4689. left: rect.left + window.pageXOffset,
  4690. top: rect.top + window.pageYOffset,
  4691. right: rect.right + window.pageXOffset,
  4692. bottom: rect.bottom + window.pageYOffset,
  4693. };
  4694. }
  4695. function computeClippedClientRect(el) {
  4696. var clippingParents = getClippingParents(el);
  4697. var rect = el.getBoundingClientRect();
  4698. for (var _i = 0, clippingParents_1 = clippingParents; _i < clippingParents_1.length; _i++) {
  4699. var clippingParent = clippingParents_1[_i];
  4700. var intersection = intersectRects(rect, clippingParent.getBoundingClientRect());
  4701. if (intersection) {
  4702. rect = intersection;
  4703. }
  4704. else {
  4705. return null;
  4706. }
  4707. }
  4708. return rect;
  4709. }
  4710. function computeHeightAndMargins(el) {
  4711. return el.getBoundingClientRect().height + computeVMargins(el);
  4712. }
  4713. function computeVMargins(el) {
  4714. var computed = window.getComputedStyle(el);
  4715. return parseInt(computed.marginTop, 10) +
  4716. parseInt(computed.marginBottom, 10);
  4717. }
  4718. // does not return window
  4719. function getClippingParents(el) {
  4720. var parents = [];
  4721. while (el instanceof HTMLElement) { // will stop when gets to document or null
  4722. var computedStyle = window.getComputedStyle(el);
  4723. if (computedStyle.position === 'fixed') {
  4724. break;
  4725. }
  4726. if ((/(auto|scroll)/).test(computedStyle.overflow + computedStyle.overflowY + computedStyle.overflowX)) {
  4727. parents.push(el);
  4728. }
  4729. el = el.parentNode;
  4730. }
  4731. return parents;
  4732. }
  4733. // given a function that resolves a result asynchronously.
  4734. // the function can either call passed-in success and failure callbacks,
  4735. // or it can return a promise.
  4736. // if you need to pass additional params to func, bind them first.
  4737. function unpromisify(func, success, failure) {
  4738. // guard against success/failure callbacks being called more than once
  4739. // and guard against a promise AND callback being used together.
  4740. var isResolved = false;
  4741. var wrappedSuccess = function () {
  4742. if (!isResolved) {
  4743. isResolved = true;
  4744. success.apply(this, arguments); // eslint-disable-line prefer-rest-params
  4745. }
  4746. };
  4747. var wrappedFailure = function () {
  4748. if (!isResolved) {
  4749. isResolved = true;
  4750. if (failure) {
  4751. failure.apply(this, arguments); // eslint-disable-line prefer-rest-params
  4752. }
  4753. }
  4754. };
  4755. var res = func(wrappedSuccess, wrappedFailure);
  4756. if (res && typeof res.then === 'function') {
  4757. res.then(wrappedSuccess, wrappedFailure);
  4758. }
  4759. }
  4760. var Emitter = /** @class */ (function () {
  4761. function Emitter() {
  4762. this.handlers = {};
  4763. this.thisContext = null;
  4764. }
  4765. Emitter.prototype.setThisContext = function (thisContext) {
  4766. this.thisContext = thisContext;
  4767. };
  4768. Emitter.prototype.setOptions = function (options) {
  4769. this.options = options;
  4770. };
  4771. Emitter.prototype.on = function (type, handler) {
  4772. addToHash(this.handlers, type, handler);
  4773. };
  4774. Emitter.prototype.off = function (type, handler) {
  4775. removeFromHash(this.handlers, type, handler);
  4776. };
  4777. Emitter.prototype.trigger = function (type) {
  4778. var args = [];
  4779. for (var _i = 1; _i < arguments.length; _i++) {
  4780. args[_i - 1] = arguments[_i];
  4781. }
  4782. var attachedHandlers = this.handlers[type] || [];
  4783. var optionHandler = this.options && this.options[type];
  4784. var handlers = [].concat(optionHandler || [], attachedHandlers);
  4785. for (var _a = 0, handlers_1 = handlers; _a < handlers_1.length; _a++) {
  4786. var handler = handlers_1[_a];
  4787. handler.apply(this.thisContext, args);
  4788. }
  4789. };
  4790. Emitter.prototype.hasHandlers = function (type) {
  4791. return Boolean((this.handlers[type] && this.handlers[type].length) ||
  4792. (this.options && this.options[type]));
  4793. };
  4794. return Emitter;
  4795. }());
  4796. function addToHash(hash, type, handler) {
  4797. (hash[type] || (hash[type] = []))
  4798. .push(handler);
  4799. }
  4800. function removeFromHash(hash, type, handler) {
  4801. if (handler) {
  4802. if (hash[type]) {
  4803. hash[type] = hash[type].filter(function (func) { return func !== handler; });
  4804. }
  4805. }
  4806. else {
  4807. delete hash[type]; // remove all handler funcs for this type
  4808. }
  4809. }
  4810. /*
  4811. Records offset information for a set of elements, relative to an origin element.
  4812. Can record the left/right OR the top/bottom OR both.
  4813. Provides methods for querying the cache by position.
  4814. */
  4815. var PositionCache = /** @class */ (function () {
  4816. function PositionCache(originEl, els, isHorizontal, isVertical) {
  4817. this.els = els;
  4818. var originClientRect = this.originClientRect = originEl.getBoundingClientRect(); // relative to viewport top-left
  4819. if (isHorizontal) {
  4820. this.buildElHorizontals(originClientRect.left);
  4821. }
  4822. if (isVertical) {
  4823. this.buildElVerticals(originClientRect.top);
  4824. }
  4825. }
  4826. // Populates the left/right internal coordinate arrays
  4827. PositionCache.prototype.buildElHorizontals = function (originClientLeft) {
  4828. var lefts = [];
  4829. var rights = [];
  4830. for (var _i = 0, _a = this.els; _i < _a.length; _i++) {
  4831. var el = _a[_i];
  4832. var rect = el.getBoundingClientRect();
  4833. lefts.push(rect.left - originClientLeft);
  4834. rights.push(rect.right - originClientLeft);
  4835. }
  4836. this.lefts = lefts;
  4837. this.rights = rights;
  4838. };
  4839. // Populates the top/bottom internal coordinate arrays
  4840. PositionCache.prototype.buildElVerticals = function (originClientTop) {
  4841. var tops = [];
  4842. var bottoms = [];
  4843. for (var _i = 0, _a = this.els; _i < _a.length; _i++) {
  4844. var el = _a[_i];
  4845. var rect = el.getBoundingClientRect();
  4846. tops.push(rect.top - originClientTop);
  4847. bottoms.push(rect.bottom - originClientTop);
  4848. }
  4849. this.tops = tops;
  4850. this.bottoms = bottoms;
  4851. };
  4852. // Given a left offset (from document left), returns the index of the el that it horizontally intersects.
  4853. // If no intersection is made, returns undefined.
  4854. PositionCache.prototype.leftToIndex = function (leftPosition) {
  4855. var _a = this, lefts = _a.lefts, rights = _a.rights;
  4856. var len = lefts.length;
  4857. var i;
  4858. for (i = 0; i < len; i += 1) {
  4859. if (leftPosition >= lefts[i] && leftPosition < rights[i]) {
  4860. return i;
  4861. }
  4862. }
  4863. return undefined; // TODO: better
  4864. };
  4865. // Given a top offset (from document top), returns the index of the el that it vertically intersects.
  4866. // If no intersection is made, returns undefined.
  4867. PositionCache.prototype.topToIndex = function (topPosition) {
  4868. var _a = this, tops = _a.tops, bottoms = _a.bottoms;
  4869. var len = tops.length;
  4870. var i;
  4871. for (i = 0; i < len; i += 1) {
  4872. if (topPosition >= tops[i] && topPosition < bottoms[i]) {
  4873. return i;
  4874. }
  4875. }
  4876. return undefined; // TODO: better
  4877. };
  4878. // Gets the width of the element at the given index
  4879. PositionCache.prototype.getWidth = function (leftIndex) {
  4880. return this.rights[leftIndex] - this.lefts[leftIndex];
  4881. };
  4882. // Gets the height of the element at the given index
  4883. PositionCache.prototype.getHeight = function (topIndex) {
  4884. return this.bottoms[topIndex] - this.tops[topIndex];
  4885. };
  4886. return PositionCache;
  4887. }());
  4888. /* eslint max-classes-per-file: "off" */
  4889. /*
  4890. An object for getting/setting scroll-related information for an element.
  4891. Internally, this is done very differently for window versus DOM element,
  4892. so this object serves as a common interface.
  4893. */
  4894. var ScrollController = /** @class */ (function () {
  4895. function ScrollController() {
  4896. }
  4897. ScrollController.prototype.getMaxScrollTop = function () {
  4898. return this.getScrollHeight() - this.getClientHeight();
  4899. };
  4900. ScrollController.prototype.getMaxScrollLeft = function () {
  4901. return this.getScrollWidth() - this.getClientWidth();
  4902. };
  4903. ScrollController.prototype.canScrollVertically = function () {
  4904. return this.getMaxScrollTop() > 0;
  4905. };
  4906. ScrollController.prototype.canScrollHorizontally = function () {
  4907. return this.getMaxScrollLeft() > 0;
  4908. };
  4909. ScrollController.prototype.canScrollUp = function () {
  4910. return this.getScrollTop() > 0;
  4911. };
  4912. ScrollController.prototype.canScrollDown = function () {
  4913. return this.getScrollTop() < this.getMaxScrollTop();
  4914. };
  4915. ScrollController.prototype.canScrollLeft = function () {
  4916. return this.getScrollLeft() > 0;
  4917. };
  4918. ScrollController.prototype.canScrollRight = function () {
  4919. return this.getScrollLeft() < this.getMaxScrollLeft();
  4920. };
  4921. return ScrollController;
  4922. }());
  4923. var ElementScrollController = /** @class */ (function (_super) {
  4924. __extends(ElementScrollController, _super);
  4925. function ElementScrollController(el) {
  4926. var _this = _super.call(this) || this;
  4927. _this.el = el;
  4928. return _this;
  4929. }
  4930. ElementScrollController.prototype.getScrollTop = function () {
  4931. return this.el.scrollTop;
  4932. };
  4933. ElementScrollController.prototype.getScrollLeft = function () {
  4934. return this.el.scrollLeft;
  4935. };
  4936. ElementScrollController.prototype.setScrollTop = function (top) {
  4937. this.el.scrollTop = top;
  4938. };
  4939. ElementScrollController.prototype.setScrollLeft = function (left) {
  4940. this.el.scrollLeft = left;
  4941. };
  4942. ElementScrollController.prototype.getScrollWidth = function () {
  4943. return this.el.scrollWidth;
  4944. };
  4945. ElementScrollController.prototype.getScrollHeight = function () {
  4946. return this.el.scrollHeight;
  4947. };
  4948. ElementScrollController.prototype.getClientHeight = function () {
  4949. return this.el.clientHeight;
  4950. };
  4951. ElementScrollController.prototype.getClientWidth = function () {
  4952. return this.el.clientWidth;
  4953. };
  4954. return ElementScrollController;
  4955. }(ScrollController));
  4956. var WindowScrollController = /** @class */ (function (_super) {
  4957. __extends(WindowScrollController, _super);
  4958. function WindowScrollController() {
  4959. return _super !== null && _super.apply(this, arguments) || this;
  4960. }
  4961. WindowScrollController.prototype.getScrollTop = function () {
  4962. return window.pageYOffset;
  4963. };
  4964. WindowScrollController.prototype.getScrollLeft = function () {
  4965. return window.pageXOffset;
  4966. };
  4967. WindowScrollController.prototype.setScrollTop = function (n) {
  4968. window.scroll(window.pageXOffset, n);
  4969. };
  4970. WindowScrollController.prototype.setScrollLeft = function (n) {
  4971. window.scroll(n, window.pageYOffset);
  4972. };
  4973. WindowScrollController.prototype.getScrollWidth = function () {
  4974. return document.documentElement.scrollWidth;
  4975. };
  4976. WindowScrollController.prototype.getScrollHeight = function () {
  4977. return document.documentElement.scrollHeight;
  4978. };
  4979. WindowScrollController.prototype.getClientHeight = function () {
  4980. return document.documentElement.clientHeight;
  4981. };
  4982. WindowScrollController.prototype.getClientWidth = function () {
  4983. return document.documentElement.clientWidth;
  4984. };
  4985. return WindowScrollController;
  4986. }(ScrollController));
  4987. var Theme = /** @class */ (function () {
  4988. function Theme(calendarOptions) {
  4989. if (this.iconOverrideOption) {
  4990. this.setIconOverride(calendarOptions[this.iconOverrideOption]);
  4991. }
  4992. }
  4993. Theme.prototype.setIconOverride = function (iconOverrideHash) {
  4994. var iconClassesCopy;
  4995. var buttonName;
  4996. if (typeof iconOverrideHash === 'object' && iconOverrideHash) { // non-null object
  4997. iconClassesCopy = __assign({}, this.iconClasses);
  4998. for (buttonName in iconOverrideHash) {
  4999. iconClassesCopy[buttonName] = this.applyIconOverridePrefix(iconOverrideHash[buttonName]);
  5000. }
  5001. this.iconClasses = iconClassesCopy;
  5002. }
  5003. else if (iconOverrideHash === false) {
  5004. this.iconClasses = {};
  5005. }
  5006. };
  5007. Theme.prototype.applyIconOverridePrefix = function (className) {
  5008. var prefix = this.iconOverridePrefix;
  5009. if (prefix && className.indexOf(prefix) !== 0) { // if not already present
  5010. className = prefix + className;
  5011. }
  5012. return className;
  5013. };
  5014. Theme.prototype.getClass = function (key) {
  5015. return this.classes[key] || '';
  5016. };
  5017. Theme.prototype.getIconClass = function (buttonName, isRtl) {
  5018. var className;
  5019. if (isRtl && this.rtlIconClasses) {
  5020. className = this.rtlIconClasses[buttonName] || this.iconClasses[buttonName];
  5021. }
  5022. else {
  5023. className = this.iconClasses[buttonName];
  5024. }
  5025. if (className) {
  5026. return this.baseIconClass + " " + className;
  5027. }
  5028. return '';
  5029. };
  5030. Theme.prototype.getCustomButtonIconClass = function (customButtonProps) {
  5031. var className;
  5032. if (this.iconOverrideCustomButtonOption) {
  5033. className = customButtonProps[this.iconOverrideCustomButtonOption];
  5034. if (className) {
  5035. return this.baseIconClass + " " + this.applyIconOverridePrefix(className);
  5036. }
  5037. }
  5038. return '';
  5039. };
  5040. return Theme;
  5041. }());
  5042. Theme.prototype.classes = {};
  5043. Theme.prototype.iconClasses = {};
  5044. Theme.prototype.baseIconClass = '';
  5045. Theme.prototype.iconOverridePrefix = '';
  5046. /// <reference types="@fullcalendar/core-preact" />
  5047. if (typeof FullCalendarVDom === 'undefined') {
  5048. throw new Error('Please import the top-level fullcalendar lib before attempting to import a plugin.');
  5049. }
  5050. var Component = FullCalendarVDom.Component;
  5051. var createElement = FullCalendarVDom.createElement;
  5052. var render = FullCalendarVDom.render;
  5053. var createRef = FullCalendarVDom.createRef;
  5054. var Fragment = FullCalendarVDom.Fragment;
  5055. var createContext = FullCalendarVDom.createContext;
  5056. var createPortal = FullCalendarVDom.createPortal;
  5057. var flushSync = FullCalendarVDom.flushSync;
  5058. var unmountComponentAtNode = FullCalendarVDom.unmountComponentAtNode;
  5059. /* eslint-enable */
  5060. var ScrollResponder = /** @class */ (function () {
  5061. function ScrollResponder(execFunc, emitter, scrollTime, scrollTimeReset) {
  5062. var _this = this;
  5063. this.execFunc = execFunc;
  5064. this.emitter = emitter;
  5065. this.scrollTime = scrollTime;
  5066. this.scrollTimeReset = scrollTimeReset;
  5067. this.handleScrollRequest = function (request) {
  5068. _this.queuedRequest = __assign({}, _this.queuedRequest || {}, request);
  5069. _this.drain();
  5070. };
  5071. emitter.on('_scrollRequest', this.handleScrollRequest);
  5072. this.fireInitialScroll();
  5073. }
  5074. ScrollResponder.prototype.detach = function () {
  5075. this.emitter.off('_scrollRequest', this.handleScrollRequest);
  5076. };
  5077. ScrollResponder.prototype.update = function (isDatesNew) {
  5078. if (isDatesNew && this.scrollTimeReset) {
  5079. this.fireInitialScroll(); // will drain
  5080. }
  5081. else {
  5082. this.drain();
  5083. }
  5084. };
  5085. ScrollResponder.prototype.fireInitialScroll = function () {
  5086. this.handleScrollRequest({
  5087. time: this.scrollTime,
  5088. });
  5089. };
  5090. ScrollResponder.prototype.drain = function () {
  5091. if (this.queuedRequest && this.execFunc(this.queuedRequest)) {
  5092. this.queuedRequest = null;
  5093. }
  5094. };
  5095. return ScrollResponder;
  5096. }());
  5097. var ViewContextType = createContext({}); // for Components
  5098. function buildViewContext(viewSpec, viewApi, viewOptions, dateProfileGenerator, dateEnv, theme, pluginHooks, dispatch, getCurrentData, emitter, calendarApi, registerInteractiveComponent, unregisterInteractiveComponent) {
  5099. return {
  5100. dateEnv: dateEnv,
  5101. options: viewOptions,
  5102. pluginHooks: pluginHooks,
  5103. emitter: emitter,
  5104. dispatch: dispatch,
  5105. getCurrentData: getCurrentData,
  5106. calendarApi: calendarApi,
  5107. viewSpec: viewSpec,
  5108. viewApi: viewApi,
  5109. dateProfileGenerator: dateProfileGenerator,
  5110. theme: theme,
  5111. isRtl: viewOptions.direction === 'rtl',
  5112. addResizeHandler: function (handler) {
  5113. emitter.on('_resize', handler);
  5114. },
  5115. removeResizeHandler: function (handler) {
  5116. emitter.off('_resize', handler);
  5117. },
  5118. createScrollResponder: function (execFunc) {
  5119. return new ScrollResponder(execFunc, emitter, createDuration(viewOptions.scrollTime), viewOptions.scrollTimeReset);
  5120. },
  5121. registerInteractiveComponent: registerInteractiveComponent,
  5122. unregisterInteractiveComponent: unregisterInteractiveComponent,
  5123. };
  5124. }
  5125. /* eslint max-classes-per-file: off */
  5126. var PureComponent = /** @class */ (function (_super) {
  5127. __extends(PureComponent, _super);
  5128. function PureComponent() {
  5129. return _super !== null && _super.apply(this, arguments) || this;
  5130. }
  5131. PureComponent.prototype.shouldComponentUpdate = function (nextProps, nextState) {
  5132. if (this.debug) {
  5133. // eslint-disable-next-line no-console
  5134. console.log(getUnequalProps(nextProps, this.props), getUnequalProps(nextState, this.state));
  5135. }
  5136. return !compareObjs(this.props, nextProps, this.propEquality) ||
  5137. !compareObjs(this.state, nextState, this.stateEquality);
  5138. };
  5139. // HACK for freakin' React StrictMode
  5140. PureComponent.prototype.safeSetState = function (newState) {
  5141. if (!compareObjs(this.state, __assign(__assign({}, this.state), newState), this.stateEquality)) {
  5142. this.setState(newState);
  5143. }
  5144. };
  5145. PureComponent.addPropsEquality = addPropsEquality;
  5146. PureComponent.addStateEquality = addStateEquality;
  5147. PureComponent.contextType = ViewContextType;
  5148. return PureComponent;
  5149. }(Component));
  5150. PureComponent.prototype.propEquality = {};
  5151. PureComponent.prototype.stateEquality = {};
  5152. var BaseComponent = /** @class */ (function (_super) {
  5153. __extends(BaseComponent, _super);
  5154. function BaseComponent() {
  5155. return _super !== null && _super.apply(this, arguments) || this;
  5156. }
  5157. BaseComponent.contextType = ViewContextType;
  5158. return BaseComponent;
  5159. }(PureComponent));
  5160. function addPropsEquality(propEquality) {
  5161. var hash = Object.create(this.prototype.propEquality);
  5162. __assign(hash, propEquality);
  5163. this.prototype.propEquality = hash;
  5164. }
  5165. function addStateEquality(stateEquality) {
  5166. var hash = Object.create(this.prototype.stateEquality);
  5167. __assign(hash, stateEquality);
  5168. this.prototype.stateEquality = hash;
  5169. }
  5170. // use other one
  5171. function setRef(ref, current) {
  5172. if (typeof ref === 'function') {
  5173. ref(current);
  5174. }
  5175. else if (ref) {
  5176. // see https://github.com/facebook/react/issues/13029
  5177. ref.current = current;
  5178. }
  5179. }
  5180. /*
  5181. an INTERACTABLE date component
  5182. PURPOSES:
  5183. - hook up to fg, fill, and mirror renderers
  5184. - interface for dragging and hits
  5185. */
  5186. var DateComponent = /** @class */ (function (_super) {
  5187. __extends(DateComponent, _super);
  5188. function DateComponent() {
  5189. var _this = _super !== null && _super.apply(this, arguments) || this;
  5190. _this.uid = guid();
  5191. return _this;
  5192. }
  5193. // Hit System
  5194. // -----------------------------------------------------------------------------------------------------------------
  5195. DateComponent.prototype.prepareHits = function () {
  5196. };
  5197. DateComponent.prototype.queryHit = function (positionLeft, positionTop, elWidth, elHeight) {
  5198. return null; // this should be abstract
  5199. };
  5200. // Pointer Interaction Utils
  5201. // -----------------------------------------------------------------------------------------------------------------
  5202. DateComponent.prototype.isValidSegDownEl = function (el) {
  5203. return !this.props.eventDrag && // HACK
  5204. !this.props.eventResize && // HACK
  5205. !elementClosest(el, '.fc-event-mirror');
  5206. };
  5207. DateComponent.prototype.isValidDateDownEl = function (el) {
  5208. return !elementClosest(el, '.fc-event:not(.fc-bg-event)') &&
  5209. !elementClosest(el, '.fc-more-link') && // a "more.." link
  5210. !elementClosest(el, 'a[data-navlink]') && // a clickable nav link
  5211. !elementClosest(el, '.fc-popover'); // hack
  5212. };
  5213. return DateComponent;
  5214. }(BaseComponent));
  5215. // TODO: easier way to add new hooks? need to update a million things
  5216. function createPlugin(input) {
  5217. return {
  5218. id: guid(),
  5219. deps: input.deps || [],
  5220. reducers: input.reducers || [],
  5221. isLoadingFuncs: input.isLoadingFuncs || [],
  5222. contextInit: [].concat(input.contextInit || []),
  5223. eventRefiners: input.eventRefiners || {},
  5224. eventDefMemberAdders: input.eventDefMemberAdders || [],
  5225. eventSourceRefiners: input.eventSourceRefiners || {},
  5226. isDraggableTransformers: input.isDraggableTransformers || [],
  5227. eventDragMutationMassagers: input.eventDragMutationMassagers || [],
  5228. eventDefMutationAppliers: input.eventDefMutationAppliers || [],
  5229. dateSelectionTransformers: input.dateSelectionTransformers || [],
  5230. datePointTransforms: input.datePointTransforms || [],
  5231. dateSpanTransforms: input.dateSpanTransforms || [],
  5232. views: input.views || {},
  5233. viewPropsTransformers: input.viewPropsTransformers || [],
  5234. isPropsValid: input.isPropsValid || null,
  5235. externalDefTransforms: input.externalDefTransforms || [],
  5236. viewContainerAppends: input.viewContainerAppends || [],
  5237. eventDropTransformers: input.eventDropTransformers || [],
  5238. componentInteractions: input.componentInteractions || [],
  5239. calendarInteractions: input.calendarInteractions || [],
  5240. themeClasses: input.themeClasses || {},
  5241. eventSourceDefs: input.eventSourceDefs || [],
  5242. cmdFormatter: input.cmdFormatter,
  5243. recurringTypes: input.recurringTypes || [],
  5244. namedTimeZonedImpl: input.namedTimeZonedImpl,
  5245. initialView: input.initialView || '',
  5246. elementDraggingImpl: input.elementDraggingImpl,
  5247. optionChangeHandlers: input.optionChangeHandlers || {},
  5248. scrollGridImpl: input.scrollGridImpl || null,
  5249. contentTypeHandlers: input.contentTypeHandlers || {},
  5250. listenerRefiners: input.listenerRefiners || {},
  5251. optionRefiners: input.optionRefiners || {},
  5252. propSetHandlers: input.propSetHandlers || {},
  5253. };
  5254. }
  5255. function buildPluginHooks(pluginDefs, globalDefs) {
  5256. var isAdded = {};
  5257. var hooks = {
  5258. reducers: [],
  5259. isLoadingFuncs: [],
  5260. contextInit: [],
  5261. eventRefiners: {},
  5262. eventDefMemberAdders: [],
  5263. eventSourceRefiners: {},
  5264. isDraggableTransformers: [],
  5265. eventDragMutationMassagers: [],
  5266. eventDefMutationAppliers: [],
  5267. dateSelectionTransformers: [],
  5268. datePointTransforms: [],
  5269. dateSpanTransforms: [],
  5270. views: {},
  5271. viewPropsTransformers: [],
  5272. isPropsValid: null,
  5273. externalDefTransforms: [],
  5274. viewContainerAppends: [],
  5275. eventDropTransformers: [],
  5276. componentInteractions: [],
  5277. calendarInteractions: [],
  5278. themeClasses: {},
  5279. eventSourceDefs: [],
  5280. cmdFormatter: null,
  5281. recurringTypes: [],
  5282. namedTimeZonedImpl: null,
  5283. initialView: '',
  5284. elementDraggingImpl: null,
  5285. optionChangeHandlers: {},
  5286. scrollGridImpl: null,
  5287. contentTypeHandlers: {},
  5288. listenerRefiners: {},
  5289. optionRefiners: {},
  5290. propSetHandlers: {},
  5291. };
  5292. function addDefs(defs) {
  5293. for (var _i = 0, defs_1 = defs; _i < defs_1.length; _i++) {
  5294. var def = defs_1[_i];
  5295. if (!isAdded[def.id]) {
  5296. isAdded[def.id] = true;
  5297. addDefs(def.deps);
  5298. hooks = combineHooks(hooks, def);
  5299. }
  5300. }
  5301. }
  5302. if (pluginDefs) {
  5303. addDefs(pluginDefs);
  5304. }
  5305. addDefs(globalDefs);
  5306. return hooks;
  5307. }
  5308. function buildBuildPluginHooks() {
  5309. var currentOverrideDefs = [];
  5310. var currentGlobalDefs = [];
  5311. var currentHooks;
  5312. return function (overrideDefs, globalDefs) {
  5313. if (!currentHooks || !isArraysEqual(overrideDefs, currentOverrideDefs) || !isArraysEqual(globalDefs, currentGlobalDefs)) {
  5314. currentHooks = buildPluginHooks(overrideDefs, globalDefs);
  5315. }
  5316. currentOverrideDefs = overrideDefs;
  5317. currentGlobalDefs = globalDefs;
  5318. return currentHooks;
  5319. };
  5320. }
  5321. function combineHooks(hooks0, hooks1) {
  5322. return {
  5323. reducers: hooks0.reducers.concat(hooks1.reducers),
  5324. isLoadingFuncs: hooks0.isLoadingFuncs.concat(hooks1.isLoadingFuncs),
  5325. contextInit: hooks0.contextInit.concat(hooks1.contextInit),
  5326. eventRefiners: __assign(__assign({}, hooks0.eventRefiners), hooks1.eventRefiners),
  5327. eventDefMemberAdders: hooks0.eventDefMemberAdders.concat(hooks1.eventDefMemberAdders),
  5328. eventSourceRefiners: __assign(__assign({}, hooks0.eventSourceRefiners), hooks1.eventSourceRefiners),
  5329. isDraggableTransformers: hooks0.isDraggableTransformers.concat(hooks1.isDraggableTransformers),
  5330. eventDragMutationMassagers: hooks0.eventDragMutationMassagers.concat(hooks1.eventDragMutationMassagers),
  5331. eventDefMutationAppliers: hooks0.eventDefMutationAppliers.concat(hooks1.eventDefMutationAppliers),
  5332. dateSelectionTransformers: hooks0.dateSelectionTransformers.concat(hooks1.dateSelectionTransformers),
  5333. datePointTransforms: hooks0.datePointTransforms.concat(hooks1.datePointTransforms),
  5334. dateSpanTransforms: hooks0.dateSpanTransforms.concat(hooks1.dateSpanTransforms),
  5335. views: __assign(__assign({}, hooks0.views), hooks1.views),
  5336. viewPropsTransformers: hooks0.viewPropsTransformers.concat(hooks1.viewPropsTransformers),
  5337. isPropsValid: hooks1.isPropsValid || hooks0.isPropsValid,
  5338. externalDefTransforms: hooks0.externalDefTransforms.concat(hooks1.externalDefTransforms),
  5339. viewContainerAppends: hooks0.viewContainerAppends.concat(hooks1.viewContainerAppends),
  5340. eventDropTransformers: hooks0.eventDropTransformers.concat(hooks1.eventDropTransformers),
  5341. calendarInteractions: hooks0.calendarInteractions.concat(hooks1.calendarInteractions),
  5342. componentInteractions: hooks0.componentInteractions.concat(hooks1.componentInteractions),
  5343. themeClasses: __assign(__assign({}, hooks0.themeClasses), hooks1.themeClasses),
  5344. eventSourceDefs: hooks0.eventSourceDefs.concat(hooks1.eventSourceDefs),
  5345. cmdFormatter: hooks1.cmdFormatter || hooks0.cmdFormatter,
  5346. recurringTypes: hooks0.recurringTypes.concat(hooks1.recurringTypes),
  5347. namedTimeZonedImpl: hooks1.namedTimeZonedImpl || hooks0.namedTimeZonedImpl,
  5348. initialView: hooks0.initialView || hooks1.initialView,
  5349. elementDraggingImpl: hooks0.elementDraggingImpl || hooks1.elementDraggingImpl,
  5350. optionChangeHandlers: __assign(__assign({}, hooks0.optionChangeHandlers), hooks1.optionChangeHandlers),
  5351. scrollGridImpl: hooks1.scrollGridImpl || hooks0.scrollGridImpl,
  5352. contentTypeHandlers: __assign(__assign({}, hooks0.contentTypeHandlers), hooks1.contentTypeHandlers),
  5353. listenerRefiners: __assign(__assign({}, hooks0.listenerRefiners), hooks1.listenerRefiners),
  5354. optionRefiners: __assign(__assign({}, hooks0.optionRefiners), hooks1.optionRefiners),
  5355. propSetHandlers: __assign(__assign({}, hooks0.propSetHandlers), hooks1.propSetHandlers),
  5356. };
  5357. }
  5358. var StandardTheme = /** @class */ (function (_super) {
  5359. __extends(StandardTheme, _super);
  5360. function StandardTheme() {
  5361. return _super !== null && _super.apply(this, arguments) || this;
  5362. }
  5363. return StandardTheme;
  5364. }(Theme));
  5365. StandardTheme.prototype.classes = {
  5366. root: 'fc-theme-standard',
  5367. tableCellShaded: 'fc-cell-shaded',
  5368. buttonGroup: 'fc-button-group',
  5369. button: 'fc-button fc-button-primary',
  5370. buttonActive: 'fc-button-active',
  5371. };
  5372. StandardTheme.prototype.baseIconClass = 'fc-icon';
  5373. StandardTheme.prototype.iconClasses = {
  5374. close: 'fc-icon-x',
  5375. prev: 'fc-icon-chevron-left',
  5376. next: 'fc-icon-chevron-right',
  5377. prevYear: 'fc-icon-chevrons-left',
  5378. nextYear: 'fc-icon-chevrons-right',
  5379. };
  5380. StandardTheme.prototype.rtlIconClasses = {
  5381. prev: 'fc-icon-chevron-right',
  5382. next: 'fc-icon-chevron-left',
  5383. prevYear: 'fc-icon-chevrons-right',
  5384. nextYear: 'fc-icon-chevrons-left',
  5385. };
  5386. StandardTheme.prototype.iconOverrideOption = 'buttonIcons'; // TODO: make TS-friendly
  5387. StandardTheme.prototype.iconOverrideCustomButtonOption = 'icon';
  5388. StandardTheme.prototype.iconOverridePrefix = 'fc-icon-';
  5389. function compileViewDefs(defaultConfigs, overrideConfigs) {
  5390. var hash = {};
  5391. var viewType;
  5392. for (viewType in defaultConfigs) {
  5393. ensureViewDef(viewType, hash, defaultConfigs, overrideConfigs);
  5394. }
  5395. for (viewType in overrideConfigs) {
  5396. ensureViewDef(viewType, hash, defaultConfigs, overrideConfigs);
  5397. }
  5398. return hash;
  5399. }
  5400. function ensureViewDef(viewType, hash, defaultConfigs, overrideConfigs) {
  5401. if (hash[viewType]) {
  5402. return hash[viewType];
  5403. }
  5404. var viewDef = buildViewDef(viewType, hash, defaultConfigs, overrideConfigs);
  5405. if (viewDef) {
  5406. hash[viewType] = viewDef;
  5407. }
  5408. return viewDef;
  5409. }
  5410. function buildViewDef(viewType, hash, defaultConfigs, overrideConfigs) {
  5411. var defaultConfig = defaultConfigs[viewType];
  5412. var overrideConfig = overrideConfigs[viewType];
  5413. var queryProp = function (name) { return ((defaultConfig && defaultConfig[name] !== null) ? defaultConfig[name] :
  5414. ((overrideConfig && overrideConfig[name] !== null) ? overrideConfig[name] : null)); };
  5415. var theComponent = queryProp('component');
  5416. var superType = queryProp('superType');
  5417. var superDef = null;
  5418. if (superType) {
  5419. if (superType === viewType) {
  5420. throw new Error('Can\'t have a custom view type that references itself');
  5421. }
  5422. superDef = ensureViewDef(superType, hash, defaultConfigs, overrideConfigs);
  5423. }
  5424. if (!theComponent && superDef) {
  5425. theComponent = superDef.component;
  5426. }
  5427. if (!theComponent) {
  5428. return null; // don't throw a warning, might be settings for a single-unit view
  5429. }
  5430. return {
  5431. type: viewType,
  5432. component: theComponent,
  5433. defaults: __assign(__assign({}, (superDef ? superDef.defaults : {})), (defaultConfig ? defaultConfig.rawOptions : {})),
  5434. overrides: __assign(__assign({}, (superDef ? superDef.overrides : {})), (overrideConfig ? overrideConfig.rawOptions : {})),
  5435. };
  5436. }
  5437. /* eslint max-classes-per-file: off */
  5438. // NOTE: in JSX, you should always use this class with <HookProps> arg. otherwise, will default to any???
  5439. var RenderHook = /** @class */ (function (_super) {
  5440. __extends(RenderHook, _super);
  5441. function RenderHook() {
  5442. var _this = _super !== null && _super.apply(this, arguments) || this;
  5443. _this.rootElRef = createRef();
  5444. _this.handleRootEl = function (el) {
  5445. setRef(_this.rootElRef, el);
  5446. if (_this.props.elRef) {
  5447. setRef(_this.props.elRef, el);
  5448. }
  5449. };
  5450. return _this;
  5451. }
  5452. RenderHook.prototype.render = function () {
  5453. var _this = this;
  5454. var props = this.props;
  5455. var hookProps = props.hookProps;
  5456. 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); })); }));
  5457. };
  5458. return RenderHook;
  5459. }(BaseComponent));
  5460. // TODO: rename to be about function, not default. use in above type
  5461. // for forcing rerender of components that use the ContentHook
  5462. var CustomContentRenderContext = createContext(0);
  5463. function ContentHook(props) {
  5464. return (createElement(CustomContentRenderContext.Consumer, null, function (renderId) { return (createElement(ContentHookInner, __assign({ renderId: renderId }, props))); }));
  5465. }
  5466. var ContentHookInner = /** @class */ (function (_super) {
  5467. __extends(ContentHookInner, _super);
  5468. function ContentHookInner() {
  5469. var _this = _super !== null && _super.apply(this, arguments) || this;
  5470. _this.innerElRef = createRef();
  5471. return _this;
  5472. }
  5473. ContentHookInner.prototype.render = function () {
  5474. return this.props.children(this.innerElRef, this.renderInnerContent());
  5475. };
  5476. ContentHookInner.prototype.componentDidMount = function () {
  5477. this.updateCustomContent();
  5478. };
  5479. ContentHookInner.prototype.componentDidUpdate = function () {
  5480. this.updateCustomContent();
  5481. };
  5482. ContentHookInner.prototype.componentWillUnmount = function () {
  5483. if (this.customContentInfo && this.customContentInfo.destroy) {
  5484. this.customContentInfo.destroy();
  5485. }
  5486. };
  5487. ContentHookInner.prototype.renderInnerContent = function () {
  5488. var customContentInfo = this.customContentInfo; // only populated if using non-[p]react node(s)
  5489. var innerContent = this.getInnerContent();
  5490. var meta = this.getContentMeta(innerContent);
  5491. // initial run, or content-type changing? (from vue -> react for example)
  5492. if (!customContentInfo || customContentInfo.contentKey !== meta.contentKey) {
  5493. // clearing old value
  5494. if (customContentInfo) {
  5495. if (customContentInfo.destroy) {
  5496. customContentInfo.destroy();
  5497. }
  5498. customContentInfo = this.customContentInfo = null;
  5499. }
  5500. // assigning new value
  5501. if (meta.contentKey) {
  5502. customContentInfo = this.customContentInfo = __assign({ contentKey: meta.contentKey, contentVal: innerContent[meta.contentKey] }, meta.buildLifecycleFuncs());
  5503. }
  5504. // updating
  5505. }
  5506. else if (customContentInfo) {
  5507. customContentInfo.contentVal = innerContent[meta.contentKey];
  5508. }
  5509. return customContentInfo
  5510. ? [] // signal that something was specified
  5511. : innerContent; // assume a [p]react vdom node. use it
  5512. };
  5513. ContentHookInner.prototype.getInnerContent = function () {
  5514. var props = this.props;
  5515. var innerContent = normalizeContent(props.content, props.hookProps);
  5516. if (innerContent === undefined) { // use the default
  5517. innerContent = normalizeContent(props.defaultContent, props.hookProps);
  5518. }
  5519. return innerContent == null ? null : innerContent; // convert undefined to null (better for React)
  5520. };
  5521. ContentHookInner.prototype.getContentMeta = function (innerContent) {
  5522. var contentTypeHandlers = this.context.pluginHooks.contentTypeHandlers;
  5523. var contentKey = '';
  5524. var buildLifecycleFuncs = null;
  5525. if (innerContent) { // allowed to be null, for convenience to caller
  5526. for (var searchKey in contentTypeHandlers) {
  5527. if (innerContent[searchKey] !== undefined) {
  5528. contentKey = searchKey;
  5529. buildLifecycleFuncs = contentTypeHandlers[searchKey];
  5530. break;
  5531. }
  5532. }
  5533. }
  5534. return { contentKey: contentKey, buildLifecycleFuncs: buildLifecycleFuncs };
  5535. };
  5536. ContentHookInner.prototype.updateCustomContent = function () {
  5537. if (this.customContentInfo) { // for non-[p]react
  5538. this.customContentInfo.render(this.innerElRef.current || this.props.backupElRef.current, // the element to render into
  5539. this.customContentInfo.contentVal);
  5540. }
  5541. };
  5542. return ContentHookInner;
  5543. }(BaseComponent));
  5544. var MountHook = /** @class */ (function (_super) {
  5545. __extends(MountHook, _super);
  5546. function MountHook() {
  5547. var _this = _super !== null && _super.apply(this, arguments) || this;
  5548. _this.handleRootEl = function (rootEl) {
  5549. _this.rootEl = rootEl;
  5550. if (_this.props.elRef) {
  5551. setRef(_this.props.elRef, rootEl);
  5552. }
  5553. };
  5554. return _this;
  5555. }
  5556. MountHook.prototype.render = function () {
  5557. return this.props.children(this.handleRootEl);
  5558. };
  5559. MountHook.prototype.componentDidMount = function () {
  5560. var callback = this.props.didMount;
  5561. if (callback) {
  5562. callback(__assign(__assign({}, this.props.hookProps), { el: this.rootEl }));
  5563. }
  5564. };
  5565. MountHook.prototype.componentWillUnmount = function () {
  5566. var callback = this.props.willUnmount;
  5567. if (callback) {
  5568. callback(__assign(__assign({}, this.props.hookProps), { el: this.rootEl }));
  5569. }
  5570. };
  5571. return MountHook;
  5572. }(BaseComponent));
  5573. function buildClassNameNormalizer() {
  5574. var currentGenerator;
  5575. var currentHookProps;
  5576. var currentClassNames = [];
  5577. return function (generator, hookProps) {
  5578. if (!currentHookProps || !isPropsEqual(currentHookProps, hookProps) || generator !== currentGenerator) {
  5579. currentGenerator = generator;
  5580. currentHookProps = hookProps;
  5581. currentClassNames = normalizeClassNames(generator, hookProps);
  5582. }
  5583. return currentClassNames;
  5584. };
  5585. }
  5586. function normalizeClassNames(classNames, hookProps) {
  5587. if (typeof classNames === 'function') {
  5588. classNames = classNames(hookProps);
  5589. }
  5590. return parseClassNames(classNames);
  5591. }
  5592. function normalizeContent(input, hookProps) {
  5593. if (typeof input === 'function') {
  5594. return input(hookProps, createElement); // give the function the vdom-creation func
  5595. }
  5596. return input;
  5597. }
  5598. var ViewRoot = /** @class */ (function (_super) {
  5599. __extends(ViewRoot, _super);
  5600. function ViewRoot() {
  5601. var _this = _super !== null && _super.apply(this, arguments) || this;
  5602. _this.normalizeClassNames = buildClassNameNormalizer();
  5603. return _this;
  5604. }
  5605. ViewRoot.prototype.render = function () {
  5606. var _a = this, props = _a.props, context = _a.context;
  5607. var options = context.options;
  5608. var hookProps = { view: context.viewApi };
  5609. var customClassNames = this.normalizeClassNames(options.viewClassNames, hookProps);
  5610. 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)); }));
  5611. };
  5612. return ViewRoot;
  5613. }(BaseComponent));
  5614. function parseViewConfigs(inputs) {
  5615. return mapHash(inputs, parseViewConfig);
  5616. }
  5617. function parseViewConfig(input) {
  5618. var rawOptions = typeof input === 'function' ?
  5619. { component: input } :
  5620. input;
  5621. var component = rawOptions.component;
  5622. if (rawOptions.content) {
  5623. component = createViewHookComponent(rawOptions);
  5624. // TODO: remove content/classNames/didMount/etc from options?
  5625. }
  5626. return {
  5627. superType: rawOptions.type,
  5628. component: component,
  5629. rawOptions: rawOptions,
  5630. };
  5631. }
  5632. function createViewHookComponent(options) {
  5633. return function (viewProps) { return (createElement(ViewContextType.Consumer, null, function (context) { return (createElement(ViewRoot, { viewSpec: context.viewSpec }, function (viewElRef, viewClassNames) {
  5634. var hookProps = __assign(__assign({}, viewProps), { nextDayThreshold: context.options.nextDayThreshold });
  5635. return (createElement(RenderHook, { hookProps: hookProps, classNames: options.classNames, content: options.content, didMount: options.didMount, willUnmount: options.willUnmount, elRef: viewElRef }, function (rootElRef, customClassNames, innerElRef, innerContent) { return (createElement("div", { className: viewClassNames.concat(customClassNames).join(' '), ref: rootElRef }, innerContent)); }));
  5636. })); })); };
  5637. }
  5638. function buildViewSpecs(defaultInputs, optionOverrides, dynamicOptionOverrides, localeDefaults) {
  5639. var defaultConfigs = parseViewConfigs(defaultInputs);
  5640. var overrideConfigs = parseViewConfigs(optionOverrides.views);
  5641. var viewDefs = compileViewDefs(defaultConfigs, overrideConfigs);
  5642. return mapHash(viewDefs, function (viewDef) { return buildViewSpec(viewDef, overrideConfigs, optionOverrides, dynamicOptionOverrides, localeDefaults); });
  5643. }
  5644. function buildViewSpec(viewDef, overrideConfigs, optionOverrides, dynamicOptionOverrides, localeDefaults) {
  5645. var durationInput = viewDef.overrides.duration ||
  5646. viewDef.defaults.duration ||
  5647. dynamicOptionOverrides.duration ||
  5648. optionOverrides.duration;
  5649. var duration = null;
  5650. var durationUnit = '';
  5651. var singleUnit = '';
  5652. var singleUnitOverrides = {};
  5653. if (durationInput) {
  5654. duration = createDurationCached(durationInput);
  5655. if (duration) { // valid?
  5656. var denom = greatestDurationDenominator(duration);
  5657. durationUnit = denom.unit;
  5658. if (denom.value === 1) {
  5659. singleUnit = durationUnit;
  5660. singleUnitOverrides = overrideConfigs[durationUnit] ? overrideConfigs[durationUnit].rawOptions : {};
  5661. }
  5662. }
  5663. }
  5664. var queryButtonText = function (optionsSubset) {
  5665. var buttonTextMap = optionsSubset.buttonText || {};
  5666. var buttonTextKey = viewDef.defaults.buttonTextKey;
  5667. if (buttonTextKey != null && buttonTextMap[buttonTextKey] != null) {
  5668. return buttonTextMap[buttonTextKey];
  5669. }
  5670. if (buttonTextMap[viewDef.type] != null) {
  5671. return buttonTextMap[viewDef.type];
  5672. }
  5673. if (buttonTextMap[singleUnit] != null) {
  5674. return buttonTextMap[singleUnit];
  5675. }
  5676. return null;
  5677. };
  5678. var queryButtonTitle = function (optionsSubset) {
  5679. var buttonHints = optionsSubset.buttonHints || {};
  5680. var buttonKey = viewDef.defaults.buttonTextKey; // use same key as text
  5681. if (buttonKey != null && buttonHints[buttonKey] != null) {
  5682. return buttonHints[buttonKey];
  5683. }
  5684. if (buttonHints[viewDef.type] != null) {
  5685. return buttonHints[viewDef.type];
  5686. }
  5687. if (buttonHints[singleUnit] != null) {
  5688. return buttonHints[singleUnit];
  5689. }
  5690. return null;
  5691. };
  5692. return {
  5693. type: viewDef.type,
  5694. component: viewDef.component,
  5695. duration: duration,
  5696. durationUnit: durationUnit,
  5697. singleUnit: singleUnit,
  5698. optionDefaults: viewDef.defaults,
  5699. optionOverrides: __assign(__assign({}, singleUnitOverrides), viewDef.overrides),
  5700. buttonTextOverride: queryButtonText(dynamicOptionOverrides) ||
  5701. queryButtonText(optionOverrides) || // constructor-specified buttonText lookup hash takes precedence
  5702. viewDef.overrides.buttonText,
  5703. buttonTextDefault: queryButtonText(localeDefaults) ||
  5704. viewDef.defaults.buttonText ||
  5705. queryButtonText(BASE_OPTION_DEFAULTS) ||
  5706. viewDef.type,
  5707. // not DRY
  5708. buttonTitleOverride: queryButtonTitle(dynamicOptionOverrides) ||
  5709. queryButtonTitle(optionOverrides) ||
  5710. viewDef.overrides.buttonHint,
  5711. buttonTitleDefault: queryButtonTitle(localeDefaults) ||
  5712. viewDef.defaults.buttonHint ||
  5713. queryButtonTitle(BASE_OPTION_DEFAULTS),
  5714. // will eventually fall back to buttonText
  5715. };
  5716. }
  5717. // hack to get memoization working
  5718. var durationInputMap = {};
  5719. function createDurationCached(durationInput) {
  5720. var json = JSON.stringify(durationInput);
  5721. var res = durationInputMap[json];
  5722. if (res === undefined) {
  5723. res = createDuration(durationInput);
  5724. durationInputMap[json] = res;
  5725. }
  5726. return res;
  5727. }
  5728. var DateProfileGenerator = /** @class */ (function () {
  5729. function DateProfileGenerator(props) {
  5730. this.props = props;
  5731. this.nowDate = getNow(props.nowInput, props.dateEnv);
  5732. this.initHiddenDays();
  5733. }
  5734. /* Date Range Computation
  5735. ------------------------------------------------------------------------------------------------------------------*/
  5736. // Builds a structure with info about what the dates/ranges will be for the "prev" view.
  5737. DateProfileGenerator.prototype.buildPrev = function (currentDateProfile, currentDate, forceToValid) {
  5738. var dateEnv = this.props.dateEnv;
  5739. var prevDate = dateEnv.subtract(dateEnv.startOf(currentDate, currentDateProfile.currentRangeUnit), // important for start-of-month
  5740. currentDateProfile.dateIncrement);
  5741. return this.build(prevDate, -1, forceToValid);
  5742. };
  5743. // Builds a structure with info about what the dates/ranges will be for the "next" view.
  5744. DateProfileGenerator.prototype.buildNext = function (currentDateProfile, currentDate, forceToValid) {
  5745. var dateEnv = this.props.dateEnv;
  5746. var nextDate = dateEnv.add(dateEnv.startOf(currentDate, currentDateProfile.currentRangeUnit), // important for start-of-month
  5747. currentDateProfile.dateIncrement);
  5748. return this.build(nextDate, 1, forceToValid);
  5749. };
  5750. // Builds a structure holding dates/ranges for rendering around the given date.
  5751. // Optional direction param indicates whether the date is being incremented/decremented
  5752. // from its previous value. decremented = -1, incremented = 1 (default).
  5753. DateProfileGenerator.prototype.build = function (currentDate, direction, forceToValid) {
  5754. if (forceToValid === void 0) { forceToValid = true; }
  5755. var props = this.props;
  5756. var validRange;
  5757. var currentInfo;
  5758. var isRangeAllDay;
  5759. var renderRange;
  5760. var activeRange;
  5761. var isValid;
  5762. validRange = this.buildValidRange();
  5763. validRange = this.trimHiddenDays(validRange);
  5764. if (forceToValid) {
  5765. currentDate = constrainMarkerToRange(currentDate, validRange);
  5766. }
  5767. currentInfo = this.buildCurrentRangeInfo(currentDate, direction);
  5768. isRangeAllDay = /^(year|month|week|day)$/.test(currentInfo.unit);
  5769. renderRange = this.buildRenderRange(this.trimHiddenDays(currentInfo.range), currentInfo.unit, isRangeAllDay);
  5770. renderRange = this.trimHiddenDays(renderRange);
  5771. activeRange = renderRange;
  5772. if (!props.showNonCurrentDates) {
  5773. activeRange = intersectRanges(activeRange, currentInfo.range);
  5774. }
  5775. activeRange = this.adjustActiveRange(activeRange);
  5776. activeRange = intersectRanges(activeRange, validRange); // might return null
  5777. // it's invalid if the originally requested date is not contained,
  5778. // or if the range is completely outside of the valid range.
  5779. isValid = rangesIntersect(currentInfo.range, validRange);
  5780. return {
  5781. // constraint for where prev/next operations can go and where events can be dragged/resized to.
  5782. // an object with optional start and end properties.
  5783. validRange: validRange,
  5784. // range the view is formally responsible for.
  5785. // for example, a month view might have 1st-31st, excluding padded dates
  5786. currentRange: currentInfo.range,
  5787. // name of largest unit being displayed, like "month" or "week"
  5788. currentRangeUnit: currentInfo.unit,
  5789. isRangeAllDay: isRangeAllDay,
  5790. // dates that display events and accept drag-n-drop
  5791. // will be `null` if no dates accept events
  5792. activeRange: activeRange,
  5793. // date range with a rendered skeleton
  5794. // includes not-active days that need some sort of DOM
  5795. renderRange: renderRange,
  5796. // Duration object that denotes the first visible time of any given day
  5797. slotMinTime: props.slotMinTime,
  5798. // Duration object that denotes the exclusive visible end time of any given day
  5799. slotMaxTime: props.slotMaxTime,
  5800. isValid: isValid,
  5801. // how far the current date will move for a prev/next operation
  5802. dateIncrement: this.buildDateIncrement(currentInfo.duration),
  5803. // pass a fallback (might be null) ^
  5804. };
  5805. };
  5806. // Builds an object with optional start/end properties.
  5807. // Indicates the minimum/maximum dates to display.
  5808. // not responsible for trimming hidden days.
  5809. DateProfileGenerator.prototype.buildValidRange = function () {
  5810. var input = this.props.validRangeInput;
  5811. var simpleInput = typeof input === 'function'
  5812. ? input.call(this.props.calendarApi, this.nowDate)
  5813. : input;
  5814. return this.refineRange(simpleInput) ||
  5815. { start: null, end: null }; // completely open-ended
  5816. };
  5817. // Builds a structure with info about the "current" range, the range that is
  5818. // highlighted as being the current month for example.
  5819. // See build() for a description of `direction`.
  5820. // Guaranteed to have `range` and `unit` properties. `duration` is optional.
  5821. DateProfileGenerator.prototype.buildCurrentRangeInfo = function (date, direction) {
  5822. var props = this.props;
  5823. var duration = null;
  5824. var unit = null;
  5825. var range = null;
  5826. var dayCount;
  5827. if (props.duration) {
  5828. duration = props.duration;
  5829. unit = props.durationUnit;
  5830. range = this.buildRangeFromDuration(date, direction, duration, unit);
  5831. }
  5832. else if ((dayCount = this.props.dayCount)) {
  5833. unit = 'day';
  5834. range = this.buildRangeFromDayCount(date, direction, dayCount);
  5835. }
  5836. else if ((range = this.buildCustomVisibleRange(date))) {
  5837. unit = props.dateEnv.greatestWholeUnit(range.start, range.end).unit;
  5838. }
  5839. else {
  5840. duration = this.getFallbackDuration();
  5841. unit = greatestDurationDenominator(duration).unit;
  5842. range = this.buildRangeFromDuration(date, direction, duration, unit);
  5843. }
  5844. return { duration: duration, unit: unit, range: range };
  5845. };
  5846. DateProfileGenerator.prototype.getFallbackDuration = function () {
  5847. return createDuration({ day: 1 });
  5848. };
  5849. // Returns a new activeRange to have time values (un-ambiguate)
  5850. // slotMinTime or slotMaxTime causes the range to expand.
  5851. DateProfileGenerator.prototype.adjustActiveRange = function (range) {
  5852. var _a = this.props, dateEnv = _a.dateEnv, usesMinMaxTime = _a.usesMinMaxTime, slotMinTime = _a.slotMinTime, slotMaxTime = _a.slotMaxTime;
  5853. var start = range.start, end = range.end;
  5854. if (usesMinMaxTime) {
  5855. // expand active range if slotMinTime is negative (why not when positive?)
  5856. if (asRoughDays(slotMinTime) < 0) {
  5857. start = startOfDay(start); // necessary?
  5858. start = dateEnv.add(start, slotMinTime);
  5859. }
  5860. // expand active range if slotMaxTime is beyond one day (why not when negative?)
  5861. if (asRoughDays(slotMaxTime) > 1) {
  5862. end = startOfDay(end); // necessary?
  5863. end = addDays(end, -1);
  5864. end = dateEnv.add(end, slotMaxTime);
  5865. }
  5866. }
  5867. return { start: start, end: end };
  5868. };
  5869. // Builds the "current" range when it is specified as an explicit duration.
  5870. // `unit` is the already-computed greatestDurationDenominator unit of duration.
  5871. DateProfileGenerator.prototype.buildRangeFromDuration = function (date, direction, duration, unit) {
  5872. var _a = this.props, dateEnv = _a.dateEnv, dateAlignment = _a.dateAlignment;
  5873. var start;
  5874. var end;
  5875. var res;
  5876. // compute what the alignment should be
  5877. if (!dateAlignment) {
  5878. var dateIncrement = this.props.dateIncrement;
  5879. if (dateIncrement) {
  5880. // use the smaller of the two units
  5881. if (asRoughMs(dateIncrement) < asRoughMs(duration)) {
  5882. dateAlignment = greatestDurationDenominator(dateIncrement).unit;
  5883. }
  5884. else {
  5885. dateAlignment = unit;
  5886. }
  5887. }
  5888. else {
  5889. dateAlignment = unit;
  5890. }
  5891. }
  5892. // if the view displays a single day or smaller
  5893. if (asRoughDays(duration) <= 1) {
  5894. if (this.isHiddenDay(start)) {
  5895. start = this.skipHiddenDays(start, direction);
  5896. start = startOfDay(start);
  5897. }
  5898. }
  5899. function computeRes() {
  5900. start = dateEnv.startOf(date, dateAlignment);
  5901. end = dateEnv.add(start, duration);
  5902. res = { start: start, end: end };
  5903. }
  5904. computeRes();
  5905. // if range is completely enveloped by hidden days, go past the hidden days
  5906. if (!this.trimHiddenDays(res)) {
  5907. date = this.skipHiddenDays(date, direction);
  5908. computeRes();
  5909. }
  5910. return res;
  5911. };
  5912. // Builds the "current" range when a dayCount is specified.
  5913. DateProfileGenerator.prototype.buildRangeFromDayCount = function (date, direction, dayCount) {
  5914. var _a = this.props, dateEnv = _a.dateEnv, dateAlignment = _a.dateAlignment;
  5915. var runningCount = 0;
  5916. var start = date;
  5917. var end;
  5918. if (dateAlignment) {
  5919. start = dateEnv.startOf(start, dateAlignment);
  5920. }
  5921. start = startOfDay(start);
  5922. start = this.skipHiddenDays(start, direction);
  5923. end = start;
  5924. do {
  5925. end = addDays(end, 1);
  5926. if (!this.isHiddenDay(end)) {
  5927. runningCount += 1;
  5928. }
  5929. } while (runningCount < dayCount);
  5930. return { start: start, end: end };
  5931. };
  5932. // Builds a normalized range object for the "visible" range,
  5933. // which is a way to define the currentRange and activeRange at the same time.
  5934. DateProfileGenerator.prototype.buildCustomVisibleRange = function (date) {
  5935. var props = this.props;
  5936. var input = props.visibleRangeInput;
  5937. var simpleInput = typeof input === 'function'
  5938. ? input.call(props.calendarApi, props.dateEnv.toDate(date))
  5939. : input;
  5940. var range = this.refineRange(simpleInput);
  5941. if (range && (range.start == null || range.end == null)) {
  5942. return null;
  5943. }
  5944. return range;
  5945. };
  5946. // Computes the range that will represent the element/cells for *rendering*,
  5947. // but which may have voided days/times.
  5948. // not responsible for trimming hidden days.
  5949. DateProfileGenerator.prototype.buildRenderRange = function (currentRange, currentRangeUnit, isRangeAllDay) {
  5950. return currentRange;
  5951. };
  5952. // Compute the duration value that should be added/substracted to the current date
  5953. // when a prev/next operation happens.
  5954. DateProfileGenerator.prototype.buildDateIncrement = function (fallback) {
  5955. var dateIncrement = this.props.dateIncrement;
  5956. var customAlignment;
  5957. if (dateIncrement) {
  5958. return dateIncrement;
  5959. }
  5960. if ((customAlignment = this.props.dateAlignment)) {
  5961. return createDuration(1, customAlignment);
  5962. }
  5963. if (fallback) {
  5964. return fallback;
  5965. }
  5966. return createDuration({ days: 1 });
  5967. };
  5968. DateProfileGenerator.prototype.refineRange = function (rangeInput) {
  5969. if (rangeInput) {
  5970. var range = parseRange(rangeInput, this.props.dateEnv);
  5971. if (range) {
  5972. range = computeVisibleDayRange(range);
  5973. }
  5974. return range;
  5975. }
  5976. return null;
  5977. };
  5978. /* Hidden Days
  5979. ------------------------------------------------------------------------------------------------------------------*/
  5980. // Initializes internal variables related to calculating hidden days-of-week
  5981. DateProfileGenerator.prototype.initHiddenDays = function () {
  5982. var hiddenDays = this.props.hiddenDays || []; // array of day-of-week indices that are hidden
  5983. var isHiddenDayHash = []; // is the day-of-week hidden? (hash with day-of-week-index -> bool)
  5984. var dayCnt = 0;
  5985. var i;
  5986. if (this.props.weekends === false) {
  5987. hiddenDays.push(0, 6); // 0=sunday, 6=saturday
  5988. }
  5989. for (i = 0; i < 7; i += 1) {
  5990. if (!(isHiddenDayHash[i] = hiddenDays.indexOf(i) !== -1)) {
  5991. dayCnt += 1;
  5992. }
  5993. }
  5994. if (!dayCnt) {
  5995. throw new Error('invalid hiddenDays'); // all days were hidden? bad.
  5996. }
  5997. this.isHiddenDayHash = isHiddenDayHash;
  5998. };
  5999. // Remove days from the beginning and end of the range that are computed as hidden.
  6000. // If the whole range is trimmed off, returns null
  6001. DateProfileGenerator.prototype.trimHiddenDays = function (range) {
  6002. var start = range.start, end = range.end;
  6003. if (start) {
  6004. start = this.skipHiddenDays(start);
  6005. }
  6006. if (end) {
  6007. end = this.skipHiddenDays(end, -1, true);
  6008. }
  6009. if (start == null || end == null || start < end) {
  6010. return { start: start, end: end };
  6011. }
  6012. return null;
  6013. };
  6014. // Is the current day hidden?
  6015. // `day` is a day-of-week index (0-6), or a Date (used for UTC)
  6016. DateProfileGenerator.prototype.isHiddenDay = function (day) {
  6017. if (day instanceof Date) {
  6018. day = day.getUTCDay();
  6019. }
  6020. return this.isHiddenDayHash[day];
  6021. };
  6022. // Incrementing the current day until it is no longer a hidden day, returning a copy.
  6023. // DOES NOT CONSIDER validRange!
  6024. // If the initial value of `date` is not a hidden day, don't do anything.
  6025. // Pass `isExclusive` as `true` if you are dealing with an end date.
  6026. // `inc` defaults to `1` (increment one day forward each time)
  6027. DateProfileGenerator.prototype.skipHiddenDays = function (date, inc, isExclusive) {
  6028. if (inc === void 0) { inc = 1; }
  6029. if (isExclusive === void 0) { isExclusive = false; }
  6030. while (this.isHiddenDayHash[(date.getUTCDay() + (isExclusive ? inc : 0) + 7) % 7]) {
  6031. date = addDays(date, inc);
  6032. }
  6033. return date;
  6034. };
  6035. return DateProfileGenerator;
  6036. }());
  6037. function reduceViewType(viewType, action) {
  6038. switch (action.type) {
  6039. case 'CHANGE_VIEW_TYPE':
  6040. viewType = action.viewType;
  6041. }
  6042. return viewType;
  6043. }
  6044. function reduceDynamicOptionOverrides(dynamicOptionOverrides, action) {
  6045. var _a;
  6046. switch (action.type) {
  6047. case 'SET_OPTION':
  6048. return __assign(__assign({}, dynamicOptionOverrides), (_a = {}, _a[action.optionName] = action.rawOptionValue, _a));
  6049. default:
  6050. return dynamicOptionOverrides;
  6051. }
  6052. }
  6053. function reduceDateProfile(currentDateProfile, action, currentDate, dateProfileGenerator) {
  6054. var dp;
  6055. switch (action.type) {
  6056. case 'CHANGE_VIEW_TYPE':
  6057. return dateProfileGenerator.build(action.dateMarker || currentDate);
  6058. case 'CHANGE_DATE':
  6059. return dateProfileGenerator.build(action.dateMarker);
  6060. case 'PREV':
  6061. dp = dateProfileGenerator.buildPrev(currentDateProfile, currentDate);
  6062. if (dp.isValid) {
  6063. return dp;
  6064. }
  6065. break;
  6066. case 'NEXT':
  6067. dp = dateProfileGenerator.buildNext(currentDateProfile, currentDate);
  6068. if (dp.isValid) {
  6069. return dp;
  6070. }
  6071. break;
  6072. }
  6073. return currentDateProfile;
  6074. }
  6075. function initEventSources(calendarOptions, dateProfile, context) {
  6076. var activeRange = dateProfile ? dateProfile.activeRange : null;
  6077. return addSources({}, parseInitialSources(calendarOptions, context), activeRange, context);
  6078. }
  6079. function reduceEventSources(eventSources, action, dateProfile, context) {
  6080. var activeRange = dateProfile ? dateProfile.activeRange : null; // need this check?
  6081. switch (action.type) {
  6082. case 'ADD_EVENT_SOURCES': // already parsed
  6083. return addSources(eventSources, action.sources, activeRange, context);
  6084. case 'REMOVE_EVENT_SOURCE':
  6085. return removeSource(eventSources, action.sourceId);
  6086. case 'PREV': // TODO: how do we track all actions that affect dateProfile :(
  6087. case 'NEXT':
  6088. case 'CHANGE_DATE':
  6089. case 'CHANGE_VIEW_TYPE':
  6090. if (dateProfile) {
  6091. return fetchDirtySources(eventSources, activeRange, context);
  6092. }
  6093. return eventSources;
  6094. case 'FETCH_EVENT_SOURCES':
  6095. return fetchSourcesByIds(eventSources, action.sourceIds ? // why no type?
  6096. arrayToHash(action.sourceIds) :
  6097. excludeStaticSources(eventSources, context), activeRange, action.isRefetch || false, context);
  6098. case 'RECEIVE_EVENTS':
  6099. case 'RECEIVE_EVENT_ERROR':
  6100. return receiveResponse(eventSources, action.sourceId, action.fetchId, action.fetchRange);
  6101. case 'REMOVE_ALL_EVENT_SOURCES':
  6102. return {};
  6103. default:
  6104. return eventSources;
  6105. }
  6106. }
  6107. function reduceEventSourcesNewTimeZone(eventSources, dateProfile, context) {
  6108. var activeRange = dateProfile ? dateProfile.activeRange : null; // need this check?
  6109. return fetchSourcesByIds(eventSources, excludeStaticSources(eventSources, context), activeRange, true, context);
  6110. }
  6111. function computeEventSourcesLoading(eventSources) {
  6112. for (var sourceId in eventSources) {
  6113. if (eventSources[sourceId].isFetching) {
  6114. return true;
  6115. }
  6116. }
  6117. return false;
  6118. }
  6119. function addSources(eventSourceHash, sources, fetchRange, context) {
  6120. var hash = {};
  6121. for (var _i = 0, sources_1 = sources; _i < sources_1.length; _i++) {
  6122. var source = sources_1[_i];
  6123. hash[source.sourceId] = source;
  6124. }
  6125. if (fetchRange) {
  6126. hash = fetchDirtySources(hash, fetchRange, context);
  6127. }
  6128. return __assign(__assign({}, eventSourceHash), hash);
  6129. }
  6130. function removeSource(eventSourceHash, sourceId) {
  6131. return filterHash(eventSourceHash, function (eventSource) { return eventSource.sourceId !== sourceId; });
  6132. }
  6133. function fetchDirtySources(sourceHash, fetchRange, context) {
  6134. return fetchSourcesByIds(sourceHash, filterHash(sourceHash, function (eventSource) { return isSourceDirty(eventSource, fetchRange, context); }), fetchRange, false, context);
  6135. }
  6136. function isSourceDirty(eventSource, fetchRange, context) {
  6137. if (!doesSourceNeedRange(eventSource, context)) {
  6138. return !eventSource.latestFetchId;
  6139. }
  6140. return !context.options.lazyFetching ||
  6141. !eventSource.fetchRange ||
  6142. eventSource.isFetching || // always cancel outdated in-progress fetches
  6143. fetchRange.start < eventSource.fetchRange.start ||
  6144. fetchRange.end > eventSource.fetchRange.end;
  6145. }
  6146. function fetchSourcesByIds(prevSources, sourceIdHash, fetchRange, isRefetch, context) {
  6147. var nextSources = {};
  6148. for (var sourceId in prevSources) {
  6149. var source = prevSources[sourceId];
  6150. if (sourceIdHash[sourceId]) {
  6151. nextSources[sourceId] = fetchSource(source, fetchRange, isRefetch, context);
  6152. }
  6153. else {
  6154. nextSources[sourceId] = source;
  6155. }
  6156. }
  6157. return nextSources;
  6158. }
  6159. function fetchSource(eventSource, fetchRange, isRefetch, context) {
  6160. var options = context.options, calendarApi = context.calendarApi;
  6161. var sourceDef = context.pluginHooks.eventSourceDefs[eventSource.sourceDefId];
  6162. var fetchId = guid();
  6163. sourceDef.fetch({
  6164. eventSource: eventSource,
  6165. range: fetchRange,
  6166. isRefetch: isRefetch,
  6167. context: context,
  6168. }, function (res) {
  6169. var rawEvents = res.rawEvents;
  6170. if (options.eventSourceSuccess) {
  6171. rawEvents = options.eventSourceSuccess.call(calendarApi, rawEvents, res.xhr) || rawEvents;
  6172. }
  6173. if (eventSource.success) {
  6174. rawEvents = eventSource.success.call(calendarApi, rawEvents, res.xhr) || rawEvents;
  6175. }
  6176. context.dispatch({
  6177. type: 'RECEIVE_EVENTS',
  6178. sourceId: eventSource.sourceId,
  6179. fetchId: fetchId,
  6180. fetchRange: fetchRange,
  6181. rawEvents: rawEvents,
  6182. });
  6183. }, function (error) {
  6184. console.warn(error.message, error);
  6185. if (options.eventSourceFailure) {
  6186. options.eventSourceFailure.call(calendarApi, error);
  6187. }
  6188. if (eventSource.failure) {
  6189. eventSource.failure(error);
  6190. }
  6191. context.dispatch({
  6192. type: 'RECEIVE_EVENT_ERROR',
  6193. sourceId: eventSource.sourceId,
  6194. fetchId: fetchId,
  6195. fetchRange: fetchRange,
  6196. error: error,
  6197. });
  6198. });
  6199. return __assign(__assign({}, eventSource), { isFetching: true, latestFetchId: fetchId });
  6200. }
  6201. function receiveResponse(sourceHash, sourceId, fetchId, fetchRange) {
  6202. var _a;
  6203. var eventSource = sourceHash[sourceId];
  6204. if (eventSource && // not already removed
  6205. fetchId === eventSource.latestFetchId) {
  6206. return __assign(__assign({}, sourceHash), (_a = {}, _a[sourceId] = __assign(__assign({}, eventSource), { isFetching: false, fetchRange: fetchRange }), _a));
  6207. }
  6208. return sourceHash;
  6209. }
  6210. function excludeStaticSources(eventSources, context) {
  6211. return filterHash(eventSources, function (eventSource) { return doesSourceNeedRange(eventSource, context); });
  6212. }
  6213. function parseInitialSources(rawOptions, context) {
  6214. var refiners = buildEventSourceRefiners(context);
  6215. var rawSources = [].concat(rawOptions.eventSources || []);
  6216. var sources = []; // parsed
  6217. if (rawOptions.initialEvents) {
  6218. rawSources.unshift(rawOptions.initialEvents);
  6219. }
  6220. if (rawOptions.events) {
  6221. rawSources.unshift(rawOptions.events);
  6222. }
  6223. for (var _i = 0, rawSources_1 = rawSources; _i < rawSources_1.length; _i++) {
  6224. var rawSource = rawSources_1[_i];
  6225. var source = parseEventSource(rawSource, context, refiners);
  6226. if (source) {
  6227. sources.push(source);
  6228. }
  6229. }
  6230. return sources;
  6231. }
  6232. function doesSourceNeedRange(eventSource, context) {
  6233. var defs = context.pluginHooks.eventSourceDefs;
  6234. return !defs[eventSource.sourceDefId].ignoreRange;
  6235. }
  6236. function reduceEventStore(eventStore, action, eventSources, dateProfile, context) {
  6237. switch (action.type) {
  6238. case 'RECEIVE_EVENTS': // raw
  6239. return receiveRawEvents(eventStore, eventSources[action.sourceId], action.fetchId, action.fetchRange, action.rawEvents, context);
  6240. case 'ADD_EVENTS': // already parsed, but not expanded
  6241. return addEvent(eventStore, action.eventStore, // new ones
  6242. dateProfile ? dateProfile.activeRange : null, context);
  6243. case 'RESET_EVENTS':
  6244. return action.eventStore;
  6245. case 'MERGE_EVENTS': // already parsed and expanded
  6246. return mergeEventStores(eventStore, action.eventStore);
  6247. case 'PREV': // TODO: how do we track all actions that affect dateProfile :(
  6248. case 'NEXT':
  6249. case 'CHANGE_DATE':
  6250. case 'CHANGE_VIEW_TYPE':
  6251. if (dateProfile) {
  6252. return expandRecurring(eventStore, dateProfile.activeRange, context);
  6253. }
  6254. return eventStore;
  6255. case 'REMOVE_EVENTS':
  6256. return excludeSubEventStore(eventStore, action.eventStore);
  6257. case 'REMOVE_EVENT_SOURCE':
  6258. return excludeEventsBySourceId(eventStore, action.sourceId);
  6259. case 'REMOVE_ALL_EVENT_SOURCES':
  6260. return filterEventStoreDefs(eventStore, function (eventDef) { return (!eventDef.sourceId // only keep events with no source id
  6261. ); });
  6262. case 'REMOVE_ALL_EVENTS':
  6263. return createEmptyEventStore();
  6264. default:
  6265. return eventStore;
  6266. }
  6267. }
  6268. function receiveRawEvents(eventStore, eventSource, fetchId, fetchRange, rawEvents, context) {
  6269. if (eventSource && // not already removed
  6270. fetchId === eventSource.latestFetchId // TODO: wish this logic was always in event-sources
  6271. ) {
  6272. var subset = parseEvents(transformRawEvents(rawEvents, eventSource, context), eventSource, context);
  6273. if (fetchRange) {
  6274. subset = expandRecurring(subset, fetchRange, context);
  6275. }
  6276. return mergeEventStores(excludeEventsBySourceId(eventStore, eventSource.sourceId), subset);
  6277. }
  6278. return eventStore;
  6279. }
  6280. function transformRawEvents(rawEvents, eventSource, context) {
  6281. var calEachTransform = context.options.eventDataTransform;
  6282. var sourceEachTransform = eventSource ? eventSource.eventDataTransform : null;
  6283. if (sourceEachTransform) {
  6284. rawEvents = transformEachRawEvent(rawEvents, sourceEachTransform);
  6285. }
  6286. if (calEachTransform) {
  6287. rawEvents = transformEachRawEvent(rawEvents, calEachTransform);
  6288. }
  6289. return rawEvents;
  6290. }
  6291. function transformEachRawEvent(rawEvents, func) {
  6292. var refinedEvents;
  6293. if (!func) {
  6294. refinedEvents = rawEvents;
  6295. }
  6296. else {
  6297. refinedEvents = [];
  6298. for (var _i = 0, rawEvents_1 = rawEvents; _i < rawEvents_1.length; _i++) {
  6299. var rawEvent = rawEvents_1[_i];
  6300. var refinedEvent = func(rawEvent);
  6301. if (refinedEvent) {
  6302. refinedEvents.push(refinedEvent);
  6303. }
  6304. else if (refinedEvent == null) {
  6305. refinedEvents.push(rawEvent);
  6306. } // if a different falsy value, do nothing
  6307. }
  6308. }
  6309. return refinedEvents;
  6310. }
  6311. function addEvent(eventStore, subset, expandRange, context) {
  6312. if (expandRange) {
  6313. subset = expandRecurring(subset, expandRange, context);
  6314. }
  6315. return mergeEventStores(eventStore, subset);
  6316. }
  6317. function rezoneEventStoreDates(eventStore, oldDateEnv, newDateEnv) {
  6318. var defs = eventStore.defs;
  6319. var instances = mapHash(eventStore.instances, function (instance) {
  6320. var def = defs[instance.defId];
  6321. if (def.allDay || def.recurringDef) {
  6322. return instance; // isn't dependent on timezone
  6323. }
  6324. return __assign(__assign({}, instance), { range: {
  6325. start: newDateEnv.createMarker(oldDateEnv.toDate(instance.range.start, instance.forcedStartTzo)),
  6326. end: newDateEnv.createMarker(oldDateEnv.toDate(instance.range.end, instance.forcedEndTzo)),
  6327. }, forcedStartTzo: newDateEnv.canComputeOffset ? null : instance.forcedStartTzo, forcedEndTzo: newDateEnv.canComputeOffset ? null : instance.forcedEndTzo });
  6328. });
  6329. return { defs: defs, instances: instances };
  6330. }
  6331. function excludeEventsBySourceId(eventStore, sourceId) {
  6332. return filterEventStoreDefs(eventStore, function (eventDef) { return eventDef.sourceId !== sourceId; });
  6333. }
  6334. // QUESTION: why not just return instances? do a general object-property-exclusion util
  6335. function excludeInstances(eventStore, removals) {
  6336. return {
  6337. defs: eventStore.defs,
  6338. instances: filterHash(eventStore.instances, function (instance) { return !removals[instance.instanceId]; }),
  6339. };
  6340. }
  6341. function reduceDateSelection(currentSelection, action) {
  6342. switch (action.type) {
  6343. case 'UNSELECT_DATES':
  6344. return null;
  6345. case 'SELECT_DATES':
  6346. return action.selection;
  6347. default:
  6348. return currentSelection;
  6349. }
  6350. }
  6351. function reduceSelectedEvent(currentInstanceId, action) {
  6352. switch (action.type) {
  6353. case 'UNSELECT_EVENT':
  6354. return '';
  6355. case 'SELECT_EVENT':
  6356. return action.eventInstanceId;
  6357. default:
  6358. return currentInstanceId;
  6359. }
  6360. }
  6361. function reduceEventDrag(currentDrag, action) {
  6362. var newDrag;
  6363. switch (action.type) {
  6364. case 'UNSET_EVENT_DRAG':
  6365. return null;
  6366. case 'SET_EVENT_DRAG':
  6367. newDrag = action.state;
  6368. return {
  6369. affectedEvents: newDrag.affectedEvents,
  6370. mutatedEvents: newDrag.mutatedEvents,
  6371. isEvent: newDrag.isEvent,
  6372. };
  6373. default:
  6374. return currentDrag;
  6375. }
  6376. }
  6377. function reduceEventResize(currentResize, action) {
  6378. var newResize;
  6379. switch (action.type) {
  6380. case 'UNSET_EVENT_RESIZE':
  6381. return null;
  6382. case 'SET_EVENT_RESIZE':
  6383. newResize = action.state;
  6384. return {
  6385. affectedEvents: newResize.affectedEvents,
  6386. mutatedEvents: newResize.mutatedEvents,
  6387. isEvent: newResize.isEvent,
  6388. };
  6389. default:
  6390. return currentResize;
  6391. }
  6392. }
  6393. function parseToolbars(calendarOptions, calendarOptionOverrides, theme, viewSpecs, calendarApi) {
  6394. var header = calendarOptions.headerToolbar ? parseToolbar(calendarOptions.headerToolbar, calendarOptions, calendarOptionOverrides, theme, viewSpecs, calendarApi) : null;
  6395. var footer = calendarOptions.footerToolbar ? parseToolbar(calendarOptions.footerToolbar, calendarOptions, calendarOptionOverrides, theme, viewSpecs, calendarApi) : null;
  6396. return { header: header, footer: footer };
  6397. }
  6398. function parseToolbar(sectionStrHash, calendarOptions, calendarOptionOverrides, theme, viewSpecs, calendarApi) {
  6399. var sectionWidgets = {};
  6400. var viewsWithButtons = [];
  6401. var hasTitle = false;
  6402. for (var sectionName in sectionStrHash) {
  6403. var sectionStr = sectionStrHash[sectionName];
  6404. var sectionRes = parseSection(sectionStr, calendarOptions, calendarOptionOverrides, theme, viewSpecs, calendarApi);
  6405. sectionWidgets[sectionName] = sectionRes.widgets;
  6406. viewsWithButtons.push.apply(viewsWithButtons, sectionRes.viewsWithButtons);
  6407. hasTitle = hasTitle || sectionRes.hasTitle;
  6408. }
  6409. return { sectionWidgets: sectionWidgets, viewsWithButtons: viewsWithButtons, hasTitle: hasTitle };
  6410. }
  6411. /*
  6412. BAD: querying icons and text here. should be done at render time
  6413. */
  6414. function parseSection(sectionStr, calendarOptions, // defaults+overrides, then refined
  6415. calendarOptionOverrides, // overrides only!, unrefined :(
  6416. theme, viewSpecs, calendarApi) {
  6417. var isRtl = calendarOptions.direction === 'rtl';
  6418. var calendarCustomButtons = calendarOptions.customButtons || {};
  6419. var calendarButtonTextOverrides = calendarOptionOverrides.buttonText || {};
  6420. var calendarButtonText = calendarOptions.buttonText || {};
  6421. var calendarButtonHintOverrides = calendarOptionOverrides.buttonHints || {};
  6422. var calendarButtonHints = calendarOptions.buttonHints || {};
  6423. var sectionSubstrs = sectionStr ? sectionStr.split(' ') : [];
  6424. var viewsWithButtons = [];
  6425. var hasTitle = false;
  6426. var widgets = sectionSubstrs.map(function (buttonGroupStr) { return (buttonGroupStr.split(',').map(function (buttonName) {
  6427. if (buttonName === 'title') {
  6428. hasTitle = true;
  6429. return { buttonName: buttonName };
  6430. }
  6431. var customButtonProps;
  6432. var viewSpec;
  6433. var buttonClick;
  6434. var buttonIcon; // only one of these will be set
  6435. var buttonText; // "
  6436. var buttonHint;
  6437. // ^ for the title="" attribute, for accessibility
  6438. if ((customButtonProps = calendarCustomButtons[buttonName])) {
  6439. buttonClick = function (ev) {
  6440. if (customButtonProps.click) {
  6441. customButtonProps.click.call(ev.target, ev, ev.target); // TODO: use Calendar this context?
  6442. }
  6443. };
  6444. (buttonIcon = theme.getCustomButtonIconClass(customButtonProps)) ||
  6445. (buttonIcon = theme.getIconClass(buttonName, isRtl)) ||
  6446. (buttonText = customButtonProps.text);
  6447. buttonHint = customButtonProps.hint || customButtonProps.text;
  6448. }
  6449. else if ((viewSpec = viewSpecs[buttonName])) {
  6450. viewsWithButtons.push(buttonName);
  6451. buttonClick = function () {
  6452. calendarApi.changeView(buttonName);
  6453. };
  6454. (buttonText = viewSpec.buttonTextOverride) ||
  6455. (buttonIcon = theme.getIconClass(buttonName, isRtl)) ||
  6456. (buttonText = viewSpec.buttonTextDefault);
  6457. var textFallback = viewSpec.buttonTextOverride ||
  6458. viewSpec.buttonTextDefault;
  6459. buttonHint = formatWithOrdinals(viewSpec.buttonTitleOverride ||
  6460. viewSpec.buttonTitleDefault ||
  6461. calendarOptions.viewHint, [textFallback, buttonName], // view-name = buttonName
  6462. textFallback);
  6463. }
  6464. else if (calendarApi[buttonName]) { // a calendarApi method
  6465. buttonClick = function () {
  6466. calendarApi[buttonName]();
  6467. };
  6468. (buttonText = calendarButtonTextOverrides[buttonName]) ||
  6469. (buttonIcon = theme.getIconClass(buttonName, isRtl)) ||
  6470. (buttonText = calendarButtonText[buttonName]); // everything else is considered default
  6471. if (buttonName === 'prevYear' || buttonName === 'nextYear') {
  6472. var prevOrNext = buttonName === 'prevYear' ? 'prev' : 'next';
  6473. buttonHint = formatWithOrdinals(calendarButtonHintOverrides[prevOrNext] ||
  6474. calendarButtonHints[prevOrNext], [
  6475. calendarButtonText.year || 'year',
  6476. 'year',
  6477. ], calendarButtonText[buttonName]);
  6478. }
  6479. else {
  6480. buttonHint = function (navUnit) { return formatWithOrdinals(calendarButtonHintOverrides[buttonName] ||
  6481. calendarButtonHints[buttonName], [
  6482. calendarButtonText[navUnit] || navUnit,
  6483. navUnit,
  6484. ], calendarButtonText[buttonName]); };
  6485. }
  6486. }
  6487. return { buttonName: buttonName, buttonClick: buttonClick, buttonIcon: buttonIcon, buttonText: buttonText, buttonHint: buttonHint };
  6488. })); });
  6489. return { widgets: widgets, viewsWithButtons: viewsWithButtons, hasTitle: hasTitle };
  6490. }
  6491. var eventSourceDef$3 = {
  6492. ignoreRange: true,
  6493. parseMeta: function (refined) {
  6494. if (Array.isArray(refined.events)) {
  6495. return refined.events;
  6496. }
  6497. return null;
  6498. },
  6499. fetch: function (arg, success) {
  6500. success({
  6501. rawEvents: arg.eventSource.meta,
  6502. });
  6503. },
  6504. };
  6505. var arrayEventSourcePlugin = createPlugin({
  6506. eventSourceDefs: [eventSourceDef$3],
  6507. });
  6508. var eventSourceDef$2 = {
  6509. parseMeta: function (refined) {
  6510. if (typeof refined.events === 'function') {
  6511. return refined.events;
  6512. }
  6513. return null;
  6514. },
  6515. fetch: function (arg, success, failure) {
  6516. var dateEnv = arg.context.dateEnv;
  6517. var func = arg.eventSource.meta;
  6518. unpromisify(func.bind(null, buildRangeApiWithTimeZone(arg.range, dateEnv)), function (rawEvents) {
  6519. success({ rawEvents: rawEvents }); // needs an object response
  6520. }, failure);
  6521. },
  6522. };
  6523. var funcEventSourcePlugin = createPlugin({
  6524. eventSourceDefs: [eventSourceDef$2],
  6525. });
  6526. function requestJson(method, url, params, successCallback, failureCallback) {
  6527. method = method.toUpperCase();
  6528. var body = null;
  6529. if (method === 'GET') {
  6530. url = injectQueryStringParams(url, params);
  6531. }
  6532. else {
  6533. body = encodeParams(params);
  6534. }
  6535. var xhr = new XMLHttpRequest();
  6536. xhr.open(method, url, true);
  6537. if (method !== 'GET') {
  6538. xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
  6539. }
  6540. xhr.onload = function () {
  6541. if (xhr.status >= 200 && xhr.status < 400) {
  6542. var parsed = false;
  6543. var res = void 0;
  6544. try {
  6545. res = JSON.parse(xhr.responseText);
  6546. parsed = true;
  6547. }
  6548. catch (err) {
  6549. // will handle parsed=false
  6550. }
  6551. if (parsed) {
  6552. successCallback(res, xhr);
  6553. }
  6554. else {
  6555. failureCallback('Failure parsing JSON', xhr);
  6556. }
  6557. }
  6558. else {
  6559. failureCallback('Request failed', xhr);
  6560. }
  6561. };
  6562. xhr.onerror = function () {
  6563. failureCallback('Request failed', xhr);
  6564. };
  6565. xhr.send(body);
  6566. }
  6567. function injectQueryStringParams(url, params) {
  6568. return url +
  6569. (url.indexOf('?') === -1 ? '?' : '&') +
  6570. encodeParams(params);
  6571. }
  6572. function encodeParams(params) {
  6573. var parts = [];
  6574. for (var key in params) {
  6575. parts.push(encodeURIComponent(key) + "=" + encodeURIComponent(params[key]));
  6576. }
  6577. return parts.join('&');
  6578. }
  6579. var JSON_FEED_EVENT_SOURCE_REFINERS = {
  6580. method: String,
  6581. extraParams: identity,
  6582. startParam: String,
  6583. endParam: String,
  6584. timeZoneParam: String,
  6585. };
  6586. var eventSourceDef$1 = {
  6587. parseMeta: function (refined) {
  6588. if (refined.url && (refined.format === 'json' || !refined.format)) {
  6589. return {
  6590. url: refined.url,
  6591. format: 'json',
  6592. method: (refined.method || 'GET').toUpperCase(),
  6593. extraParams: refined.extraParams,
  6594. startParam: refined.startParam,
  6595. endParam: refined.endParam,
  6596. timeZoneParam: refined.timeZoneParam,
  6597. };
  6598. }
  6599. return null;
  6600. },
  6601. fetch: function (arg, success, failure) {
  6602. var meta = arg.eventSource.meta;
  6603. var requestParams = buildRequestParams$1(meta, arg.range, arg.context);
  6604. requestJson(meta.method, meta.url, requestParams, function (rawEvents, xhr) {
  6605. success({ rawEvents: rawEvents, xhr: xhr });
  6606. }, function (errorMessage, xhr) {
  6607. failure({ message: errorMessage, xhr: xhr });
  6608. });
  6609. },
  6610. };
  6611. var jsonFeedEventSourcePlugin = createPlugin({
  6612. eventSourceRefiners: JSON_FEED_EVENT_SOURCE_REFINERS,
  6613. eventSourceDefs: [eventSourceDef$1],
  6614. });
  6615. function buildRequestParams$1(meta, range, context) {
  6616. var dateEnv = context.dateEnv, options = context.options;
  6617. var startParam;
  6618. var endParam;
  6619. var timeZoneParam;
  6620. var customRequestParams;
  6621. var params = {};
  6622. startParam = meta.startParam;
  6623. if (startParam == null) {
  6624. startParam = options.startParam;
  6625. }
  6626. endParam = meta.endParam;
  6627. if (endParam == null) {
  6628. endParam = options.endParam;
  6629. }
  6630. timeZoneParam = meta.timeZoneParam;
  6631. if (timeZoneParam == null) {
  6632. timeZoneParam = options.timeZoneParam;
  6633. }
  6634. // retrieve any outbound GET/POST data from the options
  6635. if (typeof meta.extraParams === 'function') {
  6636. // supplied as a function that returns a key/value object
  6637. customRequestParams = meta.extraParams();
  6638. }
  6639. else {
  6640. // probably supplied as a straight key/value object
  6641. customRequestParams = meta.extraParams || {};
  6642. }
  6643. __assign(params, customRequestParams);
  6644. params[startParam] = dateEnv.formatIso(range.start);
  6645. params[endParam] = dateEnv.formatIso(range.end);
  6646. if (dateEnv.timeZone !== 'local') {
  6647. params[timeZoneParam] = dateEnv.timeZone;
  6648. }
  6649. return params;
  6650. }
  6651. var SIMPLE_RECURRING_REFINERS = {
  6652. daysOfWeek: identity,
  6653. startTime: createDuration,
  6654. endTime: createDuration,
  6655. duration: createDuration,
  6656. startRecur: identity,
  6657. endRecur: identity,
  6658. };
  6659. var recurring = {
  6660. parse: function (refined, dateEnv) {
  6661. if (refined.daysOfWeek || refined.startTime || refined.endTime || refined.startRecur || refined.endRecur) {
  6662. var recurringData = {
  6663. daysOfWeek: refined.daysOfWeek || null,
  6664. startTime: refined.startTime || null,
  6665. endTime: refined.endTime || null,
  6666. startRecur: refined.startRecur ? dateEnv.createMarker(refined.startRecur) : null,
  6667. endRecur: refined.endRecur ? dateEnv.createMarker(refined.endRecur) : null,
  6668. };
  6669. var duration = void 0;
  6670. if (refined.duration) {
  6671. duration = refined.duration;
  6672. }
  6673. if (!duration && refined.startTime && refined.endTime) {
  6674. duration = subtractDurations(refined.endTime, refined.startTime);
  6675. }
  6676. return {
  6677. allDayGuess: Boolean(!refined.startTime && !refined.endTime),
  6678. duration: duration,
  6679. typeData: recurringData, // doesn't need endTime anymore but oh well
  6680. };
  6681. }
  6682. return null;
  6683. },
  6684. expand: function (typeData, framingRange, dateEnv) {
  6685. var clippedFramingRange = intersectRanges(framingRange, { start: typeData.startRecur, end: typeData.endRecur });
  6686. if (clippedFramingRange) {
  6687. return expandRanges(typeData.daysOfWeek, typeData.startTime, clippedFramingRange, dateEnv);
  6688. }
  6689. return [];
  6690. },
  6691. };
  6692. var simpleRecurringEventsPlugin = createPlugin({
  6693. recurringTypes: [recurring],
  6694. eventRefiners: SIMPLE_RECURRING_REFINERS,
  6695. });
  6696. function expandRanges(daysOfWeek, startTime, framingRange, dateEnv) {
  6697. var dowHash = daysOfWeek ? arrayToHash(daysOfWeek) : null;
  6698. var dayMarker = startOfDay(framingRange.start);
  6699. var endMarker = framingRange.end;
  6700. var instanceStarts = [];
  6701. while (dayMarker < endMarker) {
  6702. var instanceStart
  6703. // if everyday, or this particular day-of-week
  6704. = void 0;
  6705. // if everyday, or this particular day-of-week
  6706. if (!dowHash || dowHash[dayMarker.getUTCDay()]) {
  6707. if (startTime) {
  6708. instanceStart = dateEnv.add(dayMarker, startTime);
  6709. }
  6710. else {
  6711. instanceStart = dayMarker;
  6712. }
  6713. instanceStarts.push(instanceStart);
  6714. }
  6715. dayMarker = addDays(dayMarker, 1);
  6716. }
  6717. return instanceStarts;
  6718. }
  6719. var changeHandlerPlugin = createPlugin({
  6720. optionChangeHandlers: {
  6721. events: function (events, context) {
  6722. handleEventSources([events], context);
  6723. },
  6724. eventSources: handleEventSources,
  6725. },
  6726. });
  6727. /*
  6728. BUG: if `event` was supplied, all previously-given `eventSources` will be wiped out
  6729. */
  6730. function handleEventSources(inputs, context) {
  6731. var unfoundSources = hashValuesToArray(context.getCurrentData().eventSources);
  6732. var newInputs = [];
  6733. for (var _i = 0, inputs_1 = inputs; _i < inputs_1.length; _i++) {
  6734. var input = inputs_1[_i];
  6735. var inputFound = false;
  6736. for (var i = 0; i < unfoundSources.length; i += 1) {
  6737. if (unfoundSources[i]._raw === input) {
  6738. unfoundSources.splice(i, 1); // delete
  6739. inputFound = true;
  6740. break;
  6741. }
  6742. }
  6743. if (!inputFound) {
  6744. newInputs.push(input);
  6745. }
  6746. }
  6747. for (var _a = 0, unfoundSources_1 = unfoundSources; _a < unfoundSources_1.length; _a++) {
  6748. var unfoundSource = unfoundSources_1[_a];
  6749. context.dispatch({
  6750. type: 'REMOVE_EVENT_SOURCE',
  6751. sourceId: unfoundSource.sourceId,
  6752. });
  6753. }
  6754. for (var _b = 0, newInputs_1 = newInputs; _b < newInputs_1.length; _b++) {
  6755. var newInput = newInputs_1[_b];
  6756. context.calendarApi.addEventSource(newInput);
  6757. }
  6758. }
  6759. function handleDateProfile(dateProfile, context) {
  6760. context.emitter.trigger('datesSet', __assign(__assign({}, buildRangeApiWithTimeZone(dateProfile.activeRange, context.dateEnv)), { view: context.viewApi }));
  6761. }
  6762. function handleEventStore(eventStore, context) {
  6763. var emitter = context.emitter;
  6764. if (emitter.hasHandlers('eventsSet')) {
  6765. emitter.trigger('eventsSet', buildEventApis(eventStore, context));
  6766. }
  6767. }
  6768. /*
  6769. this array is exposed on the root namespace so that UMD plugins can add to it.
  6770. see the rollup-bundles script.
  6771. */
  6772. var globalPlugins = [
  6773. arrayEventSourcePlugin,
  6774. funcEventSourcePlugin,
  6775. jsonFeedEventSourcePlugin,
  6776. simpleRecurringEventsPlugin,
  6777. changeHandlerPlugin,
  6778. createPlugin({
  6779. isLoadingFuncs: [
  6780. function (state) { return computeEventSourcesLoading(state.eventSources); },
  6781. ],
  6782. contentTypeHandlers: {
  6783. html: buildHtmlRenderer,
  6784. domNodes: buildDomNodeRenderer,
  6785. },
  6786. propSetHandlers: {
  6787. dateProfile: handleDateProfile,
  6788. eventStore: handleEventStore,
  6789. },
  6790. }),
  6791. ];
  6792. function buildHtmlRenderer() {
  6793. var currentEl = null;
  6794. var currentHtml = '';
  6795. function render(el, html) {
  6796. if (el !== currentEl || html !== currentHtml) {
  6797. el.innerHTML = html;
  6798. }
  6799. currentEl = el;
  6800. currentHtml = html;
  6801. }
  6802. function destroy() {
  6803. currentEl.innerHTML = '';
  6804. currentEl = null;
  6805. currentHtml = '';
  6806. }
  6807. return { render: render, destroy: destroy };
  6808. }
  6809. function buildDomNodeRenderer() {
  6810. var currentEl = null;
  6811. var currentDomNodes = [];
  6812. function render(el, domNodes) {
  6813. var newDomNodes = Array.prototype.slice.call(domNodes);
  6814. if (el !== currentEl || !isArraysEqual(currentDomNodes, newDomNodes)) {
  6815. // append first, remove second (for scroll resetting)
  6816. for (var _i = 0, newDomNodes_1 = newDomNodes; _i < newDomNodes_1.length; _i++) {
  6817. var newNode = newDomNodes_1[_i];
  6818. el.appendChild(newNode);
  6819. }
  6820. destroy();
  6821. }
  6822. currentEl = el;
  6823. currentDomNodes = newDomNodes;
  6824. }
  6825. function destroy() {
  6826. currentDomNodes.forEach(removeElement);
  6827. currentDomNodes = [];
  6828. currentEl = null;
  6829. }
  6830. return { render: render, destroy: destroy };
  6831. }
  6832. var DelayedRunner = /** @class */ (function () {
  6833. function DelayedRunner(drainedOption) {
  6834. this.drainedOption = drainedOption;
  6835. this.isRunning = false;
  6836. this.isDirty = false;
  6837. this.pauseDepths = {};
  6838. this.timeoutId = 0;
  6839. }
  6840. DelayedRunner.prototype.request = function (delay) {
  6841. this.isDirty = true;
  6842. if (!this.isPaused()) {
  6843. this.clearTimeout();
  6844. if (delay == null) {
  6845. this.tryDrain();
  6846. }
  6847. else {
  6848. this.timeoutId = setTimeout(// NOT OPTIMAL! TODO: look at debounce
  6849. this.tryDrain.bind(this), delay);
  6850. }
  6851. }
  6852. };
  6853. DelayedRunner.prototype.pause = function (scope) {
  6854. if (scope === void 0) { scope = ''; }
  6855. var pauseDepths = this.pauseDepths;
  6856. pauseDepths[scope] = (pauseDepths[scope] || 0) + 1;
  6857. this.clearTimeout();
  6858. };
  6859. DelayedRunner.prototype.resume = function (scope, force) {
  6860. if (scope === void 0) { scope = ''; }
  6861. var pauseDepths = this.pauseDepths;
  6862. if (scope in pauseDepths) {
  6863. if (force) {
  6864. delete pauseDepths[scope];
  6865. }
  6866. else {
  6867. pauseDepths[scope] -= 1;
  6868. var depth = pauseDepths[scope];
  6869. if (depth <= 0) {
  6870. delete pauseDepths[scope];
  6871. }
  6872. }
  6873. this.tryDrain();
  6874. }
  6875. };
  6876. DelayedRunner.prototype.isPaused = function () {
  6877. return Object.keys(this.pauseDepths).length;
  6878. };
  6879. DelayedRunner.prototype.tryDrain = function () {
  6880. if (!this.isRunning && !this.isPaused()) {
  6881. this.isRunning = true;
  6882. while (this.isDirty) {
  6883. this.isDirty = false;
  6884. this.drained(); // might set isDirty to true again
  6885. }
  6886. this.isRunning = false;
  6887. }
  6888. };
  6889. DelayedRunner.prototype.clear = function () {
  6890. this.clearTimeout();
  6891. this.isDirty = false;
  6892. this.pauseDepths = {};
  6893. };
  6894. DelayedRunner.prototype.clearTimeout = function () {
  6895. if (this.timeoutId) {
  6896. clearTimeout(this.timeoutId);
  6897. this.timeoutId = 0;
  6898. }
  6899. };
  6900. DelayedRunner.prototype.drained = function () {
  6901. if (this.drainedOption) {
  6902. this.drainedOption();
  6903. }
  6904. };
  6905. return DelayedRunner;
  6906. }());
  6907. var TaskRunner = /** @class */ (function () {
  6908. function TaskRunner(runTaskOption, drainedOption) {
  6909. this.runTaskOption = runTaskOption;
  6910. this.drainedOption = drainedOption;
  6911. this.queue = [];
  6912. this.delayedRunner = new DelayedRunner(this.drain.bind(this));
  6913. }
  6914. TaskRunner.prototype.request = function (task, delay) {
  6915. this.queue.push(task);
  6916. this.delayedRunner.request(delay);
  6917. };
  6918. TaskRunner.prototype.pause = function (scope) {
  6919. this.delayedRunner.pause(scope);
  6920. };
  6921. TaskRunner.prototype.resume = function (scope, force) {
  6922. this.delayedRunner.resume(scope, force);
  6923. };
  6924. TaskRunner.prototype.drain = function () {
  6925. var queue = this.queue;
  6926. while (queue.length) {
  6927. var completedTasks = [];
  6928. var task = void 0;
  6929. while ((task = queue.shift())) {
  6930. this.runTask(task);
  6931. completedTasks.push(task);
  6932. }
  6933. this.drained(completedTasks);
  6934. } // keep going, in case new tasks were added in the drained handler
  6935. };
  6936. TaskRunner.prototype.runTask = function (task) {
  6937. if (this.runTaskOption) {
  6938. this.runTaskOption(task);
  6939. }
  6940. };
  6941. TaskRunner.prototype.drained = function (completedTasks) {
  6942. if (this.drainedOption) {
  6943. this.drainedOption(completedTasks);
  6944. }
  6945. };
  6946. return TaskRunner;
  6947. }());
  6948. // Computes what the title at the top of the calendarApi should be for this view
  6949. function buildTitle(dateProfile, viewOptions, dateEnv) {
  6950. var range;
  6951. // for views that span a large unit of time, show the proper interval, ignoring stray days before and after
  6952. if (/^(year|month)$/.test(dateProfile.currentRangeUnit)) {
  6953. range = dateProfile.currentRange;
  6954. }
  6955. else { // for day units or smaller, use the actual day range
  6956. range = dateProfile.activeRange;
  6957. }
  6958. return dateEnv.formatRange(range.start, range.end, createFormatter(viewOptions.titleFormat || buildTitleFormat(dateProfile)), {
  6959. isEndExclusive: dateProfile.isRangeAllDay,
  6960. defaultSeparator: viewOptions.titleRangeSeparator,
  6961. });
  6962. }
  6963. // Generates the format string that should be used to generate the title for the current date range.
  6964. // Attempts to compute the most appropriate format if not explicitly specified with `titleFormat`.
  6965. function buildTitleFormat(dateProfile) {
  6966. var currentRangeUnit = dateProfile.currentRangeUnit;
  6967. if (currentRangeUnit === 'year') {
  6968. return { year: 'numeric' };
  6969. }
  6970. if (currentRangeUnit === 'month') {
  6971. return { year: 'numeric', month: 'long' }; // like "September 2014"
  6972. }
  6973. var days = diffWholeDays(dateProfile.currentRange.start, dateProfile.currentRange.end);
  6974. if (days !== null && days > 1) {
  6975. // multi-day range. shorter, like "Sep 9 - 10 2014"
  6976. return { year: 'numeric', month: 'short', day: 'numeric' };
  6977. }
  6978. // one day. longer, like "September 9 2014"
  6979. return { year: 'numeric', month: 'long', day: 'numeric' };
  6980. }
  6981. // in future refactor, do the redux-style function(state=initial) for initial-state
  6982. // also, whatever is happening in constructor, have it happen in action queue too
  6983. var CalendarDataManager = /** @class */ (function () {
  6984. function CalendarDataManager(props) {
  6985. var _this = this;
  6986. this.computeOptionsData = memoize(this._computeOptionsData);
  6987. this.computeCurrentViewData = memoize(this._computeCurrentViewData);
  6988. this.organizeRawLocales = memoize(organizeRawLocales);
  6989. this.buildLocale = memoize(buildLocale);
  6990. this.buildPluginHooks = buildBuildPluginHooks();
  6991. this.buildDateEnv = memoize(buildDateEnv);
  6992. this.buildTheme = memoize(buildTheme);
  6993. this.parseToolbars = memoize(parseToolbars);
  6994. this.buildViewSpecs = memoize(buildViewSpecs);
  6995. this.buildDateProfileGenerator = memoizeObjArg(buildDateProfileGenerator);
  6996. this.buildViewApi = memoize(buildViewApi);
  6997. this.buildViewUiProps = memoizeObjArg(buildViewUiProps);
  6998. this.buildEventUiBySource = memoize(buildEventUiBySource, isPropsEqual);
  6999. this.buildEventUiBases = memoize(buildEventUiBases);
  7000. this.parseContextBusinessHours = memoizeObjArg(parseContextBusinessHours);
  7001. this.buildTitle = memoize(buildTitle);
  7002. this.emitter = new Emitter();
  7003. this.actionRunner = new TaskRunner(this._handleAction.bind(this), this.updateData.bind(this));
  7004. this.currentCalendarOptionsInput = {};
  7005. this.currentCalendarOptionsRefined = {};
  7006. this.currentViewOptionsInput = {};
  7007. this.currentViewOptionsRefined = {};
  7008. this.currentCalendarOptionsRefiners = {};
  7009. this.getCurrentData = function () { return _this.data; };
  7010. this.dispatch = function (action) {
  7011. _this.actionRunner.request(action); // protects against recursive calls to _handleAction
  7012. };
  7013. this.props = props;
  7014. this.actionRunner.pause();
  7015. var dynamicOptionOverrides = {};
  7016. var optionsData = this.computeOptionsData(props.optionOverrides, dynamicOptionOverrides, props.calendarApi);
  7017. var currentViewType = optionsData.calendarOptions.initialView || optionsData.pluginHooks.initialView;
  7018. var currentViewData = this.computeCurrentViewData(currentViewType, optionsData, props.optionOverrides, dynamicOptionOverrides);
  7019. // wire things up
  7020. // TODO: not DRY
  7021. props.calendarApi.currentDataManager = this;
  7022. this.emitter.setThisContext(props.calendarApi);
  7023. this.emitter.setOptions(currentViewData.options);
  7024. var currentDate = getInitialDate(optionsData.calendarOptions, optionsData.dateEnv);
  7025. var dateProfile = currentViewData.dateProfileGenerator.build(currentDate);
  7026. if (!rangeContainsMarker(dateProfile.activeRange, currentDate)) {
  7027. currentDate = dateProfile.currentRange.start;
  7028. }
  7029. var calendarContext = {
  7030. dateEnv: optionsData.dateEnv,
  7031. options: optionsData.calendarOptions,
  7032. pluginHooks: optionsData.pluginHooks,
  7033. calendarApi: props.calendarApi,
  7034. dispatch: this.dispatch,
  7035. emitter: this.emitter,
  7036. getCurrentData: this.getCurrentData,
  7037. };
  7038. // needs to be after setThisContext
  7039. for (var _i = 0, _a = optionsData.pluginHooks.contextInit; _i < _a.length; _i++) {
  7040. var callback = _a[_i];
  7041. callback(calendarContext);
  7042. }
  7043. // NOT DRY
  7044. var eventSources = initEventSources(optionsData.calendarOptions, dateProfile, calendarContext);
  7045. var initialState = {
  7046. dynamicOptionOverrides: dynamicOptionOverrides,
  7047. currentViewType: currentViewType,
  7048. currentDate: currentDate,
  7049. dateProfile: dateProfile,
  7050. businessHours: this.parseContextBusinessHours(calendarContext),
  7051. eventSources: eventSources,
  7052. eventUiBases: {},
  7053. eventStore: createEmptyEventStore(),
  7054. renderableEventStore: createEmptyEventStore(),
  7055. dateSelection: null,
  7056. eventSelection: '',
  7057. eventDrag: null,
  7058. eventResize: null,
  7059. selectionConfig: this.buildViewUiProps(calendarContext).selectionConfig,
  7060. };
  7061. var contextAndState = __assign(__assign({}, calendarContext), initialState);
  7062. for (var _b = 0, _c = optionsData.pluginHooks.reducers; _b < _c.length; _b++) {
  7063. var reducer = _c[_b];
  7064. __assign(initialState, reducer(null, null, contextAndState));
  7065. }
  7066. if (computeIsLoading(initialState, calendarContext)) {
  7067. this.emitter.trigger('loading', true); // NOT DRY
  7068. }
  7069. this.state = initialState;
  7070. this.updateData();
  7071. this.actionRunner.resume();
  7072. }
  7073. CalendarDataManager.prototype.resetOptions = function (optionOverrides, append) {
  7074. var props = this.props;
  7075. props.optionOverrides = append
  7076. ? __assign(__assign({}, props.optionOverrides), optionOverrides) : optionOverrides;
  7077. this.actionRunner.request({
  7078. type: 'NOTHING',
  7079. });
  7080. };
  7081. CalendarDataManager.prototype._handleAction = function (action) {
  7082. var _a = this, props = _a.props, state = _a.state, emitter = _a.emitter;
  7083. var dynamicOptionOverrides = reduceDynamicOptionOverrides(state.dynamicOptionOverrides, action);
  7084. var optionsData = this.computeOptionsData(props.optionOverrides, dynamicOptionOverrides, props.calendarApi);
  7085. var currentViewType = reduceViewType(state.currentViewType, action);
  7086. var currentViewData = this.computeCurrentViewData(currentViewType, optionsData, props.optionOverrides, dynamicOptionOverrides);
  7087. // wire things up
  7088. // TODO: not DRY
  7089. props.calendarApi.currentDataManager = this;
  7090. emitter.setThisContext(props.calendarApi);
  7091. emitter.setOptions(currentViewData.options);
  7092. var calendarContext = {
  7093. dateEnv: optionsData.dateEnv,
  7094. options: optionsData.calendarOptions,
  7095. pluginHooks: optionsData.pluginHooks,
  7096. calendarApi: props.calendarApi,
  7097. dispatch: this.dispatch,
  7098. emitter: emitter,
  7099. getCurrentData: this.getCurrentData,
  7100. };
  7101. var currentDate = state.currentDate, dateProfile = state.dateProfile;
  7102. if (this.data && this.data.dateProfileGenerator !== currentViewData.dateProfileGenerator) { // hack
  7103. dateProfile = currentViewData.dateProfileGenerator.build(currentDate);
  7104. }
  7105. currentDate = reduceCurrentDate(currentDate, action);
  7106. dateProfile = reduceDateProfile(dateProfile, action, currentDate, currentViewData.dateProfileGenerator);
  7107. if (action.type === 'PREV' || // TODO: move this logic into DateProfileGenerator
  7108. action.type === 'NEXT' || // "
  7109. !rangeContainsMarker(dateProfile.currentRange, currentDate)) {
  7110. currentDate = dateProfile.currentRange.start;
  7111. }
  7112. var eventSources = reduceEventSources(state.eventSources, action, dateProfile, calendarContext);
  7113. var eventStore = reduceEventStore(state.eventStore, action, eventSources, dateProfile, calendarContext);
  7114. var isEventsLoading = computeEventSourcesLoading(eventSources); // BAD. also called in this func in computeIsLoading
  7115. var renderableEventStore = (isEventsLoading && !currentViewData.options.progressiveEventRendering) ?
  7116. (state.renderableEventStore || eventStore) : // try from previous state
  7117. eventStore;
  7118. var _b = this.buildViewUiProps(calendarContext), eventUiSingleBase = _b.eventUiSingleBase, selectionConfig = _b.selectionConfig; // will memoize obj
  7119. var eventUiBySource = this.buildEventUiBySource(eventSources);
  7120. var eventUiBases = this.buildEventUiBases(renderableEventStore.defs, eventUiSingleBase, eventUiBySource);
  7121. var newState = {
  7122. dynamicOptionOverrides: dynamicOptionOverrides,
  7123. currentViewType: currentViewType,
  7124. currentDate: currentDate,
  7125. dateProfile: dateProfile,
  7126. eventSources: eventSources,
  7127. eventStore: eventStore,
  7128. renderableEventStore: renderableEventStore,
  7129. selectionConfig: selectionConfig,
  7130. eventUiBases: eventUiBases,
  7131. businessHours: this.parseContextBusinessHours(calendarContext),
  7132. dateSelection: reduceDateSelection(state.dateSelection, action),
  7133. eventSelection: reduceSelectedEvent(state.eventSelection, action),
  7134. eventDrag: reduceEventDrag(state.eventDrag, action),
  7135. eventResize: reduceEventResize(state.eventResize, action),
  7136. };
  7137. var contextAndState = __assign(__assign({}, calendarContext), newState);
  7138. for (var _i = 0, _c = optionsData.pluginHooks.reducers; _i < _c.length; _i++) {
  7139. var reducer = _c[_i];
  7140. __assign(newState, reducer(state, action, contextAndState)); // give the OLD state, for old value
  7141. }
  7142. var wasLoading = computeIsLoading(state, calendarContext);
  7143. var isLoading = computeIsLoading(newState, calendarContext);
  7144. // TODO: use propSetHandlers in plugin system
  7145. if (!wasLoading && isLoading) {
  7146. emitter.trigger('loading', true);
  7147. }
  7148. else if (wasLoading && !isLoading) {
  7149. emitter.trigger('loading', false);
  7150. }
  7151. this.state = newState;
  7152. if (props.onAction) {
  7153. props.onAction(action);
  7154. }
  7155. };
  7156. CalendarDataManager.prototype.updateData = function () {
  7157. var _a = this, props = _a.props, state = _a.state;
  7158. var oldData = this.data;
  7159. var optionsData = this.computeOptionsData(props.optionOverrides, state.dynamicOptionOverrides, props.calendarApi);
  7160. var currentViewData = this.computeCurrentViewData(state.currentViewType, optionsData, props.optionOverrides, state.dynamicOptionOverrides);
  7161. 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);
  7162. var changeHandlers = optionsData.pluginHooks.optionChangeHandlers;
  7163. var oldCalendarOptions = oldData && oldData.calendarOptions;
  7164. var newCalendarOptions = optionsData.calendarOptions;
  7165. if (oldCalendarOptions && oldCalendarOptions !== newCalendarOptions) {
  7166. if (oldCalendarOptions.timeZone !== newCalendarOptions.timeZone) {
  7167. // hack
  7168. state.eventSources = data.eventSources = reduceEventSourcesNewTimeZone(data.eventSources, state.dateProfile, data);
  7169. state.eventStore = data.eventStore = rezoneEventStoreDates(data.eventStore, oldData.dateEnv, data.dateEnv);
  7170. }
  7171. for (var optionName in changeHandlers) {
  7172. if (oldCalendarOptions[optionName] !== newCalendarOptions[optionName]) {
  7173. changeHandlers[optionName](newCalendarOptions[optionName], data);
  7174. }
  7175. }
  7176. }
  7177. if (props.onData) {
  7178. props.onData(data);
  7179. }
  7180. };
  7181. CalendarDataManager.prototype._computeOptionsData = function (optionOverrides, dynamicOptionOverrides, calendarApi) {
  7182. // TODO: blacklist options that are handled by optionChangeHandlers
  7183. var _a = this.processRawCalendarOptions(optionOverrides, dynamicOptionOverrides), refinedOptions = _a.refinedOptions, pluginHooks = _a.pluginHooks, localeDefaults = _a.localeDefaults, availableLocaleData = _a.availableLocaleData, extra = _a.extra;
  7184. warnUnknownOptions(extra);
  7185. var dateEnv = this.buildDateEnv(refinedOptions.timeZone, refinedOptions.locale, refinedOptions.weekNumberCalculation, refinedOptions.firstDay, refinedOptions.weekText, pluginHooks, availableLocaleData, refinedOptions.defaultRangeSeparator);
  7186. var viewSpecs = this.buildViewSpecs(pluginHooks.views, optionOverrides, dynamicOptionOverrides, localeDefaults);
  7187. var theme = this.buildTheme(refinedOptions, pluginHooks);
  7188. var toolbarConfig = this.parseToolbars(refinedOptions, optionOverrides, theme, viewSpecs, calendarApi);
  7189. return {
  7190. calendarOptions: refinedOptions,
  7191. pluginHooks: pluginHooks,
  7192. dateEnv: dateEnv,
  7193. viewSpecs: viewSpecs,
  7194. theme: theme,
  7195. toolbarConfig: toolbarConfig,
  7196. localeDefaults: localeDefaults,
  7197. availableRawLocales: availableLocaleData.map,
  7198. };
  7199. };
  7200. // always called from behind a memoizer
  7201. CalendarDataManager.prototype.processRawCalendarOptions = function (optionOverrides, dynamicOptionOverrides) {
  7202. var _a = mergeRawOptions([
  7203. BASE_OPTION_DEFAULTS,
  7204. optionOverrides,
  7205. dynamicOptionOverrides,
  7206. ]), locales = _a.locales, locale = _a.locale;
  7207. var availableLocaleData = this.organizeRawLocales(locales);
  7208. var availableRawLocales = availableLocaleData.map;
  7209. var localeDefaults = this.buildLocale(locale || availableLocaleData.defaultCode, availableRawLocales).options;
  7210. var pluginHooks = this.buildPluginHooks(optionOverrides.plugins || [], globalPlugins);
  7211. var refiners = this.currentCalendarOptionsRefiners = __assign(__assign(__assign(__assign(__assign({}, BASE_OPTION_REFINERS), CALENDAR_LISTENER_REFINERS), CALENDAR_OPTION_REFINERS), pluginHooks.listenerRefiners), pluginHooks.optionRefiners);
  7212. var extra = {};
  7213. var raw = mergeRawOptions([
  7214. BASE_OPTION_DEFAULTS,
  7215. localeDefaults,
  7216. optionOverrides,
  7217. dynamicOptionOverrides,
  7218. ]);
  7219. var refined = {};
  7220. var currentRaw = this.currentCalendarOptionsInput;
  7221. var currentRefined = this.currentCalendarOptionsRefined;
  7222. var anyChanges = false;
  7223. for (var optionName in raw) {
  7224. if (optionName !== 'plugins') { // because plugins is special-cased
  7225. if (raw[optionName] === currentRaw[optionName] ||
  7226. (COMPLEX_OPTION_COMPARATORS[optionName] &&
  7227. (optionName in currentRaw) &&
  7228. COMPLEX_OPTION_COMPARATORS[optionName](currentRaw[optionName], raw[optionName]))) {
  7229. refined[optionName] = currentRefined[optionName];
  7230. }
  7231. else if (refiners[optionName]) {
  7232. refined[optionName] = refiners[optionName](raw[optionName]);
  7233. anyChanges = true;
  7234. }
  7235. else {
  7236. extra[optionName] = currentRaw[optionName];
  7237. }
  7238. }
  7239. }
  7240. if (anyChanges) {
  7241. this.currentCalendarOptionsInput = raw;
  7242. this.currentCalendarOptionsRefined = refined;
  7243. }
  7244. return {
  7245. rawOptions: this.currentCalendarOptionsInput,
  7246. refinedOptions: this.currentCalendarOptionsRefined,
  7247. pluginHooks: pluginHooks,
  7248. availableLocaleData: availableLocaleData,
  7249. localeDefaults: localeDefaults,
  7250. extra: extra,
  7251. };
  7252. };
  7253. CalendarDataManager.prototype._computeCurrentViewData = function (viewType, optionsData, optionOverrides, dynamicOptionOverrides) {
  7254. var viewSpec = optionsData.viewSpecs[viewType];
  7255. if (!viewSpec) {
  7256. throw new Error("viewType \"" + viewType + "\" is not available. Please make sure you've loaded all neccessary plugins");
  7257. }
  7258. var _a = this.processRawViewOptions(viewSpec, optionsData.pluginHooks, optionsData.localeDefaults, optionOverrides, dynamicOptionOverrides), refinedOptions = _a.refinedOptions, extra = _a.extra;
  7259. warnUnknownOptions(extra);
  7260. var dateProfileGenerator = this.buildDateProfileGenerator({
  7261. dateProfileGeneratorClass: viewSpec.optionDefaults.dateProfileGeneratorClass,
  7262. duration: viewSpec.duration,
  7263. durationUnit: viewSpec.durationUnit,
  7264. usesMinMaxTime: viewSpec.optionDefaults.usesMinMaxTime,
  7265. dateEnv: optionsData.dateEnv,
  7266. calendarApi: this.props.calendarApi,
  7267. slotMinTime: refinedOptions.slotMinTime,
  7268. slotMaxTime: refinedOptions.slotMaxTime,
  7269. showNonCurrentDates: refinedOptions.showNonCurrentDates,
  7270. dayCount: refinedOptions.dayCount,
  7271. dateAlignment: refinedOptions.dateAlignment,
  7272. dateIncrement: refinedOptions.dateIncrement,
  7273. hiddenDays: refinedOptions.hiddenDays,
  7274. weekends: refinedOptions.weekends,
  7275. nowInput: refinedOptions.now,
  7276. validRangeInput: refinedOptions.validRange,
  7277. visibleRangeInput: refinedOptions.visibleRange,
  7278. monthMode: refinedOptions.monthMode,
  7279. fixedWeekCount: refinedOptions.fixedWeekCount,
  7280. });
  7281. var viewApi = this.buildViewApi(viewType, this.getCurrentData, optionsData.dateEnv);
  7282. return { viewSpec: viewSpec, options: refinedOptions, dateProfileGenerator: dateProfileGenerator, viewApi: viewApi };
  7283. };
  7284. CalendarDataManager.prototype.processRawViewOptions = function (viewSpec, pluginHooks, localeDefaults, optionOverrides, dynamicOptionOverrides) {
  7285. var raw = mergeRawOptions([
  7286. BASE_OPTION_DEFAULTS,
  7287. viewSpec.optionDefaults,
  7288. localeDefaults,
  7289. optionOverrides,
  7290. viewSpec.optionOverrides,
  7291. dynamicOptionOverrides,
  7292. ]);
  7293. var refiners = __assign(__assign(__assign(__assign(__assign(__assign({}, BASE_OPTION_REFINERS), CALENDAR_LISTENER_REFINERS), CALENDAR_OPTION_REFINERS), VIEW_OPTION_REFINERS), pluginHooks.listenerRefiners), pluginHooks.optionRefiners);
  7294. var refined = {};
  7295. var currentRaw = this.currentViewOptionsInput;
  7296. var currentRefined = this.currentViewOptionsRefined;
  7297. var anyChanges = false;
  7298. var extra = {};
  7299. for (var optionName in raw) {
  7300. if (raw[optionName] === currentRaw[optionName] ||
  7301. (COMPLEX_OPTION_COMPARATORS[optionName] &&
  7302. COMPLEX_OPTION_COMPARATORS[optionName](raw[optionName], currentRaw[optionName]))) {
  7303. refined[optionName] = currentRefined[optionName];
  7304. }
  7305. else {
  7306. if (raw[optionName] === this.currentCalendarOptionsInput[optionName] ||
  7307. (COMPLEX_OPTION_COMPARATORS[optionName] &&
  7308. COMPLEX_OPTION_COMPARATORS[optionName](raw[optionName], this.currentCalendarOptionsInput[optionName]))) {
  7309. if (optionName in this.currentCalendarOptionsRefined) { // might be an "extra" prop
  7310. refined[optionName] = this.currentCalendarOptionsRefined[optionName];
  7311. }
  7312. }
  7313. else if (refiners[optionName]) {
  7314. refined[optionName] = refiners[optionName](raw[optionName]);
  7315. }
  7316. else {
  7317. extra[optionName] = raw[optionName];
  7318. }
  7319. anyChanges = true;
  7320. }
  7321. }
  7322. if (anyChanges) {
  7323. this.currentViewOptionsInput = raw;
  7324. this.currentViewOptionsRefined = refined;
  7325. }
  7326. return {
  7327. rawOptions: this.currentViewOptionsInput,
  7328. refinedOptions: this.currentViewOptionsRefined,
  7329. extra: extra,
  7330. };
  7331. };
  7332. return CalendarDataManager;
  7333. }());
  7334. function buildDateEnv(timeZone, explicitLocale, weekNumberCalculation, firstDay, weekText, pluginHooks, availableLocaleData, defaultSeparator) {
  7335. var locale = buildLocale(explicitLocale || availableLocaleData.defaultCode, availableLocaleData.map);
  7336. return new DateEnv({
  7337. calendarSystem: 'gregory',
  7338. timeZone: timeZone,
  7339. namedTimeZoneImpl: pluginHooks.namedTimeZonedImpl,
  7340. locale: locale,
  7341. weekNumberCalculation: weekNumberCalculation,
  7342. firstDay: firstDay,
  7343. weekText: weekText,
  7344. cmdFormatter: pluginHooks.cmdFormatter,
  7345. defaultSeparator: defaultSeparator,
  7346. });
  7347. }
  7348. function buildTheme(options, pluginHooks) {
  7349. var ThemeClass = pluginHooks.themeClasses[options.themeSystem] || StandardTheme;
  7350. return new ThemeClass(options);
  7351. }
  7352. function buildDateProfileGenerator(props) {
  7353. var DateProfileGeneratorClass = props.dateProfileGeneratorClass || DateProfileGenerator;
  7354. return new DateProfileGeneratorClass(props);
  7355. }
  7356. function buildViewApi(type, getCurrentData, dateEnv) {
  7357. return new ViewApi(type, getCurrentData, dateEnv);
  7358. }
  7359. function buildEventUiBySource(eventSources) {
  7360. return mapHash(eventSources, function (eventSource) { return eventSource.ui; });
  7361. }
  7362. function buildEventUiBases(eventDefs, eventUiSingleBase, eventUiBySource) {
  7363. var eventUiBases = { '': eventUiSingleBase };
  7364. for (var defId in eventDefs) {
  7365. var def = eventDefs[defId];
  7366. if (def.sourceId && eventUiBySource[def.sourceId]) {
  7367. eventUiBases[defId] = eventUiBySource[def.sourceId];
  7368. }
  7369. }
  7370. return eventUiBases;
  7371. }
  7372. function buildViewUiProps(calendarContext) {
  7373. var options = calendarContext.options;
  7374. return {
  7375. eventUiSingleBase: createEventUi({
  7376. display: options.eventDisplay,
  7377. editable: options.editable,
  7378. startEditable: options.eventStartEditable,
  7379. durationEditable: options.eventDurationEditable,
  7380. constraint: options.eventConstraint,
  7381. overlap: typeof options.eventOverlap === 'boolean' ? options.eventOverlap : undefined,
  7382. allow: options.eventAllow,
  7383. backgroundColor: options.eventBackgroundColor,
  7384. borderColor: options.eventBorderColor,
  7385. textColor: options.eventTextColor,
  7386. color: options.eventColor,
  7387. // classNames: options.eventClassNames // render hook will handle this
  7388. }, calendarContext),
  7389. selectionConfig: createEventUi({
  7390. constraint: options.selectConstraint,
  7391. overlap: typeof options.selectOverlap === 'boolean' ? options.selectOverlap : undefined,
  7392. allow: options.selectAllow,
  7393. }, calendarContext),
  7394. };
  7395. }
  7396. function computeIsLoading(state, context) {
  7397. for (var _i = 0, _a = context.pluginHooks.isLoadingFuncs; _i < _a.length; _i++) {
  7398. var isLoadingFunc = _a[_i];
  7399. if (isLoadingFunc(state)) {
  7400. return true;
  7401. }
  7402. }
  7403. return false;
  7404. }
  7405. function parseContextBusinessHours(calendarContext) {
  7406. return parseBusinessHours(calendarContext.options.businessHours, calendarContext);
  7407. }
  7408. function warnUnknownOptions(options, viewName) {
  7409. for (var optionName in options) {
  7410. console.warn("Unknown option '" + optionName + "'" +
  7411. (viewName ? " for view '" + viewName + "'" : ''));
  7412. }
  7413. }
  7414. // TODO: move this to react plugin?
  7415. var CalendarDataProvider = /** @class */ (function (_super) {
  7416. __extends(CalendarDataProvider, _super);
  7417. function CalendarDataProvider(props) {
  7418. var _this = _super.call(this, props) || this;
  7419. _this.handleData = function (data) {
  7420. if (!_this.dataManager) { // still within initial run, before assignment in constructor
  7421. // eslint-disable-next-line react/no-direct-mutation-state
  7422. _this.state = data; // can't use setState yet
  7423. }
  7424. else {
  7425. _this.setState(data);
  7426. }
  7427. };
  7428. _this.dataManager = new CalendarDataManager({
  7429. optionOverrides: props.optionOverrides,
  7430. calendarApi: props.calendarApi,
  7431. onData: _this.handleData,
  7432. });
  7433. return _this;
  7434. }
  7435. CalendarDataProvider.prototype.render = function () {
  7436. return this.props.children(this.state);
  7437. };
  7438. CalendarDataProvider.prototype.componentDidUpdate = function (prevProps) {
  7439. var newOptionOverrides = this.props.optionOverrides;
  7440. if (newOptionOverrides !== prevProps.optionOverrides) { // prevent recursive handleData
  7441. this.dataManager.resetOptions(newOptionOverrides);
  7442. }
  7443. };
  7444. return CalendarDataProvider;
  7445. }(Component));
  7446. // HELPERS
  7447. /*
  7448. if nextDayThreshold is specified, slicing is done in an all-day fashion.
  7449. you can get nextDayThreshold from context.nextDayThreshold
  7450. */
  7451. function sliceEvents(props, allDay) {
  7452. return sliceEventStore(props.eventStore, props.eventUiBases, props.dateProfile.activeRange, allDay ? props.nextDayThreshold : null).fg;
  7453. }
  7454. var NamedTimeZoneImpl = /** @class */ (function () {
  7455. function NamedTimeZoneImpl(timeZoneName) {
  7456. this.timeZoneName = timeZoneName;
  7457. }
  7458. return NamedTimeZoneImpl;
  7459. }());
  7460. var SegHierarchy = /** @class */ (function () {
  7461. function SegHierarchy() {
  7462. // settings
  7463. this.strictOrder = false;
  7464. this.allowReslicing = false;
  7465. this.maxCoord = -1; // -1 means no max
  7466. this.maxStackCnt = -1; // -1 means no max
  7467. this.levelCoords = []; // ordered
  7468. this.entriesByLevel = []; // parallel with levelCoords
  7469. this.stackCnts = {}; // TODO: use better technique!?
  7470. }
  7471. SegHierarchy.prototype.addSegs = function (inputs) {
  7472. var hiddenEntries = [];
  7473. for (var _i = 0, inputs_1 = inputs; _i < inputs_1.length; _i++) {
  7474. var input = inputs_1[_i];
  7475. this.insertEntry(input, hiddenEntries);
  7476. }
  7477. return hiddenEntries;
  7478. };
  7479. SegHierarchy.prototype.insertEntry = function (entry, hiddenEntries) {
  7480. var insertion = this.findInsertion(entry);
  7481. if (this.isInsertionValid(insertion, entry)) {
  7482. this.insertEntryAt(entry, insertion);
  7483. return 1;
  7484. }
  7485. return this.handleInvalidInsertion(insertion, entry, hiddenEntries);
  7486. };
  7487. SegHierarchy.prototype.isInsertionValid = function (insertion, entry) {
  7488. return (this.maxCoord === -1 || insertion.levelCoord + entry.thickness <= this.maxCoord) &&
  7489. (this.maxStackCnt === -1 || insertion.stackCnt < this.maxStackCnt);
  7490. };
  7491. // returns number of new entries inserted
  7492. SegHierarchy.prototype.handleInvalidInsertion = function (insertion, entry, hiddenEntries) {
  7493. if (this.allowReslicing && insertion.touchingEntry) {
  7494. return this.splitEntry(entry, insertion.touchingEntry, hiddenEntries);
  7495. }
  7496. hiddenEntries.push(entry);
  7497. return 0;
  7498. };
  7499. SegHierarchy.prototype.splitEntry = function (entry, barrier, hiddenEntries) {
  7500. var partCnt = 0;
  7501. var splitHiddenEntries = [];
  7502. var entrySpan = entry.span;
  7503. var barrierSpan = barrier.span;
  7504. if (entrySpan.start < barrierSpan.start) {
  7505. partCnt += this.insertEntry({
  7506. index: entry.index,
  7507. thickness: entry.thickness,
  7508. span: { start: entrySpan.start, end: barrierSpan.start },
  7509. }, splitHiddenEntries);
  7510. }
  7511. if (entrySpan.end > barrierSpan.end) {
  7512. partCnt += this.insertEntry({
  7513. index: entry.index,
  7514. thickness: entry.thickness,
  7515. span: { start: barrierSpan.end, end: entrySpan.end },
  7516. }, splitHiddenEntries);
  7517. }
  7518. if (partCnt) {
  7519. hiddenEntries.push.apply(hiddenEntries, __spreadArray([{
  7520. index: entry.index,
  7521. thickness: entry.thickness,
  7522. span: intersectSpans(barrierSpan, entrySpan), // guaranteed to intersect
  7523. }], splitHiddenEntries));
  7524. return partCnt;
  7525. }
  7526. hiddenEntries.push(entry);
  7527. return 0;
  7528. };
  7529. SegHierarchy.prototype.insertEntryAt = function (entry, insertion) {
  7530. var _a = this, entriesByLevel = _a.entriesByLevel, levelCoords = _a.levelCoords;
  7531. if (insertion.lateral === -1) {
  7532. // create a new level
  7533. insertAt(levelCoords, insertion.level, insertion.levelCoord);
  7534. insertAt(entriesByLevel, insertion.level, [entry]);
  7535. }
  7536. else {
  7537. // insert into existing level
  7538. insertAt(entriesByLevel[insertion.level], insertion.lateral, entry);
  7539. }
  7540. this.stackCnts[buildEntryKey(entry)] = insertion.stackCnt;
  7541. };
  7542. SegHierarchy.prototype.findInsertion = function (newEntry) {
  7543. var _a = this, levelCoords = _a.levelCoords, entriesByLevel = _a.entriesByLevel, strictOrder = _a.strictOrder, stackCnts = _a.stackCnts;
  7544. var levelCnt = levelCoords.length;
  7545. var candidateCoord = 0;
  7546. var touchingLevel = -1;
  7547. var touchingLateral = -1;
  7548. var touchingEntry = null;
  7549. var stackCnt = 0;
  7550. for (var trackingLevel = 0; trackingLevel < levelCnt; trackingLevel += 1) {
  7551. var trackingCoord = levelCoords[trackingLevel];
  7552. // if the current level is past the placed entry, we have found a good empty space and can stop.
  7553. // if strictOrder, keep finding more lateral intersections.
  7554. if (!strictOrder && trackingCoord >= candidateCoord + newEntry.thickness) {
  7555. break;
  7556. }
  7557. var trackingEntries = entriesByLevel[trackingLevel];
  7558. var trackingEntry = void 0;
  7559. var searchRes = binarySearch(trackingEntries, newEntry.span.start, getEntrySpanEnd); // find first entry after newEntry's end
  7560. var lateralIndex = searchRes[0] + searchRes[1]; // if exact match (which doesn't collide), go to next one
  7561. while ( // loop through entries that horizontally intersect
  7562. (trackingEntry = trackingEntries[lateralIndex]) && // but not past the whole entry list
  7563. trackingEntry.span.start < newEntry.span.end // and not entirely past newEntry
  7564. ) {
  7565. var trackingEntryBottom = trackingCoord + trackingEntry.thickness;
  7566. // intersects into the top of the candidate?
  7567. if (trackingEntryBottom > candidateCoord) {
  7568. candidateCoord = trackingEntryBottom;
  7569. touchingEntry = trackingEntry;
  7570. touchingLevel = trackingLevel;
  7571. touchingLateral = lateralIndex;
  7572. }
  7573. // butts up against top of candidate? (will happen if just intersected as well)
  7574. if (trackingEntryBottom === candidateCoord) {
  7575. // accumulate the highest possible stackCnt of the trackingEntries that butt up
  7576. stackCnt = Math.max(stackCnt, stackCnts[buildEntryKey(trackingEntry)] + 1);
  7577. }
  7578. lateralIndex += 1;
  7579. }
  7580. }
  7581. // the destination level will be after touchingEntry's level. find it
  7582. var destLevel = 0;
  7583. if (touchingEntry) {
  7584. destLevel = touchingLevel + 1;
  7585. while (destLevel < levelCnt && levelCoords[destLevel] < candidateCoord) {
  7586. destLevel += 1;
  7587. }
  7588. }
  7589. // if adding to an existing level, find where to insert
  7590. var destLateral = -1;
  7591. if (destLevel < levelCnt && levelCoords[destLevel] === candidateCoord) {
  7592. destLateral = binarySearch(entriesByLevel[destLevel], newEntry.span.end, getEntrySpanEnd)[0];
  7593. }
  7594. return {
  7595. touchingLevel: touchingLevel,
  7596. touchingLateral: touchingLateral,
  7597. touchingEntry: touchingEntry,
  7598. stackCnt: stackCnt,
  7599. levelCoord: candidateCoord,
  7600. level: destLevel,
  7601. lateral: destLateral,
  7602. };
  7603. };
  7604. // sorted by levelCoord (lowest to highest)
  7605. SegHierarchy.prototype.toRects = function () {
  7606. var _a = this, entriesByLevel = _a.entriesByLevel, levelCoords = _a.levelCoords;
  7607. var levelCnt = entriesByLevel.length;
  7608. var rects = [];
  7609. for (var level = 0; level < levelCnt; level += 1) {
  7610. var entries = entriesByLevel[level];
  7611. var levelCoord = levelCoords[level];
  7612. for (var _i = 0, entries_1 = entries; _i < entries_1.length; _i++) {
  7613. var entry = entries_1[_i];
  7614. rects.push(__assign(__assign({}, entry), { levelCoord: levelCoord }));
  7615. }
  7616. }
  7617. return rects;
  7618. };
  7619. return SegHierarchy;
  7620. }());
  7621. function getEntrySpanEnd(entry) {
  7622. return entry.span.end;
  7623. }
  7624. function buildEntryKey(entry) {
  7625. return entry.index + ':' + entry.span.start;
  7626. }
  7627. // returns groups with entries sorted by input order
  7628. function groupIntersectingEntries(entries) {
  7629. var merges = [];
  7630. for (var _i = 0, entries_2 = entries; _i < entries_2.length; _i++) {
  7631. var entry = entries_2[_i];
  7632. var filteredMerges = [];
  7633. var hungryMerge = {
  7634. span: entry.span,
  7635. entries: [entry],
  7636. };
  7637. for (var _a = 0, merges_1 = merges; _a < merges_1.length; _a++) {
  7638. var merge = merges_1[_a];
  7639. if (intersectSpans(merge.span, hungryMerge.span)) {
  7640. hungryMerge = {
  7641. entries: merge.entries.concat(hungryMerge.entries),
  7642. span: joinSpans(merge.span, hungryMerge.span),
  7643. };
  7644. }
  7645. else {
  7646. filteredMerges.push(merge);
  7647. }
  7648. }
  7649. filteredMerges.push(hungryMerge);
  7650. merges = filteredMerges;
  7651. }
  7652. return merges;
  7653. }
  7654. function joinSpans(span0, span1) {
  7655. return {
  7656. start: Math.min(span0.start, span1.start),
  7657. end: Math.max(span0.end, span1.end),
  7658. };
  7659. }
  7660. function intersectSpans(span0, span1) {
  7661. var start = Math.max(span0.start, span1.start);
  7662. var end = Math.min(span0.end, span1.end);
  7663. if (start < end) {
  7664. return { start: start, end: end };
  7665. }
  7666. return null;
  7667. }
  7668. // general util
  7669. // ---------------------------------------------------------------------------------------------------------------------
  7670. function insertAt(arr, index, item) {
  7671. arr.splice(index, 0, item);
  7672. }
  7673. function binarySearch(a, searchVal, getItemVal) {
  7674. var startIndex = 0;
  7675. var endIndex = a.length; // exclusive
  7676. if (!endIndex || searchVal < getItemVal(a[startIndex])) { // no items OR before first item
  7677. return [0, 0];
  7678. }
  7679. if (searchVal > getItemVal(a[endIndex - 1])) { // after last item
  7680. return [endIndex, 0];
  7681. }
  7682. while (startIndex < endIndex) {
  7683. var middleIndex = Math.floor(startIndex + (endIndex - startIndex) / 2);
  7684. var middleVal = getItemVal(a[middleIndex]);
  7685. if (searchVal < middleVal) {
  7686. endIndex = middleIndex;
  7687. }
  7688. else if (searchVal > middleVal) {
  7689. startIndex = middleIndex + 1;
  7690. }
  7691. else { // equal!
  7692. return [middleIndex, 1];
  7693. }
  7694. }
  7695. return [startIndex, 0];
  7696. }
  7697. var Interaction = /** @class */ (function () {
  7698. function Interaction(settings) {
  7699. this.component = settings.component;
  7700. this.isHitComboAllowed = settings.isHitComboAllowed || null;
  7701. }
  7702. Interaction.prototype.destroy = function () {
  7703. };
  7704. return Interaction;
  7705. }());
  7706. function parseInteractionSettings(component, input) {
  7707. return {
  7708. component: component,
  7709. el: input.el,
  7710. useEventCenter: input.useEventCenter != null ? input.useEventCenter : true,
  7711. isHitComboAllowed: input.isHitComboAllowed || null,
  7712. };
  7713. }
  7714. function interactionSettingsToStore(settings) {
  7715. var _a;
  7716. return _a = {},
  7717. _a[settings.component.uid] = settings,
  7718. _a;
  7719. }
  7720. // global state
  7721. var interactionSettingsStore = {};
  7722. /*
  7723. An abstraction for a dragging interaction originating on an event.
  7724. Does higher-level things than PointerDragger, such as possibly:
  7725. - a "mirror" that moves with the pointer
  7726. - a minimum number of pixels or other criteria for a true drag to begin
  7727. subclasses must emit:
  7728. - pointerdown
  7729. - dragstart
  7730. - dragmove
  7731. - pointerup
  7732. - dragend
  7733. */
  7734. var ElementDragging = /** @class */ (function () {
  7735. function ElementDragging(el, selector) {
  7736. this.emitter = new Emitter();
  7737. }
  7738. ElementDragging.prototype.destroy = function () {
  7739. };
  7740. ElementDragging.prototype.setMirrorIsVisible = function (bool) {
  7741. // optional if subclass doesn't want to support a mirror
  7742. };
  7743. ElementDragging.prototype.setMirrorNeedsRevert = function (bool) {
  7744. // optional if subclass doesn't want to support a mirror
  7745. };
  7746. ElementDragging.prototype.setAutoScrollEnabled = function (bool) {
  7747. // optional
  7748. };
  7749. return ElementDragging;
  7750. }());
  7751. // TODO: get rid of this in favor of options system,
  7752. // tho it's really easy to access this globally rather than pass thru options.
  7753. var config = {};
  7754. /*
  7755. Information about what will happen when an external element is dragged-and-dropped
  7756. onto a calendar. Contains information for creating an event.
  7757. */
  7758. var DRAG_META_REFINERS = {
  7759. startTime: createDuration,
  7760. duration: createDuration,
  7761. create: Boolean,
  7762. sourceId: String,
  7763. };
  7764. function parseDragMeta(raw) {
  7765. var _a = refineProps(raw, DRAG_META_REFINERS), refined = _a.refined, extra = _a.extra;
  7766. return {
  7767. startTime: refined.startTime || null,
  7768. duration: refined.duration || null,
  7769. create: refined.create != null ? refined.create : true,
  7770. sourceId: refined.sourceId,
  7771. leftoverProps: extra,
  7772. };
  7773. }
  7774. var ToolbarSection = /** @class */ (function (_super) {
  7775. __extends(ToolbarSection, _super);
  7776. function ToolbarSection() {
  7777. return _super !== null && _super.apply(this, arguments) || this;
  7778. }
  7779. ToolbarSection.prototype.render = function () {
  7780. var _this = this;
  7781. var children = this.props.widgetGroups.map(function (widgetGroup) { return _this.renderWidgetGroup(widgetGroup); });
  7782. return createElement.apply(void 0, __spreadArray(['div', { className: 'fc-toolbar-chunk' }], children));
  7783. };
  7784. ToolbarSection.prototype.renderWidgetGroup = function (widgetGroup) {
  7785. var props = this.props;
  7786. var theme = this.context.theme;
  7787. var children = [];
  7788. var isOnlyButtons = true;
  7789. for (var _i = 0, widgetGroup_1 = widgetGroup; _i < widgetGroup_1.length; _i++) {
  7790. var widget = widgetGroup_1[_i];
  7791. var buttonName = widget.buttonName, buttonClick = widget.buttonClick, buttonText = widget.buttonText, buttonIcon = widget.buttonIcon, buttonHint = widget.buttonHint;
  7792. if (buttonName === 'title') {
  7793. isOnlyButtons = false;
  7794. children.push(createElement("h2", { className: "fc-toolbar-title", id: props.titleId }, props.title));
  7795. }
  7796. else {
  7797. var isPressed = buttonName === props.activeButton;
  7798. var isDisabled = (!props.isTodayEnabled && buttonName === 'today') ||
  7799. (!props.isPrevEnabled && buttonName === 'prev') ||
  7800. (!props.isNextEnabled && buttonName === 'next');
  7801. var buttonClasses = ["fc-" + buttonName + "-button", theme.getClass('button')];
  7802. if (isPressed) {
  7803. buttonClasses.push(theme.getClass('buttonActive'));
  7804. }
  7805. children.push(createElement("button", { type: "button", title: typeof buttonHint === 'function' ? buttonHint(props.navUnit) : buttonHint, disabled: isDisabled, "aria-pressed": isPressed, className: buttonClasses.join(' '), onClick: buttonClick }, buttonText || (buttonIcon ? createElement("span", { className: buttonIcon }) : '')));
  7806. }
  7807. }
  7808. if (children.length > 1) {
  7809. var groupClassName = (isOnlyButtons && theme.getClass('buttonGroup')) || '';
  7810. return createElement.apply(void 0, __spreadArray(['div', { className: groupClassName }], children));
  7811. }
  7812. return children[0];
  7813. };
  7814. return ToolbarSection;
  7815. }(BaseComponent));
  7816. var Toolbar = /** @class */ (function (_super) {
  7817. __extends(Toolbar, _super);
  7818. function Toolbar() {
  7819. return _super !== null && _super.apply(this, arguments) || this;
  7820. }
  7821. Toolbar.prototype.render = function () {
  7822. var _a = this.props, model = _a.model, extraClassName = _a.extraClassName;
  7823. var forceLtr = false;
  7824. var startContent;
  7825. var endContent;
  7826. var sectionWidgets = model.sectionWidgets;
  7827. var centerContent = sectionWidgets.center;
  7828. if (sectionWidgets.left) {
  7829. forceLtr = true;
  7830. startContent = sectionWidgets.left;
  7831. }
  7832. else {
  7833. startContent = sectionWidgets.start;
  7834. }
  7835. if (sectionWidgets.right) {
  7836. forceLtr = true;
  7837. endContent = sectionWidgets.right;
  7838. }
  7839. else {
  7840. endContent = sectionWidgets.end;
  7841. }
  7842. var classNames = [
  7843. extraClassName || '',
  7844. 'fc-toolbar',
  7845. forceLtr ? 'fc-toolbar-ltr' : '',
  7846. ];
  7847. return (createElement("div", { className: classNames.join(' ') },
  7848. this.renderSection('start', startContent || []),
  7849. this.renderSection('center', centerContent || []),
  7850. this.renderSection('end', endContent || [])));
  7851. };
  7852. Toolbar.prototype.renderSection = function (key, widgetGroups) {
  7853. var props = this.props;
  7854. return (createElement(ToolbarSection, { key: key, widgetGroups: widgetGroups, title: props.title, navUnit: props.navUnit, activeButton: props.activeButton, isTodayEnabled: props.isTodayEnabled, isPrevEnabled: props.isPrevEnabled, isNextEnabled: props.isNextEnabled, titleId: props.titleId }));
  7855. };
  7856. return Toolbar;
  7857. }(BaseComponent));
  7858. // TODO: do function component?
  7859. var ViewContainer = /** @class */ (function (_super) {
  7860. __extends(ViewContainer, _super);
  7861. function ViewContainer() {
  7862. var _this = _super !== null && _super.apply(this, arguments) || this;
  7863. _this.state = {
  7864. availableWidth: null,
  7865. };
  7866. _this.handleEl = function (el) {
  7867. _this.el = el;
  7868. setRef(_this.props.elRef, el);
  7869. _this.updateAvailableWidth();
  7870. };
  7871. _this.handleResize = function () {
  7872. _this.updateAvailableWidth();
  7873. };
  7874. return _this;
  7875. }
  7876. ViewContainer.prototype.render = function () {
  7877. var _a = this, props = _a.props, state = _a.state;
  7878. var aspectRatio = props.aspectRatio;
  7879. var classNames = [
  7880. 'fc-view-harness',
  7881. (aspectRatio || props.liquid || props.height)
  7882. ? 'fc-view-harness-active' // harness controls the height
  7883. : 'fc-view-harness-passive', // let the view do the height
  7884. ];
  7885. var height = '';
  7886. var paddingBottom = '';
  7887. if (aspectRatio) {
  7888. if (state.availableWidth !== null) {
  7889. height = state.availableWidth / aspectRatio;
  7890. }
  7891. else {
  7892. // while waiting to know availableWidth, we can't set height to *zero*
  7893. // because will cause lots of unnecessary scrollbars within scrollgrid.
  7894. // BETTER: don't start rendering ANYTHING yet until we know container width
  7895. // NOTE: why not always use paddingBottom? Causes height oscillation (issue 5606)
  7896. paddingBottom = (1 / aspectRatio) * 100 + "%";
  7897. }
  7898. }
  7899. else {
  7900. height = props.height || '';
  7901. }
  7902. return (createElement("div", { "aria-labelledby": props.labeledById, ref: this.handleEl, className: classNames.join(' '), style: { height: height, paddingBottom: paddingBottom } }, props.children));
  7903. };
  7904. ViewContainer.prototype.componentDidMount = function () {
  7905. this.context.addResizeHandler(this.handleResize);
  7906. };
  7907. ViewContainer.prototype.componentWillUnmount = function () {
  7908. this.context.removeResizeHandler(this.handleResize);
  7909. };
  7910. ViewContainer.prototype.updateAvailableWidth = function () {
  7911. if (this.el && // needed. but why?
  7912. this.props.aspectRatio // aspectRatio is the only height setting that needs availableWidth
  7913. ) {
  7914. this.setState({ availableWidth: this.el.offsetWidth });
  7915. }
  7916. };
  7917. return ViewContainer;
  7918. }(BaseComponent));
  7919. /*
  7920. Detects when the user clicks on an event within a DateComponent
  7921. */
  7922. var EventClicking = /** @class */ (function (_super) {
  7923. __extends(EventClicking, _super);
  7924. function EventClicking(settings) {
  7925. var _this = _super.call(this, settings) || this;
  7926. _this.handleSegClick = function (ev, segEl) {
  7927. var component = _this.component;
  7928. var context = component.context;
  7929. var seg = getElSeg(segEl);
  7930. if (seg && // might be the <div> surrounding the more link
  7931. component.isValidSegDownEl(ev.target)) {
  7932. // our way to simulate a link click for elements that can't be <a> tags
  7933. // grab before trigger fired in case trigger trashes DOM thru rerendering
  7934. var hasUrlContainer = elementClosest(ev.target, '.fc-event-forced-url');
  7935. var url = hasUrlContainer ? hasUrlContainer.querySelector('a[href]').href : '';
  7936. context.emitter.trigger('eventClick', {
  7937. el: segEl,
  7938. event: new EventApi(component.context, seg.eventRange.def, seg.eventRange.instance),
  7939. jsEvent: ev,
  7940. view: context.viewApi,
  7941. });
  7942. if (url && !ev.defaultPrevented) {
  7943. window.location.href = url;
  7944. }
  7945. }
  7946. };
  7947. _this.destroy = listenBySelector(settings.el, 'click', '.fc-event', // on both fg and bg events
  7948. _this.handleSegClick);
  7949. return _this;
  7950. }
  7951. return EventClicking;
  7952. }(Interaction));
  7953. /*
  7954. Triggers events and adds/removes core classNames when the user's pointer
  7955. enters/leaves event-elements of a component.
  7956. */
  7957. var EventHovering = /** @class */ (function (_super) {
  7958. __extends(EventHovering, _super);
  7959. function EventHovering(settings) {
  7960. var _this = _super.call(this, settings) || this;
  7961. // for simulating an eventMouseLeave when the event el is destroyed while mouse is over it
  7962. _this.handleEventElRemove = function (el) {
  7963. if (el === _this.currentSegEl) {
  7964. _this.handleSegLeave(null, _this.currentSegEl);
  7965. }
  7966. };
  7967. _this.handleSegEnter = function (ev, segEl) {
  7968. if (getElSeg(segEl)) { // TODO: better way to make sure not hovering over more+ link or its wrapper
  7969. _this.currentSegEl = segEl;
  7970. _this.triggerEvent('eventMouseEnter', ev, segEl);
  7971. }
  7972. };
  7973. _this.handleSegLeave = function (ev, segEl) {
  7974. if (_this.currentSegEl) {
  7975. _this.currentSegEl = null;
  7976. _this.triggerEvent('eventMouseLeave', ev, segEl);
  7977. }
  7978. };
  7979. _this.removeHoverListeners = listenToHoverBySelector(settings.el, '.fc-event', // on both fg and bg events
  7980. _this.handleSegEnter, _this.handleSegLeave);
  7981. return _this;
  7982. }
  7983. EventHovering.prototype.destroy = function () {
  7984. this.removeHoverListeners();
  7985. };
  7986. EventHovering.prototype.triggerEvent = function (publicEvName, ev, segEl) {
  7987. var component = this.component;
  7988. var context = component.context;
  7989. var seg = getElSeg(segEl);
  7990. if (!ev || component.isValidSegDownEl(ev.target)) {
  7991. context.emitter.trigger(publicEvName, {
  7992. el: segEl,
  7993. event: new EventApi(context, seg.eventRange.def, seg.eventRange.instance),
  7994. jsEvent: ev,
  7995. view: context.viewApi,
  7996. });
  7997. }
  7998. };
  7999. return EventHovering;
  8000. }(Interaction));
  8001. var CalendarContent = /** @class */ (function (_super) {
  8002. __extends(CalendarContent, _super);
  8003. function CalendarContent() {
  8004. var _this = _super !== null && _super.apply(this, arguments) || this;
  8005. _this.buildViewContext = memoize(buildViewContext);
  8006. _this.buildViewPropTransformers = memoize(buildViewPropTransformers);
  8007. _this.buildToolbarProps = memoize(buildToolbarProps);
  8008. _this.headerRef = createRef();
  8009. _this.footerRef = createRef();
  8010. _this.interactionsStore = {};
  8011. // eslint-disable-next-line
  8012. _this.state = {
  8013. viewLabelId: getUniqueDomId(),
  8014. };
  8015. // Component Registration
  8016. // -----------------------------------------------------------------------------------------------------------------
  8017. _this.registerInteractiveComponent = function (component, settingsInput) {
  8018. var settings = parseInteractionSettings(component, settingsInput);
  8019. var DEFAULT_INTERACTIONS = [
  8020. EventClicking,
  8021. EventHovering,
  8022. ];
  8023. var interactionClasses = DEFAULT_INTERACTIONS.concat(_this.props.pluginHooks.componentInteractions);
  8024. var interactions = interactionClasses.map(function (TheInteractionClass) { return new TheInteractionClass(settings); });
  8025. _this.interactionsStore[component.uid] = interactions;
  8026. interactionSettingsStore[component.uid] = settings;
  8027. };
  8028. _this.unregisterInteractiveComponent = function (component) {
  8029. var listeners = _this.interactionsStore[component.uid];
  8030. if (listeners) {
  8031. for (var _i = 0, listeners_1 = listeners; _i < listeners_1.length; _i++) {
  8032. var listener = listeners_1[_i];
  8033. listener.destroy();
  8034. }
  8035. delete _this.interactionsStore[component.uid];
  8036. }
  8037. delete interactionSettingsStore[component.uid];
  8038. };
  8039. // Resizing
  8040. // -----------------------------------------------------------------------------------------------------------------
  8041. _this.resizeRunner = new DelayedRunner(function () {
  8042. _this.props.emitter.trigger('_resize', true); // should window resizes be considered "forced" ?
  8043. _this.props.emitter.trigger('windowResize', { view: _this.props.viewApi });
  8044. });
  8045. _this.handleWindowResize = function (ev) {
  8046. var options = _this.props.options;
  8047. if (options.handleWindowResize &&
  8048. ev.target === window // avoid jqui events
  8049. ) {
  8050. _this.resizeRunner.request(options.windowResizeDelay);
  8051. }
  8052. };
  8053. return _this;
  8054. }
  8055. /*
  8056. renders INSIDE of an outer div
  8057. */
  8058. CalendarContent.prototype.render = function () {
  8059. var props = this.props;
  8060. var toolbarConfig = props.toolbarConfig, options = props.options;
  8061. var toolbarProps = this.buildToolbarProps(props.viewSpec, props.dateProfile, props.dateProfileGenerator, props.currentDate, getNow(props.options.now, props.dateEnv), // TODO: use NowTimer????
  8062. props.viewTitle);
  8063. var viewVGrow = false;
  8064. var viewHeight = '';
  8065. var viewAspectRatio;
  8066. if (props.isHeightAuto || props.forPrint) {
  8067. viewHeight = '';
  8068. }
  8069. else if (options.height != null) {
  8070. viewVGrow = true;
  8071. }
  8072. else if (options.contentHeight != null) {
  8073. viewHeight = options.contentHeight;
  8074. }
  8075. else {
  8076. viewAspectRatio = Math.max(options.aspectRatio, 0.5); // prevent from getting too tall
  8077. }
  8078. 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);
  8079. var viewLabelId = (toolbarConfig.header && toolbarConfig.header.hasTitle)
  8080. ? this.state.viewLabelId
  8081. : '';
  8082. return (createElement(ViewContextType.Provider, { value: viewContext },
  8083. toolbarConfig.header && (createElement(Toolbar, __assign({ ref: this.headerRef, extraClassName: "fc-header-toolbar", model: toolbarConfig.header, titleId: viewLabelId }, toolbarProps))),
  8084. createElement(ViewContainer, { liquid: viewVGrow, height: viewHeight, aspectRatio: viewAspectRatio, labeledById: viewLabelId },
  8085. this.renderView(props),
  8086. this.buildAppendContent()),
  8087. toolbarConfig.footer && (createElement(Toolbar, __assign({ ref: this.footerRef, extraClassName: "fc-footer-toolbar", model: toolbarConfig.footer, titleId: "" }, toolbarProps)))));
  8088. };
  8089. CalendarContent.prototype.componentDidMount = function () {
  8090. var props = this.props;
  8091. this.calendarInteractions = props.pluginHooks.calendarInteractions
  8092. .map(function (CalendarInteractionClass) { return new CalendarInteractionClass(props); });
  8093. window.addEventListener('resize', this.handleWindowResize);
  8094. var propSetHandlers = props.pluginHooks.propSetHandlers;
  8095. for (var propName in propSetHandlers) {
  8096. propSetHandlers[propName](props[propName], props);
  8097. }
  8098. };
  8099. CalendarContent.prototype.componentDidUpdate = function (prevProps) {
  8100. var props = this.props;
  8101. var propSetHandlers = props.pluginHooks.propSetHandlers;
  8102. for (var propName in propSetHandlers) {
  8103. if (props[propName] !== prevProps[propName]) {
  8104. propSetHandlers[propName](props[propName], props);
  8105. }
  8106. }
  8107. };
  8108. CalendarContent.prototype.componentWillUnmount = function () {
  8109. window.removeEventListener('resize', this.handleWindowResize);
  8110. this.resizeRunner.clear();
  8111. for (var _i = 0, _a = this.calendarInteractions; _i < _a.length; _i++) {
  8112. var interaction = _a[_i];
  8113. interaction.destroy();
  8114. }
  8115. this.props.emitter.trigger('_unmount');
  8116. };
  8117. CalendarContent.prototype.buildAppendContent = function () {
  8118. var props = this.props;
  8119. var children = props.pluginHooks.viewContainerAppends.map(function (buildAppendContent) { return buildAppendContent(props); });
  8120. return createElement.apply(void 0, __spreadArray([Fragment, {}], children));
  8121. };
  8122. CalendarContent.prototype.renderView = function (props) {
  8123. var pluginHooks = props.pluginHooks;
  8124. var viewSpec = props.viewSpec;
  8125. var viewProps = {
  8126. dateProfile: props.dateProfile,
  8127. businessHours: props.businessHours,
  8128. eventStore: props.renderableEventStore,
  8129. eventUiBases: props.eventUiBases,
  8130. dateSelection: props.dateSelection,
  8131. eventSelection: props.eventSelection,
  8132. eventDrag: props.eventDrag,
  8133. eventResize: props.eventResize,
  8134. isHeightAuto: props.isHeightAuto,
  8135. forPrint: props.forPrint,
  8136. };
  8137. var transformers = this.buildViewPropTransformers(pluginHooks.viewPropsTransformers);
  8138. for (var _i = 0, transformers_1 = transformers; _i < transformers_1.length; _i++) {
  8139. var transformer = transformers_1[_i];
  8140. __assign(viewProps, transformer.transform(viewProps, props));
  8141. }
  8142. var ViewComponent = viewSpec.component;
  8143. return (createElement(ViewComponent, __assign({}, viewProps)));
  8144. };
  8145. return CalendarContent;
  8146. }(PureComponent));
  8147. function buildToolbarProps(viewSpec, dateProfile, dateProfileGenerator, currentDate, now, title) {
  8148. // don't force any date-profiles to valid date profiles (the `false`) so that we can tell if it's invalid
  8149. var todayInfo = dateProfileGenerator.build(now, undefined, false); // TODO: need `undefined` or else INFINITE LOOP for some reason
  8150. var prevInfo = dateProfileGenerator.buildPrev(dateProfile, currentDate, false);
  8151. var nextInfo = dateProfileGenerator.buildNext(dateProfile, currentDate, false);
  8152. return {
  8153. title: title,
  8154. activeButton: viewSpec.type,
  8155. navUnit: viewSpec.singleUnit,
  8156. isTodayEnabled: todayInfo.isValid && !rangeContainsMarker(dateProfile.currentRange, now),
  8157. isPrevEnabled: prevInfo.isValid,
  8158. isNextEnabled: nextInfo.isValid,
  8159. };
  8160. }
  8161. // Plugin
  8162. // -----------------------------------------------------------------------------------------------------------------
  8163. function buildViewPropTransformers(theClasses) {
  8164. return theClasses.map(function (TheClass) { return new TheClass(); });
  8165. }
  8166. var CalendarRoot = /** @class */ (function (_super) {
  8167. __extends(CalendarRoot, _super);
  8168. function CalendarRoot() {
  8169. var _this = _super !== null && _super.apply(this, arguments) || this;
  8170. _this.state = {
  8171. forPrint: false,
  8172. };
  8173. _this.handleBeforePrint = function () {
  8174. _this.setState({ forPrint: true });
  8175. };
  8176. _this.handleAfterPrint = function () {
  8177. _this.setState({ forPrint: false });
  8178. };
  8179. return _this;
  8180. }
  8181. CalendarRoot.prototype.render = function () {
  8182. var props = this.props;
  8183. var options = props.options;
  8184. var forPrint = this.state.forPrint;
  8185. var isHeightAuto = forPrint || options.height === 'auto' || options.contentHeight === 'auto';
  8186. var height = (!isHeightAuto && options.height != null) ? options.height : '';
  8187. var classNames = [
  8188. 'fc',
  8189. forPrint ? 'fc-media-print' : 'fc-media-screen',
  8190. "fc-direction-" + options.direction,
  8191. props.theme.getClass('root'),
  8192. ];
  8193. if (!getCanVGrowWithinCell()) {
  8194. classNames.push('fc-liquid-hack');
  8195. }
  8196. return props.children(classNames, height, isHeightAuto, forPrint);
  8197. };
  8198. CalendarRoot.prototype.componentDidMount = function () {
  8199. var emitter = this.props.emitter;
  8200. emitter.on('_beforeprint', this.handleBeforePrint);
  8201. emitter.on('_afterprint', this.handleAfterPrint);
  8202. };
  8203. CalendarRoot.prototype.componentWillUnmount = function () {
  8204. var emitter = this.props.emitter;
  8205. emitter.off('_beforeprint', this.handleBeforePrint);
  8206. emitter.off('_afterprint', this.handleAfterPrint);
  8207. };
  8208. return CalendarRoot;
  8209. }(BaseComponent));
  8210. // Computes a default column header formatting string if `colFormat` is not explicitly defined
  8211. function computeFallbackHeaderFormat(datesRepDistinctDays, dayCnt) {
  8212. // if more than one week row, or if there are a lot of columns with not much space,
  8213. // put just the day numbers will be in each cell
  8214. if (!datesRepDistinctDays || dayCnt > 10) {
  8215. return createFormatter({ weekday: 'short' }); // "Sat"
  8216. }
  8217. if (dayCnt > 1) {
  8218. return createFormatter({ weekday: 'short', month: 'numeric', day: 'numeric', omitCommas: true }); // "Sat 11/12"
  8219. }
  8220. return createFormatter({ weekday: 'long' }); // "Saturday"
  8221. }
  8222. var CLASS_NAME = 'fc-col-header-cell'; // do the cushion too? no
  8223. function renderInner$1(hookProps) {
  8224. return hookProps.text;
  8225. }
  8226. var TableDateCell = /** @class */ (function (_super) {
  8227. __extends(TableDateCell, _super);
  8228. function TableDateCell() {
  8229. return _super !== null && _super.apply(this, arguments) || this;
  8230. }
  8231. TableDateCell.prototype.render = function () {
  8232. var _a = this.context, dateEnv = _a.dateEnv, options = _a.options, theme = _a.theme, viewApi = _a.viewApi;
  8233. var props = this.props;
  8234. var date = props.date, dateProfile = props.dateProfile;
  8235. var dayMeta = getDateMeta(date, props.todayRange, null, dateProfile);
  8236. var classNames = [CLASS_NAME].concat(getDayClassNames(dayMeta, theme));
  8237. var text = dateEnv.format(date, props.dayHeaderFormat);
  8238. // if colCnt is 1, we are already in a day-view and don't need a navlink
  8239. var navLinkAttrs = (!dayMeta.isDisabled && props.colCnt > 1)
  8240. ? buildNavLinkAttrs(this.context, date)
  8241. : {};
  8242. var hookProps = __assign(__assign(__assign({ date: dateEnv.toDate(date), view: viewApi }, props.extraHookProps), { text: text }), dayMeta);
  8243. return (createElement(RenderHook, { hookProps: hookProps, classNames: options.dayHeaderClassNames, content: options.dayHeaderContent, defaultContent: renderInner$1, didMount: options.dayHeaderDidMount, willUnmount: options.dayHeaderWillUnmount }, function (rootElRef, customClassNames, innerElRef, innerContent) { return (createElement("th", __assign({ ref: rootElRef, role: "columnheader", className: classNames.concat(customClassNames).join(' '), "data-date": !dayMeta.isDisabled ? formatDayString(date) : undefined, colSpan: props.colSpan }, props.extraDataAttrs),
  8244. createElement("div", { className: "fc-scrollgrid-sync-inner" }, !dayMeta.isDisabled && (createElement("a", __assign({ ref: innerElRef, className: [
  8245. 'fc-col-header-cell-cushion',
  8246. props.isSticky ? 'fc-sticky' : '',
  8247. ].join(' ') }, navLinkAttrs), innerContent))))); }));
  8248. };
  8249. return TableDateCell;
  8250. }(BaseComponent));
  8251. var WEEKDAY_FORMAT = createFormatter({ weekday: 'long' });
  8252. var TableDowCell = /** @class */ (function (_super) {
  8253. __extends(TableDowCell, _super);
  8254. function TableDowCell() {
  8255. return _super !== null && _super.apply(this, arguments) || this;
  8256. }
  8257. TableDowCell.prototype.render = function () {
  8258. var props = this.props;
  8259. var _a = this.context, dateEnv = _a.dateEnv, theme = _a.theme, viewApi = _a.viewApi, options = _a.options;
  8260. var date = addDays(new Date(259200000), props.dow); // start with Sun, 04 Jan 1970 00:00:00 GMT
  8261. var dateMeta = {
  8262. dow: props.dow,
  8263. isDisabled: false,
  8264. isFuture: false,
  8265. isPast: false,
  8266. isToday: false,
  8267. isOther: false,
  8268. };
  8269. var classNames = [CLASS_NAME].concat(getDayClassNames(dateMeta, theme), props.extraClassNames || []);
  8270. var text = dateEnv.format(date, props.dayHeaderFormat);
  8271. var hookProps = __assign(__assign(__assign(__assign({ // TODO: make this public?
  8272. date: date }, dateMeta), { view: viewApi }), props.extraHookProps), { text: text });
  8273. return (createElement(RenderHook, { hookProps: hookProps, classNames: options.dayHeaderClassNames, content: options.dayHeaderContent, defaultContent: renderInner$1, didMount: options.dayHeaderDidMount, willUnmount: options.dayHeaderWillUnmount }, function (rootElRef, customClassNames, innerElRef, innerContent) { return (createElement("th", __assign({ ref: rootElRef, role: "columnheader", className: classNames.concat(customClassNames).join(' '), colSpan: props.colSpan }, props.extraDataAttrs),
  8274. createElement("div", { className: "fc-scrollgrid-sync-inner" },
  8275. createElement("a", { "aria-label": dateEnv.format(date, WEEKDAY_FORMAT), className: [
  8276. 'fc-col-header-cell-cushion',
  8277. props.isSticky ? 'fc-sticky' : '',
  8278. ].join(' '), ref: innerElRef }, innerContent)))); }));
  8279. };
  8280. return TableDowCell;
  8281. }(BaseComponent));
  8282. var NowTimer = /** @class */ (function (_super) {
  8283. __extends(NowTimer, _super);
  8284. function NowTimer(props, context) {
  8285. var _this = _super.call(this, props, context) || this;
  8286. _this.initialNowDate = getNow(context.options.now, context.dateEnv);
  8287. _this.initialNowQueriedMs = new Date().valueOf();
  8288. _this.state = _this.computeTiming().currentState;
  8289. return _this;
  8290. }
  8291. NowTimer.prototype.render = function () {
  8292. var _a = this, props = _a.props, state = _a.state;
  8293. return props.children(state.nowDate, state.todayRange);
  8294. };
  8295. NowTimer.prototype.componentDidMount = function () {
  8296. this.setTimeout();
  8297. };
  8298. NowTimer.prototype.componentDidUpdate = function (prevProps) {
  8299. if (prevProps.unit !== this.props.unit) {
  8300. this.clearTimeout();
  8301. this.setTimeout();
  8302. }
  8303. };
  8304. NowTimer.prototype.componentWillUnmount = function () {
  8305. this.clearTimeout();
  8306. };
  8307. NowTimer.prototype.computeTiming = function () {
  8308. var _a = this, props = _a.props, context = _a.context;
  8309. var unroundedNow = addMs(this.initialNowDate, new Date().valueOf() - this.initialNowQueriedMs);
  8310. var currentUnitStart = context.dateEnv.startOf(unroundedNow, props.unit);
  8311. var nextUnitStart = context.dateEnv.add(currentUnitStart, createDuration(1, props.unit));
  8312. var waitMs = nextUnitStart.valueOf() - unroundedNow.valueOf();
  8313. // there is a max setTimeout ms value (https://stackoverflow.com/a/3468650/96342)
  8314. // ensure no longer than a day
  8315. waitMs = Math.min(1000 * 60 * 60 * 24, waitMs);
  8316. return {
  8317. currentState: { nowDate: currentUnitStart, todayRange: buildDayRange(currentUnitStart) },
  8318. nextState: { nowDate: nextUnitStart, todayRange: buildDayRange(nextUnitStart) },
  8319. waitMs: waitMs,
  8320. };
  8321. };
  8322. NowTimer.prototype.setTimeout = function () {
  8323. var _this = this;
  8324. var _a = this.computeTiming(), nextState = _a.nextState, waitMs = _a.waitMs;
  8325. this.timeoutId = setTimeout(function () {
  8326. _this.setState(nextState, function () {
  8327. _this.setTimeout();
  8328. });
  8329. }, waitMs);
  8330. };
  8331. NowTimer.prototype.clearTimeout = function () {
  8332. if (this.timeoutId) {
  8333. clearTimeout(this.timeoutId);
  8334. }
  8335. };
  8336. NowTimer.contextType = ViewContextType;
  8337. return NowTimer;
  8338. }(Component));
  8339. function buildDayRange(date) {
  8340. var start = startOfDay(date);
  8341. var end = addDays(start, 1);
  8342. return { start: start, end: end };
  8343. }
  8344. var DayHeader = /** @class */ (function (_super) {
  8345. __extends(DayHeader, _super);
  8346. function DayHeader() {
  8347. var _this = _super !== null && _super.apply(this, arguments) || this;
  8348. _this.createDayHeaderFormatter = memoize(createDayHeaderFormatter);
  8349. return _this;
  8350. }
  8351. DayHeader.prototype.render = function () {
  8352. var context = this.context;
  8353. var _a = this.props, dates = _a.dates, dateProfile = _a.dateProfile, datesRepDistinctDays = _a.datesRepDistinctDays, renderIntro = _a.renderIntro;
  8354. var dayHeaderFormat = this.createDayHeaderFormatter(context.options.dayHeaderFormat, datesRepDistinctDays, dates.length);
  8355. return (createElement(NowTimer, { unit: "day" }, function (nowDate, todayRange) { return (createElement("tr", { role: "row" },
  8356. renderIntro && renderIntro('day'),
  8357. dates.map(function (date) { return (datesRepDistinctDays ? (createElement(TableDateCell, { key: date.toISOString(), date: date, dateProfile: dateProfile, todayRange: todayRange, colCnt: dates.length, dayHeaderFormat: dayHeaderFormat })) : (createElement(TableDowCell, { key: date.getUTCDay(), dow: date.getUTCDay(), dayHeaderFormat: dayHeaderFormat }))); }))); }));
  8358. };
  8359. return DayHeader;
  8360. }(BaseComponent));
  8361. function createDayHeaderFormatter(explicitFormat, datesRepDistinctDays, dateCnt) {
  8362. return explicitFormat || computeFallbackHeaderFormat(datesRepDistinctDays, dateCnt);
  8363. }
  8364. var DaySeriesModel = /** @class */ (function () {
  8365. function DaySeriesModel(range, dateProfileGenerator) {
  8366. var date = range.start;
  8367. var end = range.end;
  8368. var indices = [];
  8369. var dates = [];
  8370. var dayIndex = -1;
  8371. while (date < end) { // loop each day from start to end
  8372. if (dateProfileGenerator.isHiddenDay(date)) {
  8373. indices.push(dayIndex + 0.5); // mark that it's between indices
  8374. }
  8375. else {
  8376. dayIndex += 1;
  8377. indices.push(dayIndex);
  8378. dates.push(date);
  8379. }
  8380. date = addDays(date, 1);
  8381. }
  8382. this.dates = dates;
  8383. this.indices = indices;
  8384. this.cnt = dates.length;
  8385. }
  8386. DaySeriesModel.prototype.sliceRange = function (range) {
  8387. var firstIndex = this.getDateDayIndex(range.start); // inclusive first index
  8388. var lastIndex = this.getDateDayIndex(addDays(range.end, -1)); // inclusive last index
  8389. var clippedFirstIndex = Math.max(0, firstIndex);
  8390. var clippedLastIndex = Math.min(this.cnt - 1, lastIndex);
  8391. // deal with in-between indices
  8392. clippedFirstIndex = Math.ceil(clippedFirstIndex); // in-between starts round to next cell
  8393. clippedLastIndex = Math.floor(clippedLastIndex); // in-between ends round to prev cell
  8394. if (clippedFirstIndex <= clippedLastIndex) {
  8395. return {
  8396. firstIndex: clippedFirstIndex,
  8397. lastIndex: clippedLastIndex,
  8398. isStart: firstIndex === clippedFirstIndex,
  8399. isEnd: lastIndex === clippedLastIndex,
  8400. };
  8401. }
  8402. return null;
  8403. };
  8404. // Given a date, returns its chronolocial cell-index from the first cell of the grid.
  8405. // If the date lies between cells (because of hiddenDays), returns a floating-point value between offsets.
  8406. // If before the first offset, returns a negative number.
  8407. // If after the last offset, returns an offset past the last cell offset.
  8408. // Only works for *start* dates of cells. Will not work for exclusive end dates for cells.
  8409. DaySeriesModel.prototype.getDateDayIndex = function (date) {
  8410. var indices = this.indices;
  8411. var dayOffset = Math.floor(diffDays(this.dates[0], date));
  8412. if (dayOffset < 0) {
  8413. return indices[0] - 1;
  8414. }
  8415. if (dayOffset >= indices.length) {
  8416. return indices[indices.length - 1] + 1;
  8417. }
  8418. return indices[dayOffset];
  8419. };
  8420. return DaySeriesModel;
  8421. }());
  8422. var DayTableModel = /** @class */ (function () {
  8423. function DayTableModel(daySeries, breakOnWeeks) {
  8424. var dates = daySeries.dates;
  8425. var daysPerRow;
  8426. var firstDay;
  8427. var rowCnt;
  8428. if (breakOnWeeks) {
  8429. // count columns until the day-of-week repeats
  8430. firstDay = dates[0].getUTCDay();
  8431. for (daysPerRow = 1; daysPerRow < dates.length; daysPerRow += 1) {
  8432. if (dates[daysPerRow].getUTCDay() === firstDay) {
  8433. break;
  8434. }
  8435. }
  8436. rowCnt = Math.ceil(dates.length / daysPerRow);
  8437. }
  8438. else {
  8439. rowCnt = 1;
  8440. daysPerRow = dates.length;
  8441. }
  8442. this.rowCnt = rowCnt;
  8443. this.colCnt = daysPerRow;
  8444. this.daySeries = daySeries;
  8445. this.cells = this.buildCells();
  8446. this.headerDates = this.buildHeaderDates();
  8447. }
  8448. DayTableModel.prototype.buildCells = function () {
  8449. var rows = [];
  8450. for (var row = 0; row < this.rowCnt; row += 1) {
  8451. var cells = [];
  8452. for (var col = 0; col < this.colCnt; col += 1) {
  8453. cells.push(this.buildCell(row, col));
  8454. }
  8455. rows.push(cells);
  8456. }
  8457. return rows;
  8458. };
  8459. DayTableModel.prototype.buildCell = function (row, col) {
  8460. var date = this.daySeries.dates[row * this.colCnt + col];
  8461. return {
  8462. key: date.toISOString(),
  8463. date: date,
  8464. };
  8465. };
  8466. DayTableModel.prototype.buildHeaderDates = function () {
  8467. var dates = [];
  8468. for (var col = 0; col < this.colCnt; col += 1) {
  8469. dates.push(this.cells[0][col].date);
  8470. }
  8471. return dates;
  8472. };
  8473. DayTableModel.prototype.sliceRange = function (range) {
  8474. var colCnt = this.colCnt;
  8475. var seriesSeg = this.daySeries.sliceRange(range);
  8476. var segs = [];
  8477. if (seriesSeg) {
  8478. var firstIndex = seriesSeg.firstIndex, lastIndex = seriesSeg.lastIndex;
  8479. var index = firstIndex;
  8480. while (index <= lastIndex) {
  8481. var row = Math.floor(index / colCnt);
  8482. var nextIndex = Math.min((row + 1) * colCnt, lastIndex + 1);
  8483. segs.push({
  8484. row: row,
  8485. firstCol: index % colCnt,
  8486. lastCol: (nextIndex - 1) % colCnt,
  8487. isStart: seriesSeg.isStart && index === firstIndex,
  8488. isEnd: seriesSeg.isEnd && (nextIndex - 1) === lastIndex,
  8489. });
  8490. index = nextIndex;
  8491. }
  8492. }
  8493. return segs;
  8494. };
  8495. return DayTableModel;
  8496. }());
  8497. var Slicer = /** @class */ (function () {
  8498. function Slicer() {
  8499. this.sliceBusinessHours = memoize(this._sliceBusinessHours);
  8500. this.sliceDateSelection = memoize(this._sliceDateSpan);
  8501. this.sliceEventStore = memoize(this._sliceEventStore);
  8502. this.sliceEventDrag = memoize(this._sliceInteraction);
  8503. this.sliceEventResize = memoize(this._sliceInteraction);
  8504. this.forceDayIfListItem = false; // hack
  8505. }
  8506. Slicer.prototype.sliceProps = function (props, dateProfile, nextDayThreshold, context) {
  8507. var extraArgs = [];
  8508. for (var _i = 4; _i < arguments.length; _i++) {
  8509. extraArgs[_i - 4] = arguments[_i];
  8510. }
  8511. var eventUiBases = props.eventUiBases;
  8512. var eventSegs = this.sliceEventStore.apply(this, __spreadArray([props.eventStore, eventUiBases, dateProfile, nextDayThreshold], extraArgs));
  8513. return {
  8514. dateSelectionSegs: this.sliceDateSelection.apply(this, __spreadArray([props.dateSelection, eventUiBases, context], extraArgs)),
  8515. businessHourSegs: this.sliceBusinessHours.apply(this, __spreadArray([props.businessHours, dateProfile, nextDayThreshold, context], extraArgs)),
  8516. fgEventSegs: eventSegs.fg,
  8517. bgEventSegs: eventSegs.bg,
  8518. eventDrag: this.sliceEventDrag.apply(this, __spreadArray([props.eventDrag, eventUiBases, dateProfile, nextDayThreshold], extraArgs)),
  8519. eventResize: this.sliceEventResize.apply(this, __spreadArray([props.eventResize, eventUiBases, dateProfile, nextDayThreshold], extraArgs)),
  8520. eventSelection: props.eventSelection,
  8521. }; // TODO: give interactionSegs?
  8522. };
  8523. Slicer.prototype.sliceNowDate = function (// does not memoize
  8524. date, context) {
  8525. var extraArgs = [];
  8526. for (var _i = 2; _i < arguments.length; _i++) {
  8527. extraArgs[_i - 2] = arguments[_i];
  8528. }
  8529. return this._sliceDateSpan.apply(this, __spreadArray([{ range: { start: date, end: addMs(date, 1) }, allDay: false },
  8530. {},
  8531. context], extraArgs));
  8532. };
  8533. Slicer.prototype._sliceBusinessHours = function (businessHours, dateProfile, nextDayThreshold, context) {
  8534. var extraArgs = [];
  8535. for (var _i = 4; _i < arguments.length; _i++) {
  8536. extraArgs[_i - 4] = arguments[_i];
  8537. }
  8538. if (!businessHours) {
  8539. return [];
  8540. }
  8541. return this._sliceEventStore.apply(this, __spreadArray([expandRecurring(businessHours, computeActiveRange(dateProfile, Boolean(nextDayThreshold)), context),
  8542. {},
  8543. dateProfile,
  8544. nextDayThreshold], extraArgs)).bg;
  8545. };
  8546. Slicer.prototype._sliceEventStore = function (eventStore, eventUiBases, dateProfile, nextDayThreshold) {
  8547. var extraArgs = [];
  8548. for (var _i = 4; _i < arguments.length; _i++) {
  8549. extraArgs[_i - 4] = arguments[_i];
  8550. }
  8551. if (eventStore) {
  8552. var rangeRes = sliceEventStore(eventStore, eventUiBases, computeActiveRange(dateProfile, Boolean(nextDayThreshold)), nextDayThreshold);
  8553. return {
  8554. bg: this.sliceEventRanges(rangeRes.bg, extraArgs),
  8555. fg: this.sliceEventRanges(rangeRes.fg, extraArgs),
  8556. };
  8557. }
  8558. return { bg: [], fg: [] };
  8559. };
  8560. Slicer.prototype._sliceInteraction = function (interaction, eventUiBases, dateProfile, nextDayThreshold) {
  8561. var extraArgs = [];
  8562. for (var _i = 4; _i < arguments.length; _i++) {
  8563. extraArgs[_i - 4] = arguments[_i];
  8564. }
  8565. if (!interaction) {
  8566. return null;
  8567. }
  8568. var rangeRes = sliceEventStore(interaction.mutatedEvents, eventUiBases, computeActiveRange(dateProfile, Boolean(nextDayThreshold)), nextDayThreshold);
  8569. return {
  8570. segs: this.sliceEventRanges(rangeRes.fg, extraArgs),
  8571. affectedInstances: interaction.affectedEvents.instances,
  8572. isEvent: interaction.isEvent,
  8573. };
  8574. };
  8575. Slicer.prototype._sliceDateSpan = function (dateSpan, eventUiBases, context) {
  8576. var extraArgs = [];
  8577. for (var _i = 3; _i < arguments.length; _i++) {
  8578. extraArgs[_i - 3] = arguments[_i];
  8579. }
  8580. if (!dateSpan) {
  8581. return [];
  8582. }
  8583. var eventRange = fabricateEventRange(dateSpan, eventUiBases, context);
  8584. var segs = this.sliceRange.apply(this, __spreadArray([dateSpan.range], extraArgs));
  8585. for (var _a = 0, segs_1 = segs; _a < segs_1.length; _a++) {
  8586. var seg = segs_1[_a];
  8587. seg.eventRange = eventRange;
  8588. }
  8589. return segs;
  8590. };
  8591. /*
  8592. "complete" seg means it has component and eventRange
  8593. */
  8594. Slicer.prototype.sliceEventRanges = function (eventRanges, extraArgs) {
  8595. var segs = [];
  8596. for (var _i = 0, eventRanges_1 = eventRanges; _i < eventRanges_1.length; _i++) {
  8597. var eventRange = eventRanges_1[_i];
  8598. segs.push.apply(segs, this.sliceEventRange(eventRange, extraArgs));
  8599. }
  8600. return segs;
  8601. };
  8602. /*
  8603. "complete" seg means it has component and eventRange
  8604. */
  8605. Slicer.prototype.sliceEventRange = function (eventRange, extraArgs) {
  8606. var dateRange = eventRange.range;
  8607. // hack to make multi-day events that are being force-displayed as list-items to take up only one day
  8608. if (this.forceDayIfListItem && eventRange.ui.display === 'list-item') {
  8609. dateRange = {
  8610. start: dateRange.start,
  8611. end: addDays(dateRange.start, 1),
  8612. };
  8613. }
  8614. var segs = this.sliceRange.apply(this, __spreadArray([dateRange], extraArgs));
  8615. for (var _i = 0, segs_2 = segs; _i < segs_2.length; _i++) {
  8616. var seg = segs_2[_i];
  8617. seg.eventRange = eventRange;
  8618. seg.isStart = eventRange.isStart && seg.isStart;
  8619. seg.isEnd = eventRange.isEnd && seg.isEnd;
  8620. }
  8621. return segs;
  8622. };
  8623. return Slicer;
  8624. }());
  8625. /*
  8626. for incorporating slotMinTime/slotMaxTime if appropriate
  8627. TODO: should be part of DateProfile!
  8628. TimelineDateProfile already does this btw
  8629. */
  8630. function computeActiveRange(dateProfile, isComponentAllDay) {
  8631. var range = dateProfile.activeRange;
  8632. if (isComponentAllDay) {
  8633. return range;
  8634. }
  8635. return {
  8636. start: addMs(range.start, dateProfile.slotMinTime.milliseconds),
  8637. end: addMs(range.end, dateProfile.slotMaxTime.milliseconds - 864e5), // 864e5 = ms in a day
  8638. };
  8639. }
  8640. // high-level segmenting-aware tester functions
  8641. // ------------------------------------------------------------------------------------------------------------------------
  8642. function isInteractionValid(interaction, dateProfile, context) {
  8643. var instances = interaction.mutatedEvents.instances;
  8644. for (var instanceId in instances) {
  8645. if (!rangeContainsRange(dateProfile.validRange, instances[instanceId].range)) {
  8646. return false;
  8647. }
  8648. }
  8649. return isNewPropsValid({ eventDrag: interaction }, context); // HACK: the eventDrag props is used for ALL interactions
  8650. }
  8651. function isDateSelectionValid(dateSelection, dateProfile, context) {
  8652. if (!rangeContainsRange(dateProfile.validRange, dateSelection.range)) {
  8653. return false;
  8654. }
  8655. return isNewPropsValid({ dateSelection: dateSelection }, context);
  8656. }
  8657. function isNewPropsValid(newProps, context) {
  8658. var calendarState = context.getCurrentData();
  8659. var props = __assign({ businessHours: calendarState.businessHours, dateSelection: '', eventStore: calendarState.eventStore, eventUiBases: calendarState.eventUiBases, eventSelection: '', eventDrag: null, eventResize: null }, newProps);
  8660. return (context.pluginHooks.isPropsValid || isPropsValid)(props, context);
  8661. }
  8662. function isPropsValid(state, context, dateSpanMeta, filterConfig) {
  8663. if (dateSpanMeta === void 0) { dateSpanMeta = {}; }
  8664. if (state.eventDrag && !isInteractionPropsValid(state, context, dateSpanMeta, filterConfig)) {
  8665. return false;
  8666. }
  8667. if (state.dateSelection && !isDateSelectionPropsValid(state, context, dateSpanMeta, filterConfig)) {
  8668. return false;
  8669. }
  8670. return true;
  8671. }
  8672. // Moving Event Validation
  8673. // ------------------------------------------------------------------------------------------------------------------------
  8674. function isInteractionPropsValid(state, context, dateSpanMeta, filterConfig) {
  8675. var currentState = context.getCurrentData();
  8676. var interaction = state.eventDrag; // HACK: the eventDrag props is used for ALL interactions
  8677. var subjectEventStore = interaction.mutatedEvents;
  8678. var subjectDefs = subjectEventStore.defs;
  8679. var subjectInstances = subjectEventStore.instances;
  8680. var subjectConfigs = compileEventUis(subjectDefs, interaction.isEvent ?
  8681. state.eventUiBases :
  8682. { '': currentState.selectionConfig });
  8683. if (filterConfig) {
  8684. subjectConfigs = mapHash(subjectConfigs, filterConfig);
  8685. }
  8686. // exclude the subject events. TODO: exclude defs too?
  8687. var otherEventStore = excludeInstances(state.eventStore, interaction.affectedEvents.instances);
  8688. var otherDefs = otherEventStore.defs;
  8689. var otherInstances = otherEventStore.instances;
  8690. var otherConfigs = compileEventUis(otherDefs, state.eventUiBases);
  8691. for (var subjectInstanceId in subjectInstances) {
  8692. var subjectInstance = subjectInstances[subjectInstanceId];
  8693. var subjectRange = subjectInstance.range;
  8694. var subjectConfig = subjectConfigs[subjectInstance.defId];
  8695. var subjectDef = subjectDefs[subjectInstance.defId];
  8696. // constraint
  8697. if (!allConstraintsPass(subjectConfig.constraints, subjectRange, otherEventStore, state.businessHours, context)) {
  8698. return false;
  8699. }
  8700. // overlap
  8701. var eventOverlap = context.options.eventOverlap;
  8702. var eventOverlapFunc = typeof eventOverlap === 'function' ? eventOverlap : null;
  8703. for (var otherInstanceId in otherInstances) {
  8704. var otherInstance = otherInstances[otherInstanceId];
  8705. // intersect! evaluate
  8706. if (rangesIntersect(subjectRange, otherInstance.range)) {
  8707. var otherOverlap = otherConfigs[otherInstance.defId].overlap;
  8708. // consider the other event's overlap. only do this if the subject event is a "real" event
  8709. if (otherOverlap === false && interaction.isEvent) {
  8710. return false;
  8711. }
  8712. if (subjectConfig.overlap === false) {
  8713. return false;
  8714. }
  8715. if (eventOverlapFunc && !eventOverlapFunc(new EventApi(context, otherDefs[otherInstance.defId], otherInstance), // still event
  8716. new EventApi(context, subjectDef, subjectInstance))) {
  8717. return false;
  8718. }
  8719. }
  8720. }
  8721. // allow (a function)
  8722. var calendarEventStore = currentState.eventStore; // need global-to-calendar, not local to component (splittable)state
  8723. for (var _i = 0, _a = subjectConfig.allows; _i < _a.length; _i++) {
  8724. var subjectAllow = _a[_i];
  8725. var subjectDateSpan = __assign(__assign({}, dateSpanMeta), { range: subjectInstance.range, allDay: subjectDef.allDay });
  8726. var origDef = calendarEventStore.defs[subjectDef.defId];
  8727. var origInstance = calendarEventStore.instances[subjectInstanceId];
  8728. var eventApi = void 0;
  8729. if (origDef) { // was previously in the calendar
  8730. eventApi = new EventApi(context, origDef, origInstance);
  8731. }
  8732. else { // was an external event
  8733. eventApi = new EventApi(context, subjectDef); // no instance, because had no dates
  8734. }
  8735. if (!subjectAllow(buildDateSpanApiWithContext(subjectDateSpan, context), eventApi)) {
  8736. return false;
  8737. }
  8738. }
  8739. }
  8740. return true;
  8741. }
  8742. // Date Selection Validation
  8743. // ------------------------------------------------------------------------------------------------------------------------
  8744. function isDateSelectionPropsValid(state, context, dateSpanMeta, filterConfig) {
  8745. var relevantEventStore = state.eventStore;
  8746. var relevantDefs = relevantEventStore.defs;
  8747. var relevantInstances = relevantEventStore.instances;
  8748. var selection = state.dateSelection;
  8749. var selectionRange = selection.range;
  8750. var selectionConfig = context.getCurrentData().selectionConfig;
  8751. if (filterConfig) {
  8752. selectionConfig = filterConfig(selectionConfig);
  8753. }
  8754. // constraint
  8755. if (!allConstraintsPass(selectionConfig.constraints, selectionRange, relevantEventStore, state.businessHours, context)) {
  8756. return false;
  8757. }
  8758. // overlap
  8759. var selectOverlap = context.options.selectOverlap;
  8760. var selectOverlapFunc = typeof selectOverlap === 'function' ? selectOverlap : null;
  8761. for (var relevantInstanceId in relevantInstances) {
  8762. var relevantInstance = relevantInstances[relevantInstanceId];
  8763. // intersect! evaluate
  8764. if (rangesIntersect(selectionRange, relevantInstance.range)) {
  8765. if (selectionConfig.overlap === false) {
  8766. return false;
  8767. }
  8768. if (selectOverlapFunc && !selectOverlapFunc(new EventApi(context, relevantDefs[relevantInstance.defId], relevantInstance), null)) {
  8769. return false;
  8770. }
  8771. }
  8772. }
  8773. // allow (a function)
  8774. for (var _i = 0, _a = selectionConfig.allows; _i < _a.length; _i++) {
  8775. var selectionAllow = _a[_i];
  8776. var fullDateSpan = __assign(__assign({}, dateSpanMeta), selection);
  8777. if (!selectionAllow(buildDateSpanApiWithContext(fullDateSpan, context), null)) {
  8778. return false;
  8779. }
  8780. }
  8781. return true;
  8782. }
  8783. // Constraint Utils
  8784. // ------------------------------------------------------------------------------------------------------------------------
  8785. function allConstraintsPass(constraints, subjectRange, otherEventStore, businessHoursUnexpanded, context) {
  8786. for (var _i = 0, constraints_1 = constraints; _i < constraints_1.length; _i++) {
  8787. var constraint = constraints_1[_i];
  8788. if (!anyRangesContainRange(constraintToRanges(constraint, subjectRange, otherEventStore, businessHoursUnexpanded, context), subjectRange)) {
  8789. return false;
  8790. }
  8791. }
  8792. return true;
  8793. }
  8794. function constraintToRanges(constraint, subjectRange, // for expanding a recurring constraint, or expanding business hours
  8795. otherEventStore, // for if constraint is an even group ID
  8796. businessHoursUnexpanded, // for if constraint is 'businessHours'
  8797. context) {
  8798. if (constraint === 'businessHours') {
  8799. return eventStoreToRanges(expandRecurring(businessHoursUnexpanded, subjectRange, context));
  8800. }
  8801. if (typeof constraint === 'string') { // an group ID
  8802. return eventStoreToRanges(filterEventStoreDefs(otherEventStore, function (eventDef) { return eventDef.groupId === constraint; }));
  8803. }
  8804. if (typeof constraint === 'object' && constraint) { // non-null object
  8805. return eventStoreToRanges(expandRecurring(constraint, subjectRange, context));
  8806. }
  8807. return []; // if it's false
  8808. }
  8809. // TODO: move to event-store file?
  8810. function eventStoreToRanges(eventStore) {
  8811. var instances = eventStore.instances;
  8812. var ranges = [];
  8813. for (var instanceId in instances) {
  8814. ranges.push(instances[instanceId].range);
  8815. }
  8816. return ranges;
  8817. }
  8818. // TODO: move to geom file?
  8819. function anyRangesContainRange(outerRanges, innerRange) {
  8820. for (var _i = 0, outerRanges_1 = outerRanges; _i < outerRanges_1.length; _i++) {
  8821. var outerRange = outerRanges_1[_i];
  8822. if (rangeContainsRange(outerRange, innerRange)) {
  8823. return true;
  8824. }
  8825. }
  8826. return false;
  8827. }
  8828. var VISIBLE_HIDDEN_RE = /^(visible|hidden)$/;
  8829. var Scroller = /** @class */ (function (_super) {
  8830. __extends(Scroller, _super);
  8831. function Scroller() {
  8832. var _this = _super !== null && _super.apply(this, arguments) || this;
  8833. _this.handleEl = function (el) {
  8834. _this.el = el;
  8835. setRef(_this.props.elRef, el);
  8836. };
  8837. return _this;
  8838. }
  8839. Scroller.prototype.render = function () {
  8840. var props = this.props;
  8841. var liquid = props.liquid, liquidIsAbsolute = props.liquidIsAbsolute;
  8842. var isAbsolute = liquid && liquidIsAbsolute;
  8843. var className = ['fc-scroller'];
  8844. if (liquid) {
  8845. if (liquidIsAbsolute) {
  8846. className.push('fc-scroller-liquid-absolute');
  8847. }
  8848. else {
  8849. className.push('fc-scroller-liquid');
  8850. }
  8851. }
  8852. return (createElement("div", { ref: this.handleEl, className: className.join(' '), style: {
  8853. overflowX: props.overflowX,
  8854. overflowY: props.overflowY,
  8855. left: (isAbsolute && -(props.overcomeLeft || 0)) || '',
  8856. right: (isAbsolute && -(props.overcomeRight || 0)) || '',
  8857. bottom: (isAbsolute && -(props.overcomeBottom || 0)) || '',
  8858. marginLeft: (!isAbsolute && -(props.overcomeLeft || 0)) || '',
  8859. marginRight: (!isAbsolute && -(props.overcomeRight || 0)) || '',
  8860. marginBottom: (!isAbsolute && -(props.overcomeBottom || 0)) || '',
  8861. maxHeight: props.maxHeight || '',
  8862. } }, props.children));
  8863. };
  8864. Scroller.prototype.needsXScrolling = function () {
  8865. if (VISIBLE_HIDDEN_RE.test(this.props.overflowX)) {
  8866. return false;
  8867. }
  8868. // testing scrollWidth>clientWidth is unreliable cross-browser when pixel heights aren't integers.
  8869. // much more reliable to see if children are taller than the scroller, even tho doesn't account for
  8870. // inner-child margins and absolute positioning
  8871. var el = this.el;
  8872. var realClientWidth = this.el.getBoundingClientRect().width - this.getYScrollbarWidth();
  8873. var children = el.children;
  8874. for (var i = 0; i < children.length; i += 1) {
  8875. var childEl = children[i];
  8876. if (childEl.getBoundingClientRect().width > realClientWidth) {
  8877. return true;
  8878. }
  8879. }
  8880. return false;
  8881. };
  8882. Scroller.prototype.needsYScrolling = function () {
  8883. if (VISIBLE_HIDDEN_RE.test(this.props.overflowY)) {
  8884. return false;
  8885. }
  8886. // testing scrollHeight>clientHeight is unreliable cross-browser when pixel heights aren't integers.
  8887. // much more reliable to see if children are taller than the scroller, even tho doesn't account for
  8888. // inner-child margins and absolute positioning
  8889. var el = this.el;
  8890. var realClientHeight = this.el.getBoundingClientRect().height - this.getXScrollbarWidth();
  8891. var children = el.children;
  8892. for (var i = 0; i < children.length; i += 1) {
  8893. var childEl = children[i];
  8894. if (childEl.getBoundingClientRect().height > realClientHeight) {
  8895. return true;
  8896. }
  8897. }
  8898. return false;
  8899. };
  8900. Scroller.prototype.getXScrollbarWidth = function () {
  8901. if (VISIBLE_HIDDEN_RE.test(this.props.overflowX)) {
  8902. return 0;
  8903. }
  8904. return this.el.offsetHeight - this.el.clientHeight; // only works because we guarantee no borders. TODO: add to CSS with important?
  8905. };
  8906. Scroller.prototype.getYScrollbarWidth = function () {
  8907. if (VISIBLE_HIDDEN_RE.test(this.props.overflowY)) {
  8908. return 0;
  8909. }
  8910. return this.el.offsetWidth - this.el.clientWidth; // only works because we guarantee no borders. TODO: add to CSS with important?
  8911. };
  8912. return Scroller;
  8913. }(BaseComponent));
  8914. /*
  8915. TODO: somehow infer OtherArgs from masterCallback?
  8916. TODO: infer RefType from masterCallback if provided
  8917. */
  8918. var RefMap = /** @class */ (function () {
  8919. function RefMap(masterCallback) {
  8920. var _this = this;
  8921. this.masterCallback = masterCallback;
  8922. this.currentMap = {};
  8923. this.depths = {};
  8924. this.callbackMap = {};
  8925. this.handleValue = function (val, key) {
  8926. var _a = _this, depths = _a.depths, currentMap = _a.currentMap;
  8927. var removed = false;
  8928. var added = false;
  8929. if (val !== null) {
  8930. // for bug... ACTUALLY: can probably do away with this now that callers don't share numeric indices anymore
  8931. removed = (key in currentMap);
  8932. currentMap[key] = val;
  8933. depths[key] = (depths[key] || 0) + 1;
  8934. added = true;
  8935. }
  8936. else {
  8937. depths[key] -= 1;
  8938. if (!depths[key]) {
  8939. delete currentMap[key];
  8940. delete _this.callbackMap[key];
  8941. removed = true;
  8942. }
  8943. }
  8944. if (_this.masterCallback) {
  8945. if (removed) {
  8946. _this.masterCallback(null, String(key));
  8947. }
  8948. if (added) {
  8949. _this.masterCallback(val, String(key));
  8950. }
  8951. }
  8952. };
  8953. }
  8954. RefMap.prototype.createRef = function (key) {
  8955. var _this = this;
  8956. var refCallback = this.callbackMap[key];
  8957. if (!refCallback) {
  8958. refCallback = this.callbackMap[key] = function (val) {
  8959. _this.handleValue(val, String(key));
  8960. };
  8961. }
  8962. return refCallback;
  8963. };
  8964. // TODO: check callers that don't care about order. should use getAll instead
  8965. // NOTE: this method has become less valuable now that we are encouraged to map order by some other index
  8966. // TODO: provide ONE array-export function, buildArray, which fails on non-numeric indexes. caller can manipulate and "collect"
  8967. RefMap.prototype.collect = function (startIndex, endIndex, step) {
  8968. return collectFromHash(this.currentMap, startIndex, endIndex, step);
  8969. };
  8970. RefMap.prototype.getAll = function () {
  8971. return hashValuesToArray(this.currentMap);
  8972. };
  8973. return RefMap;
  8974. }());
  8975. function computeShrinkWidth(chunkEls) {
  8976. var shrinkCells = findElements(chunkEls, '.fc-scrollgrid-shrink');
  8977. var largestWidth = 0;
  8978. for (var _i = 0, shrinkCells_1 = shrinkCells; _i < shrinkCells_1.length; _i++) {
  8979. var shrinkCell = shrinkCells_1[_i];
  8980. largestWidth = Math.max(largestWidth, computeSmallestCellWidth(shrinkCell));
  8981. }
  8982. return Math.ceil(largestWidth); // <table> elements work best with integers. round up to ensure contents fits
  8983. }
  8984. function getSectionHasLiquidHeight(props, sectionConfig) {
  8985. return props.liquid && sectionConfig.liquid; // does the section do liquid-height? (need to have whole scrollgrid liquid-height as well)
  8986. }
  8987. function getAllowYScrolling(props, sectionConfig) {
  8988. return sectionConfig.maxHeight != null || // if its possible for the height to max out, we might need scrollbars
  8989. getSectionHasLiquidHeight(props, sectionConfig); // if the section is liquid height, it might condense enough to require scrollbars
  8990. }
  8991. // TODO: ONLY use `arg`. force out internal function to use same API
  8992. function renderChunkContent(sectionConfig, chunkConfig, arg, isHeader) {
  8993. var expandRows = arg.expandRows;
  8994. var content = typeof chunkConfig.content === 'function' ?
  8995. chunkConfig.content(arg) :
  8996. createElement('table', {
  8997. role: 'presentation',
  8998. className: [
  8999. chunkConfig.tableClassName,
  9000. sectionConfig.syncRowHeights ? 'fc-scrollgrid-sync-table' : '',
  9001. ].join(' '),
  9002. style: {
  9003. minWidth: arg.tableMinWidth,
  9004. width: arg.clientWidth,
  9005. height: expandRows ? arg.clientHeight : '', // css `height` on a <table> serves as a min-height
  9006. },
  9007. }, arg.tableColGroupNode, createElement(isHeader ? 'thead' : 'tbody', {
  9008. role: 'presentation',
  9009. }, typeof chunkConfig.rowContent === 'function'
  9010. ? chunkConfig.rowContent(arg)
  9011. : chunkConfig.rowContent));
  9012. return content;
  9013. }
  9014. function isColPropsEqual(cols0, cols1) {
  9015. return isArraysEqual(cols0, cols1, isPropsEqual);
  9016. }
  9017. function renderMicroColGroup(cols, shrinkWidth) {
  9018. var colNodes = [];
  9019. /*
  9020. for ColProps with spans, it would have been great to make a single <col span="">
  9021. HOWEVER, Chrome was getting messing up distributing the width to <td>/<th> elements with colspans.
  9022. SOLUTION: making individual <col> elements makes Chrome behave.
  9023. */
  9024. for (var _i = 0, cols_1 = cols; _i < cols_1.length; _i++) {
  9025. var colProps = cols_1[_i];
  9026. var span = colProps.span || 1;
  9027. for (var i = 0; i < span; i += 1) {
  9028. colNodes.push(createElement("col", { style: {
  9029. width: colProps.width === 'shrink' ? sanitizeShrinkWidth(shrinkWidth) : (colProps.width || ''),
  9030. minWidth: colProps.minWidth || '',
  9031. } }));
  9032. }
  9033. }
  9034. return createElement.apply(void 0, __spreadArray(['colgroup', {}], colNodes));
  9035. }
  9036. function sanitizeShrinkWidth(shrinkWidth) {
  9037. /* why 4? if we do 0, it will kill any border, which are needed for computeSmallestCellWidth
  9038. 4 accounts for 2 2-pixel borders. TODO: better solution? */
  9039. return shrinkWidth == null ? 4 : shrinkWidth;
  9040. }
  9041. function hasShrinkWidth(cols) {
  9042. for (var _i = 0, cols_2 = cols; _i < cols_2.length; _i++) {
  9043. var col = cols_2[_i];
  9044. if (col.width === 'shrink') {
  9045. return true;
  9046. }
  9047. }
  9048. return false;
  9049. }
  9050. function getScrollGridClassNames(liquid, context) {
  9051. var classNames = [
  9052. 'fc-scrollgrid',
  9053. context.theme.getClass('table'),
  9054. ];
  9055. if (liquid) {
  9056. classNames.push('fc-scrollgrid-liquid');
  9057. }
  9058. return classNames;
  9059. }
  9060. function getSectionClassNames(sectionConfig, wholeTableVGrow) {
  9061. var classNames = [
  9062. 'fc-scrollgrid-section',
  9063. "fc-scrollgrid-section-" + sectionConfig.type,
  9064. sectionConfig.className, // used?
  9065. ];
  9066. if (wholeTableVGrow && sectionConfig.liquid && sectionConfig.maxHeight == null) {
  9067. classNames.push('fc-scrollgrid-section-liquid');
  9068. }
  9069. if (sectionConfig.isSticky) {
  9070. classNames.push('fc-scrollgrid-section-sticky');
  9071. }
  9072. return classNames;
  9073. }
  9074. function renderScrollShim(arg) {
  9075. return (createElement("div", { className: "fc-scrollgrid-sticky-shim", style: {
  9076. width: arg.clientWidth,
  9077. minWidth: arg.tableMinWidth,
  9078. } }));
  9079. }
  9080. function getStickyHeaderDates(options) {
  9081. var stickyHeaderDates = options.stickyHeaderDates;
  9082. if (stickyHeaderDates == null || stickyHeaderDates === 'auto') {
  9083. stickyHeaderDates = options.height === 'auto' || options.viewHeight === 'auto';
  9084. }
  9085. return stickyHeaderDates;
  9086. }
  9087. function getStickyFooterScrollbar(options) {
  9088. var stickyFooterScrollbar = options.stickyFooterScrollbar;
  9089. if (stickyFooterScrollbar == null || stickyFooterScrollbar === 'auto') {
  9090. stickyFooterScrollbar = options.height === 'auto' || options.viewHeight === 'auto';
  9091. }
  9092. return stickyFooterScrollbar;
  9093. }
  9094. var SimpleScrollGrid = /** @class */ (function (_super) {
  9095. __extends(SimpleScrollGrid, _super);
  9096. function SimpleScrollGrid() {
  9097. var _this = _super !== null && _super.apply(this, arguments) || this;
  9098. _this.processCols = memoize(function (a) { return a; }, isColPropsEqual); // so we get same `cols` props every time
  9099. // yucky to memoize VNodes, but much more efficient for consumers
  9100. _this.renderMicroColGroup = memoize(renderMicroColGroup);
  9101. _this.scrollerRefs = new RefMap();
  9102. _this.scrollerElRefs = new RefMap(_this._handleScrollerEl.bind(_this));
  9103. _this.state = {
  9104. shrinkWidth: null,
  9105. forceYScrollbars: false,
  9106. scrollerClientWidths: {},
  9107. scrollerClientHeights: {},
  9108. };
  9109. // TODO: can do a really simple print-view. dont need to join rows
  9110. _this.handleSizing = function () {
  9111. _this.safeSetState(__assign({ shrinkWidth: _this.computeShrinkWidth() }, _this.computeScrollerDims()));
  9112. };
  9113. return _this;
  9114. }
  9115. SimpleScrollGrid.prototype.render = function () {
  9116. var _a = this, props = _a.props, state = _a.state, context = _a.context;
  9117. var sectionConfigs = props.sections || [];
  9118. var cols = this.processCols(props.cols);
  9119. var microColGroupNode = this.renderMicroColGroup(cols, state.shrinkWidth);
  9120. var classNames = getScrollGridClassNames(props.liquid, context);
  9121. if (props.collapsibleWidth) {
  9122. classNames.push('fc-scrollgrid-collapsible');
  9123. }
  9124. // TODO: make DRY
  9125. var configCnt = sectionConfigs.length;
  9126. var configI = 0;
  9127. var currentConfig;
  9128. var headSectionNodes = [];
  9129. var bodySectionNodes = [];
  9130. var footSectionNodes = [];
  9131. while (configI < configCnt && (currentConfig = sectionConfigs[configI]).type === 'header') {
  9132. headSectionNodes.push(this.renderSection(currentConfig, microColGroupNode, true));
  9133. configI += 1;
  9134. }
  9135. while (configI < configCnt && (currentConfig = sectionConfigs[configI]).type === 'body') {
  9136. bodySectionNodes.push(this.renderSection(currentConfig, microColGroupNode, false));
  9137. configI += 1;
  9138. }
  9139. while (configI < configCnt && (currentConfig = sectionConfigs[configI]).type === 'footer') {
  9140. footSectionNodes.push(this.renderSection(currentConfig, microColGroupNode, true));
  9141. configI += 1;
  9142. }
  9143. // firefox bug: when setting height on table and there is a thead or tfoot,
  9144. // the necessary height:100% on the liquid-height body section forces the *whole* table to be taller. (bug #5524)
  9145. // use getCanVGrowWithinCell as a way to detect table-stupid firefox.
  9146. // if so, use a simpler dom structure, jam everything into a lone tbody.
  9147. var isBuggy = !getCanVGrowWithinCell();
  9148. var roleAttrs = { role: 'rowgroup' };
  9149. return createElement('table', {
  9150. role: 'grid',
  9151. className: classNames.join(' '),
  9152. style: { height: props.height },
  9153. }, Boolean(!isBuggy && headSectionNodes.length) && createElement.apply(void 0, __spreadArray(['thead', roleAttrs], headSectionNodes)), Boolean(!isBuggy && bodySectionNodes.length) && createElement.apply(void 0, __spreadArray(['tbody', roleAttrs], bodySectionNodes)), Boolean(!isBuggy && footSectionNodes.length) && createElement.apply(void 0, __spreadArray(['tfoot', roleAttrs], footSectionNodes)), isBuggy && createElement.apply(void 0, __spreadArray(__spreadArray(__spreadArray(['tbody', roleAttrs], headSectionNodes), bodySectionNodes), footSectionNodes)));
  9154. };
  9155. SimpleScrollGrid.prototype.renderSection = function (sectionConfig, microColGroupNode, isHeader) {
  9156. if ('outerContent' in sectionConfig) {
  9157. return (createElement(Fragment, { key: sectionConfig.key }, sectionConfig.outerContent));
  9158. }
  9159. return (createElement("tr", { key: sectionConfig.key, role: "presentation", className: getSectionClassNames(sectionConfig, this.props.liquid).join(' ') }, this.renderChunkTd(sectionConfig, microColGroupNode, sectionConfig.chunk, isHeader)));
  9160. };
  9161. SimpleScrollGrid.prototype.renderChunkTd = function (sectionConfig, microColGroupNode, chunkConfig, isHeader) {
  9162. if ('outerContent' in chunkConfig) {
  9163. return chunkConfig.outerContent;
  9164. }
  9165. var props = this.props;
  9166. var _a = this.state, forceYScrollbars = _a.forceYScrollbars, scrollerClientWidths = _a.scrollerClientWidths, scrollerClientHeights = _a.scrollerClientHeights;
  9167. var needsYScrolling = getAllowYScrolling(props, sectionConfig); // TODO: do lazily. do in section config?
  9168. var isLiquid = getSectionHasLiquidHeight(props, sectionConfig);
  9169. // for `!props.liquid` - is WHOLE scrollgrid natural height?
  9170. // TODO: do same thing in advanced scrollgrid? prolly not b/c always has horizontal scrollbars
  9171. var overflowY = !props.liquid ? 'visible' :
  9172. forceYScrollbars ? 'scroll' :
  9173. !needsYScrolling ? 'hidden' :
  9174. 'auto';
  9175. var sectionKey = sectionConfig.key;
  9176. var content = renderChunkContent(sectionConfig, chunkConfig, {
  9177. tableColGroupNode: microColGroupNode,
  9178. tableMinWidth: '',
  9179. clientWidth: (!props.collapsibleWidth && scrollerClientWidths[sectionKey] !== undefined) ? scrollerClientWidths[sectionKey] : null,
  9180. clientHeight: scrollerClientHeights[sectionKey] !== undefined ? scrollerClientHeights[sectionKey] : null,
  9181. expandRows: sectionConfig.expandRows,
  9182. syncRowHeights: false,
  9183. rowSyncHeights: [],
  9184. reportRowHeightChange: function () { },
  9185. }, isHeader);
  9186. return createElement(isHeader ? 'th' : 'td', {
  9187. ref: chunkConfig.elRef,
  9188. role: 'presentation',
  9189. }, createElement("div", { className: "fc-scroller-harness" + (isLiquid ? ' fc-scroller-harness-liquid' : '') },
  9190. createElement(Scroller, { ref: this.scrollerRefs.createRef(sectionKey), elRef: this.scrollerElRefs.createRef(sectionKey), overflowY: overflowY, overflowX: !props.liquid ? 'visible' : 'hidden' /* natural height? */, maxHeight: sectionConfig.maxHeight, liquid: isLiquid, liquidIsAbsolute // because its within a harness
  9191. : true }, content)));
  9192. };
  9193. SimpleScrollGrid.prototype._handleScrollerEl = function (scrollerEl, key) {
  9194. var section = getSectionByKey(this.props.sections, key);
  9195. if (section) {
  9196. setRef(section.chunk.scrollerElRef, scrollerEl);
  9197. }
  9198. };
  9199. SimpleScrollGrid.prototype.componentDidMount = function () {
  9200. this.handleSizing();
  9201. this.context.addResizeHandler(this.handleSizing);
  9202. };
  9203. SimpleScrollGrid.prototype.componentDidUpdate = function () {
  9204. // TODO: need better solution when state contains non-sizing things
  9205. this.handleSizing();
  9206. };
  9207. SimpleScrollGrid.prototype.componentWillUnmount = function () {
  9208. this.context.removeResizeHandler(this.handleSizing);
  9209. };
  9210. SimpleScrollGrid.prototype.computeShrinkWidth = function () {
  9211. return hasShrinkWidth(this.props.cols)
  9212. ? computeShrinkWidth(this.scrollerElRefs.getAll())
  9213. : 0;
  9214. };
  9215. SimpleScrollGrid.prototype.computeScrollerDims = function () {
  9216. var scrollbarWidth = getScrollbarWidths();
  9217. var _a = this, scrollerRefs = _a.scrollerRefs, scrollerElRefs = _a.scrollerElRefs;
  9218. var forceYScrollbars = false;
  9219. var scrollerClientWidths = {};
  9220. var scrollerClientHeights = {};
  9221. for (var sectionKey in scrollerRefs.currentMap) {
  9222. var scroller = scrollerRefs.currentMap[sectionKey];
  9223. if (scroller && scroller.needsYScrolling()) {
  9224. forceYScrollbars = true;
  9225. break;
  9226. }
  9227. }
  9228. for (var _i = 0, _b = this.props.sections; _i < _b.length; _i++) {
  9229. var section = _b[_i];
  9230. var sectionKey = section.key;
  9231. var scrollerEl = scrollerElRefs.currentMap[sectionKey];
  9232. if (scrollerEl) {
  9233. var harnessEl = scrollerEl.parentNode; // TODO: weird way to get this. need harness b/c doesn't include table borders
  9234. scrollerClientWidths[sectionKey] = Math.floor(harnessEl.getBoundingClientRect().width - (forceYScrollbars
  9235. ? scrollbarWidth.y // use global because scroller might not have scrollbars yet but will need them in future
  9236. : 0));
  9237. scrollerClientHeights[sectionKey] = Math.floor(harnessEl.getBoundingClientRect().height);
  9238. }
  9239. }
  9240. return { forceYScrollbars: forceYScrollbars, scrollerClientWidths: scrollerClientWidths, scrollerClientHeights: scrollerClientHeights };
  9241. };
  9242. return SimpleScrollGrid;
  9243. }(BaseComponent));
  9244. SimpleScrollGrid.addStateEquality({
  9245. scrollerClientWidths: isPropsEqual,
  9246. scrollerClientHeights: isPropsEqual,
  9247. });
  9248. function getSectionByKey(sections, key) {
  9249. for (var _i = 0, sections_1 = sections; _i < sections_1.length; _i++) {
  9250. var section = sections_1[_i];
  9251. if (section.key === key) {
  9252. return section;
  9253. }
  9254. }
  9255. return null;
  9256. }
  9257. var EventRoot = /** @class */ (function (_super) {
  9258. __extends(EventRoot, _super);
  9259. function EventRoot() {
  9260. var _this = _super !== null && _super.apply(this, arguments) || this;
  9261. _this.elRef = createRef();
  9262. return _this;
  9263. }
  9264. EventRoot.prototype.render = function () {
  9265. var _a = this, props = _a.props, context = _a.context;
  9266. var options = context.options;
  9267. var seg = props.seg;
  9268. var eventRange = seg.eventRange;
  9269. var ui = eventRange.ui;
  9270. var hookProps = {
  9271. event: new EventApi(context, eventRange.def, eventRange.instance),
  9272. view: context.viewApi,
  9273. timeText: props.timeText,
  9274. textColor: ui.textColor,
  9275. backgroundColor: ui.backgroundColor,
  9276. borderColor: ui.borderColor,
  9277. isDraggable: !props.disableDragging && computeSegDraggable(seg, context),
  9278. isStartResizable: !props.disableResizing && computeSegStartResizable(seg, context),
  9279. isEndResizable: !props.disableResizing && computeSegEndResizable(seg),
  9280. isMirror: Boolean(props.isDragging || props.isResizing || props.isDateSelecting),
  9281. isStart: Boolean(seg.isStart),
  9282. isEnd: Boolean(seg.isEnd),
  9283. isPast: Boolean(props.isPast),
  9284. isFuture: Boolean(props.isFuture),
  9285. isToday: Boolean(props.isToday),
  9286. isSelected: Boolean(props.isSelected),
  9287. isDragging: Boolean(props.isDragging),
  9288. isResizing: Boolean(props.isResizing),
  9289. };
  9290. var standardClassNames = getEventClassNames(hookProps).concat(ui.classNames);
  9291. 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); }));
  9292. };
  9293. EventRoot.prototype.componentDidMount = function () {
  9294. setElSeg(this.elRef.current, this.props.seg);
  9295. };
  9296. /*
  9297. need to re-assign seg to the element if seg changes, even if the element is the same
  9298. */
  9299. EventRoot.prototype.componentDidUpdate = function (prevProps) {
  9300. var seg = this.props.seg;
  9301. if (seg !== prevProps.seg) {
  9302. setElSeg(this.elRef.current, seg);
  9303. }
  9304. };
  9305. return EventRoot;
  9306. }(BaseComponent));
  9307. // should not be a purecomponent
  9308. var StandardEvent = /** @class */ (function (_super) {
  9309. __extends(StandardEvent, _super);
  9310. function StandardEvent() {
  9311. return _super !== null && _super.apply(this, arguments) || this;
  9312. }
  9313. StandardEvent.prototype.render = function () {
  9314. var _a = this, props = _a.props, context = _a.context;
  9315. var seg = props.seg;
  9316. var timeFormat = context.options.eventTimeFormat || props.defaultTimeFormat;
  9317. var timeText = buildSegTimeText(seg, timeFormat, context, props.defaultDisplayEventTime, props.defaultDisplayEventEnd);
  9318. return (createElement(EventRoot, { seg: seg, timeText: timeText, disableDragging: props.disableDragging, disableResizing: props.disableResizing, defaultContent: props.defaultContent || renderInnerContent$4, isDragging: props.isDragging, isResizing: props.isResizing, isDateSelecting: props.isDateSelecting, isSelected: props.isSelected, isPast: props.isPast, isFuture: props.isFuture, isToday: props.isToday }, function (rootElRef, classNames, innerElRef, innerContent, hookProps) { return (createElement("a", __assign({ className: props.extraClassNames.concat(classNames).join(' '), style: {
  9319. borderColor: hookProps.borderColor,
  9320. backgroundColor: hookProps.backgroundColor,
  9321. }, ref: rootElRef }, getSegAnchorAttrs(seg, context)),
  9322. createElement("div", { className: "fc-event-main", ref: innerElRef, style: { color: hookProps.textColor } }, innerContent),
  9323. hookProps.isStartResizable &&
  9324. createElement("div", { className: "fc-event-resizer fc-event-resizer-start" }),
  9325. hookProps.isEndResizable &&
  9326. createElement("div", { className: "fc-event-resizer fc-event-resizer-end" }))); }));
  9327. };
  9328. return StandardEvent;
  9329. }(BaseComponent));
  9330. function renderInnerContent$4(innerProps) {
  9331. return (createElement("div", { className: "fc-event-main-frame" },
  9332. innerProps.timeText && (createElement("div", { className: "fc-event-time" }, innerProps.timeText)),
  9333. createElement("div", { className: "fc-event-title-container" },
  9334. createElement("div", { className: "fc-event-title fc-sticky" }, innerProps.event.title || createElement(Fragment, null, "\u00A0")))));
  9335. }
  9336. var NowIndicatorRoot = function (props) { return (createElement(ViewContextType.Consumer, null, function (context) {
  9337. var options = context.options;
  9338. var hookProps = {
  9339. isAxis: props.isAxis,
  9340. date: context.dateEnv.toDate(props.date),
  9341. view: context.viewApi,
  9342. };
  9343. return (createElement(RenderHook, { hookProps: hookProps, classNames: options.nowIndicatorClassNames, content: options.nowIndicatorContent, didMount: options.nowIndicatorDidMount, willUnmount: options.nowIndicatorWillUnmount }, props.children));
  9344. })); };
  9345. var DAY_NUM_FORMAT = createFormatter({ day: 'numeric' });
  9346. var DayCellContent = /** @class */ (function (_super) {
  9347. __extends(DayCellContent, _super);
  9348. function DayCellContent() {
  9349. return _super !== null && _super.apply(this, arguments) || this;
  9350. }
  9351. DayCellContent.prototype.render = function () {
  9352. var _a = this, props = _a.props, context = _a.context;
  9353. var options = context.options;
  9354. var hookProps = refineDayCellHookProps({
  9355. date: props.date,
  9356. dateProfile: props.dateProfile,
  9357. todayRange: props.todayRange,
  9358. showDayNumber: props.showDayNumber,
  9359. extraProps: props.extraHookProps,
  9360. viewApi: context.viewApi,
  9361. dateEnv: context.dateEnv,
  9362. });
  9363. return (createElement(ContentHook, { hookProps: hookProps, content: options.dayCellContent, defaultContent: props.defaultContent }, props.children));
  9364. };
  9365. return DayCellContent;
  9366. }(BaseComponent));
  9367. function refineDayCellHookProps(raw) {
  9368. var date = raw.date, dateEnv = raw.dateEnv;
  9369. var dayMeta = getDateMeta(date, raw.todayRange, null, raw.dateProfile);
  9370. return __assign(__assign(__assign({ date: dateEnv.toDate(date), view: raw.viewApi }, dayMeta), { dayNumberText: raw.showDayNumber ? dateEnv.format(date, DAY_NUM_FORMAT) : '' }), raw.extraProps);
  9371. }
  9372. var DayCellRoot = /** @class */ (function (_super) {
  9373. __extends(DayCellRoot, _super);
  9374. function DayCellRoot() {
  9375. var _this = _super !== null && _super.apply(this, arguments) || this;
  9376. _this.refineHookProps = memoizeObjArg(refineDayCellHookProps);
  9377. _this.normalizeClassNames = buildClassNameNormalizer();
  9378. return _this;
  9379. }
  9380. DayCellRoot.prototype.render = function () {
  9381. var _a = this, props = _a.props, context = _a.context;
  9382. var options = context.options;
  9383. var hookProps = this.refineHookProps({
  9384. date: props.date,
  9385. dateProfile: props.dateProfile,
  9386. todayRange: props.todayRange,
  9387. showDayNumber: props.showDayNumber,
  9388. extraProps: props.extraHookProps,
  9389. viewApi: context.viewApi,
  9390. dateEnv: context.dateEnv,
  9391. });
  9392. var classNames = getDayClassNames(hookProps, context.theme).concat(hookProps.isDisabled
  9393. ? [] // don't use custom classNames if disabled
  9394. : this.normalizeClassNames(options.dayCellClassNames, hookProps));
  9395. var dataAttrs = hookProps.isDisabled ? {} : {
  9396. 'data-date': formatDayString(props.date),
  9397. };
  9398. return (createElement(MountHook, { hookProps: hookProps, didMount: options.dayCellDidMount, willUnmount: options.dayCellWillUnmount, elRef: props.elRef }, function (rootElRef) { return props.children(rootElRef, classNames, dataAttrs, hookProps.isDisabled); }));
  9399. };
  9400. return DayCellRoot;
  9401. }(BaseComponent));
  9402. function renderFill(fillType) {
  9403. return (createElement("div", { className: "fc-" + fillType }));
  9404. }
  9405. var BgEvent = function (props) { return (createElement(EventRoot, { defaultContent: renderInnerContent$3, seg: props.seg /* uselesss i think */, timeText: "", disableDragging: true, disableResizing: true, isDragging: false, isResizing: false, isDateSelecting: false, isSelected: false, isPast: props.isPast, isFuture: props.isFuture, isToday: props.isToday }, function (rootElRef, classNames, innerElRef, innerContent, hookProps) { return (createElement("div", { ref: rootElRef, className: ['fc-bg-event'].concat(classNames).join(' '), style: {
  9406. backgroundColor: hookProps.backgroundColor,
  9407. } }, innerContent)); })); };
  9408. function renderInnerContent$3(props) {
  9409. var title = props.event.title;
  9410. return title && (createElement("div", { className: "fc-event-title" }, props.event.title));
  9411. }
  9412. var WeekNumberRoot = function (props) { return (createElement(ViewContextType.Consumer, null, function (context) {
  9413. var dateEnv = context.dateEnv, options = context.options;
  9414. var date = props.date;
  9415. var format = options.weekNumberFormat || props.defaultFormat;
  9416. var num = dateEnv.computeWeekNumber(date); // TODO: somehow use for formatting as well?
  9417. var text = dateEnv.format(date, format);
  9418. var hookProps = { num: num, text: text, date: date };
  9419. return (createElement(RenderHook, { hookProps: hookProps, classNames: options.weekNumberClassNames, content: options.weekNumberContent, defaultContent: renderInner, didMount: options.weekNumberDidMount, willUnmount: options.weekNumberWillUnmount }, props.children));
  9420. })); };
  9421. function renderInner(innerProps) {
  9422. return innerProps.text;
  9423. }
  9424. var PADDING_FROM_VIEWPORT = 10;
  9425. var Popover = /** @class */ (function (_super) {
  9426. __extends(Popover, _super);
  9427. function Popover() {
  9428. var _this = _super !== null && _super.apply(this, arguments) || this;
  9429. _this.state = {
  9430. titleId: getUniqueDomId(),
  9431. };
  9432. _this.handleRootEl = function (el) {
  9433. _this.rootEl = el;
  9434. if (_this.props.elRef) {
  9435. setRef(_this.props.elRef, el);
  9436. }
  9437. };
  9438. // Triggered when the user clicks *anywhere* in the document, for the autoHide feature
  9439. _this.handleDocumentMouseDown = function (ev) {
  9440. // only hide the popover if the click happened outside the popover
  9441. var target = getEventTargetViaRoot(ev);
  9442. if (!_this.rootEl.contains(target)) {
  9443. _this.handleCloseClick();
  9444. }
  9445. };
  9446. _this.handleDocumentKeyDown = function (ev) {
  9447. if (ev.key === 'Escape') {
  9448. _this.handleCloseClick();
  9449. }
  9450. };
  9451. _this.handleCloseClick = function () {
  9452. var onClose = _this.props.onClose;
  9453. if (onClose) {
  9454. onClose();
  9455. }
  9456. };
  9457. return _this;
  9458. }
  9459. Popover.prototype.render = function () {
  9460. var _a = this.context, theme = _a.theme, options = _a.options;
  9461. var _b = this, props = _b.props, state = _b.state;
  9462. var classNames = [
  9463. 'fc-popover',
  9464. theme.getClass('popover'),
  9465. ].concat(props.extraClassNames || []);
  9466. return createPortal(createElement("div", __assign({ id: props.id, className: classNames.join(' '), "aria-labelledby": state.titleId }, props.extraAttrs, { ref: this.handleRootEl }),
  9467. createElement("div", { className: 'fc-popover-header ' + theme.getClass('popoverHeader') },
  9468. createElement("span", { className: "fc-popover-title", id: state.titleId }, props.title),
  9469. createElement("span", { className: 'fc-popover-close ' + theme.getIconClass('close'), title: options.closeHint, onClick: this.handleCloseClick })),
  9470. createElement("div", { className: 'fc-popover-body ' + theme.getClass('popoverContent') }, props.children)), props.parentEl);
  9471. };
  9472. Popover.prototype.componentDidMount = function () {
  9473. document.addEventListener('mousedown', this.handleDocumentMouseDown);
  9474. document.addEventListener('keydown', this.handleDocumentKeyDown);
  9475. this.updateSize();
  9476. };
  9477. Popover.prototype.componentWillUnmount = function () {
  9478. document.removeEventListener('mousedown', this.handleDocumentMouseDown);
  9479. document.removeEventListener('keydown', this.handleDocumentKeyDown);
  9480. };
  9481. Popover.prototype.updateSize = function () {
  9482. var isRtl = this.context.isRtl;
  9483. var _a = this.props, alignmentEl = _a.alignmentEl, alignGridTop = _a.alignGridTop;
  9484. var rootEl = this.rootEl;
  9485. var alignmentRect = computeClippedClientRect(alignmentEl);
  9486. if (alignmentRect) {
  9487. var popoverDims = rootEl.getBoundingClientRect();
  9488. // position relative to viewport
  9489. var popoverTop = alignGridTop
  9490. ? elementClosest(alignmentEl, '.fc-scrollgrid').getBoundingClientRect().top
  9491. : alignmentRect.top;
  9492. var popoverLeft = isRtl ? alignmentRect.right - popoverDims.width : alignmentRect.left;
  9493. // constrain
  9494. popoverTop = Math.max(popoverTop, PADDING_FROM_VIEWPORT);
  9495. popoverLeft = Math.min(popoverLeft, document.documentElement.clientWidth - PADDING_FROM_VIEWPORT - popoverDims.width);
  9496. popoverLeft = Math.max(popoverLeft, PADDING_FROM_VIEWPORT);
  9497. var origin_1 = rootEl.offsetParent.getBoundingClientRect();
  9498. applyStyle(rootEl, {
  9499. top: popoverTop - origin_1.top,
  9500. left: popoverLeft - origin_1.left,
  9501. });
  9502. }
  9503. };
  9504. return Popover;
  9505. }(BaseComponent));
  9506. var MorePopover = /** @class */ (function (_super) {
  9507. __extends(MorePopover, _super);
  9508. function MorePopover() {
  9509. var _this = _super !== null && _super.apply(this, arguments) || this;
  9510. _this.handleRootEl = function (rootEl) {
  9511. _this.rootEl = rootEl;
  9512. if (rootEl) {
  9513. _this.context.registerInteractiveComponent(_this, {
  9514. el: rootEl,
  9515. useEventCenter: false,
  9516. });
  9517. }
  9518. else {
  9519. _this.context.unregisterInteractiveComponent(_this);
  9520. }
  9521. };
  9522. return _this;
  9523. }
  9524. MorePopover.prototype.render = function () {
  9525. var _a = this.context, options = _a.options, dateEnv = _a.dateEnv;
  9526. var props = this.props;
  9527. var startDate = props.startDate, todayRange = props.todayRange, dateProfile = props.dateProfile;
  9528. var title = dateEnv.format(startDate, options.dayPopoverFormat);
  9529. return (createElement(DayCellRoot, { date: startDate, dateProfile: dateProfile, todayRange: todayRange, elRef: this.handleRootEl }, function (rootElRef, dayClassNames, dataAttrs) { return (createElement(Popover, { elRef: rootElRef, id: props.id, title: title, extraClassNames: ['fc-more-popover'].concat(dayClassNames), extraAttrs: dataAttrs /* TODO: make these time-based when not whole-day? */, parentEl: props.parentEl, alignmentEl: props.alignmentEl, alignGridTop: props.alignGridTop, onClose: props.onClose },
  9530. createElement(DayCellContent, { date: startDate, dateProfile: dateProfile, todayRange: todayRange }, function (innerElRef, innerContent) { return (innerContent &&
  9531. createElement("div", { className: "fc-more-popover-misc", ref: innerElRef }, innerContent)); }),
  9532. props.children)); }));
  9533. };
  9534. MorePopover.prototype.queryHit = function (positionLeft, positionTop, elWidth, elHeight) {
  9535. var _a = this, rootEl = _a.rootEl, props = _a.props;
  9536. if (positionLeft >= 0 && positionLeft < elWidth &&
  9537. positionTop >= 0 && positionTop < elHeight) {
  9538. return {
  9539. dateProfile: props.dateProfile,
  9540. dateSpan: __assign({ allDay: true, range: {
  9541. start: props.startDate,
  9542. end: props.endDate,
  9543. } }, props.extraDateSpan),
  9544. dayEl: rootEl,
  9545. rect: {
  9546. left: 0,
  9547. top: 0,
  9548. right: elWidth,
  9549. bottom: elHeight,
  9550. },
  9551. layer: 1, // important when comparing with hits from other components
  9552. };
  9553. }
  9554. return null;
  9555. };
  9556. return MorePopover;
  9557. }(DateComponent));
  9558. var MoreLinkRoot = /** @class */ (function (_super) {
  9559. __extends(MoreLinkRoot, _super);
  9560. function MoreLinkRoot() {
  9561. var _this = _super !== null && _super.apply(this, arguments) || this;
  9562. _this.linkElRef = createRef();
  9563. _this.state = {
  9564. isPopoverOpen: false,
  9565. popoverId: getUniqueDomId(),
  9566. };
  9567. _this.handleClick = function (ev) {
  9568. var _a = _this, props = _a.props, context = _a.context;
  9569. var moreLinkClick = context.options.moreLinkClick;
  9570. var date = computeRange(props).start;
  9571. function buildPublicSeg(seg) {
  9572. var _a = seg.eventRange, def = _a.def, instance = _a.instance, range = _a.range;
  9573. return {
  9574. event: new EventApi(context, def, instance),
  9575. start: context.dateEnv.toDate(range.start),
  9576. end: context.dateEnv.toDate(range.end),
  9577. isStart: seg.isStart,
  9578. isEnd: seg.isEnd,
  9579. };
  9580. }
  9581. if (typeof moreLinkClick === 'function') {
  9582. moreLinkClick = moreLinkClick({
  9583. date: date,
  9584. allDay: Boolean(props.allDayDate),
  9585. allSegs: props.allSegs.map(buildPublicSeg),
  9586. hiddenSegs: props.hiddenSegs.map(buildPublicSeg),
  9587. jsEvent: ev,
  9588. view: context.viewApi,
  9589. });
  9590. }
  9591. if (!moreLinkClick || moreLinkClick === 'popover') {
  9592. _this.setState({ isPopoverOpen: true });
  9593. }
  9594. else if (typeof moreLinkClick === 'string') { // a view name
  9595. context.calendarApi.zoomTo(date, moreLinkClick);
  9596. }
  9597. };
  9598. _this.handlePopoverClose = function () {
  9599. _this.setState({ isPopoverOpen: false });
  9600. };
  9601. return _this;
  9602. }
  9603. MoreLinkRoot.prototype.render = function () {
  9604. var _this = this;
  9605. var _a = this, props = _a.props, state = _a.state;
  9606. return (createElement(ViewContextType.Consumer, null, function (context) {
  9607. var viewApi = context.viewApi, options = context.options, calendarApi = context.calendarApi;
  9608. var moreLinkText = options.moreLinkText;
  9609. var moreCnt = props.moreCnt;
  9610. var range = computeRange(props);
  9611. var text = typeof moreLinkText === 'function' // TODO: eventually use formatWithOrdinals
  9612. ? moreLinkText.call(calendarApi, moreCnt)
  9613. : "+" + moreCnt + " " + moreLinkText;
  9614. var title = formatWithOrdinals(options.moreLinkHint, [moreCnt], text);
  9615. var hookProps = {
  9616. num: moreCnt,
  9617. shortText: "+" + moreCnt,
  9618. text: text,
  9619. view: viewApi,
  9620. };
  9621. return (createElement(Fragment, null,
  9622. Boolean(props.moreCnt) && (createElement(RenderHook, { elRef: _this.linkElRef, hookProps: hookProps, classNames: options.moreLinkClassNames, content: options.moreLinkContent, defaultContent: props.defaultContent || renderMoreLinkInner$1, didMount: options.moreLinkDidMount, willUnmount: options.moreLinkWillUnmount }, function (rootElRef, customClassNames, innerElRef, innerContent) { return props.children(rootElRef, ['fc-more-link'].concat(customClassNames), innerElRef, innerContent, _this.handleClick, title, state.isPopoverOpen, state.isPopoverOpen ? state.popoverId : ''); })),
  9623. state.isPopoverOpen && (createElement(MorePopover, { id: state.popoverId, startDate: range.start, endDate: range.end, dateProfile: props.dateProfile, todayRange: props.todayRange, extraDateSpan: props.extraDateSpan, parentEl: _this.parentEl, alignmentEl: props.alignmentElRef.current, alignGridTop: props.alignGridTop, onClose: _this.handlePopoverClose }, props.popoverContent()))));
  9624. }));
  9625. };
  9626. MoreLinkRoot.prototype.componentDidMount = function () {
  9627. this.updateParentEl();
  9628. };
  9629. MoreLinkRoot.prototype.componentDidUpdate = function () {
  9630. this.updateParentEl();
  9631. };
  9632. MoreLinkRoot.prototype.updateParentEl = function () {
  9633. if (this.linkElRef.current) {
  9634. this.parentEl = elementClosest(this.linkElRef.current, '.fc-view-harness');
  9635. }
  9636. };
  9637. return MoreLinkRoot;
  9638. }(BaseComponent));
  9639. function renderMoreLinkInner$1(props) {
  9640. return props.text;
  9641. }
  9642. function computeRange(props) {
  9643. if (props.allDayDate) {
  9644. return {
  9645. start: props.allDayDate,
  9646. end: addDays(props.allDayDate, 1),
  9647. };
  9648. }
  9649. var hiddenSegs = props.hiddenSegs;
  9650. return {
  9651. start: computeEarliestSegStart(hiddenSegs),
  9652. end: computeLatestSegEnd(hiddenSegs),
  9653. };
  9654. }
  9655. function computeEarliestSegStart(segs) {
  9656. return segs.reduce(pickEarliestStart).eventRange.range.start;
  9657. }
  9658. function pickEarliestStart(seg0, seg1) {
  9659. return seg0.eventRange.range.start < seg1.eventRange.range.start ? seg0 : seg1;
  9660. }
  9661. function computeLatestSegEnd(segs) {
  9662. return segs.reduce(pickLatestEnd).eventRange.range.end;
  9663. }
  9664. function pickLatestEnd(seg0, seg1) {
  9665. return seg0.eventRange.range.end > seg1.eventRange.range.end ? seg0 : seg1;
  9666. }
  9667. // exports
  9668. // --------------------------------------------------------------------------------------------------
  9669. var version = '5.11.3'; // important to type it, so .d.ts has generic string
  9670. var Calendar = /** @class */ (function (_super) {
  9671. __extends(Calendar, _super);
  9672. function Calendar(el, optionOverrides) {
  9673. if (optionOverrides === void 0) { optionOverrides = {}; }
  9674. var _this = _super.call(this) || this;
  9675. _this.isRendering = false;
  9676. _this.isRendered = false;
  9677. _this.currentClassNames = [];
  9678. _this.customContentRenderId = 0; // will affect custom generated classNames?
  9679. _this.handleAction = function (action) {
  9680. // actions we know we want to render immediately
  9681. switch (action.type) {
  9682. case 'SET_EVENT_DRAG':
  9683. case 'SET_EVENT_RESIZE':
  9684. _this.renderRunner.tryDrain();
  9685. }
  9686. };
  9687. _this.handleData = function (data) {
  9688. _this.currentData = data;
  9689. _this.renderRunner.request(data.calendarOptions.rerenderDelay);
  9690. };
  9691. _this.handleRenderRequest = function () {
  9692. if (_this.isRendering) {
  9693. _this.isRendered = true;
  9694. var currentData_1 = _this.currentData;
  9695. flushSync(function () {
  9696. render(createElement(CalendarRoot, { options: currentData_1.calendarOptions, theme: currentData_1.theme, emitter: currentData_1.emitter }, function (classNames, height, isHeightAuto, forPrint) {
  9697. _this.setClassNames(classNames);
  9698. _this.setHeight(height);
  9699. return (createElement(CustomContentRenderContext.Provider, { value: _this.customContentRenderId },
  9700. createElement(CalendarContent, __assign({ isHeightAuto: isHeightAuto, forPrint: forPrint }, currentData_1))));
  9701. }), _this.el);
  9702. });
  9703. }
  9704. else if (_this.isRendered) {
  9705. _this.isRendered = false;
  9706. unmountComponentAtNode(_this.el);
  9707. _this.setClassNames([]);
  9708. _this.setHeight('');
  9709. }
  9710. };
  9711. _this.el = el;
  9712. _this.renderRunner = new DelayedRunner(_this.handleRenderRequest);
  9713. new CalendarDataManager({
  9714. optionOverrides: optionOverrides,
  9715. calendarApi: _this,
  9716. onAction: _this.handleAction,
  9717. onData: _this.handleData,
  9718. });
  9719. return _this;
  9720. }
  9721. Object.defineProperty(Calendar.prototype, "view", {
  9722. get: function () { return this.currentData.viewApi; } // for public API
  9723. ,
  9724. enumerable: false,
  9725. configurable: true
  9726. });
  9727. Calendar.prototype.render = function () {
  9728. var wasRendering = this.isRendering;
  9729. if (!wasRendering) {
  9730. this.isRendering = true;
  9731. }
  9732. else {
  9733. this.customContentRenderId += 1;
  9734. }
  9735. this.renderRunner.request();
  9736. if (wasRendering) {
  9737. this.updateSize();
  9738. }
  9739. };
  9740. Calendar.prototype.destroy = function () {
  9741. if (this.isRendering) {
  9742. this.isRendering = false;
  9743. this.renderRunner.request();
  9744. }
  9745. };
  9746. Calendar.prototype.updateSize = function () {
  9747. var _this = this;
  9748. flushSync(function () {
  9749. _super.prototype.updateSize.call(_this);
  9750. });
  9751. };
  9752. Calendar.prototype.batchRendering = function (func) {
  9753. this.renderRunner.pause('batchRendering');
  9754. func();
  9755. this.renderRunner.resume('batchRendering');
  9756. };
  9757. Calendar.prototype.pauseRendering = function () {
  9758. this.renderRunner.pause('pauseRendering');
  9759. };
  9760. Calendar.prototype.resumeRendering = function () {
  9761. this.renderRunner.resume('pauseRendering', true);
  9762. };
  9763. Calendar.prototype.resetOptions = function (optionOverrides, append) {
  9764. this.currentDataManager.resetOptions(optionOverrides, append);
  9765. };
  9766. Calendar.prototype.setClassNames = function (classNames) {
  9767. if (!isArraysEqual(classNames, this.currentClassNames)) {
  9768. var classList = this.el.classList;
  9769. for (var _i = 0, _a = this.currentClassNames; _i < _a.length; _i++) {
  9770. var className = _a[_i];
  9771. classList.remove(className);
  9772. }
  9773. for (var _b = 0, classNames_1 = classNames; _b < classNames_1.length; _b++) {
  9774. var className = classNames_1[_b];
  9775. classList.add(className);
  9776. }
  9777. this.currentClassNames = classNames;
  9778. }
  9779. };
  9780. Calendar.prototype.setHeight = function (height) {
  9781. applyStyleProp(this.el, 'height', height);
  9782. };
  9783. return Calendar;
  9784. }(CalendarApi));
  9785. config.touchMouseIgnoreWait = 500;
  9786. var ignoreMouseDepth = 0;
  9787. var listenerCnt = 0;
  9788. var isWindowTouchMoveCancelled = false;
  9789. /*
  9790. Uses a "pointer" abstraction, which monitors UI events for both mouse and touch.
  9791. Tracks when the pointer "drags" on a certain element, meaning down+move+up.
  9792. Also, tracks if there was touch-scrolling.
  9793. Also, can prevent touch-scrolling from happening.
  9794. Also, can fire pointermove events when scrolling happens underneath, even when no real pointer movement.
  9795. emits:
  9796. - pointerdown
  9797. - pointermove
  9798. - pointerup
  9799. */
  9800. var PointerDragging = /** @class */ (function () {
  9801. function PointerDragging(containerEl) {
  9802. var _this = this;
  9803. this.subjectEl = null;
  9804. // options that can be directly assigned by caller
  9805. this.selector = ''; // will cause subjectEl in all emitted events to be this element
  9806. this.handleSelector = '';
  9807. this.shouldIgnoreMove = false;
  9808. this.shouldWatchScroll = true; // for simulating pointermove on scroll
  9809. // internal states
  9810. this.isDragging = false;
  9811. this.isTouchDragging = false;
  9812. this.wasTouchScroll = false;
  9813. // Mouse
  9814. // ----------------------------------------------------------------------------------------------------
  9815. this.handleMouseDown = function (ev) {
  9816. if (!_this.shouldIgnoreMouse() &&
  9817. isPrimaryMouseButton(ev) &&
  9818. _this.tryStart(ev)) {
  9819. var pev = _this.createEventFromMouse(ev, true);
  9820. _this.emitter.trigger('pointerdown', pev);
  9821. _this.initScrollWatch(pev);
  9822. if (!_this.shouldIgnoreMove) {
  9823. document.addEventListener('mousemove', _this.handleMouseMove);
  9824. }
  9825. document.addEventListener('mouseup', _this.handleMouseUp);
  9826. }
  9827. };
  9828. this.handleMouseMove = function (ev) {
  9829. var pev = _this.createEventFromMouse(ev);
  9830. _this.recordCoords(pev);
  9831. _this.emitter.trigger('pointermove', pev);
  9832. };
  9833. this.handleMouseUp = function (ev) {
  9834. document.removeEventListener('mousemove', _this.handleMouseMove);
  9835. document.removeEventListener('mouseup', _this.handleMouseUp);
  9836. _this.emitter.trigger('pointerup', _this.createEventFromMouse(ev));
  9837. _this.cleanup(); // call last so that pointerup has access to props
  9838. };
  9839. // Touch
  9840. // ----------------------------------------------------------------------------------------------------
  9841. this.handleTouchStart = function (ev) {
  9842. if (_this.tryStart(ev)) {
  9843. _this.isTouchDragging = true;
  9844. var pev = _this.createEventFromTouch(ev, true);
  9845. _this.emitter.trigger('pointerdown', pev);
  9846. _this.initScrollWatch(pev);
  9847. // unlike mouse, need to attach to target, not document
  9848. // https://stackoverflow.com/a/45760014
  9849. var targetEl = ev.target;
  9850. if (!_this.shouldIgnoreMove) {
  9851. targetEl.addEventListener('touchmove', _this.handleTouchMove);
  9852. }
  9853. targetEl.addEventListener('touchend', _this.handleTouchEnd);
  9854. targetEl.addEventListener('touchcancel', _this.handleTouchEnd); // treat it as a touch end
  9855. // attach a handler to get called when ANY scroll action happens on the page.
  9856. // this was impossible to do with normal on/off because 'scroll' doesn't bubble.
  9857. // http://stackoverflow.com/a/32954565/96342
  9858. window.addEventListener('scroll', _this.handleTouchScroll, true);
  9859. }
  9860. };
  9861. this.handleTouchMove = function (ev) {
  9862. var pev = _this.createEventFromTouch(ev);
  9863. _this.recordCoords(pev);
  9864. _this.emitter.trigger('pointermove', pev);
  9865. };
  9866. this.handleTouchEnd = function (ev) {
  9867. if (_this.isDragging) { // done to guard against touchend followed by touchcancel
  9868. var targetEl = ev.target;
  9869. targetEl.removeEventListener('touchmove', _this.handleTouchMove);
  9870. targetEl.removeEventListener('touchend', _this.handleTouchEnd);
  9871. targetEl.removeEventListener('touchcancel', _this.handleTouchEnd);
  9872. window.removeEventListener('scroll', _this.handleTouchScroll, true); // useCaptured=true
  9873. _this.emitter.trigger('pointerup', _this.createEventFromTouch(ev));
  9874. _this.cleanup(); // call last so that pointerup has access to props
  9875. _this.isTouchDragging = false;
  9876. startIgnoringMouse();
  9877. }
  9878. };
  9879. this.handleTouchScroll = function () {
  9880. _this.wasTouchScroll = true;
  9881. };
  9882. this.handleScroll = function (ev) {
  9883. if (!_this.shouldIgnoreMove) {
  9884. var pageX = (window.pageXOffset - _this.prevScrollX) + _this.prevPageX;
  9885. var pageY = (window.pageYOffset - _this.prevScrollY) + _this.prevPageY;
  9886. _this.emitter.trigger('pointermove', {
  9887. origEvent: ev,
  9888. isTouch: _this.isTouchDragging,
  9889. subjectEl: _this.subjectEl,
  9890. pageX: pageX,
  9891. pageY: pageY,
  9892. deltaX: pageX - _this.origPageX,
  9893. deltaY: pageY - _this.origPageY,
  9894. });
  9895. }
  9896. };
  9897. this.containerEl = containerEl;
  9898. this.emitter = new Emitter();
  9899. containerEl.addEventListener('mousedown', this.handleMouseDown);
  9900. containerEl.addEventListener('touchstart', this.handleTouchStart, { passive: true });
  9901. listenerCreated();
  9902. }
  9903. PointerDragging.prototype.destroy = function () {
  9904. this.containerEl.removeEventListener('mousedown', this.handleMouseDown);
  9905. this.containerEl.removeEventListener('touchstart', this.handleTouchStart, { passive: true });
  9906. listenerDestroyed();
  9907. };
  9908. PointerDragging.prototype.tryStart = function (ev) {
  9909. var subjectEl = this.querySubjectEl(ev);
  9910. var downEl = ev.target;
  9911. if (subjectEl &&
  9912. (!this.handleSelector || elementClosest(downEl, this.handleSelector))) {
  9913. this.subjectEl = subjectEl;
  9914. this.isDragging = true; // do this first so cancelTouchScroll will work
  9915. this.wasTouchScroll = false;
  9916. return true;
  9917. }
  9918. return false;
  9919. };
  9920. PointerDragging.prototype.cleanup = function () {
  9921. isWindowTouchMoveCancelled = false;
  9922. this.isDragging = false;
  9923. this.subjectEl = null;
  9924. // keep wasTouchScroll around for later access
  9925. this.destroyScrollWatch();
  9926. };
  9927. PointerDragging.prototype.querySubjectEl = function (ev) {
  9928. if (this.selector) {
  9929. return elementClosest(ev.target, this.selector);
  9930. }
  9931. return this.containerEl;
  9932. };
  9933. PointerDragging.prototype.shouldIgnoreMouse = function () {
  9934. return ignoreMouseDepth || this.isTouchDragging;
  9935. };
  9936. // can be called by user of this class, to cancel touch-based scrolling for the current drag
  9937. PointerDragging.prototype.cancelTouchScroll = function () {
  9938. if (this.isDragging) {
  9939. isWindowTouchMoveCancelled = true;
  9940. }
  9941. };
  9942. // Scrolling that simulates pointermoves
  9943. // ----------------------------------------------------------------------------------------------------
  9944. PointerDragging.prototype.initScrollWatch = function (ev) {
  9945. if (this.shouldWatchScroll) {
  9946. this.recordCoords(ev);
  9947. window.addEventListener('scroll', this.handleScroll, true); // useCapture=true
  9948. }
  9949. };
  9950. PointerDragging.prototype.recordCoords = function (ev) {
  9951. if (this.shouldWatchScroll) {
  9952. this.prevPageX = ev.pageX;
  9953. this.prevPageY = ev.pageY;
  9954. this.prevScrollX = window.pageXOffset;
  9955. this.prevScrollY = window.pageYOffset;
  9956. }
  9957. };
  9958. PointerDragging.prototype.destroyScrollWatch = function () {
  9959. if (this.shouldWatchScroll) {
  9960. window.removeEventListener('scroll', this.handleScroll, true); // useCaptured=true
  9961. }
  9962. };
  9963. // Event Normalization
  9964. // ----------------------------------------------------------------------------------------------------
  9965. PointerDragging.prototype.createEventFromMouse = function (ev, isFirst) {
  9966. var deltaX = 0;
  9967. var deltaY = 0;
  9968. // TODO: repeat code
  9969. if (isFirst) {
  9970. this.origPageX = ev.pageX;
  9971. this.origPageY = ev.pageY;
  9972. }
  9973. else {
  9974. deltaX = ev.pageX - this.origPageX;
  9975. deltaY = ev.pageY - this.origPageY;
  9976. }
  9977. return {
  9978. origEvent: ev,
  9979. isTouch: false,
  9980. subjectEl: this.subjectEl,
  9981. pageX: ev.pageX,
  9982. pageY: ev.pageY,
  9983. deltaX: deltaX,
  9984. deltaY: deltaY,
  9985. };
  9986. };
  9987. PointerDragging.prototype.createEventFromTouch = function (ev, isFirst) {
  9988. var touches = ev.touches;
  9989. var pageX;
  9990. var pageY;
  9991. var deltaX = 0;
  9992. var deltaY = 0;
  9993. // if touch coords available, prefer,
  9994. // because FF would give bad ev.pageX ev.pageY
  9995. if (touches && touches.length) {
  9996. pageX = touches[0].pageX;
  9997. pageY = touches[0].pageY;
  9998. }
  9999. else {
  10000. pageX = ev.pageX;
  10001. pageY = ev.pageY;
  10002. }
  10003. // TODO: repeat code
  10004. if (isFirst) {
  10005. this.origPageX = pageX;
  10006. this.origPageY = pageY;
  10007. }
  10008. else {
  10009. deltaX = pageX - this.origPageX;
  10010. deltaY = pageY - this.origPageY;
  10011. }
  10012. return {
  10013. origEvent: ev,
  10014. isTouch: true,
  10015. subjectEl: this.subjectEl,
  10016. pageX: pageX,
  10017. pageY: pageY,
  10018. deltaX: deltaX,
  10019. deltaY: deltaY,
  10020. };
  10021. };
  10022. return PointerDragging;
  10023. }());
  10024. // Returns a boolean whether this was a left mouse click and no ctrl key (which means right click on Mac)
  10025. function isPrimaryMouseButton(ev) {
  10026. return ev.button === 0 && !ev.ctrlKey;
  10027. }
  10028. // Ignoring fake mouse events generated by touch
  10029. // ----------------------------------------------------------------------------------------------------
  10030. function startIgnoringMouse() {
  10031. ignoreMouseDepth += 1;
  10032. setTimeout(function () {
  10033. ignoreMouseDepth -= 1;
  10034. }, config.touchMouseIgnoreWait);
  10035. }
  10036. // We want to attach touchmove as early as possible for Safari
  10037. // ----------------------------------------------------------------------------------------------------
  10038. function listenerCreated() {
  10039. listenerCnt += 1;
  10040. if (listenerCnt === 1) {
  10041. window.addEventListener('touchmove', onWindowTouchMove, { passive: false });
  10042. }
  10043. }
  10044. function listenerDestroyed() {
  10045. listenerCnt -= 1;
  10046. if (!listenerCnt) {
  10047. window.removeEventListener('touchmove', onWindowTouchMove, { passive: false });
  10048. }
  10049. }
  10050. function onWindowTouchMove(ev) {
  10051. if (isWindowTouchMoveCancelled) {
  10052. ev.preventDefault();
  10053. }
  10054. }
  10055. /*
  10056. An effect in which an element follows the movement of a pointer across the screen.
  10057. The moving element is a clone of some other element.
  10058. Must call start + handleMove + stop.
  10059. */
  10060. var ElementMirror = /** @class */ (function () {
  10061. function ElementMirror() {
  10062. this.isVisible = false; // must be explicitly enabled
  10063. this.sourceEl = null;
  10064. this.mirrorEl = null;
  10065. this.sourceElRect = null; // screen coords relative to viewport
  10066. // options that can be set directly by caller
  10067. this.parentNode = document.body; // HIGHLY SUGGESTED to set this to sidestep ShadowDOM issues
  10068. this.zIndex = 9999;
  10069. this.revertDuration = 0;
  10070. }
  10071. ElementMirror.prototype.start = function (sourceEl, pageX, pageY) {
  10072. this.sourceEl = sourceEl;
  10073. this.sourceElRect = this.sourceEl.getBoundingClientRect();
  10074. this.origScreenX = pageX - window.pageXOffset;
  10075. this.origScreenY = pageY - window.pageYOffset;
  10076. this.deltaX = 0;
  10077. this.deltaY = 0;
  10078. this.updateElPosition();
  10079. };
  10080. ElementMirror.prototype.handleMove = function (pageX, pageY) {
  10081. this.deltaX = (pageX - window.pageXOffset) - this.origScreenX;
  10082. this.deltaY = (pageY - window.pageYOffset) - this.origScreenY;
  10083. this.updateElPosition();
  10084. };
  10085. // can be called before start
  10086. ElementMirror.prototype.setIsVisible = function (bool) {
  10087. if (bool) {
  10088. if (!this.isVisible) {
  10089. if (this.mirrorEl) {
  10090. this.mirrorEl.style.display = '';
  10091. }
  10092. this.isVisible = bool; // needs to happen before updateElPosition
  10093. this.updateElPosition(); // because was not updating the position while invisible
  10094. }
  10095. }
  10096. else if (this.isVisible) {
  10097. if (this.mirrorEl) {
  10098. this.mirrorEl.style.display = 'none';
  10099. }
  10100. this.isVisible = bool;
  10101. }
  10102. };
  10103. // always async
  10104. ElementMirror.prototype.stop = function (needsRevertAnimation, callback) {
  10105. var _this = this;
  10106. var done = function () {
  10107. _this.cleanup();
  10108. callback();
  10109. };
  10110. if (needsRevertAnimation &&
  10111. this.mirrorEl &&
  10112. this.isVisible &&
  10113. this.revertDuration && // if 0, transition won't work
  10114. (this.deltaX || this.deltaY) // if same coords, transition won't work
  10115. ) {
  10116. this.doRevertAnimation(done, this.revertDuration);
  10117. }
  10118. else {
  10119. setTimeout(done, 0);
  10120. }
  10121. };
  10122. ElementMirror.prototype.doRevertAnimation = function (callback, revertDuration) {
  10123. var mirrorEl = this.mirrorEl;
  10124. var finalSourceElRect = this.sourceEl.getBoundingClientRect(); // because autoscrolling might have happened
  10125. mirrorEl.style.transition =
  10126. 'top ' + revertDuration + 'ms,' +
  10127. 'left ' + revertDuration + 'ms';
  10128. applyStyle(mirrorEl, {
  10129. left: finalSourceElRect.left,
  10130. top: finalSourceElRect.top,
  10131. });
  10132. whenTransitionDone(mirrorEl, function () {
  10133. mirrorEl.style.transition = '';
  10134. callback();
  10135. });
  10136. };
  10137. ElementMirror.prototype.cleanup = function () {
  10138. if (this.mirrorEl) {
  10139. removeElement(this.mirrorEl);
  10140. this.mirrorEl = null;
  10141. }
  10142. this.sourceEl = null;
  10143. };
  10144. ElementMirror.prototype.updateElPosition = function () {
  10145. if (this.sourceEl && this.isVisible) {
  10146. applyStyle(this.getMirrorEl(), {
  10147. left: this.sourceElRect.left + this.deltaX,
  10148. top: this.sourceElRect.top + this.deltaY,
  10149. });
  10150. }
  10151. };
  10152. ElementMirror.prototype.getMirrorEl = function () {
  10153. var sourceElRect = this.sourceElRect;
  10154. var mirrorEl = this.mirrorEl;
  10155. if (!mirrorEl) {
  10156. mirrorEl = this.mirrorEl = this.sourceEl.cloneNode(true); // cloneChildren=true
  10157. // we don't want long taps or any mouse interaction causing selection/menus.
  10158. // would use preventSelection(), but that prevents selectstart, causing problems.
  10159. mirrorEl.classList.add('fc-unselectable');
  10160. mirrorEl.classList.add('fc-event-dragging');
  10161. applyStyle(mirrorEl, {
  10162. position: 'fixed',
  10163. zIndex: this.zIndex,
  10164. visibility: '',
  10165. boxSizing: 'border-box',
  10166. width: sourceElRect.right - sourceElRect.left,
  10167. height: sourceElRect.bottom - sourceElRect.top,
  10168. right: 'auto',
  10169. bottom: 'auto',
  10170. margin: 0,
  10171. });
  10172. this.parentNode.appendChild(mirrorEl);
  10173. }
  10174. return mirrorEl;
  10175. };
  10176. return ElementMirror;
  10177. }());
  10178. /*
  10179. Is a cache for a given element's scroll information (all the info that ScrollController stores)
  10180. in addition the "client rectangle" of the element.. the area within the scrollbars.
  10181. The cache can be in one of two modes:
  10182. - doesListening:false - ignores when the container is scrolled by someone else
  10183. - doesListening:true - watch for scrolling and update the cache
  10184. */
  10185. var ScrollGeomCache = /** @class */ (function (_super) {
  10186. __extends(ScrollGeomCache, _super);
  10187. function ScrollGeomCache(scrollController, doesListening) {
  10188. var _this = _super.call(this) || this;
  10189. _this.handleScroll = function () {
  10190. _this.scrollTop = _this.scrollController.getScrollTop();
  10191. _this.scrollLeft = _this.scrollController.getScrollLeft();
  10192. _this.handleScrollChange();
  10193. };
  10194. _this.scrollController = scrollController;
  10195. _this.doesListening = doesListening;
  10196. _this.scrollTop = _this.origScrollTop = scrollController.getScrollTop();
  10197. _this.scrollLeft = _this.origScrollLeft = scrollController.getScrollLeft();
  10198. _this.scrollWidth = scrollController.getScrollWidth();
  10199. _this.scrollHeight = scrollController.getScrollHeight();
  10200. _this.clientWidth = scrollController.getClientWidth();
  10201. _this.clientHeight = scrollController.getClientHeight();
  10202. _this.clientRect = _this.computeClientRect(); // do last in case it needs cached values
  10203. if (_this.doesListening) {
  10204. _this.getEventTarget().addEventListener('scroll', _this.handleScroll);
  10205. }
  10206. return _this;
  10207. }
  10208. ScrollGeomCache.prototype.destroy = function () {
  10209. if (this.doesListening) {
  10210. this.getEventTarget().removeEventListener('scroll', this.handleScroll);
  10211. }
  10212. };
  10213. ScrollGeomCache.prototype.getScrollTop = function () {
  10214. return this.scrollTop;
  10215. };
  10216. ScrollGeomCache.prototype.getScrollLeft = function () {
  10217. return this.scrollLeft;
  10218. };
  10219. ScrollGeomCache.prototype.setScrollTop = function (top) {
  10220. this.scrollController.setScrollTop(top);
  10221. if (!this.doesListening) {
  10222. // we are not relying on the element to normalize out-of-bounds scroll values
  10223. // so we need to sanitize ourselves
  10224. this.scrollTop = Math.max(Math.min(top, this.getMaxScrollTop()), 0);
  10225. this.handleScrollChange();
  10226. }
  10227. };
  10228. ScrollGeomCache.prototype.setScrollLeft = function (top) {
  10229. this.scrollController.setScrollLeft(top);
  10230. if (!this.doesListening) {
  10231. // we are not relying on the element to normalize out-of-bounds scroll values
  10232. // so we need to sanitize ourselves
  10233. this.scrollLeft = Math.max(Math.min(top, this.getMaxScrollLeft()), 0);
  10234. this.handleScrollChange();
  10235. }
  10236. };
  10237. ScrollGeomCache.prototype.getClientWidth = function () {
  10238. return this.clientWidth;
  10239. };
  10240. ScrollGeomCache.prototype.getClientHeight = function () {
  10241. return this.clientHeight;
  10242. };
  10243. ScrollGeomCache.prototype.getScrollWidth = function () {
  10244. return this.scrollWidth;
  10245. };
  10246. ScrollGeomCache.prototype.getScrollHeight = function () {
  10247. return this.scrollHeight;
  10248. };
  10249. ScrollGeomCache.prototype.handleScrollChange = function () {
  10250. };
  10251. return ScrollGeomCache;
  10252. }(ScrollController));
  10253. var ElementScrollGeomCache = /** @class */ (function (_super) {
  10254. __extends(ElementScrollGeomCache, _super);
  10255. function ElementScrollGeomCache(el, doesListening) {
  10256. return _super.call(this, new ElementScrollController(el), doesListening) || this;
  10257. }
  10258. ElementScrollGeomCache.prototype.getEventTarget = function () {
  10259. return this.scrollController.el;
  10260. };
  10261. ElementScrollGeomCache.prototype.computeClientRect = function () {
  10262. return computeInnerRect(this.scrollController.el);
  10263. };
  10264. return ElementScrollGeomCache;
  10265. }(ScrollGeomCache));
  10266. var WindowScrollGeomCache = /** @class */ (function (_super) {
  10267. __extends(WindowScrollGeomCache, _super);
  10268. function WindowScrollGeomCache(doesListening) {
  10269. return _super.call(this, new WindowScrollController(), doesListening) || this;
  10270. }
  10271. WindowScrollGeomCache.prototype.getEventTarget = function () {
  10272. return window;
  10273. };
  10274. WindowScrollGeomCache.prototype.computeClientRect = function () {
  10275. return {
  10276. left: this.scrollLeft,
  10277. right: this.scrollLeft + this.clientWidth,
  10278. top: this.scrollTop,
  10279. bottom: this.scrollTop + this.clientHeight,
  10280. };
  10281. };
  10282. // the window is the only scroll object that changes it's rectangle relative
  10283. // to the document's topleft as it scrolls
  10284. WindowScrollGeomCache.prototype.handleScrollChange = function () {
  10285. this.clientRect = this.computeClientRect();
  10286. };
  10287. return WindowScrollGeomCache;
  10288. }(ScrollGeomCache));
  10289. // If available we are using native "performance" API instead of "Date"
  10290. // Read more about it on MDN:
  10291. // https://developer.mozilla.org/en-US/docs/Web/API/Performance
  10292. var getTime = typeof performance === 'function' ? performance.now : Date.now;
  10293. /*
  10294. For a pointer interaction, automatically scrolls certain scroll containers when the pointer
  10295. approaches the edge.
  10296. The caller must call start + handleMove + stop.
  10297. */
  10298. var AutoScroller = /** @class */ (function () {
  10299. function AutoScroller() {
  10300. var _this = this;
  10301. // options that can be set by caller
  10302. this.isEnabled = true;
  10303. this.scrollQuery = [window, '.fc-scroller'];
  10304. this.edgeThreshold = 50; // pixels
  10305. this.maxVelocity = 300; // pixels per second
  10306. // internal state
  10307. this.pointerScreenX = null;
  10308. this.pointerScreenY = null;
  10309. this.isAnimating = false;
  10310. this.scrollCaches = null;
  10311. // protect against the initial pointerdown being too close to an edge and starting the scroll
  10312. this.everMovedUp = false;
  10313. this.everMovedDown = false;
  10314. this.everMovedLeft = false;
  10315. this.everMovedRight = false;
  10316. this.animate = function () {
  10317. if (_this.isAnimating) { // wasn't cancelled between animation calls
  10318. var edge = _this.computeBestEdge(_this.pointerScreenX + window.pageXOffset, _this.pointerScreenY + window.pageYOffset);
  10319. if (edge) {
  10320. var now = getTime();
  10321. _this.handleSide(edge, (now - _this.msSinceRequest) / 1000);
  10322. _this.requestAnimation(now);
  10323. }
  10324. else {
  10325. _this.isAnimating = false; // will stop animation
  10326. }
  10327. }
  10328. };
  10329. }
  10330. AutoScroller.prototype.start = function (pageX, pageY, scrollStartEl) {
  10331. if (this.isEnabled) {
  10332. this.scrollCaches = this.buildCaches(scrollStartEl);
  10333. this.pointerScreenX = null;
  10334. this.pointerScreenY = null;
  10335. this.everMovedUp = false;
  10336. this.everMovedDown = false;
  10337. this.everMovedLeft = false;
  10338. this.everMovedRight = false;
  10339. this.handleMove(pageX, pageY);
  10340. }
  10341. };
  10342. AutoScroller.prototype.handleMove = function (pageX, pageY) {
  10343. if (this.isEnabled) {
  10344. var pointerScreenX = pageX - window.pageXOffset;
  10345. var pointerScreenY = pageY - window.pageYOffset;
  10346. var yDelta = this.pointerScreenY === null ? 0 : pointerScreenY - this.pointerScreenY;
  10347. var xDelta = this.pointerScreenX === null ? 0 : pointerScreenX - this.pointerScreenX;
  10348. if (yDelta < 0) {
  10349. this.everMovedUp = true;
  10350. }
  10351. else if (yDelta > 0) {
  10352. this.everMovedDown = true;
  10353. }
  10354. if (xDelta < 0) {
  10355. this.everMovedLeft = true;
  10356. }
  10357. else if (xDelta > 0) {
  10358. this.everMovedRight = true;
  10359. }
  10360. this.pointerScreenX = pointerScreenX;
  10361. this.pointerScreenY = pointerScreenY;
  10362. if (!this.isAnimating) {
  10363. this.isAnimating = true;
  10364. this.requestAnimation(getTime());
  10365. }
  10366. }
  10367. };
  10368. AutoScroller.prototype.stop = function () {
  10369. if (this.isEnabled) {
  10370. this.isAnimating = false; // will stop animation
  10371. for (var _i = 0, _a = this.scrollCaches; _i < _a.length; _i++) {
  10372. var scrollCache = _a[_i];
  10373. scrollCache.destroy();
  10374. }
  10375. this.scrollCaches = null;
  10376. }
  10377. };
  10378. AutoScroller.prototype.requestAnimation = function (now) {
  10379. this.msSinceRequest = now;
  10380. requestAnimationFrame(this.animate);
  10381. };
  10382. AutoScroller.prototype.handleSide = function (edge, seconds) {
  10383. var scrollCache = edge.scrollCache;
  10384. var edgeThreshold = this.edgeThreshold;
  10385. var invDistance = edgeThreshold - edge.distance;
  10386. var velocity = // the closer to the edge, the faster we scroll
  10387. ((invDistance * invDistance) / (edgeThreshold * edgeThreshold)) * // quadratic
  10388. this.maxVelocity * seconds;
  10389. var sign = 1;
  10390. switch (edge.name) {
  10391. case 'left':
  10392. sign = -1;
  10393. // falls through
  10394. case 'right':
  10395. scrollCache.setScrollLeft(scrollCache.getScrollLeft() + velocity * sign);
  10396. break;
  10397. case 'top':
  10398. sign = -1;
  10399. // falls through
  10400. case 'bottom':
  10401. scrollCache.setScrollTop(scrollCache.getScrollTop() + velocity * sign);
  10402. break;
  10403. }
  10404. };
  10405. // left/top are relative to document topleft
  10406. AutoScroller.prototype.computeBestEdge = function (left, top) {
  10407. var edgeThreshold = this.edgeThreshold;
  10408. var bestSide = null;
  10409. var scrollCaches = this.scrollCaches || [];
  10410. for (var _i = 0, scrollCaches_1 = scrollCaches; _i < scrollCaches_1.length; _i++) {
  10411. var scrollCache = scrollCaches_1[_i];
  10412. var rect = scrollCache.clientRect;
  10413. var leftDist = left - rect.left;
  10414. var rightDist = rect.right - left;
  10415. var topDist = top - rect.top;
  10416. var bottomDist = rect.bottom - top;
  10417. // completely within the rect?
  10418. if (leftDist >= 0 && rightDist >= 0 && topDist >= 0 && bottomDist >= 0) {
  10419. if (topDist <= edgeThreshold && this.everMovedUp && scrollCache.canScrollUp() &&
  10420. (!bestSide || bestSide.distance > topDist)) {
  10421. bestSide = { scrollCache: scrollCache, name: 'top', distance: topDist };
  10422. }
  10423. if (bottomDist <= edgeThreshold && this.everMovedDown && scrollCache.canScrollDown() &&
  10424. (!bestSide || bestSide.distance > bottomDist)) {
  10425. bestSide = { scrollCache: scrollCache, name: 'bottom', distance: bottomDist };
  10426. }
  10427. if (leftDist <= edgeThreshold && this.everMovedLeft && scrollCache.canScrollLeft() &&
  10428. (!bestSide || bestSide.distance > leftDist)) {
  10429. bestSide = { scrollCache: scrollCache, name: 'left', distance: leftDist };
  10430. }
  10431. if (rightDist <= edgeThreshold && this.everMovedRight && scrollCache.canScrollRight() &&
  10432. (!bestSide || bestSide.distance > rightDist)) {
  10433. bestSide = { scrollCache: scrollCache, name: 'right', distance: rightDist };
  10434. }
  10435. }
  10436. }
  10437. return bestSide;
  10438. };
  10439. AutoScroller.prototype.buildCaches = function (scrollStartEl) {
  10440. return this.queryScrollEls(scrollStartEl).map(function (el) {
  10441. if (el === window) {
  10442. return new WindowScrollGeomCache(false); // false = don't listen to user-generated scrolls
  10443. }
  10444. return new ElementScrollGeomCache(el, false); // false = don't listen to user-generated scrolls
  10445. });
  10446. };
  10447. AutoScroller.prototype.queryScrollEls = function (scrollStartEl) {
  10448. var els = [];
  10449. for (var _i = 0, _a = this.scrollQuery; _i < _a.length; _i++) {
  10450. var query = _a[_i];
  10451. if (typeof query === 'object') {
  10452. els.push(query);
  10453. }
  10454. else {
  10455. els.push.apply(els, Array.prototype.slice.call(getElRoot(scrollStartEl).querySelectorAll(query)));
  10456. }
  10457. }
  10458. return els;
  10459. };
  10460. return AutoScroller;
  10461. }());
  10462. /*
  10463. Monitors dragging on an element. Has a number of high-level features:
  10464. - minimum distance required before dragging
  10465. - minimum wait time ("delay") before dragging
  10466. - a mirror element that follows the pointer
  10467. */
  10468. var FeaturefulElementDragging = /** @class */ (function (_super) {
  10469. __extends(FeaturefulElementDragging, _super);
  10470. function FeaturefulElementDragging(containerEl, selector) {
  10471. var _this = _super.call(this, containerEl) || this;
  10472. _this.containerEl = containerEl;
  10473. // options that can be directly set by caller
  10474. // the caller can also set the PointerDragging's options as well
  10475. _this.delay = null;
  10476. _this.minDistance = 0;
  10477. _this.touchScrollAllowed = true; // prevents drag from starting and blocks scrolling during drag
  10478. _this.mirrorNeedsRevert = false;
  10479. _this.isInteracting = false; // is the user validly moving the pointer? lasts until pointerup
  10480. _this.isDragging = false; // is it INTENTFULLY dragging? lasts until after revert animation
  10481. _this.isDelayEnded = false;
  10482. _this.isDistanceSurpassed = false;
  10483. _this.delayTimeoutId = null;
  10484. _this.onPointerDown = function (ev) {
  10485. if (!_this.isDragging) { // so new drag doesn't happen while revert animation is going
  10486. _this.isInteracting = true;
  10487. _this.isDelayEnded = false;
  10488. _this.isDistanceSurpassed = false;
  10489. preventSelection(document.body);
  10490. preventContextMenu(document.body);
  10491. // prevent links from being visited if there's an eventual drag.
  10492. // also prevents selection in older browsers (maybe?).
  10493. // not necessary for touch, besides, browser would complain about passiveness.
  10494. if (!ev.isTouch) {
  10495. ev.origEvent.preventDefault();
  10496. }
  10497. _this.emitter.trigger('pointerdown', ev);
  10498. if (_this.isInteracting && // not destroyed via pointerdown handler
  10499. !_this.pointer.shouldIgnoreMove) {
  10500. // actions related to initiating dragstart+dragmove+dragend...
  10501. _this.mirror.setIsVisible(false); // reset. caller must set-visible
  10502. _this.mirror.start(ev.subjectEl, ev.pageX, ev.pageY); // must happen on first pointer down
  10503. _this.startDelay(ev);
  10504. if (!_this.minDistance) {
  10505. _this.handleDistanceSurpassed(ev);
  10506. }
  10507. }
  10508. }
  10509. };
  10510. _this.onPointerMove = function (ev) {
  10511. if (_this.isInteracting) {
  10512. _this.emitter.trigger('pointermove', ev);
  10513. if (!_this.isDistanceSurpassed) {
  10514. var minDistance = _this.minDistance;
  10515. var distanceSq = void 0; // current distance from the origin, squared
  10516. var deltaX = ev.deltaX, deltaY = ev.deltaY;
  10517. distanceSq = deltaX * deltaX + deltaY * deltaY;
  10518. if (distanceSq >= minDistance * minDistance) { // use pythagorean theorem
  10519. _this.handleDistanceSurpassed(ev);
  10520. }
  10521. }
  10522. if (_this.isDragging) {
  10523. // a real pointer move? (not one simulated by scrolling)
  10524. if (ev.origEvent.type !== 'scroll') {
  10525. _this.mirror.handleMove(ev.pageX, ev.pageY);
  10526. _this.autoScroller.handleMove(ev.pageX, ev.pageY);
  10527. }
  10528. _this.emitter.trigger('dragmove', ev);
  10529. }
  10530. }
  10531. };
  10532. _this.onPointerUp = function (ev) {
  10533. if (_this.isInteracting) {
  10534. _this.isInteracting = false;
  10535. allowSelection(document.body);
  10536. allowContextMenu(document.body);
  10537. _this.emitter.trigger('pointerup', ev); // can potentially set mirrorNeedsRevert
  10538. if (_this.isDragging) {
  10539. _this.autoScroller.stop();
  10540. _this.tryStopDrag(ev); // which will stop the mirror
  10541. }
  10542. if (_this.delayTimeoutId) {
  10543. clearTimeout(_this.delayTimeoutId);
  10544. _this.delayTimeoutId = null;
  10545. }
  10546. }
  10547. };
  10548. var pointer = _this.pointer = new PointerDragging(containerEl);
  10549. pointer.emitter.on('pointerdown', _this.onPointerDown);
  10550. pointer.emitter.on('pointermove', _this.onPointerMove);
  10551. pointer.emitter.on('pointerup', _this.onPointerUp);
  10552. if (selector) {
  10553. pointer.selector = selector;
  10554. }
  10555. _this.mirror = new ElementMirror();
  10556. _this.autoScroller = new AutoScroller();
  10557. return _this;
  10558. }
  10559. FeaturefulElementDragging.prototype.destroy = function () {
  10560. this.pointer.destroy();
  10561. // HACK: simulate a pointer-up to end the current drag
  10562. // TODO: fire 'dragend' directly and stop interaction. discourage use of pointerup event (b/c might not fire)
  10563. this.onPointerUp({});
  10564. };
  10565. FeaturefulElementDragging.prototype.startDelay = function (ev) {
  10566. var _this = this;
  10567. if (typeof this.delay === 'number') {
  10568. this.delayTimeoutId = setTimeout(function () {
  10569. _this.delayTimeoutId = null;
  10570. _this.handleDelayEnd(ev);
  10571. }, this.delay); // not assignable to number!
  10572. }
  10573. else {
  10574. this.handleDelayEnd(ev);
  10575. }
  10576. };
  10577. FeaturefulElementDragging.prototype.handleDelayEnd = function (ev) {
  10578. this.isDelayEnded = true;
  10579. this.tryStartDrag(ev);
  10580. };
  10581. FeaturefulElementDragging.prototype.handleDistanceSurpassed = function (ev) {
  10582. this.isDistanceSurpassed = true;
  10583. this.tryStartDrag(ev);
  10584. };
  10585. FeaturefulElementDragging.prototype.tryStartDrag = function (ev) {
  10586. if (this.isDelayEnded && this.isDistanceSurpassed) {
  10587. if (!this.pointer.wasTouchScroll || this.touchScrollAllowed) {
  10588. this.isDragging = true;
  10589. this.mirrorNeedsRevert = false;
  10590. this.autoScroller.start(ev.pageX, ev.pageY, this.containerEl);
  10591. this.emitter.trigger('dragstart', ev);
  10592. if (this.touchScrollAllowed === false) {
  10593. this.pointer.cancelTouchScroll();
  10594. }
  10595. }
  10596. }
  10597. };
  10598. FeaturefulElementDragging.prototype.tryStopDrag = function (ev) {
  10599. // .stop() is ALWAYS asynchronous, which we NEED because we want all pointerup events
  10600. // that come from the document to fire beforehand. much more convenient this way.
  10601. this.mirror.stop(this.mirrorNeedsRevert, this.stopDrag.bind(this, ev));
  10602. };
  10603. FeaturefulElementDragging.prototype.stopDrag = function (ev) {
  10604. this.isDragging = false;
  10605. this.emitter.trigger('dragend', ev);
  10606. };
  10607. // fill in the implementations...
  10608. FeaturefulElementDragging.prototype.setIgnoreMove = function (bool) {
  10609. this.pointer.shouldIgnoreMove = bool;
  10610. };
  10611. FeaturefulElementDragging.prototype.setMirrorIsVisible = function (bool) {
  10612. this.mirror.setIsVisible(bool);
  10613. };
  10614. FeaturefulElementDragging.prototype.setMirrorNeedsRevert = function (bool) {
  10615. this.mirrorNeedsRevert = bool;
  10616. };
  10617. FeaturefulElementDragging.prototype.setAutoScrollEnabled = function (bool) {
  10618. this.autoScroller.isEnabled = bool;
  10619. };
  10620. return FeaturefulElementDragging;
  10621. }(ElementDragging));
  10622. /*
  10623. When this class is instantiated, it records the offset of an element (relative to the document topleft),
  10624. and continues to monitor scrolling, updating the cached coordinates if it needs to.
  10625. Does not access the DOM after instantiation, so highly performant.
  10626. Also keeps track of all scrolling/overflow:hidden containers that are parents of the given element
  10627. and an determine if a given point is inside the combined clipping rectangle.
  10628. */
  10629. var OffsetTracker = /** @class */ (function () {
  10630. function OffsetTracker(el) {
  10631. this.origRect = computeRect(el);
  10632. // will work fine for divs that have overflow:hidden
  10633. this.scrollCaches = getClippingParents(el).map(function (scrollEl) { return new ElementScrollGeomCache(scrollEl, true); });
  10634. }
  10635. OffsetTracker.prototype.destroy = function () {
  10636. for (var _i = 0, _a = this.scrollCaches; _i < _a.length; _i++) {
  10637. var scrollCache = _a[_i];
  10638. scrollCache.destroy();
  10639. }
  10640. };
  10641. OffsetTracker.prototype.computeLeft = function () {
  10642. var left = this.origRect.left;
  10643. for (var _i = 0, _a = this.scrollCaches; _i < _a.length; _i++) {
  10644. var scrollCache = _a[_i];
  10645. left += scrollCache.origScrollLeft - scrollCache.getScrollLeft();
  10646. }
  10647. return left;
  10648. };
  10649. OffsetTracker.prototype.computeTop = function () {
  10650. var top = this.origRect.top;
  10651. for (var _i = 0, _a = this.scrollCaches; _i < _a.length; _i++) {
  10652. var scrollCache = _a[_i];
  10653. top += scrollCache.origScrollTop - scrollCache.getScrollTop();
  10654. }
  10655. return top;
  10656. };
  10657. OffsetTracker.prototype.isWithinClipping = function (pageX, pageY) {
  10658. var point = { left: pageX, top: pageY };
  10659. for (var _i = 0, _a = this.scrollCaches; _i < _a.length; _i++) {
  10660. var scrollCache = _a[_i];
  10661. if (!isIgnoredClipping(scrollCache.getEventTarget()) &&
  10662. !pointInsideRect(point, scrollCache.clientRect)) {
  10663. return false;
  10664. }
  10665. }
  10666. return true;
  10667. };
  10668. return OffsetTracker;
  10669. }());
  10670. // certain clipping containers should never constrain interactions, like <html> and <body>
  10671. // https://github.com/fullcalendar/fullcalendar/issues/3615
  10672. function isIgnoredClipping(node) {
  10673. var tagName = node.tagName;
  10674. return tagName === 'HTML' || tagName === 'BODY';
  10675. }
  10676. /*
  10677. Tracks movement over multiple droppable areas (aka "hits")
  10678. that exist in one or more DateComponents.
  10679. Relies on an existing draggable.
  10680. emits:
  10681. - pointerdown
  10682. - dragstart
  10683. - hitchange - fires initially, even if not over a hit
  10684. - pointerup
  10685. - (hitchange - again, to null, if ended over a hit)
  10686. - dragend
  10687. */
  10688. var HitDragging = /** @class */ (function () {
  10689. function HitDragging(dragging, droppableStore) {
  10690. var _this = this;
  10691. // options that can be set by caller
  10692. this.useSubjectCenter = false;
  10693. this.requireInitial = true; // if doesn't start out on a hit, won't emit any events
  10694. this.initialHit = null;
  10695. this.movingHit = null;
  10696. this.finalHit = null; // won't ever be populated if shouldIgnoreMove
  10697. this.handlePointerDown = function (ev) {
  10698. var dragging = _this.dragging;
  10699. _this.initialHit = null;
  10700. _this.movingHit = null;
  10701. _this.finalHit = null;
  10702. _this.prepareHits();
  10703. _this.processFirstCoord(ev);
  10704. if (_this.initialHit || !_this.requireInitial) {
  10705. dragging.setIgnoreMove(false);
  10706. // TODO: fire this before computing processFirstCoord, so listeners can cancel. this gets fired by almost every handler :(
  10707. _this.emitter.trigger('pointerdown', ev);
  10708. }
  10709. else {
  10710. dragging.setIgnoreMove(true);
  10711. }
  10712. };
  10713. this.handleDragStart = function (ev) {
  10714. _this.emitter.trigger('dragstart', ev);
  10715. _this.handleMove(ev, true); // force = fire even if initially null
  10716. };
  10717. this.handleDragMove = function (ev) {
  10718. _this.emitter.trigger('dragmove', ev);
  10719. _this.handleMove(ev);
  10720. };
  10721. this.handlePointerUp = function (ev) {
  10722. _this.releaseHits();
  10723. _this.emitter.trigger('pointerup', ev);
  10724. };
  10725. this.handleDragEnd = function (ev) {
  10726. if (_this.movingHit) {
  10727. _this.emitter.trigger('hitupdate', null, true, ev);
  10728. }
  10729. _this.finalHit = _this.movingHit;
  10730. _this.movingHit = null;
  10731. _this.emitter.trigger('dragend', ev);
  10732. };
  10733. this.droppableStore = droppableStore;
  10734. dragging.emitter.on('pointerdown', this.handlePointerDown);
  10735. dragging.emitter.on('dragstart', this.handleDragStart);
  10736. dragging.emitter.on('dragmove', this.handleDragMove);
  10737. dragging.emitter.on('pointerup', this.handlePointerUp);
  10738. dragging.emitter.on('dragend', this.handleDragEnd);
  10739. this.dragging = dragging;
  10740. this.emitter = new Emitter();
  10741. }
  10742. // sets initialHit
  10743. // sets coordAdjust
  10744. HitDragging.prototype.processFirstCoord = function (ev) {
  10745. var origPoint = { left: ev.pageX, top: ev.pageY };
  10746. var adjustedPoint = origPoint;
  10747. var subjectEl = ev.subjectEl;
  10748. var subjectRect;
  10749. if (subjectEl instanceof HTMLElement) { // i.e. not a Document/ShadowRoot
  10750. subjectRect = computeRect(subjectEl);
  10751. adjustedPoint = constrainPoint(adjustedPoint, subjectRect);
  10752. }
  10753. var initialHit = this.initialHit = this.queryHitForOffset(adjustedPoint.left, adjustedPoint.top);
  10754. if (initialHit) {
  10755. if (this.useSubjectCenter && subjectRect) {
  10756. var slicedSubjectRect = intersectRects(subjectRect, initialHit.rect);
  10757. if (slicedSubjectRect) {
  10758. adjustedPoint = getRectCenter(slicedSubjectRect);
  10759. }
  10760. }
  10761. this.coordAdjust = diffPoints(adjustedPoint, origPoint);
  10762. }
  10763. else {
  10764. this.coordAdjust = { left: 0, top: 0 };
  10765. }
  10766. };
  10767. HitDragging.prototype.handleMove = function (ev, forceHandle) {
  10768. var hit = this.queryHitForOffset(ev.pageX + this.coordAdjust.left, ev.pageY + this.coordAdjust.top);
  10769. if (forceHandle || !isHitsEqual(this.movingHit, hit)) {
  10770. this.movingHit = hit;
  10771. this.emitter.trigger('hitupdate', hit, false, ev);
  10772. }
  10773. };
  10774. HitDragging.prototype.prepareHits = function () {
  10775. this.offsetTrackers = mapHash(this.droppableStore, function (interactionSettings) {
  10776. interactionSettings.component.prepareHits();
  10777. return new OffsetTracker(interactionSettings.el);
  10778. });
  10779. };
  10780. HitDragging.prototype.releaseHits = function () {
  10781. var offsetTrackers = this.offsetTrackers;
  10782. for (var id in offsetTrackers) {
  10783. offsetTrackers[id].destroy();
  10784. }
  10785. this.offsetTrackers = {};
  10786. };
  10787. HitDragging.prototype.queryHitForOffset = function (offsetLeft, offsetTop) {
  10788. var _a = this, droppableStore = _a.droppableStore, offsetTrackers = _a.offsetTrackers;
  10789. var bestHit = null;
  10790. for (var id in droppableStore) {
  10791. var component = droppableStore[id].component;
  10792. var offsetTracker = offsetTrackers[id];
  10793. if (offsetTracker && // wasn't destroyed mid-drag
  10794. offsetTracker.isWithinClipping(offsetLeft, offsetTop)) {
  10795. var originLeft = offsetTracker.computeLeft();
  10796. var originTop = offsetTracker.computeTop();
  10797. var positionLeft = offsetLeft - originLeft;
  10798. var positionTop = offsetTop - originTop;
  10799. var origRect = offsetTracker.origRect;
  10800. var width = origRect.right - origRect.left;
  10801. var height = origRect.bottom - origRect.top;
  10802. if (
  10803. // must be within the element's bounds
  10804. positionLeft >= 0 && positionLeft < width &&
  10805. positionTop >= 0 && positionTop < height) {
  10806. var hit = component.queryHit(positionLeft, positionTop, width, height);
  10807. if (hit && (
  10808. // make sure the hit is within activeRange, meaning it's not a dead cell
  10809. rangeContainsRange(hit.dateProfile.activeRange, hit.dateSpan.range)) &&
  10810. (!bestHit || hit.layer > bestHit.layer)) {
  10811. hit.componentId = id;
  10812. hit.context = component.context;
  10813. // TODO: better way to re-orient rectangle
  10814. hit.rect.left += originLeft;
  10815. hit.rect.right += originLeft;
  10816. hit.rect.top += originTop;
  10817. hit.rect.bottom += originTop;
  10818. bestHit = hit;
  10819. }
  10820. }
  10821. }
  10822. }
  10823. return bestHit;
  10824. };
  10825. return HitDragging;
  10826. }());
  10827. function isHitsEqual(hit0, hit1) {
  10828. if (!hit0 && !hit1) {
  10829. return true;
  10830. }
  10831. if (Boolean(hit0) !== Boolean(hit1)) {
  10832. return false;
  10833. }
  10834. return isDateSpansEqual(hit0.dateSpan, hit1.dateSpan);
  10835. }
  10836. function buildDatePointApiWithContext(dateSpan, context) {
  10837. var props = {};
  10838. for (var _i = 0, _a = context.pluginHooks.datePointTransforms; _i < _a.length; _i++) {
  10839. var transform = _a[_i];
  10840. __assign(props, transform(dateSpan, context));
  10841. }
  10842. __assign(props, buildDatePointApi(dateSpan, context.dateEnv));
  10843. return props;
  10844. }
  10845. function buildDatePointApi(span, dateEnv) {
  10846. return {
  10847. date: dateEnv.toDate(span.range.start),
  10848. dateStr: dateEnv.formatIso(span.range.start, { omitTime: span.allDay }),
  10849. allDay: span.allDay,
  10850. };
  10851. }
  10852. /*
  10853. Monitors when the user clicks on a specific date/time of a component.
  10854. A pointerdown+pointerup on the same "hit" constitutes a click.
  10855. */
  10856. var DateClicking = /** @class */ (function (_super) {
  10857. __extends(DateClicking, _super);
  10858. function DateClicking(settings) {
  10859. var _this = _super.call(this, settings) || this;
  10860. _this.handlePointerDown = function (pev) {
  10861. var dragging = _this.dragging;
  10862. var downEl = pev.origEvent.target;
  10863. // do this in pointerdown (not dragend) because DOM might be mutated by the time dragend is fired
  10864. dragging.setIgnoreMove(!_this.component.isValidDateDownEl(downEl));
  10865. };
  10866. // won't even fire if moving was ignored
  10867. _this.handleDragEnd = function (ev) {
  10868. var component = _this.component;
  10869. var pointer = _this.dragging.pointer;
  10870. if (!pointer.wasTouchScroll) {
  10871. var _a = _this.hitDragging, initialHit = _a.initialHit, finalHit = _a.finalHit;
  10872. if (initialHit && finalHit && isHitsEqual(initialHit, finalHit)) {
  10873. var context = component.context;
  10874. var arg = __assign(__assign({}, buildDatePointApiWithContext(initialHit.dateSpan, context)), { dayEl: initialHit.dayEl, jsEvent: ev.origEvent, view: context.viewApi || context.calendarApi.view });
  10875. context.emitter.trigger('dateClick', arg);
  10876. }
  10877. }
  10878. };
  10879. // we DO want to watch pointer moves because otherwise finalHit won't get populated
  10880. _this.dragging = new FeaturefulElementDragging(settings.el);
  10881. _this.dragging.autoScroller.isEnabled = false;
  10882. var hitDragging = _this.hitDragging = new HitDragging(_this.dragging, interactionSettingsToStore(settings));
  10883. hitDragging.emitter.on('pointerdown', _this.handlePointerDown);
  10884. hitDragging.emitter.on('dragend', _this.handleDragEnd);
  10885. return _this;
  10886. }
  10887. DateClicking.prototype.destroy = function () {
  10888. this.dragging.destroy();
  10889. };
  10890. return DateClicking;
  10891. }(Interaction));
  10892. /*
  10893. Tracks when the user selects a portion of time of a component,
  10894. constituted by a drag over date cells, with a possible delay at the beginning of the drag.
  10895. */
  10896. var DateSelecting = /** @class */ (function (_super) {
  10897. __extends(DateSelecting, _super);
  10898. function DateSelecting(settings) {
  10899. var _this = _super.call(this, settings) || this;
  10900. _this.dragSelection = null;
  10901. _this.handlePointerDown = function (ev) {
  10902. var _a = _this, component = _a.component, dragging = _a.dragging;
  10903. var options = component.context.options;
  10904. var canSelect = options.selectable &&
  10905. component.isValidDateDownEl(ev.origEvent.target);
  10906. // don't bother to watch expensive moves if component won't do selection
  10907. dragging.setIgnoreMove(!canSelect);
  10908. // if touch, require user to hold down
  10909. dragging.delay = ev.isTouch ? getComponentTouchDelay$1(component) : null;
  10910. };
  10911. _this.handleDragStart = function (ev) {
  10912. _this.component.context.calendarApi.unselect(ev); // unselect previous selections
  10913. };
  10914. _this.handleHitUpdate = function (hit, isFinal) {
  10915. var context = _this.component.context;
  10916. var dragSelection = null;
  10917. var isInvalid = false;
  10918. if (hit) {
  10919. var initialHit = _this.hitDragging.initialHit;
  10920. var disallowed = hit.componentId === initialHit.componentId
  10921. && _this.isHitComboAllowed
  10922. && !_this.isHitComboAllowed(initialHit, hit);
  10923. if (!disallowed) {
  10924. dragSelection = joinHitsIntoSelection(initialHit, hit, context.pluginHooks.dateSelectionTransformers);
  10925. }
  10926. if (!dragSelection || !isDateSelectionValid(dragSelection, hit.dateProfile, context)) {
  10927. isInvalid = true;
  10928. dragSelection = null;
  10929. }
  10930. }
  10931. if (dragSelection) {
  10932. context.dispatch({ type: 'SELECT_DATES', selection: dragSelection });
  10933. }
  10934. else if (!isFinal) { // only unselect if moved away while dragging
  10935. context.dispatch({ type: 'UNSELECT_DATES' });
  10936. }
  10937. if (!isInvalid) {
  10938. enableCursor();
  10939. }
  10940. else {
  10941. disableCursor();
  10942. }
  10943. if (!isFinal) {
  10944. _this.dragSelection = dragSelection; // only clear if moved away from all hits while dragging
  10945. }
  10946. };
  10947. _this.handlePointerUp = function (pev) {
  10948. if (_this.dragSelection) {
  10949. // selection is already rendered, so just need to report selection
  10950. triggerDateSelect(_this.dragSelection, pev, _this.component.context);
  10951. _this.dragSelection = null;
  10952. }
  10953. };
  10954. var component = settings.component;
  10955. var options = component.context.options;
  10956. var dragging = _this.dragging = new FeaturefulElementDragging(settings.el);
  10957. dragging.touchScrollAllowed = false;
  10958. dragging.minDistance = options.selectMinDistance || 0;
  10959. dragging.autoScroller.isEnabled = options.dragScroll;
  10960. var hitDragging = _this.hitDragging = new HitDragging(_this.dragging, interactionSettingsToStore(settings));
  10961. hitDragging.emitter.on('pointerdown', _this.handlePointerDown);
  10962. hitDragging.emitter.on('dragstart', _this.handleDragStart);
  10963. hitDragging.emitter.on('hitupdate', _this.handleHitUpdate);
  10964. hitDragging.emitter.on('pointerup', _this.handlePointerUp);
  10965. return _this;
  10966. }
  10967. DateSelecting.prototype.destroy = function () {
  10968. this.dragging.destroy();
  10969. };
  10970. return DateSelecting;
  10971. }(Interaction));
  10972. function getComponentTouchDelay$1(component) {
  10973. var options = component.context.options;
  10974. var delay = options.selectLongPressDelay;
  10975. if (delay == null) {
  10976. delay = options.longPressDelay;
  10977. }
  10978. return delay;
  10979. }
  10980. function joinHitsIntoSelection(hit0, hit1, dateSelectionTransformers) {
  10981. var dateSpan0 = hit0.dateSpan;
  10982. var dateSpan1 = hit1.dateSpan;
  10983. var ms = [
  10984. dateSpan0.range.start,
  10985. dateSpan0.range.end,
  10986. dateSpan1.range.start,
  10987. dateSpan1.range.end,
  10988. ];
  10989. ms.sort(compareNumbers);
  10990. var props = {};
  10991. for (var _i = 0, dateSelectionTransformers_1 = dateSelectionTransformers; _i < dateSelectionTransformers_1.length; _i++) {
  10992. var transformer = dateSelectionTransformers_1[_i];
  10993. var res = transformer(hit0, hit1);
  10994. if (res === false) {
  10995. return null;
  10996. }
  10997. if (res) {
  10998. __assign(props, res);
  10999. }
  11000. }
  11001. props.range = { start: ms[0], end: ms[3] };
  11002. props.allDay = dateSpan0.allDay;
  11003. return props;
  11004. }
  11005. var EventDragging = /** @class */ (function (_super) {
  11006. __extends(EventDragging, _super);
  11007. function EventDragging(settings) {
  11008. var _this = _super.call(this, settings) || this;
  11009. // internal state
  11010. _this.subjectEl = null;
  11011. _this.subjectSeg = null; // the seg being selected/dragged
  11012. _this.isDragging = false;
  11013. _this.eventRange = null;
  11014. _this.relevantEvents = null; // the events being dragged
  11015. _this.receivingContext = null;
  11016. _this.validMutation = null;
  11017. _this.mutatedRelevantEvents = null;
  11018. _this.handlePointerDown = function (ev) {
  11019. var origTarget = ev.origEvent.target;
  11020. var _a = _this, component = _a.component, dragging = _a.dragging;
  11021. var mirror = dragging.mirror;
  11022. var options = component.context.options;
  11023. var initialContext = component.context;
  11024. _this.subjectEl = ev.subjectEl;
  11025. var subjectSeg = _this.subjectSeg = getElSeg(ev.subjectEl);
  11026. var eventRange = _this.eventRange = subjectSeg.eventRange;
  11027. var eventInstanceId = eventRange.instance.instanceId;
  11028. _this.relevantEvents = getRelevantEvents(initialContext.getCurrentData().eventStore, eventInstanceId);
  11029. dragging.minDistance = ev.isTouch ? 0 : options.eventDragMinDistance;
  11030. dragging.delay =
  11031. // only do a touch delay if touch and this event hasn't been selected yet
  11032. (ev.isTouch && eventInstanceId !== component.props.eventSelection) ?
  11033. getComponentTouchDelay(component) :
  11034. null;
  11035. if (options.fixedMirrorParent) {
  11036. mirror.parentNode = options.fixedMirrorParent;
  11037. }
  11038. else {
  11039. mirror.parentNode = elementClosest(origTarget, '.fc');
  11040. }
  11041. mirror.revertDuration = options.dragRevertDuration;
  11042. var isValid = component.isValidSegDownEl(origTarget) &&
  11043. !elementClosest(origTarget, '.fc-event-resizer'); // NOT on a resizer
  11044. dragging.setIgnoreMove(!isValid);
  11045. // disable dragging for elements that are resizable (ie, selectable)
  11046. // but are not draggable
  11047. _this.isDragging = isValid &&
  11048. ev.subjectEl.classList.contains('fc-event-draggable');
  11049. };
  11050. _this.handleDragStart = function (ev) {
  11051. var initialContext = _this.component.context;
  11052. var eventRange = _this.eventRange;
  11053. var eventInstanceId = eventRange.instance.instanceId;
  11054. if (ev.isTouch) {
  11055. // need to select a different event?
  11056. if (eventInstanceId !== _this.component.props.eventSelection) {
  11057. initialContext.dispatch({ type: 'SELECT_EVENT', eventInstanceId: eventInstanceId });
  11058. }
  11059. }
  11060. else {
  11061. // if now using mouse, but was previous touch interaction, clear selected event
  11062. initialContext.dispatch({ type: 'UNSELECT_EVENT' });
  11063. }
  11064. if (_this.isDragging) {
  11065. initialContext.calendarApi.unselect(ev); // unselect *date* selection
  11066. initialContext.emitter.trigger('eventDragStart', {
  11067. el: _this.subjectEl,
  11068. event: new EventApi(initialContext, eventRange.def, eventRange.instance),
  11069. jsEvent: ev.origEvent,
  11070. view: initialContext.viewApi,
  11071. });
  11072. }
  11073. };
  11074. _this.handleHitUpdate = function (hit, isFinal) {
  11075. if (!_this.isDragging) {
  11076. return;
  11077. }
  11078. var relevantEvents = _this.relevantEvents;
  11079. var initialHit = _this.hitDragging.initialHit;
  11080. var initialContext = _this.component.context;
  11081. // states based on new hit
  11082. var receivingContext = null;
  11083. var mutation = null;
  11084. var mutatedRelevantEvents = null;
  11085. var isInvalid = false;
  11086. var interaction = {
  11087. affectedEvents: relevantEvents,
  11088. mutatedEvents: createEmptyEventStore(),
  11089. isEvent: true,
  11090. };
  11091. if (hit) {
  11092. receivingContext = hit.context;
  11093. var receivingOptions = receivingContext.options;
  11094. if (initialContext === receivingContext ||
  11095. (receivingOptions.editable && receivingOptions.droppable)) {
  11096. mutation = computeEventMutation(initialHit, hit, receivingContext.getCurrentData().pluginHooks.eventDragMutationMassagers);
  11097. if (mutation) {
  11098. mutatedRelevantEvents = applyMutationToEventStore(relevantEvents, receivingContext.getCurrentData().eventUiBases, mutation, receivingContext);
  11099. interaction.mutatedEvents = mutatedRelevantEvents;
  11100. if (!isInteractionValid(interaction, hit.dateProfile, receivingContext)) {
  11101. isInvalid = true;
  11102. mutation = null;
  11103. mutatedRelevantEvents = null;
  11104. interaction.mutatedEvents = createEmptyEventStore();
  11105. }
  11106. }
  11107. }
  11108. else {
  11109. receivingContext = null;
  11110. }
  11111. }
  11112. _this.displayDrag(receivingContext, interaction);
  11113. if (!isInvalid) {
  11114. enableCursor();
  11115. }
  11116. else {
  11117. disableCursor();
  11118. }
  11119. if (!isFinal) {
  11120. if (initialContext === receivingContext && // TODO: write test for this
  11121. isHitsEqual(initialHit, hit)) {
  11122. mutation = null;
  11123. }
  11124. _this.dragging.setMirrorNeedsRevert(!mutation);
  11125. // render the mirror if no already-rendered mirror
  11126. // TODO: wish we could somehow wait for dispatch to guarantee render
  11127. _this.dragging.setMirrorIsVisible(!hit || !getElRoot(_this.subjectEl).querySelector('.fc-event-mirror'));
  11128. // assign states based on new hit
  11129. _this.receivingContext = receivingContext;
  11130. _this.validMutation = mutation;
  11131. _this.mutatedRelevantEvents = mutatedRelevantEvents;
  11132. }
  11133. };
  11134. _this.handlePointerUp = function () {
  11135. if (!_this.isDragging) {
  11136. _this.cleanup(); // because handleDragEnd won't fire
  11137. }
  11138. };
  11139. _this.handleDragEnd = function (ev) {
  11140. if (_this.isDragging) {
  11141. var initialContext_1 = _this.component.context;
  11142. var initialView = initialContext_1.viewApi;
  11143. var _a = _this, receivingContext_1 = _a.receivingContext, validMutation = _a.validMutation;
  11144. var eventDef = _this.eventRange.def;
  11145. var eventInstance = _this.eventRange.instance;
  11146. var eventApi = new EventApi(initialContext_1, eventDef, eventInstance);
  11147. var relevantEvents_1 = _this.relevantEvents;
  11148. var mutatedRelevantEvents_1 = _this.mutatedRelevantEvents;
  11149. var finalHit = _this.hitDragging.finalHit;
  11150. _this.clearDrag(); // must happen after revert animation
  11151. initialContext_1.emitter.trigger('eventDragStop', {
  11152. el: _this.subjectEl,
  11153. event: eventApi,
  11154. jsEvent: ev.origEvent,
  11155. view: initialView,
  11156. });
  11157. if (validMutation) {
  11158. // dropped within same calendar
  11159. if (receivingContext_1 === initialContext_1) {
  11160. var updatedEventApi = new EventApi(initialContext_1, mutatedRelevantEvents_1.defs[eventDef.defId], eventInstance ? mutatedRelevantEvents_1.instances[eventInstance.instanceId] : null);
  11161. initialContext_1.dispatch({
  11162. type: 'MERGE_EVENTS',
  11163. eventStore: mutatedRelevantEvents_1,
  11164. });
  11165. var eventChangeArg = {
  11166. oldEvent: eventApi,
  11167. event: updatedEventApi,
  11168. relatedEvents: buildEventApis(mutatedRelevantEvents_1, initialContext_1, eventInstance),
  11169. revert: function () {
  11170. initialContext_1.dispatch({
  11171. type: 'MERGE_EVENTS',
  11172. eventStore: relevantEvents_1, // the pre-change data
  11173. });
  11174. },
  11175. };
  11176. var transformed = {};
  11177. for (var _i = 0, _b = initialContext_1.getCurrentData().pluginHooks.eventDropTransformers; _i < _b.length; _i++) {
  11178. var transformer = _b[_i];
  11179. __assign(transformed, transformer(validMutation, initialContext_1));
  11180. }
  11181. initialContext_1.emitter.trigger('eventDrop', __assign(__assign(__assign({}, eventChangeArg), transformed), { el: ev.subjectEl, delta: validMutation.datesDelta, jsEvent: ev.origEvent, view: initialView }));
  11182. initialContext_1.emitter.trigger('eventChange', eventChangeArg);
  11183. // dropped in different calendar
  11184. }
  11185. else if (receivingContext_1) {
  11186. var eventRemoveArg = {
  11187. event: eventApi,
  11188. relatedEvents: buildEventApis(relevantEvents_1, initialContext_1, eventInstance),
  11189. revert: function () {
  11190. initialContext_1.dispatch({
  11191. type: 'MERGE_EVENTS',
  11192. eventStore: relevantEvents_1,
  11193. });
  11194. },
  11195. };
  11196. initialContext_1.emitter.trigger('eventLeave', __assign(__assign({}, eventRemoveArg), { draggedEl: ev.subjectEl, view: initialView }));
  11197. initialContext_1.dispatch({
  11198. type: 'REMOVE_EVENTS',
  11199. eventStore: relevantEvents_1,
  11200. });
  11201. initialContext_1.emitter.trigger('eventRemove', eventRemoveArg);
  11202. var addedEventDef = mutatedRelevantEvents_1.defs[eventDef.defId];
  11203. var addedEventInstance = mutatedRelevantEvents_1.instances[eventInstance.instanceId];
  11204. var addedEventApi = new EventApi(receivingContext_1, addedEventDef, addedEventInstance);
  11205. receivingContext_1.dispatch({
  11206. type: 'MERGE_EVENTS',
  11207. eventStore: mutatedRelevantEvents_1,
  11208. });
  11209. var eventAddArg = {
  11210. event: addedEventApi,
  11211. relatedEvents: buildEventApis(mutatedRelevantEvents_1, receivingContext_1, addedEventInstance),
  11212. revert: function () {
  11213. receivingContext_1.dispatch({
  11214. type: 'REMOVE_EVENTS',
  11215. eventStore: mutatedRelevantEvents_1,
  11216. });
  11217. },
  11218. };
  11219. receivingContext_1.emitter.trigger('eventAdd', eventAddArg);
  11220. if (ev.isTouch) {
  11221. receivingContext_1.dispatch({
  11222. type: 'SELECT_EVENT',
  11223. eventInstanceId: eventInstance.instanceId,
  11224. });
  11225. }
  11226. receivingContext_1.emitter.trigger('drop', __assign(__assign({}, buildDatePointApiWithContext(finalHit.dateSpan, receivingContext_1)), { draggedEl: ev.subjectEl, jsEvent: ev.origEvent, view: finalHit.context.viewApi }));
  11227. receivingContext_1.emitter.trigger('eventReceive', __assign(__assign({}, eventAddArg), { draggedEl: ev.subjectEl, view: finalHit.context.viewApi }));
  11228. }
  11229. }
  11230. else {
  11231. initialContext_1.emitter.trigger('_noEventDrop');
  11232. }
  11233. }
  11234. _this.cleanup();
  11235. };
  11236. var component = _this.component;
  11237. var options = component.context.options;
  11238. var dragging = _this.dragging = new FeaturefulElementDragging(settings.el);
  11239. dragging.pointer.selector = EventDragging.SELECTOR;
  11240. dragging.touchScrollAllowed = false;
  11241. dragging.autoScroller.isEnabled = options.dragScroll;
  11242. var hitDragging = _this.hitDragging = new HitDragging(_this.dragging, interactionSettingsStore);
  11243. hitDragging.useSubjectCenter = settings.useEventCenter;
  11244. hitDragging.emitter.on('pointerdown', _this.handlePointerDown);
  11245. hitDragging.emitter.on('dragstart', _this.handleDragStart);
  11246. hitDragging.emitter.on('hitupdate', _this.handleHitUpdate);
  11247. hitDragging.emitter.on('pointerup', _this.handlePointerUp);
  11248. hitDragging.emitter.on('dragend', _this.handleDragEnd);
  11249. return _this;
  11250. }
  11251. EventDragging.prototype.destroy = function () {
  11252. this.dragging.destroy();
  11253. };
  11254. // render a drag state on the next receivingCalendar
  11255. EventDragging.prototype.displayDrag = function (nextContext, state) {
  11256. var initialContext = this.component.context;
  11257. var prevContext = this.receivingContext;
  11258. // does the previous calendar need to be cleared?
  11259. if (prevContext && prevContext !== nextContext) {
  11260. // does the initial calendar need to be cleared?
  11261. // if so, don't clear all the way. we still need to to hide the affectedEvents
  11262. if (prevContext === initialContext) {
  11263. prevContext.dispatch({
  11264. type: 'SET_EVENT_DRAG',
  11265. state: {
  11266. affectedEvents: state.affectedEvents,
  11267. mutatedEvents: createEmptyEventStore(),
  11268. isEvent: true,
  11269. },
  11270. });
  11271. // completely clear the old calendar if it wasn't the initial
  11272. }
  11273. else {
  11274. prevContext.dispatch({ type: 'UNSET_EVENT_DRAG' });
  11275. }
  11276. }
  11277. if (nextContext) {
  11278. nextContext.dispatch({ type: 'SET_EVENT_DRAG', state: state });
  11279. }
  11280. };
  11281. EventDragging.prototype.clearDrag = function () {
  11282. var initialCalendar = this.component.context;
  11283. var receivingContext = this.receivingContext;
  11284. if (receivingContext) {
  11285. receivingContext.dispatch({ type: 'UNSET_EVENT_DRAG' });
  11286. }
  11287. // the initial calendar might have an dummy drag state from displayDrag
  11288. if (initialCalendar !== receivingContext) {
  11289. initialCalendar.dispatch({ type: 'UNSET_EVENT_DRAG' });
  11290. }
  11291. };
  11292. EventDragging.prototype.cleanup = function () {
  11293. this.subjectSeg = null;
  11294. this.isDragging = false;
  11295. this.eventRange = null;
  11296. this.relevantEvents = null;
  11297. this.receivingContext = null;
  11298. this.validMutation = null;
  11299. this.mutatedRelevantEvents = null;
  11300. };
  11301. // TODO: test this in IE11
  11302. // QUESTION: why do we need it on the resizable???
  11303. EventDragging.SELECTOR = '.fc-event-draggable, .fc-event-resizable';
  11304. return EventDragging;
  11305. }(Interaction));
  11306. function computeEventMutation(hit0, hit1, massagers) {
  11307. var dateSpan0 = hit0.dateSpan;
  11308. var dateSpan1 = hit1.dateSpan;
  11309. var date0 = dateSpan0.range.start;
  11310. var date1 = dateSpan1.range.start;
  11311. var standardProps = {};
  11312. if (dateSpan0.allDay !== dateSpan1.allDay) {
  11313. standardProps.allDay = dateSpan1.allDay;
  11314. standardProps.hasEnd = hit1.context.options.allDayMaintainDuration;
  11315. if (dateSpan1.allDay) {
  11316. // means date1 is already start-of-day,
  11317. // but date0 needs to be converted
  11318. date0 = startOfDay(date0);
  11319. }
  11320. }
  11321. var delta = diffDates(date0, date1, hit0.context.dateEnv, hit0.componentId === hit1.componentId ?
  11322. hit0.largeUnit :
  11323. null);
  11324. if (delta.milliseconds) { // has hours/minutes/seconds
  11325. standardProps.allDay = false;
  11326. }
  11327. var mutation = {
  11328. datesDelta: delta,
  11329. standardProps: standardProps,
  11330. };
  11331. for (var _i = 0, massagers_1 = massagers; _i < massagers_1.length; _i++) {
  11332. var massager = massagers_1[_i];
  11333. massager(mutation, hit0, hit1);
  11334. }
  11335. return mutation;
  11336. }
  11337. function getComponentTouchDelay(component) {
  11338. var options = component.context.options;
  11339. var delay = options.eventLongPressDelay;
  11340. if (delay == null) {
  11341. delay = options.longPressDelay;
  11342. }
  11343. return delay;
  11344. }
  11345. var EventResizing = /** @class */ (function (_super) {
  11346. __extends(EventResizing, _super);
  11347. function EventResizing(settings) {
  11348. var _this = _super.call(this, settings) || this;
  11349. // internal state
  11350. _this.draggingSegEl = null;
  11351. _this.draggingSeg = null; // TODO: rename to resizingSeg? subjectSeg?
  11352. _this.eventRange = null;
  11353. _this.relevantEvents = null;
  11354. _this.validMutation = null;
  11355. _this.mutatedRelevantEvents = null;
  11356. _this.handlePointerDown = function (ev) {
  11357. var component = _this.component;
  11358. var segEl = _this.querySegEl(ev);
  11359. var seg = getElSeg(segEl);
  11360. var eventRange = _this.eventRange = seg.eventRange;
  11361. _this.dragging.minDistance = component.context.options.eventDragMinDistance;
  11362. // if touch, need to be working with a selected event
  11363. _this.dragging.setIgnoreMove(!_this.component.isValidSegDownEl(ev.origEvent.target) ||
  11364. (ev.isTouch && _this.component.props.eventSelection !== eventRange.instance.instanceId));
  11365. };
  11366. _this.handleDragStart = function (ev) {
  11367. var context = _this.component.context;
  11368. var eventRange = _this.eventRange;
  11369. _this.relevantEvents = getRelevantEvents(context.getCurrentData().eventStore, _this.eventRange.instance.instanceId);
  11370. var segEl = _this.querySegEl(ev);
  11371. _this.draggingSegEl = segEl;
  11372. _this.draggingSeg = getElSeg(segEl);
  11373. context.calendarApi.unselect();
  11374. context.emitter.trigger('eventResizeStart', {
  11375. el: segEl,
  11376. event: new EventApi(context, eventRange.def, eventRange.instance),
  11377. jsEvent: ev.origEvent,
  11378. view: context.viewApi,
  11379. });
  11380. };
  11381. _this.handleHitUpdate = function (hit, isFinal, ev) {
  11382. var context = _this.component.context;
  11383. var relevantEvents = _this.relevantEvents;
  11384. var initialHit = _this.hitDragging.initialHit;
  11385. var eventInstance = _this.eventRange.instance;
  11386. var mutation = null;
  11387. var mutatedRelevantEvents = null;
  11388. var isInvalid = false;
  11389. var interaction = {
  11390. affectedEvents: relevantEvents,
  11391. mutatedEvents: createEmptyEventStore(),
  11392. isEvent: true,
  11393. };
  11394. if (hit) {
  11395. var disallowed = hit.componentId === initialHit.componentId
  11396. && _this.isHitComboAllowed
  11397. && !_this.isHitComboAllowed(initialHit, hit);
  11398. if (!disallowed) {
  11399. mutation = computeMutation(initialHit, hit, ev.subjectEl.classList.contains('fc-event-resizer-start'), eventInstance.range);
  11400. }
  11401. }
  11402. if (mutation) {
  11403. mutatedRelevantEvents = applyMutationToEventStore(relevantEvents, context.getCurrentData().eventUiBases, mutation, context);
  11404. interaction.mutatedEvents = mutatedRelevantEvents;
  11405. if (!isInteractionValid(interaction, hit.dateProfile, context)) {
  11406. isInvalid = true;
  11407. mutation = null;
  11408. mutatedRelevantEvents = null;
  11409. interaction.mutatedEvents = null;
  11410. }
  11411. }
  11412. if (mutatedRelevantEvents) {
  11413. context.dispatch({
  11414. type: 'SET_EVENT_RESIZE',
  11415. state: interaction,
  11416. });
  11417. }
  11418. else {
  11419. context.dispatch({ type: 'UNSET_EVENT_RESIZE' });
  11420. }
  11421. if (!isInvalid) {
  11422. enableCursor();
  11423. }
  11424. else {
  11425. disableCursor();
  11426. }
  11427. if (!isFinal) {
  11428. if (mutation && isHitsEqual(initialHit, hit)) {
  11429. mutation = null;
  11430. }
  11431. _this.validMutation = mutation;
  11432. _this.mutatedRelevantEvents = mutatedRelevantEvents;
  11433. }
  11434. };
  11435. _this.handleDragEnd = function (ev) {
  11436. var context = _this.component.context;
  11437. var eventDef = _this.eventRange.def;
  11438. var eventInstance = _this.eventRange.instance;
  11439. var eventApi = new EventApi(context, eventDef, eventInstance);
  11440. var relevantEvents = _this.relevantEvents;
  11441. var mutatedRelevantEvents = _this.mutatedRelevantEvents;
  11442. context.emitter.trigger('eventResizeStop', {
  11443. el: _this.draggingSegEl,
  11444. event: eventApi,
  11445. jsEvent: ev.origEvent,
  11446. view: context.viewApi,
  11447. });
  11448. if (_this.validMutation) {
  11449. var updatedEventApi = new EventApi(context, mutatedRelevantEvents.defs[eventDef.defId], eventInstance ? mutatedRelevantEvents.instances[eventInstance.instanceId] : null);
  11450. context.dispatch({
  11451. type: 'MERGE_EVENTS',
  11452. eventStore: mutatedRelevantEvents,
  11453. });
  11454. var eventChangeArg = {
  11455. oldEvent: eventApi,
  11456. event: updatedEventApi,
  11457. relatedEvents: buildEventApis(mutatedRelevantEvents, context, eventInstance),
  11458. revert: function () {
  11459. context.dispatch({
  11460. type: 'MERGE_EVENTS',
  11461. eventStore: relevantEvents, // the pre-change events
  11462. });
  11463. },
  11464. };
  11465. 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 }));
  11466. context.emitter.trigger('eventChange', eventChangeArg);
  11467. }
  11468. else {
  11469. context.emitter.trigger('_noEventResize');
  11470. }
  11471. // reset all internal state
  11472. _this.draggingSeg = null;
  11473. _this.relevantEvents = null;
  11474. _this.validMutation = null;
  11475. // okay to keep eventInstance around. useful to set it in handlePointerDown
  11476. };
  11477. var component = settings.component;
  11478. var dragging = _this.dragging = new FeaturefulElementDragging(settings.el);
  11479. dragging.pointer.selector = '.fc-event-resizer';
  11480. dragging.touchScrollAllowed = false;
  11481. dragging.autoScroller.isEnabled = component.context.options.dragScroll;
  11482. var hitDragging = _this.hitDragging = new HitDragging(_this.dragging, interactionSettingsToStore(settings));
  11483. hitDragging.emitter.on('pointerdown', _this.handlePointerDown);
  11484. hitDragging.emitter.on('dragstart', _this.handleDragStart);
  11485. hitDragging.emitter.on('hitupdate', _this.handleHitUpdate);
  11486. hitDragging.emitter.on('dragend', _this.handleDragEnd);
  11487. return _this;
  11488. }
  11489. EventResizing.prototype.destroy = function () {
  11490. this.dragging.destroy();
  11491. };
  11492. EventResizing.prototype.querySegEl = function (ev) {
  11493. return elementClosest(ev.subjectEl, '.fc-event');
  11494. };
  11495. return EventResizing;
  11496. }(Interaction));
  11497. function computeMutation(hit0, hit1, isFromStart, instanceRange) {
  11498. var dateEnv = hit0.context.dateEnv;
  11499. var date0 = hit0.dateSpan.range.start;
  11500. var date1 = hit1.dateSpan.range.start;
  11501. var delta = diffDates(date0, date1, dateEnv, hit0.largeUnit);
  11502. if (isFromStart) {
  11503. if (dateEnv.add(instanceRange.start, delta) < instanceRange.end) {
  11504. return { startDelta: delta };
  11505. }
  11506. }
  11507. else if (dateEnv.add(instanceRange.end, delta) > instanceRange.start) {
  11508. return { endDelta: delta };
  11509. }
  11510. return null;
  11511. }
  11512. var UnselectAuto = /** @class */ (function () {
  11513. function UnselectAuto(context) {
  11514. var _this = this;
  11515. this.context = context;
  11516. this.isRecentPointerDateSelect = false; // wish we could use a selector to detect date selection, but uses hit system
  11517. this.matchesCancel = false;
  11518. this.matchesEvent = false;
  11519. this.onSelect = function (selectInfo) {
  11520. if (selectInfo.jsEvent) {
  11521. _this.isRecentPointerDateSelect = true;
  11522. }
  11523. };
  11524. this.onDocumentPointerDown = function (pev) {
  11525. var unselectCancel = _this.context.options.unselectCancel;
  11526. var downEl = getEventTargetViaRoot(pev.origEvent);
  11527. _this.matchesCancel = !!elementClosest(downEl, unselectCancel);
  11528. _this.matchesEvent = !!elementClosest(downEl, EventDragging.SELECTOR); // interaction started on an event?
  11529. };
  11530. this.onDocumentPointerUp = function (pev) {
  11531. var context = _this.context;
  11532. var documentPointer = _this.documentPointer;
  11533. var calendarState = context.getCurrentData();
  11534. // touch-scrolling should never unfocus any type of selection
  11535. if (!documentPointer.wasTouchScroll) {
  11536. if (calendarState.dateSelection && // an existing date selection?
  11537. !_this.isRecentPointerDateSelect // a new pointer-initiated date selection since last onDocumentPointerUp?
  11538. ) {
  11539. var unselectAuto = context.options.unselectAuto;
  11540. if (unselectAuto && (!unselectAuto || !_this.matchesCancel)) {
  11541. context.calendarApi.unselect(pev);
  11542. }
  11543. }
  11544. if (calendarState.eventSelection && // an existing event selected?
  11545. !_this.matchesEvent // interaction DIDN'T start on an event
  11546. ) {
  11547. context.dispatch({ type: 'UNSELECT_EVENT' });
  11548. }
  11549. }
  11550. _this.isRecentPointerDateSelect = false;
  11551. };
  11552. var documentPointer = this.documentPointer = new PointerDragging(document);
  11553. documentPointer.shouldIgnoreMove = true;
  11554. documentPointer.shouldWatchScroll = false;
  11555. documentPointer.emitter.on('pointerdown', this.onDocumentPointerDown);
  11556. documentPointer.emitter.on('pointerup', this.onDocumentPointerUp);
  11557. /*
  11558. TODO: better way to know about whether there was a selection with the pointer
  11559. */
  11560. context.emitter.on('select', this.onSelect);
  11561. }
  11562. UnselectAuto.prototype.destroy = function () {
  11563. this.context.emitter.off('select', this.onSelect);
  11564. this.documentPointer.destroy();
  11565. };
  11566. return UnselectAuto;
  11567. }());
  11568. var OPTION_REFINERS$3 = {
  11569. fixedMirrorParent: identity,
  11570. };
  11571. var LISTENER_REFINERS = {
  11572. dateClick: identity,
  11573. eventDragStart: identity,
  11574. eventDragStop: identity,
  11575. eventDrop: identity,
  11576. eventResizeStart: identity,
  11577. eventResizeStop: identity,
  11578. eventResize: identity,
  11579. drop: identity,
  11580. eventReceive: identity,
  11581. eventLeave: identity,
  11582. };
  11583. /*
  11584. Given an already instantiated draggable object for one-or-more elements,
  11585. Interprets any dragging as an attempt to drag an events that lives outside
  11586. of a calendar onto a calendar.
  11587. */
  11588. var ExternalElementDragging = /** @class */ (function () {
  11589. function ExternalElementDragging(dragging, suppliedDragMeta) {
  11590. var _this = this;
  11591. this.receivingContext = null;
  11592. this.droppableEvent = null; // will exist for all drags, even if create:false
  11593. this.suppliedDragMeta = null;
  11594. this.dragMeta = null;
  11595. this.handleDragStart = function (ev) {
  11596. _this.dragMeta = _this.buildDragMeta(ev.subjectEl);
  11597. };
  11598. this.handleHitUpdate = function (hit, isFinal, ev) {
  11599. var dragging = _this.hitDragging.dragging;
  11600. var receivingContext = null;
  11601. var droppableEvent = null;
  11602. var isInvalid = false;
  11603. var interaction = {
  11604. affectedEvents: createEmptyEventStore(),
  11605. mutatedEvents: createEmptyEventStore(),
  11606. isEvent: _this.dragMeta.create,
  11607. };
  11608. if (hit) {
  11609. receivingContext = hit.context;
  11610. if (_this.canDropElOnCalendar(ev.subjectEl, receivingContext)) {
  11611. droppableEvent = computeEventForDateSpan(hit.dateSpan, _this.dragMeta, receivingContext);
  11612. interaction.mutatedEvents = eventTupleToStore(droppableEvent);
  11613. isInvalid = !isInteractionValid(interaction, hit.dateProfile, receivingContext);
  11614. if (isInvalid) {
  11615. interaction.mutatedEvents = createEmptyEventStore();
  11616. droppableEvent = null;
  11617. }
  11618. }
  11619. }
  11620. _this.displayDrag(receivingContext, interaction);
  11621. // show mirror if no already-rendered mirror element OR if we are shutting down the mirror (?)
  11622. // TODO: wish we could somehow wait for dispatch to guarantee render
  11623. dragging.setMirrorIsVisible(isFinal || !droppableEvent || !document.querySelector('.fc-event-mirror'));
  11624. if (!isInvalid) {
  11625. enableCursor();
  11626. }
  11627. else {
  11628. disableCursor();
  11629. }
  11630. if (!isFinal) {
  11631. dragging.setMirrorNeedsRevert(!droppableEvent);
  11632. _this.receivingContext = receivingContext;
  11633. _this.droppableEvent = droppableEvent;
  11634. }
  11635. };
  11636. this.handleDragEnd = function (pev) {
  11637. var _a = _this, receivingContext = _a.receivingContext, droppableEvent = _a.droppableEvent;
  11638. _this.clearDrag();
  11639. if (receivingContext && droppableEvent) {
  11640. var finalHit = _this.hitDragging.finalHit;
  11641. var finalView = finalHit.context.viewApi;
  11642. var dragMeta = _this.dragMeta;
  11643. receivingContext.emitter.trigger('drop', __assign(__assign({}, buildDatePointApiWithContext(finalHit.dateSpan, receivingContext)), { draggedEl: pev.subjectEl, jsEvent: pev.origEvent, view: finalView }));
  11644. if (dragMeta.create) {
  11645. var addingEvents_1 = eventTupleToStore(droppableEvent);
  11646. receivingContext.dispatch({
  11647. type: 'MERGE_EVENTS',
  11648. eventStore: addingEvents_1,
  11649. });
  11650. if (pev.isTouch) {
  11651. receivingContext.dispatch({
  11652. type: 'SELECT_EVENT',
  11653. eventInstanceId: droppableEvent.instance.instanceId,
  11654. });
  11655. }
  11656. // signal that an external event landed
  11657. receivingContext.emitter.trigger('eventReceive', {
  11658. event: new EventApi(receivingContext, droppableEvent.def, droppableEvent.instance),
  11659. relatedEvents: [],
  11660. revert: function () {
  11661. receivingContext.dispatch({
  11662. type: 'REMOVE_EVENTS',
  11663. eventStore: addingEvents_1,
  11664. });
  11665. },
  11666. draggedEl: pev.subjectEl,
  11667. view: finalView,
  11668. });
  11669. }
  11670. }
  11671. _this.receivingContext = null;
  11672. _this.droppableEvent = null;
  11673. };
  11674. var hitDragging = this.hitDragging = new HitDragging(dragging, interactionSettingsStore);
  11675. hitDragging.requireInitial = false; // will start outside of a component
  11676. hitDragging.emitter.on('dragstart', this.handleDragStart);
  11677. hitDragging.emitter.on('hitupdate', this.handleHitUpdate);
  11678. hitDragging.emitter.on('dragend', this.handleDragEnd);
  11679. this.suppliedDragMeta = suppliedDragMeta;
  11680. }
  11681. ExternalElementDragging.prototype.buildDragMeta = function (subjectEl) {
  11682. if (typeof this.suppliedDragMeta === 'object') {
  11683. return parseDragMeta(this.suppliedDragMeta);
  11684. }
  11685. if (typeof this.suppliedDragMeta === 'function') {
  11686. return parseDragMeta(this.suppliedDragMeta(subjectEl));
  11687. }
  11688. return getDragMetaFromEl(subjectEl);
  11689. };
  11690. ExternalElementDragging.prototype.displayDrag = function (nextContext, state) {
  11691. var prevContext = this.receivingContext;
  11692. if (prevContext && prevContext !== nextContext) {
  11693. prevContext.dispatch({ type: 'UNSET_EVENT_DRAG' });
  11694. }
  11695. if (nextContext) {
  11696. nextContext.dispatch({ type: 'SET_EVENT_DRAG', state: state });
  11697. }
  11698. };
  11699. ExternalElementDragging.prototype.clearDrag = function () {
  11700. if (this.receivingContext) {
  11701. this.receivingContext.dispatch({ type: 'UNSET_EVENT_DRAG' });
  11702. }
  11703. };
  11704. ExternalElementDragging.prototype.canDropElOnCalendar = function (el, receivingContext) {
  11705. var dropAccept = receivingContext.options.dropAccept;
  11706. if (typeof dropAccept === 'function') {
  11707. return dropAccept.call(receivingContext.calendarApi, el);
  11708. }
  11709. if (typeof dropAccept === 'string' && dropAccept) {
  11710. return Boolean(elementMatches(el, dropAccept));
  11711. }
  11712. return true;
  11713. };
  11714. return ExternalElementDragging;
  11715. }());
  11716. // Utils for computing event store from the DragMeta
  11717. // ----------------------------------------------------------------------------------------------------
  11718. function computeEventForDateSpan(dateSpan, dragMeta, context) {
  11719. var defProps = __assign({}, dragMeta.leftoverProps);
  11720. for (var _i = 0, _a = context.pluginHooks.externalDefTransforms; _i < _a.length; _i++) {
  11721. var transform = _a[_i];
  11722. __assign(defProps, transform(dateSpan, dragMeta));
  11723. }
  11724. var _b = refineEventDef(defProps, context), refined = _b.refined, extra = _b.extra;
  11725. var def = parseEventDef(refined, extra, dragMeta.sourceId, dateSpan.allDay, context.options.forceEventDuration || Boolean(dragMeta.duration), // hasEnd
  11726. context);
  11727. var start = dateSpan.range.start;
  11728. // only rely on time info if drop zone is all-day,
  11729. // otherwise, we already know the time
  11730. if (dateSpan.allDay && dragMeta.startTime) {
  11731. start = context.dateEnv.add(start, dragMeta.startTime);
  11732. }
  11733. var end = dragMeta.duration ?
  11734. context.dateEnv.add(start, dragMeta.duration) :
  11735. getDefaultEventEnd(dateSpan.allDay, start, context);
  11736. var instance = createEventInstance(def.defId, { start: start, end: end });
  11737. return { def: def, instance: instance };
  11738. }
  11739. // Utils for extracting data from element
  11740. // ----------------------------------------------------------------------------------------------------
  11741. function getDragMetaFromEl(el) {
  11742. var str = getEmbeddedElData(el, 'event');
  11743. var obj = str ?
  11744. JSON.parse(str) :
  11745. { create: false }; // if no embedded data, assume no event creation
  11746. return parseDragMeta(obj);
  11747. }
  11748. config.dataAttrPrefix = '';
  11749. function getEmbeddedElData(el, name) {
  11750. var prefix = config.dataAttrPrefix;
  11751. var prefixedName = (prefix ? prefix + '-' : '') + name;
  11752. return el.getAttribute('data-' + prefixedName) || '';
  11753. }
  11754. /*
  11755. Makes an element (that is *external* to any calendar) draggable.
  11756. Can pass in data that determines how an event will be created when dropped onto a calendar.
  11757. Leverages FullCalendar's internal drag-n-drop functionality WITHOUT a third-party drag system.
  11758. */
  11759. var ExternalDraggable = /** @class */ (function () {
  11760. function ExternalDraggable(el, settings) {
  11761. var _this = this;
  11762. if (settings === void 0) { settings = {}; }
  11763. this.handlePointerDown = function (ev) {
  11764. var dragging = _this.dragging;
  11765. var _a = _this.settings, minDistance = _a.minDistance, longPressDelay = _a.longPressDelay;
  11766. dragging.minDistance =
  11767. minDistance != null ?
  11768. minDistance :
  11769. (ev.isTouch ? 0 : BASE_OPTION_DEFAULTS.eventDragMinDistance);
  11770. dragging.delay =
  11771. ev.isTouch ? // TODO: eventually read eventLongPressDelay instead vvv
  11772. (longPressDelay != null ? longPressDelay : BASE_OPTION_DEFAULTS.longPressDelay) :
  11773. 0;
  11774. };
  11775. this.handleDragStart = function (ev) {
  11776. if (ev.isTouch &&
  11777. _this.dragging.delay &&
  11778. ev.subjectEl.classList.contains('fc-event')) {
  11779. _this.dragging.mirror.getMirrorEl().classList.add('fc-event-selected');
  11780. }
  11781. };
  11782. this.settings = settings;
  11783. var dragging = this.dragging = new FeaturefulElementDragging(el);
  11784. dragging.touchScrollAllowed = false;
  11785. if (settings.itemSelector != null) {
  11786. dragging.pointer.selector = settings.itemSelector;
  11787. }
  11788. if (settings.appendTo != null) {
  11789. dragging.mirror.parentNode = settings.appendTo; // TODO: write tests
  11790. }
  11791. dragging.emitter.on('pointerdown', this.handlePointerDown);
  11792. dragging.emitter.on('dragstart', this.handleDragStart);
  11793. new ExternalElementDragging(dragging, settings.eventData); // eslint-disable-line no-new
  11794. }
  11795. ExternalDraggable.prototype.destroy = function () {
  11796. this.dragging.destroy();
  11797. };
  11798. return ExternalDraggable;
  11799. }());
  11800. /*
  11801. Detects when a *THIRD-PARTY* drag-n-drop system interacts with elements.
  11802. The third-party system is responsible for drawing the visuals effects of the drag.
  11803. This class simply monitors for pointer movements and fires events.
  11804. It also has the ability to hide the moving element (the "mirror") during the drag.
  11805. */
  11806. var InferredElementDragging = /** @class */ (function (_super) {
  11807. __extends(InferredElementDragging, _super);
  11808. function InferredElementDragging(containerEl) {
  11809. var _this = _super.call(this, containerEl) || this;
  11810. _this.shouldIgnoreMove = false;
  11811. _this.mirrorSelector = '';
  11812. _this.currentMirrorEl = null;
  11813. _this.handlePointerDown = function (ev) {
  11814. _this.emitter.trigger('pointerdown', ev);
  11815. if (!_this.shouldIgnoreMove) {
  11816. // fire dragstart right away. does not support delay or min-distance
  11817. _this.emitter.trigger('dragstart', ev);
  11818. }
  11819. };
  11820. _this.handlePointerMove = function (ev) {
  11821. if (!_this.shouldIgnoreMove) {
  11822. _this.emitter.trigger('dragmove', ev);
  11823. }
  11824. };
  11825. _this.handlePointerUp = function (ev) {
  11826. _this.emitter.trigger('pointerup', ev);
  11827. if (!_this.shouldIgnoreMove) {
  11828. // fire dragend right away. does not support a revert animation
  11829. _this.emitter.trigger('dragend', ev);
  11830. }
  11831. };
  11832. var pointer = _this.pointer = new PointerDragging(containerEl);
  11833. pointer.emitter.on('pointerdown', _this.handlePointerDown);
  11834. pointer.emitter.on('pointermove', _this.handlePointerMove);
  11835. pointer.emitter.on('pointerup', _this.handlePointerUp);
  11836. return _this;
  11837. }
  11838. InferredElementDragging.prototype.destroy = function () {
  11839. this.pointer.destroy();
  11840. };
  11841. InferredElementDragging.prototype.setIgnoreMove = function (bool) {
  11842. this.shouldIgnoreMove = bool;
  11843. };
  11844. InferredElementDragging.prototype.setMirrorIsVisible = function (bool) {
  11845. if (bool) {
  11846. // restore a previously hidden element.
  11847. // use the reference in case the selector class has already been removed.
  11848. if (this.currentMirrorEl) {
  11849. this.currentMirrorEl.style.visibility = '';
  11850. this.currentMirrorEl = null;
  11851. }
  11852. }
  11853. else {
  11854. var mirrorEl = this.mirrorSelector
  11855. // TODO: somehow query FullCalendars WITHIN shadow-roots
  11856. ? document.querySelector(this.mirrorSelector)
  11857. : null;
  11858. if (mirrorEl) {
  11859. this.currentMirrorEl = mirrorEl;
  11860. mirrorEl.style.visibility = 'hidden';
  11861. }
  11862. }
  11863. };
  11864. return InferredElementDragging;
  11865. }(ElementDragging));
  11866. /*
  11867. Bridges third-party drag-n-drop systems with FullCalendar.
  11868. Must be instantiated and destroyed by caller.
  11869. */
  11870. var ThirdPartyDraggable = /** @class */ (function () {
  11871. function ThirdPartyDraggable(containerOrSettings, settings) {
  11872. var containerEl = document;
  11873. if (
  11874. // wish we could just test instanceof EventTarget, but doesn't work in IE11
  11875. containerOrSettings === document ||
  11876. containerOrSettings instanceof Element) {
  11877. containerEl = containerOrSettings;
  11878. settings = settings || {};
  11879. }
  11880. else {
  11881. settings = (containerOrSettings || {});
  11882. }
  11883. var dragging = this.dragging = new InferredElementDragging(containerEl);
  11884. if (typeof settings.itemSelector === 'string') {
  11885. dragging.pointer.selector = settings.itemSelector;
  11886. }
  11887. else if (containerEl === document) {
  11888. dragging.pointer.selector = '[data-event]';
  11889. }
  11890. if (typeof settings.mirrorSelector === 'string') {
  11891. dragging.mirrorSelector = settings.mirrorSelector;
  11892. }
  11893. new ExternalElementDragging(dragging, settings.eventData); // eslint-disable-line no-new
  11894. }
  11895. ThirdPartyDraggable.prototype.destroy = function () {
  11896. this.dragging.destroy();
  11897. };
  11898. return ThirdPartyDraggable;
  11899. }());
  11900. var interactionPlugin = createPlugin({
  11901. componentInteractions: [DateClicking, DateSelecting, EventDragging, EventResizing],
  11902. calendarInteractions: [UnselectAuto],
  11903. elementDraggingImpl: FeaturefulElementDragging,
  11904. optionRefiners: OPTION_REFINERS$3,
  11905. listenerRefiners: LISTENER_REFINERS,
  11906. });
  11907. /* An abstract class for the daygrid views, as well as month view. Renders one or more rows of day cells.
  11908. ----------------------------------------------------------------------------------------------------------------------*/
  11909. // It is a manager for a Table subcomponent, which does most of the heavy lifting.
  11910. // It is responsible for managing width/height.
  11911. var TableView = /** @class */ (function (_super) {
  11912. __extends(TableView, _super);
  11913. function TableView() {
  11914. var _this = _super !== null && _super.apply(this, arguments) || this;
  11915. _this.headerElRef = createRef();
  11916. return _this;
  11917. }
  11918. TableView.prototype.renderSimpleLayout = function (headerRowContent, bodyContent) {
  11919. var _a = this, props = _a.props, context = _a.context;
  11920. var sections = [];
  11921. var stickyHeaderDates = getStickyHeaderDates(context.options);
  11922. if (headerRowContent) {
  11923. sections.push({
  11924. type: 'header',
  11925. key: 'header',
  11926. isSticky: stickyHeaderDates,
  11927. chunk: {
  11928. elRef: this.headerElRef,
  11929. tableClassName: 'fc-col-header',
  11930. rowContent: headerRowContent,
  11931. },
  11932. });
  11933. }
  11934. sections.push({
  11935. type: 'body',
  11936. key: 'body',
  11937. liquid: true,
  11938. chunk: { content: bodyContent },
  11939. });
  11940. return (createElement(ViewRoot, { viewSpec: context.viewSpec }, function (rootElRef, classNames) { return (createElement("div", { ref: rootElRef, className: ['fc-daygrid'].concat(classNames).join(' ') },
  11941. createElement(SimpleScrollGrid, { liquid: !props.isHeightAuto && !props.forPrint, collapsibleWidth: props.forPrint, cols: [] /* TODO: make optional? */, sections: sections }))); }));
  11942. };
  11943. TableView.prototype.renderHScrollLayout = function (headerRowContent, bodyContent, colCnt, dayMinWidth) {
  11944. var ScrollGrid = this.context.pluginHooks.scrollGridImpl;
  11945. if (!ScrollGrid) {
  11946. throw new Error('No ScrollGrid implementation');
  11947. }
  11948. var _a = this, props = _a.props, context = _a.context;
  11949. var stickyHeaderDates = !props.forPrint && getStickyHeaderDates(context.options);
  11950. var stickyFooterScrollbar = !props.forPrint && getStickyFooterScrollbar(context.options);
  11951. var sections = [];
  11952. if (headerRowContent) {
  11953. sections.push({
  11954. type: 'header',
  11955. key: 'header',
  11956. isSticky: stickyHeaderDates,
  11957. chunks: [{
  11958. key: 'main',
  11959. elRef: this.headerElRef,
  11960. tableClassName: 'fc-col-header',
  11961. rowContent: headerRowContent,
  11962. }],
  11963. });
  11964. }
  11965. sections.push({
  11966. type: 'body',
  11967. key: 'body',
  11968. liquid: true,
  11969. chunks: [{
  11970. key: 'main',
  11971. content: bodyContent,
  11972. }],
  11973. });
  11974. if (stickyFooterScrollbar) {
  11975. sections.push({
  11976. type: 'footer',
  11977. key: 'footer',
  11978. isSticky: true,
  11979. chunks: [{
  11980. key: 'main',
  11981. content: renderScrollShim,
  11982. }],
  11983. });
  11984. }
  11985. return (createElement(ViewRoot, { viewSpec: context.viewSpec }, function (rootElRef, classNames) { return (createElement("div", { ref: rootElRef, className: ['fc-daygrid'].concat(classNames).join(' ') },
  11986. createElement(ScrollGrid, { liquid: !props.isHeightAuto && !props.forPrint, collapsibleWidth: props.forPrint, colGroups: [{ cols: [{ span: colCnt, minWidth: dayMinWidth }] }], sections: sections }))); }));
  11987. };
  11988. return TableView;
  11989. }(DateComponent));
  11990. function splitSegsByRow(segs, rowCnt) {
  11991. var byRow = [];
  11992. for (var i = 0; i < rowCnt; i += 1) {
  11993. byRow[i] = [];
  11994. }
  11995. for (var _i = 0, segs_1 = segs; _i < segs_1.length; _i++) {
  11996. var seg = segs_1[_i];
  11997. byRow[seg.row].push(seg);
  11998. }
  11999. return byRow;
  12000. }
  12001. function splitSegsByFirstCol(segs, colCnt) {
  12002. var byCol = [];
  12003. for (var i = 0; i < colCnt; i += 1) {
  12004. byCol[i] = [];
  12005. }
  12006. for (var _i = 0, segs_2 = segs; _i < segs_2.length; _i++) {
  12007. var seg = segs_2[_i];
  12008. byCol[seg.firstCol].push(seg);
  12009. }
  12010. return byCol;
  12011. }
  12012. function splitInteractionByRow(ui, rowCnt) {
  12013. var byRow = [];
  12014. if (!ui) {
  12015. for (var i = 0; i < rowCnt; i += 1) {
  12016. byRow[i] = null;
  12017. }
  12018. }
  12019. else {
  12020. for (var i = 0; i < rowCnt; i += 1) {
  12021. byRow[i] = {
  12022. affectedInstances: ui.affectedInstances,
  12023. isEvent: ui.isEvent,
  12024. segs: [],
  12025. };
  12026. }
  12027. for (var _i = 0, _a = ui.segs; _i < _a.length; _i++) {
  12028. var seg = _a[_i];
  12029. byRow[seg.row].segs.push(seg);
  12030. }
  12031. }
  12032. return byRow;
  12033. }
  12034. var TableCellTop = /** @class */ (function (_super) {
  12035. __extends(TableCellTop, _super);
  12036. function TableCellTop() {
  12037. return _super !== null && _super.apply(this, arguments) || this;
  12038. }
  12039. TableCellTop.prototype.render = function () {
  12040. var props = this.props;
  12041. var navLinkAttrs = buildNavLinkAttrs(this.context, props.date);
  12042. return (createElement(DayCellContent, { date: props.date, dateProfile: props.dateProfile, todayRange: props.todayRange, showDayNumber: props.showDayNumber, extraHookProps: props.extraHookProps, defaultContent: renderTopInner }, function (innerElRef, innerContent) { return ((innerContent || props.forceDayTop) && (createElement("div", { className: "fc-daygrid-day-top", ref: innerElRef },
  12043. createElement("a", __assign({ id: props.dayNumberId, className: "fc-daygrid-day-number" }, navLinkAttrs), innerContent || createElement(Fragment, null, "\u00A0"))))); }));
  12044. };
  12045. return TableCellTop;
  12046. }(BaseComponent));
  12047. function renderTopInner(props) {
  12048. return props.dayNumberText;
  12049. }
  12050. var DEFAULT_TABLE_EVENT_TIME_FORMAT = createFormatter({
  12051. hour: 'numeric',
  12052. minute: '2-digit',
  12053. omitZeroMinute: true,
  12054. meridiem: 'narrow',
  12055. });
  12056. function hasListItemDisplay(seg) {
  12057. var display = seg.eventRange.ui.display;
  12058. return display === 'list-item' || (display === 'auto' &&
  12059. !seg.eventRange.def.allDay &&
  12060. seg.firstCol === seg.lastCol && // can't be multi-day
  12061. seg.isStart && // "
  12062. seg.isEnd // "
  12063. );
  12064. }
  12065. var TableBlockEvent = /** @class */ (function (_super) {
  12066. __extends(TableBlockEvent, _super);
  12067. function TableBlockEvent() {
  12068. return _super !== null && _super.apply(this, arguments) || this;
  12069. }
  12070. TableBlockEvent.prototype.render = function () {
  12071. var props = this.props;
  12072. 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 })));
  12073. };
  12074. return TableBlockEvent;
  12075. }(BaseComponent));
  12076. var TableListItemEvent = /** @class */ (function (_super) {
  12077. __extends(TableListItemEvent, _super);
  12078. function TableListItemEvent() {
  12079. return _super !== null && _super.apply(this, arguments) || this;
  12080. }
  12081. TableListItemEvent.prototype.render = function () {
  12082. var _a = this, props = _a.props, context = _a.context;
  12083. var timeFormat = context.options.eventTimeFormat || DEFAULT_TABLE_EVENT_TIME_FORMAT;
  12084. var timeText = buildSegTimeText(props.seg, timeFormat, context, true, props.defaultDisplayEventEnd);
  12085. 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!
  12086. createElement("a", __assign({ className: ['fc-daygrid-event', 'fc-daygrid-dot-event'].concat(classNames).join(' '), ref: rootElRef }, getSegAnchorAttrs(props.seg, context)), innerContent)); }));
  12087. };
  12088. return TableListItemEvent;
  12089. }(BaseComponent));
  12090. function renderInnerContent$2(innerProps) {
  12091. return (createElement(Fragment, null,
  12092. createElement("div", { className: "fc-daygrid-event-dot", style: { borderColor: innerProps.borderColor || innerProps.backgroundColor } }),
  12093. innerProps.timeText && (createElement("div", { className: "fc-event-time" }, innerProps.timeText)),
  12094. createElement("div", { className: "fc-event-title" }, innerProps.event.title || createElement(Fragment, null, "\u00A0"))));
  12095. }
  12096. var TableCellMoreLink = /** @class */ (function (_super) {
  12097. __extends(TableCellMoreLink, _super);
  12098. function TableCellMoreLink() {
  12099. var _this = _super !== null && _super.apply(this, arguments) || this;
  12100. _this.compileSegs = memoize(compileSegs);
  12101. return _this;
  12102. }
  12103. TableCellMoreLink.prototype.render = function () {
  12104. var props = this.props;
  12105. var _a = this.compileSegs(props.singlePlacements), allSegs = _a.allSegs, invisibleSegs = _a.invisibleSegs;
  12106. return (createElement(MoreLinkRoot, { dateProfile: props.dateProfile, todayRange: props.todayRange, allDayDate: props.allDayDate, moreCnt: props.moreCnt, allSegs: allSegs, hiddenSegs: invisibleSegs, alignmentElRef: props.alignmentElRef, alignGridTop: props.alignGridTop, extraDateSpan: props.extraDateSpan, popoverContent: function () {
  12107. var isForcedInvisible = (props.eventDrag ? props.eventDrag.affectedInstances : null) ||
  12108. (props.eventResize ? props.eventResize.affectedInstances : null) ||
  12109. {};
  12110. return (createElement(Fragment, null, allSegs.map(function (seg) {
  12111. var instanceId = seg.eventRange.instance.instanceId;
  12112. return (createElement("div", { className: "fc-daygrid-event-harness", key: instanceId, style: {
  12113. visibility: isForcedInvisible[instanceId] ? 'hidden' : '',
  12114. } }, hasListItemDisplay(seg) ? (createElement(TableListItemEvent, __assign({ seg: seg, isDragging: false, isSelected: instanceId === props.eventSelection, defaultDisplayEventEnd: false }, getSegMeta(seg, props.todayRange)))) : (createElement(TableBlockEvent, __assign({ seg: seg, isDragging: false, isResizing: false, isDateSelecting: false, isSelected: instanceId === props.eventSelection, defaultDisplayEventEnd: false }, getSegMeta(seg, props.todayRange))))));
  12115. })));
  12116. } }, function (rootElRef, classNames, innerElRef, innerContent, handleClick, title, isExpanded, popoverId) { return (createElement("a", __assign({ ref: rootElRef, className: ['fc-daygrid-more-link'].concat(classNames).join(' '), title: title, "aria-expanded": isExpanded, "aria-controls": popoverId }, createAriaClickAttrs(handleClick)), innerContent)); }));
  12117. };
  12118. return TableCellMoreLink;
  12119. }(BaseComponent));
  12120. function compileSegs(singlePlacements) {
  12121. var allSegs = [];
  12122. var invisibleSegs = [];
  12123. for (var _i = 0, singlePlacements_1 = singlePlacements; _i < singlePlacements_1.length; _i++) {
  12124. var placement = singlePlacements_1[_i];
  12125. allSegs.push(placement.seg);
  12126. if (!placement.isVisible) {
  12127. invisibleSegs.push(placement.seg);
  12128. }
  12129. }
  12130. return { allSegs: allSegs, invisibleSegs: invisibleSegs };
  12131. }
  12132. var DEFAULT_WEEK_NUM_FORMAT$1 = createFormatter({ week: 'narrow' });
  12133. var TableCell = /** @class */ (function (_super) {
  12134. __extends(TableCell, _super);
  12135. function TableCell() {
  12136. var _this = _super !== null && _super.apply(this, arguments) || this;
  12137. _this.rootElRef = createRef();
  12138. _this.state = {
  12139. dayNumberId: getUniqueDomId(),
  12140. };
  12141. _this.handleRootEl = function (el) {
  12142. setRef(_this.rootElRef, el);
  12143. setRef(_this.props.elRef, el);
  12144. };
  12145. return _this;
  12146. }
  12147. TableCell.prototype.render = function () {
  12148. var _a = this, context = _a.context, props = _a.props, state = _a.state, rootElRef = _a.rootElRef;
  12149. var date = props.date, dateProfile = props.dateProfile;
  12150. var navLinkAttrs = buildNavLinkAttrs(context, date, 'week');
  12151. return (createElement(DayCellRoot, { date: date, dateProfile: dateProfile, todayRange: props.todayRange, showDayNumber: props.showDayNumber, extraHookProps: props.extraHookProps, elRef: this.handleRootEl }, function (dayElRef, dayClassNames, rootDataAttrs, isDisabled) { return (createElement("td", __assign({ ref: dayElRef, role: "gridcell", className: ['fc-daygrid-day'].concat(dayClassNames, props.extraClassNames || []).join(' ') }, rootDataAttrs, props.extraDataAttrs, (props.showDayNumber ? { 'aria-labelledby': state.dayNumberId } : {})),
  12152. createElement("div", { className: "fc-daygrid-day-frame fc-scrollgrid-sync-inner", ref: props.innerElRef /* different from hook system! RENAME */ },
  12153. props.showWeekNumber && (createElement(WeekNumberRoot, { date: date, defaultFormat: DEFAULT_WEEK_NUM_FORMAT$1 }, function (weekElRef, weekClassNames, innerElRef, innerContent) { return (createElement("a", __assign({ ref: weekElRef, className: ['fc-daygrid-week-number'].concat(weekClassNames).join(' ') }, navLinkAttrs), innerContent)); })),
  12154. !isDisabled && (createElement(TableCellTop, { date: date, dateProfile: dateProfile, showDayNumber: props.showDayNumber, dayNumberId: state.dayNumberId, forceDayTop: props.forceDayTop, todayRange: props.todayRange, extraHookProps: props.extraHookProps })),
  12155. createElement("div", { className: "fc-daygrid-day-events", ref: props.fgContentElRef },
  12156. props.fgContent,
  12157. createElement("div", { className: "fc-daygrid-day-bottom", style: { marginTop: props.moreMarginTop } },
  12158. createElement(TableCellMoreLink, { allDayDate: date, singlePlacements: props.singlePlacements, moreCnt: props.moreCnt, alignmentElRef: rootElRef, alignGridTop: !props.showDayNumber, extraDateSpan: props.extraDateSpan, dateProfile: props.dateProfile, eventSelection: props.eventSelection, eventDrag: props.eventDrag, eventResize: props.eventResize, todayRange: props.todayRange }))),
  12159. createElement("div", { className: "fc-daygrid-day-bg" }, props.bgContent)))); }));
  12160. };
  12161. return TableCell;
  12162. }(DateComponent));
  12163. function computeFgSegPlacement(segs, // assumed already sorted
  12164. dayMaxEvents, dayMaxEventRows, strictOrder, eventInstanceHeights, maxContentHeight, cells) {
  12165. var hierarchy = new DayGridSegHierarchy();
  12166. hierarchy.allowReslicing = true;
  12167. hierarchy.strictOrder = strictOrder;
  12168. if (dayMaxEvents === true || dayMaxEventRows === true) {
  12169. hierarchy.maxCoord = maxContentHeight;
  12170. hierarchy.hiddenConsumes = true;
  12171. }
  12172. else if (typeof dayMaxEvents === 'number') {
  12173. hierarchy.maxStackCnt = dayMaxEvents;
  12174. }
  12175. else if (typeof dayMaxEventRows === 'number') {
  12176. hierarchy.maxStackCnt = dayMaxEventRows;
  12177. hierarchy.hiddenConsumes = true;
  12178. }
  12179. // create segInputs only for segs with known heights
  12180. var segInputs = [];
  12181. var unknownHeightSegs = [];
  12182. for (var i = 0; i < segs.length; i += 1) {
  12183. var seg = segs[i];
  12184. var instanceId = seg.eventRange.instance.instanceId;
  12185. var eventHeight = eventInstanceHeights[instanceId];
  12186. if (eventHeight != null) {
  12187. segInputs.push({
  12188. index: i,
  12189. thickness: eventHeight,
  12190. span: {
  12191. start: seg.firstCol,
  12192. end: seg.lastCol + 1,
  12193. },
  12194. });
  12195. }
  12196. else {
  12197. unknownHeightSegs.push(seg);
  12198. }
  12199. }
  12200. var hiddenEntries = hierarchy.addSegs(segInputs);
  12201. var segRects = hierarchy.toRects();
  12202. var _a = placeRects(segRects, segs, cells), singleColPlacements = _a.singleColPlacements, multiColPlacements = _a.multiColPlacements, leftoverMargins = _a.leftoverMargins;
  12203. var moreCnts = [];
  12204. var moreMarginTops = [];
  12205. // add segs with unknown heights
  12206. for (var _i = 0, unknownHeightSegs_1 = unknownHeightSegs; _i < unknownHeightSegs_1.length; _i++) {
  12207. var seg = unknownHeightSegs_1[_i];
  12208. multiColPlacements[seg.firstCol].push({
  12209. seg: seg,
  12210. isVisible: false,
  12211. isAbsolute: true,
  12212. absoluteTop: 0,
  12213. marginTop: 0,
  12214. });
  12215. for (var col = seg.firstCol; col <= seg.lastCol; col += 1) {
  12216. singleColPlacements[col].push({
  12217. seg: resliceSeg(seg, col, col + 1, cells),
  12218. isVisible: false,
  12219. isAbsolute: false,
  12220. absoluteTop: 0,
  12221. marginTop: 0,
  12222. });
  12223. }
  12224. }
  12225. // add the hidden entries
  12226. for (var col = 0; col < cells.length; col += 1) {
  12227. moreCnts.push(0);
  12228. }
  12229. for (var _b = 0, hiddenEntries_1 = hiddenEntries; _b < hiddenEntries_1.length; _b++) {
  12230. var hiddenEntry = hiddenEntries_1[_b];
  12231. var seg = segs[hiddenEntry.index];
  12232. var hiddenSpan = hiddenEntry.span;
  12233. multiColPlacements[hiddenSpan.start].push({
  12234. seg: resliceSeg(seg, hiddenSpan.start, hiddenSpan.end, cells),
  12235. isVisible: false,
  12236. isAbsolute: true,
  12237. absoluteTop: 0,
  12238. marginTop: 0,
  12239. });
  12240. for (var col = hiddenSpan.start; col < hiddenSpan.end; col += 1) {
  12241. moreCnts[col] += 1;
  12242. singleColPlacements[col].push({
  12243. seg: resliceSeg(seg, col, col + 1, cells),
  12244. isVisible: false,
  12245. isAbsolute: false,
  12246. absoluteTop: 0,
  12247. marginTop: 0,
  12248. });
  12249. }
  12250. }
  12251. // deal with leftover margins
  12252. for (var col = 0; col < cells.length; col += 1) {
  12253. moreMarginTops.push(leftoverMargins[col]);
  12254. }
  12255. return { singleColPlacements: singleColPlacements, multiColPlacements: multiColPlacements, moreCnts: moreCnts, moreMarginTops: moreMarginTops };
  12256. }
  12257. // rects ordered by top coord, then left
  12258. function placeRects(allRects, segs, cells) {
  12259. var rectsByEachCol = groupRectsByEachCol(allRects, cells.length);
  12260. var singleColPlacements = [];
  12261. var multiColPlacements = [];
  12262. var leftoverMargins = [];
  12263. for (var col = 0; col < cells.length; col += 1) {
  12264. var rects = rectsByEachCol[col];
  12265. // compute all static segs in singlePlacements
  12266. var singlePlacements = [];
  12267. var currentHeight = 0;
  12268. var currentMarginTop = 0;
  12269. for (var _i = 0, rects_1 = rects; _i < rects_1.length; _i++) {
  12270. var rect = rects_1[_i];
  12271. var seg = segs[rect.index];
  12272. singlePlacements.push({
  12273. seg: resliceSeg(seg, col, col + 1, cells),
  12274. isVisible: true,
  12275. isAbsolute: false,
  12276. absoluteTop: rect.levelCoord,
  12277. marginTop: rect.levelCoord - currentHeight,
  12278. });
  12279. currentHeight = rect.levelCoord + rect.thickness;
  12280. }
  12281. // compute mixed static/absolute segs in multiPlacements
  12282. var multiPlacements = [];
  12283. currentHeight = 0;
  12284. currentMarginTop = 0;
  12285. for (var _a = 0, rects_2 = rects; _a < rects_2.length; _a++) {
  12286. var rect = rects_2[_a];
  12287. var seg = segs[rect.index];
  12288. var isAbsolute = rect.span.end - rect.span.start > 1; // multi-column?
  12289. var isFirstCol = rect.span.start === col;
  12290. currentMarginTop += rect.levelCoord - currentHeight; // amount of space since bottom of previous seg
  12291. currentHeight = rect.levelCoord + rect.thickness; // height will now be bottom of current seg
  12292. if (isAbsolute) {
  12293. currentMarginTop += rect.thickness;
  12294. if (isFirstCol) {
  12295. multiPlacements.push({
  12296. seg: resliceSeg(seg, rect.span.start, rect.span.end, cells),
  12297. isVisible: true,
  12298. isAbsolute: true,
  12299. absoluteTop: rect.levelCoord,
  12300. marginTop: 0,
  12301. });
  12302. }
  12303. }
  12304. else if (isFirstCol) {
  12305. multiPlacements.push({
  12306. seg: resliceSeg(seg, rect.span.start, rect.span.end, cells),
  12307. isVisible: true,
  12308. isAbsolute: false,
  12309. absoluteTop: rect.levelCoord,
  12310. marginTop: currentMarginTop, // claim the margin
  12311. });
  12312. currentMarginTop = 0;
  12313. }
  12314. }
  12315. singleColPlacements.push(singlePlacements);
  12316. multiColPlacements.push(multiPlacements);
  12317. leftoverMargins.push(currentMarginTop);
  12318. }
  12319. return { singleColPlacements: singleColPlacements, multiColPlacements: multiColPlacements, leftoverMargins: leftoverMargins };
  12320. }
  12321. function groupRectsByEachCol(rects, colCnt) {
  12322. var rectsByEachCol = [];
  12323. for (var col = 0; col < colCnt; col += 1) {
  12324. rectsByEachCol.push([]);
  12325. }
  12326. for (var _i = 0, rects_3 = rects; _i < rects_3.length; _i++) {
  12327. var rect = rects_3[_i];
  12328. for (var col = rect.span.start; col < rect.span.end; col += 1) {
  12329. rectsByEachCol[col].push(rect);
  12330. }
  12331. }
  12332. return rectsByEachCol;
  12333. }
  12334. function resliceSeg(seg, spanStart, spanEnd, cells) {
  12335. if (seg.firstCol === spanStart && seg.lastCol === spanEnd - 1) {
  12336. return seg;
  12337. }
  12338. var eventRange = seg.eventRange;
  12339. var origRange = eventRange.range;
  12340. var slicedRange = intersectRanges(origRange, {
  12341. start: cells[spanStart].date,
  12342. end: addDays(cells[spanEnd - 1].date, 1),
  12343. });
  12344. return __assign(__assign({}, seg), { firstCol: spanStart, lastCol: spanEnd - 1, eventRange: {
  12345. def: eventRange.def,
  12346. ui: __assign(__assign({}, eventRange.ui), { durationEditable: false }),
  12347. instance: eventRange.instance,
  12348. range: slicedRange,
  12349. }, isStart: seg.isStart && slicedRange.start.valueOf() === origRange.start.valueOf(), isEnd: seg.isEnd && slicedRange.end.valueOf() === origRange.end.valueOf() });
  12350. }
  12351. var DayGridSegHierarchy = /** @class */ (function (_super) {
  12352. __extends(DayGridSegHierarchy, _super);
  12353. function DayGridSegHierarchy() {
  12354. var _this = _super !== null && _super.apply(this, arguments) || this;
  12355. // config
  12356. _this.hiddenConsumes = false;
  12357. // allows us to keep hidden entries in the hierarchy so they take up space
  12358. _this.forceHidden = {};
  12359. return _this;
  12360. }
  12361. DayGridSegHierarchy.prototype.addSegs = function (segInputs) {
  12362. var _this = this;
  12363. var hiddenSegs = _super.prototype.addSegs.call(this, segInputs);
  12364. var entriesByLevel = this.entriesByLevel;
  12365. var excludeHidden = function (entry) { return !_this.forceHidden[buildEntryKey(entry)]; };
  12366. // remove the forced-hidden segs
  12367. for (var level = 0; level < entriesByLevel.length; level += 1) {
  12368. entriesByLevel[level] = entriesByLevel[level].filter(excludeHidden);
  12369. }
  12370. return hiddenSegs;
  12371. };
  12372. DayGridSegHierarchy.prototype.handleInvalidInsertion = function (insertion, entry, hiddenEntries) {
  12373. var _a = this, entriesByLevel = _a.entriesByLevel, forceHidden = _a.forceHidden;
  12374. var touchingEntry = insertion.touchingEntry, touchingLevel = insertion.touchingLevel, touchingLateral = insertion.touchingLateral;
  12375. if (this.hiddenConsumes && touchingEntry) {
  12376. var touchingEntryId = buildEntryKey(touchingEntry);
  12377. // if not already hidden
  12378. if (!forceHidden[touchingEntryId]) {
  12379. if (this.allowReslicing) {
  12380. var placeholderEntry = __assign(__assign({}, touchingEntry), { span: intersectSpans(touchingEntry.span, entry.span) });
  12381. var placeholderEntryId = buildEntryKey(placeholderEntry);
  12382. forceHidden[placeholderEntryId] = true;
  12383. entriesByLevel[touchingLevel][touchingLateral] = placeholderEntry; // replace touchingEntry with our placeholder
  12384. this.splitEntry(touchingEntry, entry, hiddenEntries); // split up the touchingEntry, reinsert it
  12385. }
  12386. else {
  12387. forceHidden[touchingEntryId] = true;
  12388. hiddenEntries.push(touchingEntry);
  12389. }
  12390. }
  12391. }
  12392. return _super.prototype.handleInvalidInsertion.call(this, insertion, entry, hiddenEntries);
  12393. };
  12394. return DayGridSegHierarchy;
  12395. }(SegHierarchy));
  12396. var TableRow = /** @class */ (function (_super) {
  12397. __extends(TableRow, _super);
  12398. function TableRow() {
  12399. var _this = _super !== null && _super.apply(this, arguments) || this;
  12400. _this.cellElRefs = new RefMap(); // the <td>
  12401. _this.frameElRefs = new RefMap(); // the fc-daygrid-day-frame
  12402. _this.fgElRefs = new RefMap(); // the fc-daygrid-day-events
  12403. _this.segHarnessRefs = new RefMap(); // indexed by "instanceId:firstCol"
  12404. _this.rootElRef = createRef();
  12405. _this.state = {
  12406. framePositions: null,
  12407. maxContentHeight: null,
  12408. eventInstanceHeights: {},
  12409. };
  12410. return _this;
  12411. }
  12412. TableRow.prototype.render = function () {
  12413. var _this = this;
  12414. var _a = this, props = _a.props, state = _a.state, context = _a.context;
  12415. var options = context.options;
  12416. var colCnt = props.cells.length;
  12417. var businessHoursByCol = splitSegsByFirstCol(props.businessHourSegs, colCnt);
  12418. var bgEventSegsByCol = splitSegsByFirstCol(props.bgEventSegs, colCnt);
  12419. var highlightSegsByCol = splitSegsByFirstCol(this.getHighlightSegs(), colCnt);
  12420. var mirrorSegsByCol = splitSegsByFirstCol(this.getMirrorSegs(), colCnt);
  12421. var _b = computeFgSegPlacement(sortEventSegs(props.fgEventSegs, options.eventOrder), props.dayMaxEvents, props.dayMaxEventRows, options.eventOrderStrict, state.eventInstanceHeights, state.maxContentHeight, props.cells), singleColPlacements = _b.singleColPlacements, multiColPlacements = _b.multiColPlacements, moreCnts = _b.moreCnts, moreMarginTops = _b.moreMarginTops;
  12422. var isForcedInvisible = // TODO: messy way to compute this
  12423. (props.eventDrag && props.eventDrag.affectedInstances) ||
  12424. (props.eventResize && props.eventResize.affectedInstances) ||
  12425. {};
  12426. return (createElement("tr", { ref: this.rootElRef, role: "row" },
  12427. props.renderIntro && props.renderIntro(),
  12428. props.cells.map(function (cell, col) {
  12429. var normalFgNodes = _this.renderFgSegs(col, props.forPrint ? singleColPlacements[col] : multiColPlacements[col], props.todayRange, isForcedInvisible);
  12430. var mirrorFgNodes = _this.renderFgSegs(col, buildMirrorPlacements(mirrorSegsByCol[col], multiColPlacements), props.todayRange, {}, Boolean(props.eventDrag), Boolean(props.eventResize), false);
  12431. return (createElement(TableCell, { key: cell.key, elRef: _this.cellElRefs.createRef(cell.key), innerElRef: _this.frameElRefs.createRef(cell.key) /* FF <td> problem, but okay to use for left/right. TODO: rename prop */, dateProfile: props.dateProfile, date: cell.date, showDayNumber: props.showDayNumbers, showWeekNumber: props.showWeekNumbers && col === 0, forceDayTop: props.showWeekNumbers /* even displaying weeknum for row, not necessarily day */, todayRange: props.todayRange, eventSelection: props.eventSelection, eventDrag: props.eventDrag, eventResize: props.eventResize, extraHookProps: cell.extraHookProps, extraDataAttrs: cell.extraDataAttrs, extraClassNames: cell.extraClassNames, extraDateSpan: cell.extraDateSpan, moreCnt: moreCnts[col], moreMarginTop: moreMarginTops[col], singlePlacements: singleColPlacements[col], fgContentElRef: _this.fgElRefs.createRef(cell.key), fgContent: ( // Fragment scopes the keys
  12432. createElement(Fragment, null,
  12433. createElement(Fragment, null, normalFgNodes),
  12434. createElement(Fragment, null, mirrorFgNodes))), bgContent: ( // Fragment scopes the keys
  12435. createElement(Fragment, null,
  12436. _this.renderFillSegs(highlightSegsByCol[col], 'highlight'),
  12437. _this.renderFillSegs(businessHoursByCol[col], 'non-business'),
  12438. _this.renderFillSegs(bgEventSegsByCol[col], 'bg-event'))) }));
  12439. })));
  12440. };
  12441. TableRow.prototype.componentDidMount = function () {
  12442. this.updateSizing(true);
  12443. };
  12444. TableRow.prototype.componentDidUpdate = function (prevProps, prevState) {
  12445. var currentProps = this.props;
  12446. this.updateSizing(!isPropsEqual(prevProps, currentProps));
  12447. };
  12448. TableRow.prototype.getHighlightSegs = function () {
  12449. var props = this.props;
  12450. if (props.eventDrag && props.eventDrag.segs.length) { // messy check
  12451. return props.eventDrag.segs;
  12452. }
  12453. if (props.eventResize && props.eventResize.segs.length) { // messy check
  12454. return props.eventResize.segs;
  12455. }
  12456. return props.dateSelectionSegs;
  12457. };
  12458. TableRow.prototype.getMirrorSegs = function () {
  12459. var props = this.props;
  12460. if (props.eventResize && props.eventResize.segs.length) { // messy check
  12461. return props.eventResize.segs;
  12462. }
  12463. return [];
  12464. };
  12465. TableRow.prototype.renderFgSegs = function (col, segPlacements, todayRange, isForcedInvisible, isDragging, isResizing, isDateSelecting) {
  12466. var context = this.context;
  12467. var eventSelection = this.props.eventSelection;
  12468. var framePositions = this.state.framePositions;
  12469. var defaultDisplayEventEnd = this.props.cells.length === 1; // colCnt === 1
  12470. var isMirror = isDragging || isResizing || isDateSelecting;
  12471. var nodes = [];
  12472. if (framePositions) {
  12473. for (var _i = 0, segPlacements_1 = segPlacements; _i < segPlacements_1.length; _i++) {
  12474. var placement = segPlacements_1[_i];
  12475. var seg = placement.seg;
  12476. var instanceId = seg.eventRange.instance.instanceId;
  12477. var key = instanceId + ':' + col;
  12478. var isVisible = placement.isVisible && !isForcedInvisible[instanceId];
  12479. var isAbsolute = placement.isAbsolute;
  12480. var left = '';
  12481. var right = '';
  12482. if (isAbsolute) {
  12483. if (context.isRtl) {
  12484. right = 0;
  12485. left = framePositions.lefts[seg.lastCol] - framePositions.lefts[seg.firstCol];
  12486. }
  12487. else {
  12488. left = 0;
  12489. right = framePositions.rights[seg.firstCol] - framePositions.rights[seg.lastCol];
  12490. }
  12491. }
  12492. /*
  12493. known bug: events that are force to be list-item but span multiple days still take up space in later columns
  12494. todo: in print view, for multi-day events, don't display title within non-start/end segs
  12495. */
  12496. nodes.push(createElement("div", { className: 'fc-daygrid-event-harness' + (isAbsolute ? ' fc-daygrid-event-harness-abs' : ''), key: key, ref: isMirror ? null : this.segHarnessRefs.createRef(key), style: {
  12497. visibility: isVisible ? '' : 'hidden',
  12498. marginTop: isAbsolute ? '' : placement.marginTop,
  12499. top: isAbsolute ? placement.absoluteTop : '',
  12500. left: left,
  12501. right: right,
  12502. } }, hasListItemDisplay(seg) ? (createElement(TableListItemEvent, __assign({ seg: seg, isDragging: isDragging, isSelected: instanceId === eventSelection, defaultDisplayEventEnd: defaultDisplayEventEnd }, getSegMeta(seg, todayRange)))) : (createElement(TableBlockEvent, __assign({ seg: seg, isDragging: isDragging, isResizing: isResizing, isDateSelecting: isDateSelecting, isSelected: instanceId === eventSelection, defaultDisplayEventEnd: defaultDisplayEventEnd }, getSegMeta(seg, todayRange))))));
  12503. }
  12504. }
  12505. return nodes;
  12506. };
  12507. TableRow.prototype.renderFillSegs = function (segs, fillType) {
  12508. var isRtl = this.context.isRtl;
  12509. var todayRange = this.props.todayRange;
  12510. var framePositions = this.state.framePositions;
  12511. var nodes = [];
  12512. if (framePositions) {
  12513. for (var _i = 0, segs_1 = segs; _i < segs_1.length; _i++) {
  12514. var seg = segs_1[_i];
  12515. var leftRightCss = isRtl ? {
  12516. right: 0,
  12517. left: framePositions.lefts[seg.lastCol] - framePositions.lefts[seg.firstCol],
  12518. } : {
  12519. left: 0,
  12520. right: framePositions.rights[seg.firstCol] - framePositions.rights[seg.lastCol],
  12521. };
  12522. nodes.push(createElement("div", { key: buildEventRangeKey(seg.eventRange), className: "fc-daygrid-bg-harness", style: leftRightCss }, fillType === 'bg-event' ?
  12523. createElement(BgEvent, __assign({ seg: seg }, getSegMeta(seg, todayRange))) :
  12524. renderFill(fillType)));
  12525. }
  12526. }
  12527. return createElement.apply(void 0, __spreadArray([Fragment, {}], nodes));
  12528. };
  12529. TableRow.prototype.updateSizing = function (isExternalSizingChange) {
  12530. var _a = this, props = _a.props, frameElRefs = _a.frameElRefs;
  12531. if (!props.forPrint &&
  12532. props.clientWidth !== null // positioning ready?
  12533. ) {
  12534. if (isExternalSizingChange) {
  12535. var frameEls = props.cells.map(function (cell) { return frameElRefs.currentMap[cell.key]; });
  12536. if (frameEls.length) {
  12537. var originEl = this.rootElRef.current;
  12538. this.setState({
  12539. framePositions: new PositionCache(originEl, frameEls, true, // isHorizontal
  12540. false),
  12541. });
  12542. }
  12543. }
  12544. var oldInstanceHeights = this.state.eventInstanceHeights;
  12545. var newInstanceHeights = this.queryEventInstanceHeights();
  12546. var limitByContentHeight = props.dayMaxEvents === true || props.dayMaxEventRows === true;
  12547. this.safeSetState({
  12548. // HACK to prevent oscillations of events being shown/hidden from max-event-rows
  12549. // Essentially, once you compute an element's height, never null-out.
  12550. // TODO: always display all events, as visibility:hidden?
  12551. eventInstanceHeights: __assign(__assign({}, oldInstanceHeights), newInstanceHeights),
  12552. maxContentHeight: limitByContentHeight ? this.computeMaxContentHeight() : null,
  12553. });
  12554. }
  12555. };
  12556. TableRow.prototype.queryEventInstanceHeights = function () {
  12557. var segElMap = this.segHarnessRefs.currentMap;
  12558. var eventInstanceHeights = {};
  12559. // get the max height amongst instance segs
  12560. for (var key in segElMap) {
  12561. var height = Math.round(segElMap[key].getBoundingClientRect().height);
  12562. var instanceId = key.split(':')[0]; // deconstruct how renderFgSegs makes the key
  12563. eventInstanceHeights[instanceId] = Math.max(eventInstanceHeights[instanceId] || 0, height);
  12564. }
  12565. return eventInstanceHeights;
  12566. };
  12567. TableRow.prototype.computeMaxContentHeight = function () {
  12568. var firstKey = this.props.cells[0].key;
  12569. var cellEl = this.cellElRefs.currentMap[firstKey];
  12570. var fcContainerEl = this.fgElRefs.currentMap[firstKey];
  12571. return cellEl.getBoundingClientRect().bottom - fcContainerEl.getBoundingClientRect().top;
  12572. };
  12573. TableRow.prototype.getCellEls = function () {
  12574. var elMap = this.cellElRefs.currentMap;
  12575. return this.props.cells.map(function (cell) { return elMap[cell.key]; });
  12576. };
  12577. return TableRow;
  12578. }(DateComponent));
  12579. TableRow.addStateEquality({
  12580. eventInstanceHeights: isPropsEqual,
  12581. });
  12582. function buildMirrorPlacements(mirrorSegs, colPlacements) {
  12583. if (!mirrorSegs.length) {
  12584. return [];
  12585. }
  12586. var topsByInstanceId = buildAbsoluteTopHash(colPlacements); // TODO: cache this at first render?
  12587. return mirrorSegs.map(function (seg) { return ({
  12588. seg: seg,
  12589. isVisible: true,
  12590. isAbsolute: true,
  12591. absoluteTop: topsByInstanceId[seg.eventRange.instance.instanceId],
  12592. marginTop: 0,
  12593. }); });
  12594. }
  12595. function buildAbsoluteTopHash(colPlacements) {
  12596. var topsByInstanceId = {};
  12597. for (var _i = 0, colPlacements_1 = colPlacements; _i < colPlacements_1.length; _i++) {
  12598. var placements = colPlacements_1[_i];
  12599. for (var _a = 0, placements_1 = placements; _a < placements_1.length; _a++) {
  12600. var placement = placements_1[_a];
  12601. topsByInstanceId[placement.seg.eventRange.instance.instanceId] = placement.absoluteTop;
  12602. }
  12603. }
  12604. return topsByInstanceId;
  12605. }
  12606. var Table = /** @class */ (function (_super) {
  12607. __extends(Table, _super);
  12608. function Table() {
  12609. var _this = _super !== null && _super.apply(this, arguments) || this;
  12610. _this.splitBusinessHourSegs = memoize(splitSegsByRow);
  12611. _this.splitBgEventSegs = memoize(splitSegsByRow);
  12612. _this.splitFgEventSegs = memoize(splitSegsByRow);
  12613. _this.splitDateSelectionSegs = memoize(splitSegsByRow);
  12614. _this.splitEventDrag = memoize(splitInteractionByRow);
  12615. _this.splitEventResize = memoize(splitInteractionByRow);
  12616. _this.rowRefs = new RefMap();
  12617. _this.handleRootEl = function (rootEl) {
  12618. _this.rootEl = rootEl;
  12619. if (rootEl) {
  12620. _this.context.registerInteractiveComponent(_this, {
  12621. el: rootEl,
  12622. isHitComboAllowed: _this.props.isHitComboAllowed,
  12623. });
  12624. }
  12625. else {
  12626. _this.context.unregisterInteractiveComponent(_this);
  12627. }
  12628. };
  12629. return _this;
  12630. }
  12631. Table.prototype.render = function () {
  12632. var _this = this;
  12633. var props = this.props;
  12634. var dateProfile = props.dateProfile, dayMaxEventRows = props.dayMaxEventRows, dayMaxEvents = props.dayMaxEvents, expandRows = props.expandRows;
  12635. var rowCnt = props.cells.length;
  12636. var businessHourSegsByRow = this.splitBusinessHourSegs(props.businessHourSegs, rowCnt);
  12637. var bgEventSegsByRow = this.splitBgEventSegs(props.bgEventSegs, rowCnt);
  12638. var fgEventSegsByRow = this.splitFgEventSegs(props.fgEventSegs, rowCnt);
  12639. var dateSelectionSegsByRow = this.splitDateSelectionSegs(props.dateSelectionSegs, rowCnt);
  12640. var eventDragByRow = this.splitEventDrag(props.eventDrag, rowCnt);
  12641. var eventResizeByRow = this.splitEventResize(props.eventResize, rowCnt);
  12642. var limitViaBalanced = dayMaxEvents === true || dayMaxEventRows === true;
  12643. // if rows can't expand to fill fixed height, can't do balanced-height event limit
  12644. // TODO: best place to normalize these options?
  12645. if (limitViaBalanced && !expandRows) {
  12646. limitViaBalanced = false;
  12647. dayMaxEventRows = null;
  12648. dayMaxEvents = null;
  12649. }
  12650. var classNames = [
  12651. 'fc-daygrid-body',
  12652. limitViaBalanced ? 'fc-daygrid-body-balanced' : 'fc-daygrid-body-unbalanced',
  12653. expandRows ? '' : 'fc-daygrid-body-natural', // will height of one row depend on the others?
  12654. ];
  12655. return (createElement("div", { className: classNames.join(' '), ref: this.handleRootEl, style: {
  12656. // these props are important to give this wrapper correct dimensions for interactions
  12657. // TODO: if we set it here, can we avoid giving to inner tables?
  12658. width: props.clientWidth,
  12659. minWidth: props.tableMinWidth,
  12660. } },
  12661. createElement(NowTimer, { unit: "day" }, function (nowDate, todayRange) { return (createElement(Fragment, null,
  12662. createElement("table", { role: "presentation", className: "fc-scrollgrid-sync-table", style: {
  12663. width: props.clientWidth,
  12664. minWidth: props.tableMinWidth,
  12665. height: expandRows ? props.clientHeight : '',
  12666. } },
  12667. props.colGroupNode,
  12668. createElement("tbody", { role: "presentation" }, props.cells.map(function (cells, row) { return (createElement(TableRow, { ref: _this.rowRefs.createRef(row), key: cells.length
  12669. ? cells[0].date.toISOString() /* best? or put key on cell? or use diff formatter? */
  12670. : row // in case there are no cells (like when resource view is loading)
  12671. , showDayNumbers: rowCnt > 1, showWeekNumbers: props.showWeekNumbers, todayRange: todayRange, dateProfile: dateProfile, cells: cells, renderIntro: props.renderRowIntro, businessHourSegs: businessHourSegsByRow[row], eventSelection: props.eventSelection, bgEventSegs: bgEventSegsByRow[row].filter(isSegAllDay) /* hack */, fgEventSegs: fgEventSegsByRow[row], dateSelectionSegs: dateSelectionSegsByRow[row], eventDrag: eventDragByRow[row], eventResize: eventResizeByRow[row], dayMaxEvents: dayMaxEvents, dayMaxEventRows: dayMaxEventRows, clientWidth: props.clientWidth, clientHeight: props.clientHeight, forPrint: props.forPrint })); }))))); })));
  12672. };
  12673. // Hit System
  12674. // ----------------------------------------------------------------------------------------------------
  12675. Table.prototype.prepareHits = function () {
  12676. 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
  12677. false, true);
  12678. this.colPositions = new PositionCache(this.rootEl, this.rowRefs.currentMap[0].getCellEls(), // cell els in first row
  12679. true, // horizontal
  12680. false);
  12681. };
  12682. Table.prototype.queryHit = function (positionLeft, positionTop) {
  12683. var _a = this, colPositions = _a.colPositions, rowPositions = _a.rowPositions;
  12684. var col = colPositions.leftToIndex(positionLeft);
  12685. var row = rowPositions.topToIndex(positionTop);
  12686. if (row != null && col != null) {
  12687. var cell = this.props.cells[row][col];
  12688. return {
  12689. dateProfile: this.props.dateProfile,
  12690. dateSpan: __assign({ range: this.getCellRange(row, col), allDay: true }, cell.extraDateSpan),
  12691. dayEl: this.getCellEl(row, col),
  12692. rect: {
  12693. left: colPositions.lefts[col],
  12694. right: colPositions.rights[col],
  12695. top: rowPositions.tops[row],
  12696. bottom: rowPositions.bottoms[row],
  12697. },
  12698. layer: 0,
  12699. };
  12700. }
  12701. return null;
  12702. };
  12703. Table.prototype.getCellEl = function (row, col) {
  12704. return this.rowRefs.currentMap[row].getCellEls()[col]; // TODO: not optimal
  12705. };
  12706. Table.prototype.getCellRange = function (row, col) {
  12707. var start = this.props.cells[row][col].date;
  12708. var end = addDays(start, 1);
  12709. return { start: start, end: end };
  12710. };
  12711. return Table;
  12712. }(DateComponent));
  12713. function isSegAllDay(seg) {
  12714. return seg.eventRange.def.allDay;
  12715. }
  12716. var DayTableSlicer = /** @class */ (function (_super) {
  12717. __extends(DayTableSlicer, _super);
  12718. function DayTableSlicer() {
  12719. var _this = _super !== null && _super.apply(this, arguments) || this;
  12720. _this.forceDayIfListItem = true;
  12721. return _this;
  12722. }
  12723. DayTableSlicer.prototype.sliceRange = function (dateRange, dayTableModel) {
  12724. return dayTableModel.sliceRange(dateRange);
  12725. };
  12726. return DayTableSlicer;
  12727. }(Slicer));
  12728. var DayTable = /** @class */ (function (_super) {
  12729. __extends(DayTable, _super);
  12730. function DayTable() {
  12731. var _this = _super !== null && _super.apply(this, arguments) || this;
  12732. _this.slicer = new DayTableSlicer();
  12733. _this.tableRef = createRef();
  12734. return _this;
  12735. }
  12736. DayTable.prototype.render = function () {
  12737. var _a = this, props = _a.props, context = _a.context;
  12738. return (createElement(Table, __assign({ ref: this.tableRef }, this.slicer.sliceProps(props, props.dateProfile, props.nextDayThreshold, context, props.dayTableModel), { dateProfile: props.dateProfile, cells: props.dayTableModel.cells, colGroupNode: props.colGroupNode, tableMinWidth: props.tableMinWidth, renderRowIntro: props.renderRowIntro, dayMaxEvents: props.dayMaxEvents, dayMaxEventRows: props.dayMaxEventRows, showWeekNumbers: props.showWeekNumbers, expandRows: props.expandRows, headerAlignElRef: props.headerAlignElRef, clientWidth: props.clientWidth, clientHeight: props.clientHeight, forPrint: props.forPrint })));
  12739. };
  12740. return DayTable;
  12741. }(DateComponent));
  12742. var DayTableView = /** @class */ (function (_super) {
  12743. __extends(DayTableView, _super);
  12744. function DayTableView() {
  12745. var _this = _super !== null && _super.apply(this, arguments) || this;
  12746. _this.buildDayTableModel = memoize(buildDayTableModel);
  12747. _this.headerRef = createRef();
  12748. _this.tableRef = createRef();
  12749. return _this;
  12750. }
  12751. DayTableView.prototype.render = function () {
  12752. var _this = this;
  12753. var _a = this.context, options = _a.options, dateProfileGenerator = _a.dateProfileGenerator;
  12754. var props = this.props;
  12755. var dayTableModel = this.buildDayTableModel(props.dateProfile, dateProfileGenerator);
  12756. var headerContent = options.dayHeaders && (createElement(DayHeader, { ref: this.headerRef, dateProfile: props.dateProfile, dates: dayTableModel.headerDates, datesRepDistinctDays: dayTableModel.rowCnt === 1 }));
  12757. 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 })); };
  12758. return options.dayMinWidth
  12759. ? this.renderHScrollLayout(headerContent, bodyContent, dayTableModel.colCnt, options.dayMinWidth)
  12760. : this.renderSimpleLayout(headerContent, bodyContent);
  12761. };
  12762. return DayTableView;
  12763. }(TableView));
  12764. function buildDayTableModel(dateProfile, dateProfileGenerator) {
  12765. var daySeries = new DaySeriesModel(dateProfile.renderRange, dateProfileGenerator);
  12766. return new DayTableModel(daySeries, /year|month|week/.test(dateProfile.currentRangeUnit));
  12767. }
  12768. var TableDateProfileGenerator = /** @class */ (function (_super) {
  12769. __extends(TableDateProfileGenerator, _super);
  12770. function TableDateProfileGenerator() {
  12771. return _super !== null && _super.apply(this, arguments) || this;
  12772. }
  12773. // Computes the date range that will be rendered.
  12774. TableDateProfileGenerator.prototype.buildRenderRange = function (currentRange, currentRangeUnit, isRangeAllDay) {
  12775. var dateEnv = this.props.dateEnv;
  12776. var renderRange = _super.prototype.buildRenderRange.call(this, currentRange, currentRangeUnit, isRangeAllDay);
  12777. var start = renderRange.start;
  12778. var end = renderRange.end;
  12779. var endOfWeek;
  12780. // year and month views should be aligned with weeks. this is already done for week
  12781. if (/^(year|month)$/.test(currentRangeUnit)) {
  12782. start = dateEnv.startOfWeek(start);
  12783. // make end-of-week if not already
  12784. endOfWeek = dateEnv.startOfWeek(end);
  12785. if (endOfWeek.valueOf() !== end.valueOf()) {
  12786. end = addWeeks(endOfWeek, 1);
  12787. }
  12788. }
  12789. // ensure 6 weeks
  12790. if (this.props.monthMode &&
  12791. this.props.fixedWeekCount) {
  12792. var rowCnt = Math.ceil(// could be partial weeks due to hiddenDays
  12793. diffWeeks(start, end));
  12794. end = addWeeks(end, 6 - rowCnt);
  12795. }
  12796. return { start: start, end: end };
  12797. };
  12798. return TableDateProfileGenerator;
  12799. }(DateProfileGenerator));
  12800. var dayGridPlugin = createPlugin({
  12801. initialView: 'dayGridMonth',
  12802. views: {
  12803. dayGrid: {
  12804. component: DayTableView,
  12805. dateProfileGeneratorClass: TableDateProfileGenerator,
  12806. },
  12807. dayGridDay: {
  12808. type: 'dayGrid',
  12809. duration: { days: 1 },
  12810. },
  12811. dayGridWeek: {
  12812. type: 'dayGrid',
  12813. duration: { weeks: 1 },
  12814. },
  12815. dayGridMonth: {
  12816. type: 'dayGrid',
  12817. duration: { months: 1 },
  12818. monthMode: true,
  12819. fixedWeekCount: true,
  12820. },
  12821. },
  12822. });
  12823. var AllDaySplitter = /** @class */ (function (_super) {
  12824. __extends(AllDaySplitter, _super);
  12825. function AllDaySplitter() {
  12826. return _super !== null && _super.apply(this, arguments) || this;
  12827. }
  12828. AllDaySplitter.prototype.getKeyInfo = function () {
  12829. return {
  12830. allDay: {},
  12831. timed: {},
  12832. };
  12833. };
  12834. AllDaySplitter.prototype.getKeysForDateSpan = function (dateSpan) {
  12835. if (dateSpan.allDay) {
  12836. return ['allDay'];
  12837. }
  12838. return ['timed'];
  12839. };
  12840. AllDaySplitter.prototype.getKeysForEventDef = function (eventDef) {
  12841. if (!eventDef.allDay) {
  12842. return ['timed'];
  12843. }
  12844. if (hasBgRendering(eventDef)) {
  12845. return ['timed', 'allDay'];
  12846. }
  12847. return ['allDay'];
  12848. };
  12849. return AllDaySplitter;
  12850. }(Splitter));
  12851. var DEFAULT_SLAT_LABEL_FORMAT = createFormatter({
  12852. hour: 'numeric',
  12853. minute: '2-digit',
  12854. omitZeroMinute: true,
  12855. meridiem: 'short',
  12856. });
  12857. function TimeColsAxisCell(props) {
  12858. var classNames = [
  12859. 'fc-timegrid-slot',
  12860. 'fc-timegrid-slot-label',
  12861. props.isLabeled ? 'fc-scrollgrid-shrink' : 'fc-timegrid-slot-minor',
  12862. ];
  12863. return (createElement(ViewContextType.Consumer, null, function (context) {
  12864. if (!props.isLabeled) {
  12865. return (createElement("td", { className: classNames.join(' '), "data-time": props.isoTimeStr }));
  12866. }
  12867. var dateEnv = context.dateEnv, options = context.options, viewApi = context.viewApi;
  12868. var labelFormat = // TODO: fully pre-parse
  12869. options.slotLabelFormat == null ? DEFAULT_SLAT_LABEL_FORMAT :
  12870. Array.isArray(options.slotLabelFormat) ? createFormatter(options.slotLabelFormat[0]) :
  12871. createFormatter(options.slotLabelFormat);
  12872. var hookProps = {
  12873. level: 0,
  12874. time: props.time,
  12875. date: dateEnv.toDate(props.date),
  12876. view: viewApi,
  12877. text: dateEnv.format(props.date, labelFormat),
  12878. };
  12879. return (createElement(RenderHook, { hookProps: hookProps, classNames: options.slotLabelClassNames, content: options.slotLabelContent, defaultContent: renderInnerContent$1, didMount: options.slotLabelDidMount, willUnmount: options.slotLabelWillUnmount }, function (rootElRef, customClassNames, innerElRef, innerContent) { return (createElement("td", { ref: rootElRef, className: classNames.concat(customClassNames).join(' '), "data-time": props.isoTimeStr },
  12880. createElement("div", { className: "fc-timegrid-slot-label-frame fc-scrollgrid-shrink-frame" },
  12881. createElement("div", { className: "fc-timegrid-slot-label-cushion fc-scrollgrid-shrink-cushion", ref: innerElRef }, innerContent)))); }));
  12882. }));
  12883. }
  12884. function renderInnerContent$1(props) {
  12885. return props.text;
  12886. }
  12887. var TimeBodyAxis = /** @class */ (function (_super) {
  12888. __extends(TimeBodyAxis, _super);
  12889. function TimeBodyAxis() {
  12890. return _super !== null && _super.apply(this, arguments) || this;
  12891. }
  12892. TimeBodyAxis.prototype.render = function () {
  12893. return this.props.slatMetas.map(function (slatMeta) { return (createElement("tr", { key: slatMeta.key },
  12894. createElement(TimeColsAxisCell, __assign({}, slatMeta)))); });
  12895. };
  12896. return TimeBodyAxis;
  12897. }(BaseComponent));
  12898. var DEFAULT_WEEK_NUM_FORMAT = createFormatter({ week: 'short' });
  12899. var AUTO_ALL_DAY_MAX_EVENT_ROWS = 5;
  12900. var TimeColsView = /** @class */ (function (_super) {
  12901. __extends(TimeColsView, _super);
  12902. function TimeColsView() {
  12903. var _this = _super !== null && _super.apply(this, arguments) || this;
  12904. _this.allDaySplitter = new AllDaySplitter(); // for use by subclasses
  12905. _this.headerElRef = createRef();
  12906. _this.rootElRef = createRef();
  12907. _this.scrollerElRef = createRef();
  12908. _this.state = {
  12909. slatCoords: null,
  12910. };
  12911. _this.handleScrollTopRequest = function (scrollTop) {
  12912. var scrollerEl = _this.scrollerElRef.current;
  12913. if (scrollerEl) { // TODO: not sure how this could ever be null. weirdness with the reducer
  12914. scrollerEl.scrollTop = scrollTop;
  12915. }
  12916. };
  12917. /* Header Render Methods
  12918. ------------------------------------------------------------------------------------------------------------------*/
  12919. _this.renderHeadAxis = function (rowKey, frameHeight) {
  12920. if (frameHeight === void 0) { frameHeight = ''; }
  12921. var options = _this.context.options;
  12922. var dateProfile = _this.props.dateProfile;
  12923. var range = dateProfile.renderRange;
  12924. var dayCnt = diffDays(range.start, range.end);
  12925. var navLinkAttrs = (dayCnt === 1) // only do in day views (to avoid doing in week views that dont need it)
  12926. ? buildNavLinkAttrs(_this.context, range.start, 'week')
  12927. : {};
  12928. if (options.weekNumbers && rowKey === 'day') {
  12929. return (createElement(WeekNumberRoot, { date: range.start, defaultFormat: DEFAULT_WEEK_NUM_FORMAT }, function (rootElRef, classNames, innerElRef, innerContent) { return (createElement("th", { ref: rootElRef, "aria-hidden": true, className: [
  12930. 'fc-timegrid-axis',
  12931. 'fc-scrollgrid-shrink',
  12932. ].concat(classNames).join(' ') },
  12933. createElement("div", { className: "fc-timegrid-axis-frame fc-scrollgrid-shrink-frame fc-timegrid-axis-frame-liquid", style: { height: frameHeight } },
  12934. createElement("a", __assign({ ref: innerElRef, className: "fc-timegrid-axis-cushion fc-scrollgrid-shrink-cushion fc-scrollgrid-sync-inner" }, navLinkAttrs), innerContent)))); }));
  12935. }
  12936. return (createElement("th", { "aria-hidden": true, className: "fc-timegrid-axis" },
  12937. createElement("div", { className: "fc-timegrid-axis-frame", style: { height: frameHeight } })));
  12938. };
  12939. /* Table Component Render Methods
  12940. ------------------------------------------------------------------------------------------------------------------*/
  12941. // only a one-way height sync. we don't send the axis inner-content height to the DayGrid,
  12942. // but DayGrid still needs to have classNames on inner elements in order to measure.
  12943. _this.renderTableRowAxis = function (rowHeight) {
  12944. var _a = _this.context, options = _a.options, viewApi = _a.viewApi;
  12945. var hookProps = {
  12946. text: options.allDayText,
  12947. view: viewApi,
  12948. };
  12949. return (
  12950. // TODO: make reusable hook. used in list view too
  12951. createElement(RenderHook, { hookProps: hookProps, classNames: options.allDayClassNames, content: options.allDayContent, defaultContent: renderAllDayInner$1, didMount: options.allDayDidMount, willUnmount: options.allDayWillUnmount }, function (rootElRef, classNames, innerElRef, innerContent) { return (createElement("td", { ref: rootElRef, "aria-hidden": true, className: [
  12952. 'fc-timegrid-axis',
  12953. 'fc-scrollgrid-shrink',
  12954. ].concat(classNames).join(' ') },
  12955. createElement("div", { className: 'fc-timegrid-axis-frame fc-scrollgrid-shrink-frame' + (rowHeight == null ? ' fc-timegrid-axis-frame-liquid' : ''), style: { height: rowHeight } },
  12956. createElement("span", { className: "fc-timegrid-axis-cushion fc-scrollgrid-shrink-cushion fc-scrollgrid-sync-inner", ref: innerElRef }, innerContent)))); }));
  12957. };
  12958. _this.handleSlatCoords = function (slatCoords) {
  12959. _this.setState({ slatCoords: slatCoords });
  12960. };
  12961. return _this;
  12962. }
  12963. // rendering
  12964. // ----------------------------------------------------------------------------------------------------
  12965. TimeColsView.prototype.renderSimpleLayout = function (headerRowContent, allDayContent, timeContent) {
  12966. var _a = this, context = _a.context, props = _a.props;
  12967. var sections = [];
  12968. var stickyHeaderDates = getStickyHeaderDates(context.options);
  12969. if (headerRowContent) {
  12970. sections.push({
  12971. type: 'header',
  12972. key: 'header',
  12973. isSticky: stickyHeaderDates,
  12974. chunk: {
  12975. elRef: this.headerElRef,
  12976. tableClassName: 'fc-col-header',
  12977. rowContent: headerRowContent,
  12978. },
  12979. });
  12980. }
  12981. if (allDayContent) {
  12982. sections.push({
  12983. type: 'body',
  12984. key: 'all-day',
  12985. chunk: { content: allDayContent },
  12986. });
  12987. sections.push({
  12988. type: 'body',
  12989. key: 'all-day-divider',
  12990. outerContent: ( // TODO: rename to cellContent so don't need to define <tr>?
  12991. createElement("tr", { role: "presentation", className: "fc-scrollgrid-section" },
  12992. createElement("td", { className: 'fc-timegrid-divider ' + context.theme.getClass('tableCellShaded') }))),
  12993. });
  12994. }
  12995. sections.push({
  12996. type: 'body',
  12997. key: 'body',
  12998. liquid: true,
  12999. expandRows: Boolean(context.options.expandRows),
  13000. chunk: {
  13001. scrollerElRef: this.scrollerElRef,
  13002. content: timeContent,
  13003. },
  13004. });
  13005. return (createElement(ViewRoot, { viewSpec: context.viewSpec, elRef: this.rootElRef }, function (rootElRef, classNames) { return (createElement("div", { className: ['fc-timegrid'].concat(classNames).join(' '), ref: rootElRef },
  13006. createElement(SimpleScrollGrid, { liquid: !props.isHeightAuto && !props.forPrint, collapsibleWidth: props.forPrint, cols: [{ width: 'shrink' }], sections: sections }))); }));
  13007. };
  13008. TimeColsView.prototype.renderHScrollLayout = function (headerRowContent, allDayContent, timeContent, colCnt, dayMinWidth, slatMetas, slatCoords) {
  13009. var _this = this;
  13010. var ScrollGrid = this.context.pluginHooks.scrollGridImpl;
  13011. if (!ScrollGrid) {
  13012. throw new Error('No ScrollGrid implementation');
  13013. }
  13014. var _a = this, context = _a.context, props = _a.props;
  13015. var stickyHeaderDates = !props.forPrint && getStickyHeaderDates(context.options);
  13016. var stickyFooterScrollbar = !props.forPrint && getStickyFooterScrollbar(context.options);
  13017. var sections = [];
  13018. if (headerRowContent) {
  13019. sections.push({
  13020. type: 'header',
  13021. key: 'header',
  13022. isSticky: stickyHeaderDates,
  13023. syncRowHeights: true,
  13024. chunks: [
  13025. {
  13026. key: 'axis',
  13027. rowContent: function (arg) { return (createElement("tr", { role: "presentation" }, _this.renderHeadAxis('day', arg.rowSyncHeights[0]))); },
  13028. },
  13029. {
  13030. key: 'cols',
  13031. elRef: this.headerElRef,
  13032. tableClassName: 'fc-col-header',
  13033. rowContent: headerRowContent,
  13034. },
  13035. ],
  13036. });
  13037. }
  13038. if (allDayContent) {
  13039. sections.push({
  13040. type: 'body',
  13041. key: 'all-day',
  13042. syncRowHeights: true,
  13043. chunks: [
  13044. {
  13045. key: 'axis',
  13046. rowContent: function (contentArg) { return (createElement("tr", { role: "presentation" }, _this.renderTableRowAxis(contentArg.rowSyncHeights[0]))); },
  13047. },
  13048. {
  13049. key: 'cols',
  13050. content: allDayContent,
  13051. },
  13052. ],
  13053. });
  13054. sections.push({
  13055. key: 'all-day-divider',
  13056. type: 'body',
  13057. outerContent: ( // TODO: rename to cellContent so don't need to define <tr>?
  13058. createElement("tr", { role: "presentation", className: "fc-scrollgrid-section" },
  13059. createElement("td", { colSpan: 2, className: 'fc-timegrid-divider ' + context.theme.getClass('tableCellShaded') }))),
  13060. });
  13061. }
  13062. var isNowIndicator = context.options.nowIndicator;
  13063. sections.push({
  13064. type: 'body',
  13065. key: 'body',
  13066. liquid: true,
  13067. expandRows: Boolean(context.options.expandRows),
  13068. chunks: [
  13069. {
  13070. key: 'axis',
  13071. content: function (arg) { return (
  13072. // TODO: make this now-indicator arrow more DRY with TimeColsContent
  13073. createElement("div", { className: "fc-timegrid-axis-chunk" },
  13074. createElement("table", { "aria-hidden": true, style: { height: arg.expandRows ? arg.clientHeight : '' } },
  13075. arg.tableColGroupNode,
  13076. createElement("tbody", null,
  13077. createElement(TimeBodyAxis, { slatMetas: slatMetas }))),
  13078. createElement("div", { className: "fc-timegrid-now-indicator-container" },
  13079. createElement(NowTimer, { unit: isNowIndicator ? 'minute' : 'day' /* hacky */ }, function (nowDate) {
  13080. var nowIndicatorTop = isNowIndicator &&
  13081. slatCoords &&
  13082. slatCoords.safeComputeTop(nowDate); // might return void
  13083. if (typeof nowIndicatorTop === 'number') {
  13084. 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)); }));
  13085. }
  13086. return null;
  13087. })))); },
  13088. },
  13089. {
  13090. key: 'cols',
  13091. scrollerElRef: this.scrollerElRef,
  13092. content: timeContent,
  13093. },
  13094. ],
  13095. });
  13096. if (stickyFooterScrollbar) {
  13097. sections.push({
  13098. key: 'footer',
  13099. type: 'footer',
  13100. isSticky: true,
  13101. chunks: [
  13102. {
  13103. key: 'axis',
  13104. content: renderScrollShim,
  13105. },
  13106. {
  13107. key: 'cols',
  13108. content: renderScrollShim,
  13109. },
  13110. ],
  13111. });
  13112. }
  13113. return (createElement(ViewRoot, { viewSpec: context.viewSpec, elRef: this.rootElRef }, function (rootElRef, classNames) { return (createElement("div", { className: ['fc-timegrid'].concat(classNames).join(' '), ref: rootElRef },
  13114. createElement(ScrollGrid, { liquid: !props.isHeightAuto && !props.forPrint, collapsibleWidth: false, colGroups: [
  13115. { width: 'shrink', cols: [{ width: 'shrink' }] },
  13116. { cols: [{ span: colCnt, minWidth: dayMinWidth }] },
  13117. ], sections: sections }))); }));
  13118. };
  13119. /* Dimensions
  13120. ------------------------------------------------------------------------------------------------------------------*/
  13121. TimeColsView.prototype.getAllDayMaxEventProps = function () {
  13122. var _a = this.context.options, dayMaxEvents = _a.dayMaxEvents, dayMaxEventRows = _a.dayMaxEventRows;
  13123. if (dayMaxEvents === true || dayMaxEventRows === true) { // is auto?
  13124. dayMaxEvents = undefined;
  13125. dayMaxEventRows = AUTO_ALL_DAY_MAX_EVENT_ROWS; // make sure "auto" goes to a real number
  13126. }
  13127. return { dayMaxEvents: dayMaxEvents, dayMaxEventRows: dayMaxEventRows };
  13128. };
  13129. return TimeColsView;
  13130. }(DateComponent));
  13131. function renderAllDayInner$1(hookProps) {
  13132. return hookProps.text;
  13133. }
  13134. var TimeColsSlatsCoords = /** @class */ (function () {
  13135. function TimeColsSlatsCoords(positions, dateProfile, slotDuration) {
  13136. this.positions = positions;
  13137. this.dateProfile = dateProfile;
  13138. this.slotDuration = slotDuration;
  13139. }
  13140. TimeColsSlatsCoords.prototype.safeComputeTop = function (date) {
  13141. var dateProfile = this.dateProfile;
  13142. if (rangeContainsMarker(dateProfile.currentRange, date)) {
  13143. var startOfDayDate = startOfDay(date);
  13144. var timeMs = date.valueOf() - startOfDayDate.valueOf();
  13145. if (timeMs >= asRoughMs(dateProfile.slotMinTime) &&
  13146. timeMs < asRoughMs(dateProfile.slotMaxTime)) {
  13147. return this.computeTimeTop(createDuration(timeMs));
  13148. }
  13149. }
  13150. return null;
  13151. };
  13152. // Computes the top coordinate, relative to the bounds of the grid, of the given date.
  13153. // A `startOfDayDate` must be given for avoiding ambiguity over how to treat midnight.
  13154. TimeColsSlatsCoords.prototype.computeDateTop = function (when, startOfDayDate) {
  13155. if (!startOfDayDate) {
  13156. startOfDayDate = startOfDay(when);
  13157. }
  13158. return this.computeTimeTop(createDuration(when.valueOf() - startOfDayDate.valueOf()));
  13159. };
  13160. // Computes the top coordinate, relative to the bounds of the grid, of the given time (a Duration).
  13161. // This is a makeshify way to compute the time-top. Assumes all slatMetas dates are uniform.
  13162. // Eventually allow computation with arbirary slat dates.
  13163. TimeColsSlatsCoords.prototype.computeTimeTop = function (duration) {
  13164. var _a = this, positions = _a.positions, dateProfile = _a.dateProfile;
  13165. var len = positions.els.length;
  13166. // floating-point value of # of slots covered
  13167. var slatCoverage = (duration.milliseconds - asRoughMs(dateProfile.slotMinTime)) / asRoughMs(this.slotDuration);
  13168. var slatIndex;
  13169. var slatRemainder;
  13170. // compute a floating-point number for how many slats should be progressed through.
  13171. // from 0 to number of slats (inclusive)
  13172. // constrained because slotMinTime/slotMaxTime might be customized.
  13173. slatCoverage = Math.max(0, slatCoverage);
  13174. slatCoverage = Math.min(len, slatCoverage);
  13175. // an integer index of the furthest whole slat
  13176. // from 0 to number slats (*exclusive*, so len-1)
  13177. slatIndex = Math.floor(slatCoverage);
  13178. slatIndex = Math.min(slatIndex, len - 1);
  13179. // how much further through the slatIndex slat (from 0.0-1.0) must be covered in addition.
  13180. // could be 1.0 if slatCoverage is covering *all* the slots
  13181. slatRemainder = slatCoverage - slatIndex;
  13182. return positions.tops[slatIndex] +
  13183. positions.getHeight(slatIndex) * slatRemainder;
  13184. };
  13185. return TimeColsSlatsCoords;
  13186. }());
  13187. var TimeColsSlatsBody = /** @class */ (function (_super) {
  13188. __extends(TimeColsSlatsBody, _super);
  13189. function TimeColsSlatsBody() {
  13190. return _super !== null && _super.apply(this, arguments) || this;
  13191. }
  13192. TimeColsSlatsBody.prototype.render = function () {
  13193. var _a = this, props = _a.props, context = _a.context;
  13194. var options = context.options;
  13195. var slatElRefs = props.slatElRefs;
  13196. return (createElement("tbody", null, props.slatMetas.map(function (slatMeta, i) {
  13197. var hookProps = {
  13198. time: slatMeta.time,
  13199. date: context.dateEnv.toDate(slatMeta.date),
  13200. view: context.viewApi,
  13201. };
  13202. var classNames = [
  13203. 'fc-timegrid-slot',
  13204. 'fc-timegrid-slot-lane',
  13205. slatMeta.isLabeled ? '' : 'fc-timegrid-slot-minor',
  13206. ];
  13207. return (createElement("tr", { key: slatMeta.key, ref: slatElRefs.createRef(slatMeta.key) },
  13208. props.axis && (createElement(TimeColsAxisCell, __assign({}, slatMeta))),
  13209. 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)); })));
  13210. })));
  13211. };
  13212. return TimeColsSlatsBody;
  13213. }(BaseComponent));
  13214. /*
  13215. for the horizontal "slats" that run width-wise. Has a time axis on a side. Depends on RTL.
  13216. */
  13217. var TimeColsSlats = /** @class */ (function (_super) {
  13218. __extends(TimeColsSlats, _super);
  13219. function TimeColsSlats() {
  13220. var _this = _super !== null && _super.apply(this, arguments) || this;
  13221. _this.rootElRef = createRef();
  13222. _this.slatElRefs = new RefMap();
  13223. return _this;
  13224. }
  13225. TimeColsSlats.prototype.render = function () {
  13226. var _a = this, props = _a.props, context = _a.context;
  13227. return (createElement("div", { ref: this.rootElRef, className: "fc-timegrid-slots" },
  13228. createElement("table", { "aria-hidden": true, className: context.theme.getClass('table'), style: {
  13229. minWidth: props.tableMinWidth,
  13230. width: props.clientWidth,
  13231. height: props.minHeight,
  13232. } },
  13233. props.tableColGroupNode /* relies on there only being a single <col> for the axis */,
  13234. createElement(TimeColsSlatsBody, { slatElRefs: this.slatElRefs, axis: props.axis, slatMetas: props.slatMetas }))));
  13235. };
  13236. TimeColsSlats.prototype.componentDidMount = function () {
  13237. this.updateSizing();
  13238. };
  13239. TimeColsSlats.prototype.componentDidUpdate = function () {
  13240. this.updateSizing();
  13241. };
  13242. TimeColsSlats.prototype.componentWillUnmount = function () {
  13243. if (this.props.onCoords) {
  13244. this.props.onCoords(null);
  13245. }
  13246. };
  13247. TimeColsSlats.prototype.updateSizing = function () {
  13248. var _a = this, context = _a.context, props = _a.props;
  13249. if (props.onCoords &&
  13250. props.clientWidth !== null // means sizing has stabilized
  13251. ) {
  13252. var rootEl = this.rootElRef.current;
  13253. if (rootEl.offsetHeight) { // not hidden by css
  13254. props.onCoords(new TimeColsSlatsCoords(new PositionCache(this.rootElRef.current, collectSlatEls(this.slatElRefs.currentMap, props.slatMetas), false, true), this.props.dateProfile, context.options.slotDuration));
  13255. }
  13256. }
  13257. };
  13258. return TimeColsSlats;
  13259. }(BaseComponent));
  13260. function collectSlatEls(elMap, slatMetas) {
  13261. return slatMetas.map(function (slatMeta) { return elMap[slatMeta.key]; });
  13262. }
  13263. function splitSegsByCol(segs, colCnt) {
  13264. var segsByCol = [];
  13265. var i;
  13266. for (i = 0; i < colCnt; i += 1) {
  13267. segsByCol.push([]);
  13268. }
  13269. if (segs) {
  13270. for (i = 0; i < segs.length; i += 1) {
  13271. segsByCol[segs[i].col].push(segs[i]);
  13272. }
  13273. }
  13274. return segsByCol;
  13275. }
  13276. function splitInteractionByCol(ui, colCnt) {
  13277. var byRow = [];
  13278. if (!ui) {
  13279. for (var i = 0; i < colCnt; i += 1) {
  13280. byRow[i] = null;
  13281. }
  13282. }
  13283. else {
  13284. for (var i = 0; i < colCnt; i += 1) {
  13285. byRow[i] = {
  13286. affectedInstances: ui.affectedInstances,
  13287. isEvent: ui.isEvent,
  13288. segs: [],
  13289. };
  13290. }
  13291. for (var _i = 0, _a = ui.segs; _i < _a.length; _i++) {
  13292. var seg = _a[_i];
  13293. byRow[seg.col].segs.push(seg);
  13294. }
  13295. }
  13296. return byRow;
  13297. }
  13298. var TimeColMoreLink = /** @class */ (function (_super) {
  13299. __extends(TimeColMoreLink, _super);
  13300. function TimeColMoreLink() {
  13301. var _this = _super !== null && _super.apply(this, arguments) || this;
  13302. _this.rootElRef = createRef();
  13303. return _this;
  13304. }
  13305. TimeColMoreLink.prototype.render = function () {
  13306. var _this = this;
  13307. var props = this.props;
  13308. return (createElement(MoreLinkRoot, { allDayDate: null, moreCnt: props.hiddenSegs.length, allSegs: props.hiddenSegs, hiddenSegs: props.hiddenSegs, alignmentElRef: this.rootElRef, defaultContent: renderMoreLinkInner, extraDateSpan: props.extraDateSpan, dateProfile: props.dateProfile, todayRange: props.todayRange, popoverContent: function () { return renderPlainFgSegs(props.hiddenSegs, props); } }, function (rootElRef, classNames, innerElRef, innerContent, handleClick, title, isExpanded, popoverId) { return (createElement("a", { ref: function (el) {
  13309. setRef(rootElRef, el);
  13310. setRef(_this.rootElRef, el);
  13311. }, className: ['fc-timegrid-more-link'].concat(classNames).join(' '), style: { top: props.top, bottom: props.bottom }, onClick: handleClick, title: title, "aria-expanded": isExpanded, "aria-controls": popoverId },
  13312. createElement("div", { ref: innerElRef, className: "fc-timegrid-more-link-inner fc-sticky" }, innerContent))); }));
  13313. };
  13314. return TimeColMoreLink;
  13315. }(BaseComponent));
  13316. function renderMoreLinkInner(props) {
  13317. return props.shortText;
  13318. }
  13319. // segInputs assumed sorted
  13320. function buildPositioning(segInputs, strictOrder, maxStackCnt) {
  13321. var hierarchy = new SegHierarchy();
  13322. if (strictOrder != null) {
  13323. hierarchy.strictOrder = strictOrder;
  13324. }
  13325. if (maxStackCnt != null) {
  13326. hierarchy.maxStackCnt = maxStackCnt;
  13327. }
  13328. var hiddenEntries = hierarchy.addSegs(segInputs);
  13329. var hiddenGroups = groupIntersectingEntries(hiddenEntries);
  13330. var web = buildWeb(hierarchy);
  13331. web = stretchWeb(web, 1); // all levelCoords/thickness will have 0.0-1.0
  13332. var segRects = webToRects(web);
  13333. return { segRects: segRects, hiddenGroups: hiddenGroups };
  13334. }
  13335. function buildWeb(hierarchy) {
  13336. var entriesByLevel = hierarchy.entriesByLevel;
  13337. var buildNode = cacheable(function (level, lateral) { return level + ':' + lateral; }, function (level, lateral) {
  13338. var siblingRange = findNextLevelSegs(hierarchy, level, lateral);
  13339. var nextLevelRes = buildNodes(siblingRange, buildNode);
  13340. var entry = entriesByLevel[level][lateral];
  13341. return [
  13342. __assign(__assign({}, entry), { nextLevelNodes: nextLevelRes[0] }),
  13343. entry.thickness + nextLevelRes[1], // the pressure builds
  13344. ];
  13345. });
  13346. return buildNodes(entriesByLevel.length
  13347. ? { level: 0, lateralStart: 0, lateralEnd: entriesByLevel[0].length }
  13348. : null, buildNode)[0];
  13349. }
  13350. function buildNodes(siblingRange, buildNode) {
  13351. if (!siblingRange) {
  13352. return [[], 0];
  13353. }
  13354. var level = siblingRange.level, lateralStart = siblingRange.lateralStart, lateralEnd = siblingRange.lateralEnd;
  13355. var lateral = lateralStart;
  13356. var pairs = [];
  13357. while (lateral < lateralEnd) {
  13358. pairs.push(buildNode(level, lateral));
  13359. lateral += 1;
  13360. }
  13361. pairs.sort(cmpDescPressures);
  13362. return [
  13363. pairs.map(extractNode),
  13364. pairs[0][1], // first item's pressure
  13365. ];
  13366. }
  13367. function cmpDescPressures(a, b) {
  13368. return b[1] - a[1];
  13369. }
  13370. function extractNode(a) {
  13371. return a[0];
  13372. }
  13373. function findNextLevelSegs(hierarchy, subjectLevel, subjectLateral) {
  13374. var levelCoords = hierarchy.levelCoords, entriesByLevel = hierarchy.entriesByLevel;
  13375. var subjectEntry = entriesByLevel[subjectLevel][subjectLateral];
  13376. var afterSubject = levelCoords[subjectLevel] + subjectEntry.thickness;
  13377. var levelCnt = levelCoords.length;
  13378. var level = subjectLevel;
  13379. // skip past levels that are too high up
  13380. for (; level < levelCnt && levelCoords[level] < afterSubject; level += 1)
  13381. ; // do nothing
  13382. for (; level < levelCnt; level += 1) {
  13383. var entries = entriesByLevel[level];
  13384. var entry = void 0;
  13385. var searchIndex = binarySearch(entries, subjectEntry.span.start, getEntrySpanEnd);
  13386. var lateralStart = searchIndex[0] + searchIndex[1]; // if exact match (which doesn't collide), go to next one
  13387. var lateralEnd = lateralStart;
  13388. while ( // loop through entries that horizontally intersect
  13389. (entry = entries[lateralEnd]) && // but not past the whole seg list
  13390. entry.span.start < subjectEntry.span.end) {
  13391. lateralEnd += 1;
  13392. }
  13393. if (lateralStart < lateralEnd) {
  13394. return { level: level, lateralStart: lateralStart, lateralEnd: lateralEnd };
  13395. }
  13396. }
  13397. return null;
  13398. }
  13399. function stretchWeb(topLevelNodes, totalThickness) {
  13400. var stretchNode = cacheable(function (node, startCoord, prevThickness) { return buildEntryKey(node); }, function (node, startCoord, prevThickness) {
  13401. var nextLevelNodes = node.nextLevelNodes, thickness = node.thickness;
  13402. var allThickness = thickness + prevThickness;
  13403. var thicknessFraction = thickness / allThickness;
  13404. var endCoord;
  13405. var newChildren = [];
  13406. if (!nextLevelNodes.length) {
  13407. endCoord = totalThickness;
  13408. }
  13409. else {
  13410. for (var _i = 0, nextLevelNodes_1 = nextLevelNodes; _i < nextLevelNodes_1.length; _i++) {
  13411. var childNode = nextLevelNodes_1[_i];
  13412. if (endCoord === undefined) {
  13413. var res = stretchNode(childNode, startCoord, allThickness);
  13414. endCoord = res[0];
  13415. newChildren.push(res[1]);
  13416. }
  13417. else {
  13418. var res = stretchNode(childNode, endCoord, 0);
  13419. newChildren.push(res[1]);
  13420. }
  13421. }
  13422. }
  13423. var newThickness = (endCoord - startCoord) * thicknessFraction;
  13424. return [endCoord - newThickness, __assign(__assign({}, node), { thickness: newThickness, nextLevelNodes: newChildren })];
  13425. });
  13426. return topLevelNodes.map(function (node) { return stretchNode(node, 0, 0)[1]; });
  13427. }
  13428. // not sorted in any particular order
  13429. function webToRects(topLevelNodes) {
  13430. var rects = [];
  13431. var processNode = cacheable(function (node, levelCoord, stackDepth) { return buildEntryKey(node); }, function (node, levelCoord, stackDepth) {
  13432. var rect = __assign(__assign({}, node), { levelCoord: levelCoord,
  13433. stackDepth: stackDepth, stackForward: 0 });
  13434. rects.push(rect);
  13435. return (rect.stackForward = processNodes(node.nextLevelNodes, levelCoord + node.thickness, stackDepth + 1) + 1);
  13436. });
  13437. function processNodes(nodes, levelCoord, stackDepth) {
  13438. var stackForward = 0;
  13439. for (var _i = 0, nodes_1 = nodes; _i < nodes_1.length; _i++) {
  13440. var node = nodes_1[_i];
  13441. stackForward = Math.max(processNode(node, levelCoord, stackDepth), stackForward);
  13442. }
  13443. return stackForward;
  13444. }
  13445. processNodes(topLevelNodes, 0, 0);
  13446. return rects; // TODO: sort rects by levelCoord to be consistent with toRects?
  13447. }
  13448. // TODO: move to general util
  13449. function cacheable(keyFunc, workFunc) {
  13450. var cache = {};
  13451. return function () {
  13452. var args = [];
  13453. for (var _i = 0; _i < arguments.length; _i++) {
  13454. args[_i] = arguments[_i];
  13455. }
  13456. var key = keyFunc.apply(void 0, args);
  13457. return (key in cache)
  13458. ? cache[key]
  13459. : (cache[key] = workFunc.apply(void 0, args));
  13460. };
  13461. }
  13462. function computeSegVCoords(segs, colDate, slatCoords, eventMinHeight) {
  13463. if (slatCoords === void 0) { slatCoords = null; }
  13464. if (eventMinHeight === void 0) { eventMinHeight = 0; }
  13465. var vcoords = [];
  13466. if (slatCoords) {
  13467. for (var i = 0; i < segs.length; i += 1) {
  13468. var seg = segs[i];
  13469. var spanStart = slatCoords.computeDateTop(seg.start, colDate);
  13470. var spanEnd = Math.max(spanStart + (eventMinHeight || 0), // :(
  13471. slatCoords.computeDateTop(seg.end, colDate));
  13472. vcoords.push({
  13473. start: Math.round(spanStart),
  13474. end: Math.round(spanEnd), //
  13475. });
  13476. }
  13477. }
  13478. return vcoords;
  13479. }
  13480. function computeFgSegPlacements(segs, segVCoords, // might not have for every seg
  13481. eventOrderStrict, eventMaxStack) {
  13482. var segInputs = [];
  13483. var dumbSegs = []; // segs without coords
  13484. for (var i = 0; i < segs.length; i += 1) {
  13485. var vcoords = segVCoords[i];
  13486. if (vcoords) {
  13487. segInputs.push({
  13488. index: i,
  13489. thickness: 1,
  13490. span: vcoords,
  13491. });
  13492. }
  13493. else {
  13494. dumbSegs.push(segs[i]);
  13495. }
  13496. }
  13497. var _a = buildPositioning(segInputs, eventOrderStrict, eventMaxStack), segRects = _a.segRects, hiddenGroups = _a.hiddenGroups;
  13498. var segPlacements = [];
  13499. for (var _i = 0, segRects_1 = segRects; _i < segRects_1.length; _i++) {
  13500. var segRect = segRects_1[_i];
  13501. segPlacements.push({
  13502. seg: segs[segRect.index],
  13503. rect: segRect,
  13504. });
  13505. }
  13506. for (var _b = 0, dumbSegs_1 = dumbSegs; _b < dumbSegs_1.length; _b++) {
  13507. var dumbSeg = dumbSegs_1[_b];
  13508. segPlacements.push({ seg: dumbSeg, rect: null });
  13509. }
  13510. return { segPlacements: segPlacements, hiddenGroups: hiddenGroups };
  13511. }
  13512. var DEFAULT_TIME_FORMAT$1 = createFormatter({
  13513. hour: 'numeric',
  13514. minute: '2-digit',
  13515. meridiem: false,
  13516. });
  13517. var TimeColEvent = /** @class */ (function (_super) {
  13518. __extends(TimeColEvent, _super);
  13519. function TimeColEvent() {
  13520. return _super !== null && _super.apply(this, arguments) || this;
  13521. }
  13522. TimeColEvent.prototype.render = function () {
  13523. var classNames = [
  13524. 'fc-timegrid-event',
  13525. 'fc-v-event',
  13526. ];
  13527. if (this.props.isShort) {
  13528. classNames.push('fc-timegrid-event-short');
  13529. }
  13530. return (createElement(StandardEvent, __assign({}, this.props, { defaultTimeFormat: DEFAULT_TIME_FORMAT$1, extraClassNames: classNames })));
  13531. };
  13532. return TimeColEvent;
  13533. }(BaseComponent));
  13534. var TimeColMisc = /** @class */ (function (_super) {
  13535. __extends(TimeColMisc, _super);
  13536. function TimeColMisc() {
  13537. return _super !== null && _super.apply(this, arguments) || this;
  13538. }
  13539. TimeColMisc.prototype.render = function () {
  13540. var props = this.props;
  13541. return (createElement(DayCellContent, { date: props.date, dateProfile: props.dateProfile, todayRange: props.todayRange, extraHookProps: props.extraHookProps }, function (innerElRef, innerContent) { return (innerContent &&
  13542. createElement("div", { className: "fc-timegrid-col-misc", ref: innerElRef }, innerContent)); }));
  13543. };
  13544. return TimeColMisc;
  13545. }(BaseComponent));
  13546. var TimeCol = /** @class */ (function (_super) {
  13547. __extends(TimeCol, _super);
  13548. function TimeCol() {
  13549. var _this = _super !== null && _super.apply(this, arguments) || this;
  13550. _this.sortEventSegs = memoize(sortEventSegs);
  13551. return _this;
  13552. }
  13553. // TODO: memoize event-placement?
  13554. TimeCol.prototype.render = function () {
  13555. var _this = this;
  13556. var _a = this, props = _a.props, context = _a.context;
  13557. var isSelectMirror = context.options.selectMirror;
  13558. var mirrorSegs = (props.eventDrag && props.eventDrag.segs) ||
  13559. (props.eventResize && props.eventResize.segs) ||
  13560. (isSelectMirror && props.dateSelectionSegs) ||
  13561. [];
  13562. var interactionAffectedInstances = // TODO: messy way to compute this
  13563. (props.eventDrag && props.eventDrag.affectedInstances) ||
  13564. (props.eventResize && props.eventResize.affectedInstances) ||
  13565. {};
  13566. var sortedFgSegs = this.sortEventSegs(props.fgEventSegs, context.options.eventOrder);
  13567. return (createElement(DayCellRoot, { elRef: props.elRef, date: props.date, dateProfile: props.dateProfile, todayRange: props.todayRange, extraHookProps: props.extraHookProps }, function (rootElRef, classNames, dataAttrs) { return (createElement("td", __assign({ ref: rootElRef, role: "gridcell", className: ['fc-timegrid-col'].concat(classNames, props.extraClassNames || []).join(' ') }, dataAttrs, props.extraDataAttrs),
  13568. createElement("div", { className: "fc-timegrid-col-frame" },
  13569. createElement("div", { className: "fc-timegrid-col-bg" },
  13570. _this.renderFillSegs(props.businessHourSegs, 'non-business'),
  13571. _this.renderFillSegs(props.bgEventSegs, 'bg-event'),
  13572. _this.renderFillSegs(props.dateSelectionSegs, 'highlight')),
  13573. createElement("div", { className: "fc-timegrid-col-events" }, _this.renderFgSegs(sortedFgSegs, interactionAffectedInstances, false, false, false)),
  13574. createElement("div", { className: "fc-timegrid-col-events" }, _this.renderFgSegs(mirrorSegs, {}, Boolean(props.eventDrag), Boolean(props.eventResize), Boolean(isSelectMirror))),
  13575. createElement("div", { className: "fc-timegrid-now-indicator-container" }, _this.renderNowIndicator(props.nowIndicatorSegs)),
  13576. createElement(TimeColMisc, { date: props.date, dateProfile: props.dateProfile, todayRange: props.todayRange, extraHookProps: props.extraHookProps })))); }));
  13577. };
  13578. TimeCol.prototype.renderFgSegs = function (sortedFgSegs, segIsInvisible, isDragging, isResizing, isDateSelecting) {
  13579. var props = this.props;
  13580. if (props.forPrint) {
  13581. return renderPlainFgSegs(sortedFgSegs, props);
  13582. }
  13583. return this.renderPositionedFgSegs(sortedFgSegs, segIsInvisible, isDragging, isResizing, isDateSelecting);
  13584. };
  13585. TimeCol.prototype.renderPositionedFgSegs = function (segs, // if not mirror, needs to be sorted
  13586. segIsInvisible, isDragging, isResizing, isDateSelecting) {
  13587. var _this = this;
  13588. var _a = this.context.options, eventMaxStack = _a.eventMaxStack, eventShortHeight = _a.eventShortHeight, eventOrderStrict = _a.eventOrderStrict, eventMinHeight = _a.eventMinHeight;
  13589. var _b = this.props, date = _b.date, slatCoords = _b.slatCoords, eventSelection = _b.eventSelection, todayRange = _b.todayRange, nowDate = _b.nowDate;
  13590. var isMirror = isDragging || isResizing || isDateSelecting;
  13591. var segVCoords = computeSegVCoords(segs, date, slatCoords, eventMinHeight);
  13592. var _c = computeFgSegPlacements(segs, segVCoords, eventOrderStrict, eventMaxStack), segPlacements = _c.segPlacements, hiddenGroups = _c.hiddenGroups;
  13593. return (createElement(Fragment, null,
  13594. this.renderHiddenGroups(hiddenGroups, segs),
  13595. segPlacements.map(function (segPlacement) {
  13596. var seg = segPlacement.seg, rect = segPlacement.rect;
  13597. var instanceId = seg.eventRange.instance.instanceId;
  13598. var isVisible = isMirror || Boolean(!segIsInvisible[instanceId] && rect);
  13599. var vStyle = computeSegVStyle(rect && rect.span);
  13600. var hStyle = (!isMirror && rect) ? _this.computeSegHStyle(rect) : { left: 0, right: 0 };
  13601. var isInset = Boolean(rect) && rect.stackForward > 0;
  13602. var isShort = Boolean(rect) && (rect.span.end - rect.span.start) < eventShortHeight; // look at other places for this problem
  13603. return (createElement("div", { className: 'fc-timegrid-event-harness' +
  13604. (isInset ? ' fc-timegrid-event-harness-inset' : ''), key: instanceId, style: __assign(__assign({ visibility: isVisible ? '' : 'hidden' }, vStyle), hStyle) },
  13605. createElement(TimeColEvent, __assign({ seg: seg, isDragging: isDragging, isResizing: isResizing, isDateSelecting: isDateSelecting, isSelected: instanceId === eventSelection, isShort: isShort }, getSegMeta(seg, todayRange, nowDate)))));
  13606. })));
  13607. };
  13608. // will already have eventMinHeight applied because segInputs already had it
  13609. TimeCol.prototype.renderHiddenGroups = function (hiddenGroups, segs) {
  13610. var _a = this.props, extraDateSpan = _a.extraDateSpan, dateProfile = _a.dateProfile, todayRange = _a.todayRange, nowDate = _a.nowDate, eventSelection = _a.eventSelection, eventDrag = _a.eventDrag, eventResize = _a.eventResize;
  13611. return (createElement(Fragment, null, hiddenGroups.map(function (hiddenGroup) {
  13612. var positionCss = computeSegVStyle(hiddenGroup.span);
  13613. var hiddenSegs = compileSegsFromEntries(hiddenGroup.entries, segs);
  13614. return (createElement(TimeColMoreLink, { key: buildIsoString(computeEarliestSegStart(hiddenSegs)), hiddenSegs: hiddenSegs, top: positionCss.top, bottom: positionCss.bottom, extraDateSpan: extraDateSpan, dateProfile: dateProfile, todayRange: todayRange, nowDate: nowDate, eventSelection: eventSelection, eventDrag: eventDrag, eventResize: eventResize }));
  13615. })));
  13616. };
  13617. TimeCol.prototype.renderFillSegs = function (segs, fillType) {
  13618. var _a = this, props = _a.props, context = _a.context;
  13619. var segVCoords = computeSegVCoords(segs, props.date, props.slatCoords, context.options.eventMinHeight); // don't assume all populated
  13620. var children = segVCoords.map(function (vcoords, i) {
  13621. var seg = segs[i];
  13622. return (createElement("div", { key: buildEventRangeKey(seg.eventRange), className: "fc-timegrid-bg-harness", style: computeSegVStyle(vcoords) }, fillType === 'bg-event' ?
  13623. createElement(BgEvent, __assign({ seg: seg }, getSegMeta(seg, props.todayRange, props.nowDate))) :
  13624. renderFill(fillType)));
  13625. });
  13626. return createElement(Fragment, null, children);
  13627. };
  13628. TimeCol.prototype.renderNowIndicator = function (segs) {
  13629. var _a = this.props, slatCoords = _a.slatCoords, date = _a.date;
  13630. if (!slatCoords) {
  13631. return null;
  13632. }
  13633. return segs.map(function (seg, i) { return (createElement(NowIndicatorRoot, { isAxis: false, date: date,
  13634. // key doesn't matter. will only ever be one
  13635. key: i }, function (rootElRef, classNames, innerElRef, innerContent) { return (createElement("div", { ref: rootElRef, className: ['fc-timegrid-now-indicator-line'].concat(classNames).join(' '), style: { top: slatCoords.computeDateTop(seg.start, date) } }, innerContent)); })); });
  13636. };
  13637. TimeCol.prototype.computeSegHStyle = function (segHCoords) {
  13638. var _a = this.context, isRtl = _a.isRtl, options = _a.options;
  13639. var shouldOverlap = options.slotEventOverlap;
  13640. var nearCoord = segHCoords.levelCoord; // the left side if LTR. the right side if RTL. floating-point
  13641. var farCoord = segHCoords.levelCoord + segHCoords.thickness; // the right side if LTR. the left side if RTL. floating-point
  13642. var left; // amount of space from left edge, a fraction of the total width
  13643. var right; // amount of space from right edge, a fraction of the total width
  13644. if (shouldOverlap) {
  13645. // double the width, but don't go beyond the maximum forward coordinate (1.0)
  13646. farCoord = Math.min(1, nearCoord + (farCoord - nearCoord) * 2);
  13647. }
  13648. if (isRtl) {
  13649. left = 1 - farCoord;
  13650. right = nearCoord;
  13651. }
  13652. else {
  13653. left = nearCoord;
  13654. right = 1 - farCoord;
  13655. }
  13656. var props = {
  13657. zIndex: segHCoords.stackDepth + 1,
  13658. left: left * 100 + '%',
  13659. right: right * 100 + '%',
  13660. };
  13661. if (shouldOverlap && !segHCoords.stackForward) {
  13662. // add padding to the edge so that forward stacked events don't cover the resizer's icon
  13663. props[isRtl ? 'marginLeft' : 'marginRight'] = 10 * 2; // 10 is a guesstimate of the icon's width
  13664. }
  13665. return props;
  13666. };
  13667. return TimeCol;
  13668. }(BaseComponent));
  13669. function renderPlainFgSegs(sortedFgSegs, _a) {
  13670. var todayRange = _a.todayRange, nowDate = _a.nowDate, eventSelection = _a.eventSelection, eventDrag = _a.eventDrag, eventResize = _a.eventResize;
  13671. var hiddenInstances = (eventDrag ? eventDrag.affectedInstances : null) ||
  13672. (eventResize ? eventResize.affectedInstances : null) ||
  13673. {};
  13674. return (createElement(Fragment, null, sortedFgSegs.map(function (seg) {
  13675. var instanceId = seg.eventRange.instance.instanceId;
  13676. return (createElement("div", { key: instanceId, style: { visibility: hiddenInstances[instanceId] ? 'hidden' : '' } },
  13677. createElement(TimeColEvent, __assign({ seg: seg, isDragging: false, isResizing: false, isDateSelecting: false, isSelected: instanceId === eventSelection, isShort: false }, getSegMeta(seg, todayRange, nowDate)))));
  13678. })));
  13679. }
  13680. function computeSegVStyle(segVCoords) {
  13681. if (!segVCoords) {
  13682. return { top: '', bottom: '' };
  13683. }
  13684. return {
  13685. top: segVCoords.start,
  13686. bottom: -segVCoords.end,
  13687. };
  13688. }
  13689. function compileSegsFromEntries(segEntries, allSegs) {
  13690. return segEntries.map(function (segEntry) { return allSegs[segEntry.index]; });
  13691. }
  13692. var TimeColsContent = /** @class */ (function (_super) {
  13693. __extends(TimeColsContent, _super);
  13694. function TimeColsContent() {
  13695. var _this = _super !== null && _super.apply(this, arguments) || this;
  13696. _this.splitFgEventSegs = memoize(splitSegsByCol);
  13697. _this.splitBgEventSegs = memoize(splitSegsByCol);
  13698. _this.splitBusinessHourSegs = memoize(splitSegsByCol);
  13699. _this.splitNowIndicatorSegs = memoize(splitSegsByCol);
  13700. _this.splitDateSelectionSegs = memoize(splitSegsByCol);
  13701. _this.splitEventDrag = memoize(splitInteractionByCol);
  13702. _this.splitEventResize = memoize(splitInteractionByCol);
  13703. _this.rootElRef = createRef();
  13704. _this.cellElRefs = new RefMap();
  13705. return _this;
  13706. }
  13707. TimeColsContent.prototype.render = function () {
  13708. var _this = this;
  13709. var _a = this, props = _a.props, context = _a.context;
  13710. var nowIndicatorTop = context.options.nowIndicator &&
  13711. props.slatCoords &&
  13712. props.slatCoords.safeComputeTop(props.nowDate); // might return void
  13713. var colCnt = props.cells.length;
  13714. var fgEventSegsByRow = this.splitFgEventSegs(props.fgEventSegs, colCnt);
  13715. var bgEventSegsByRow = this.splitBgEventSegs(props.bgEventSegs, colCnt);
  13716. var businessHourSegsByRow = this.splitBusinessHourSegs(props.businessHourSegs, colCnt);
  13717. var nowIndicatorSegsByRow = this.splitNowIndicatorSegs(props.nowIndicatorSegs, colCnt);
  13718. var dateSelectionSegsByRow = this.splitDateSelectionSegs(props.dateSelectionSegs, colCnt);
  13719. var eventDragByRow = this.splitEventDrag(props.eventDrag, colCnt);
  13720. var eventResizeByRow = this.splitEventResize(props.eventResize, colCnt);
  13721. return (createElement("div", { className: "fc-timegrid-cols", ref: this.rootElRef },
  13722. createElement("table", { role: "presentation", style: {
  13723. minWidth: props.tableMinWidth,
  13724. width: props.clientWidth,
  13725. } },
  13726. props.tableColGroupNode,
  13727. createElement("tbody", { role: "presentation" },
  13728. createElement("tr", { role: "row" },
  13729. props.axis && (createElement("td", { "aria-hidden": true, className: "fc-timegrid-col fc-timegrid-axis" },
  13730. createElement("div", { className: "fc-timegrid-col-frame" },
  13731. createElement("div", { className: "fc-timegrid-now-indicator-container" }, typeof nowIndicatorTop === 'number' && (createElement(NowIndicatorRoot, { isAxis: true, date: props.nowDate }, function (rootElRef, classNames, innerElRef, innerContent) { return (createElement("div", { ref: rootElRef, className: ['fc-timegrid-now-indicator-arrow'].concat(classNames).join(' '), style: { top: nowIndicatorTop } }, innerContent)); })))))),
  13732. props.cells.map(function (cell, i) { return (createElement(TimeCol, { key: cell.key, elRef: _this.cellElRefs.createRef(cell.key), dateProfile: props.dateProfile, date: cell.date, nowDate: props.nowDate, todayRange: props.todayRange, extraHookProps: cell.extraHookProps, extraDataAttrs: cell.extraDataAttrs, extraClassNames: cell.extraClassNames, extraDateSpan: cell.extraDateSpan, fgEventSegs: fgEventSegsByRow[i], bgEventSegs: bgEventSegsByRow[i], businessHourSegs: businessHourSegsByRow[i], nowIndicatorSegs: nowIndicatorSegsByRow[i], dateSelectionSegs: dateSelectionSegsByRow[i], eventDrag: eventDragByRow[i], eventResize: eventResizeByRow[i], slatCoords: props.slatCoords, eventSelection: props.eventSelection, forPrint: props.forPrint })); }))))));
  13733. };
  13734. TimeColsContent.prototype.componentDidMount = function () {
  13735. this.updateCoords();
  13736. };
  13737. TimeColsContent.prototype.componentDidUpdate = function () {
  13738. this.updateCoords();
  13739. };
  13740. TimeColsContent.prototype.updateCoords = function () {
  13741. var props = this.props;
  13742. if (props.onColCoords &&
  13743. props.clientWidth !== null // means sizing has stabilized
  13744. ) {
  13745. props.onColCoords(new PositionCache(this.rootElRef.current, collectCellEls(this.cellElRefs.currentMap, props.cells), true, // horizontal
  13746. false));
  13747. }
  13748. };
  13749. return TimeColsContent;
  13750. }(BaseComponent));
  13751. function collectCellEls(elMap, cells) {
  13752. return cells.map(function (cell) { return elMap[cell.key]; });
  13753. }
  13754. /* A component that renders one or more columns of vertical time slots
  13755. ----------------------------------------------------------------------------------------------------------------------*/
  13756. var TimeCols = /** @class */ (function (_super) {
  13757. __extends(TimeCols, _super);
  13758. function TimeCols() {
  13759. var _this = _super !== null && _super.apply(this, arguments) || this;
  13760. _this.processSlotOptions = memoize(processSlotOptions);
  13761. _this.state = {
  13762. slatCoords: null,
  13763. };
  13764. _this.handleRootEl = function (el) {
  13765. if (el) {
  13766. _this.context.registerInteractiveComponent(_this, {
  13767. el: el,
  13768. isHitComboAllowed: _this.props.isHitComboAllowed,
  13769. });
  13770. }
  13771. else {
  13772. _this.context.unregisterInteractiveComponent(_this);
  13773. }
  13774. };
  13775. _this.handleScrollRequest = function (request) {
  13776. var onScrollTopRequest = _this.props.onScrollTopRequest;
  13777. var slatCoords = _this.state.slatCoords;
  13778. if (onScrollTopRequest && slatCoords) {
  13779. if (request.time) {
  13780. var top_1 = slatCoords.computeTimeTop(request.time);
  13781. top_1 = Math.ceil(top_1); // zoom can give weird floating-point values. rather scroll a little bit further
  13782. if (top_1) {
  13783. top_1 += 1; // to overcome top border that slots beyond the first have. looks better
  13784. }
  13785. onScrollTopRequest(top_1);
  13786. }
  13787. return true;
  13788. }
  13789. return false;
  13790. };
  13791. _this.handleColCoords = function (colCoords) {
  13792. _this.colCoords = colCoords;
  13793. };
  13794. _this.handleSlatCoords = function (slatCoords) {
  13795. _this.setState({ slatCoords: slatCoords });
  13796. if (_this.props.onSlatCoords) {
  13797. _this.props.onSlatCoords(slatCoords);
  13798. }
  13799. };
  13800. return _this;
  13801. }
  13802. TimeCols.prototype.render = function () {
  13803. var _a = this, props = _a.props, state = _a.state;
  13804. return (createElement("div", { className: "fc-timegrid-body", ref: this.handleRootEl, style: {
  13805. // these props are important to give this wrapper correct dimensions for interactions
  13806. // TODO: if we set it here, can we avoid giving to inner tables?
  13807. width: props.clientWidth,
  13808. minWidth: props.tableMinWidth,
  13809. } },
  13810. 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 }),
  13811. 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 })));
  13812. };
  13813. TimeCols.prototype.componentDidMount = function () {
  13814. this.scrollResponder = this.context.createScrollResponder(this.handleScrollRequest);
  13815. };
  13816. TimeCols.prototype.componentDidUpdate = function (prevProps) {
  13817. this.scrollResponder.update(prevProps.dateProfile !== this.props.dateProfile);
  13818. };
  13819. TimeCols.prototype.componentWillUnmount = function () {
  13820. this.scrollResponder.detach();
  13821. };
  13822. TimeCols.prototype.queryHit = function (positionLeft, positionTop) {
  13823. var _a = this.context, dateEnv = _a.dateEnv, options = _a.options;
  13824. var colCoords = this.colCoords;
  13825. var dateProfile = this.props.dateProfile;
  13826. var slatCoords = this.state.slatCoords;
  13827. var _b = this.processSlotOptions(this.props.slotDuration, options.snapDuration), snapDuration = _b.snapDuration, snapsPerSlot = _b.snapsPerSlot;
  13828. var colIndex = colCoords.leftToIndex(positionLeft);
  13829. var slatIndex = slatCoords.positions.topToIndex(positionTop);
  13830. if (colIndex != null && slatIndex != null) {
  13831. var cell = this.props.cells[colIndex];
  13832. var slatTop = slatCoords.positions.tops[slatIndex];
  13833. var slatHeight = slatCoords.positions.getHeight(slatIndex);
  13834. var partial = (positionTop - slatTop) / slatHeight; // floating point number between 0 and 1
  13835. var localSnapIndex = Math.floor(partial * snapsPerSlot); // the snap # relative to start of slat
  13836. var snapIndex = slatIndex * snapsPerSlot + localSnapIndex;
  13837. var dayDate = this.props.cells[colIndex].date;
  13838. var time = addDurations(dateProfile.slotMinTime, multiplyDuration(snapDuration, snapIndex));
  13839. var start = dateEnv.add(dayDate, time);
  13840. var end = dateEnv.add(start, snapDuration);
  13841. return {
  13842. dateProfile: dateProfile,
  13843. dateSpan: __assign({ range: { start: start, end: end }, allDay: false }, cell.extraDateSpan),
  13844. dayEl: colCoords.els[colIndex],
  13845. rect: {
  13846. left: colCoords.lefts[colIndex],
  13847. right: colCoords.rights[colIndex],
  13848. top: slatTop,
  13849. bottom: slatTop + slatHeight,
  13850. },
  13851. layer: 0,
  13852. };
  13853. }
  13854. return null;
  13855. };
  13856. return TimeCols;
  13857. }(DateComponent));
  13858. function processSlotOptions(slotDuration, snapDurationOverride) {
  13859. var snapDuration = snapDurationOverride || slotDuration;
  13860. var snapsPerSlot = wholeDivideDurations(slotDuration, snapDuration);
  13861. if (snapsPerSlot === null) {
  13862. snapDuration = slotDuration;
  13863. snapsPerSlot = 1;
  13864. // TODO: say warning?
  13865. }
  13866. return { snapDuration: snapDuration, snapsPerSlot: snapsPerSlot };
  13867. }
  13868. var DayTimeColsSlicer = /** @class */ (function (_super) {
  13869. __extends(DayTimeColsSlicer, _super);
  13870. function DayTimeColsSlicer() {
  13871. return _super !== null && _super.apply(this, arguments) || this;
  13872. }
  13873. DayTimeColsSlicer.prototype.sliceRange = function (range, dayRanges) {
  13874. var segs = [];
  13875. for (var col = 0; col < dayRanges.length; col += 1) {
  13876. var segRange = intersectRanges(range, dayRanges[col]);
  13877. if (segRange) {
  13878. segs.push({
  13879. start: segRange.start,
  13880. end: segRange.end,
  13881. isStart: segRange.start.valueOf() === range.start.valueOf(),
  13882. isEnd: segRange.end.valueOf() === range.end.valueOf(),
  13883. col: col,
  13884. });
  13885. }
  13886. }
  13887. return segs;
  13888. };
  13889. return DayTimeColsSlicer;
  13890. }(Slicer));
  13891. var DayTimeCols = /** @class */ (function (_super) {
  13892. __extends(DayTimeCols, _super);
  13893. function DayTimeCols() {
  13894. var _this = _super !== null && _super.apply(this, arguments) || this;
  13895. _this.buildDayRanges = memoize(buildDayRanges);
  13896. _this.slicer = new DayTimeColsSlicer();
  13897. _this.timeColsRef = createRef();
  13898. return _this;
  13899. }
  13900. DayTimeCols.prototype.render = function () {
  13901. var _this = this;
  13902. var _a = this, props = _a.props, context = _a.context;
  13903. var dateProfile = props.dateProfile, dayTableModel = props.dayTableModel;
  13904. var isNowIndicator = context.options.nowIndicator;
  13905. var dayRanges = this.buildDayRanges(dayTableModel, dateProfile, context.dateEnv);
  13906. // give it the first row of cells
  13907. // TODO: would move this further down hierarchy, but sliceNowDate needs it
  13908. return (createElement(NowTimer, { unit: isNowIndicator ? 'minute' : 'day' }, function (nowDate, todayRange) { return (createElement(TimeCols, __assign({ ref: _this.timeColsRef }, _this.slicer.sliceProps(props, dateProfile, null, context, dayRanges), { forPrint: props.forPrint, axis: props.axis, dateProfile: dateProfile, slatMetas: props.slatMetas, slotDuration: props.slotDuration, cells: dayTableModel.cells[0], tableColGroupNode: props.tableColGroupNode, tableMinWidth: props.tableMinWidth, clientWidth: props.clientWidth, clientHeight: props.clientHeight, expandRows: props.expandRows, nowDate: nowDate, nowIndicatorSegs: isNowIndicator && _this.slicer.sliceNowDate(nowDate, context, dayRanges), todayRange: todayRange, onScrollTopRequest: props.onScrollTopRequest, onSlatCoords: props.onSlatCoords }))); }));
  13909. };
  13910. return DayTimeCols;
  13911. }(DateComponent));
  13912. function buildDayRanges(dayTableModel, dateProfile, dateEnv) {
  13913. var ranges = [];
  13914. for (var _i = 0, _a = dayTableModel.headerDates; _i < _a.length; _i++) {
  13915. var date = _a[_i];
  13916. ranges.push({
  13917. start: dateEnv.add(date, dateProfile.slotMinTime),
  13918. end: dateEnv.add(date, dateProfile.slotMaxTime),
  13919. });
  13920. }
  13921. return ranges;
  13922. }
  13923. // potential nice values for the slot-duration and interval-duration
  13924. // from largest to smallest
  13925. var STOCK_SUB_DURATIONS = [
  13926. { hours: 1 },
  13927. { minutes: 30 },
  13928. { minutes: 15 },
  13929. { seconds: 30 },
  13930. { seconds: 15 },
  13931. ];
  13932. function buildSlatMetas(slotMinTime, slotMaxTime, explicitLabelInterval, slotDuration, dateEnv) {
  13933. var dayStart = new Date(0);
  13934. var slatTime = slotMinTime;
  13935. var slatIterator = createDuration(0);
  13936. var labelInterval = explicitLabelInterval || computeLabelInterval(slotDuration);
  13937. var metas = [];
  13938. while (asRoughMs(slatTime) < asRoughMs(slotMaxTime)) {
  13939. var date = dateEnv.add(dayStart, slatTime);
  13940. var isLabeled = wholeDivideDurations(slatIterator, labelInterval) !== null;
  13941. metas.push({
  13942. date: date,
  13943. time: slatTime,
  13944. key: date.toISOString(),
  13945. isoTimeStr: formatIsoTimeString(date),
  13946. isLabeled: isLabeled,
  13947. });
  13948. slatTime = addDurations(slatTime, slotDuration);
  13949. slatIterator = addDurations(slatIterator, slotDuration);
  13950. }
  13951. return metas;
  13952. }
  13953. // Computes an automatic value for slotLabelInterval
  13954. function computeLabelInterval(slotDuration) {
  13955. var i;
  13956. var labelInterval;
  13957. var slotsPerLabel;
  13958. // find the smallest stock label interval that results in more than one slots-per-label
  13959. for (i = STOCK_SUB_DURATIONS.length - 1; i >= 0; i -= 1) {
  13960. labelInterval = createDuration(STOCK_SUB_DURATIONS[i]);
  13961. slotsPerLabel = wholeDivideDurations(labelInterval, slotDuration);
  13962. if (slotsPerLabel !== null && slotsPerLabel > 1) {
  13963. return labelInterval;
  13964. }
  13965. }
  13966. return slotDuration; // fall back
  13967. }
  13968. var DayTimeColsView = /** @class */ (function (_super) {
  13969. __extends(DayTimeColsView, _super);
  13970. function DayTimeColsView() {
  13971. var _this = _super !== null && _super.apply(this, arguments) || this;
  13972. _this.buildTimeColsModel = memoize(buildTimeColsModel);
  13973. _this.buildSlatMetas = memoize(buildSlatMetas);
  13974. return _this;
  13975. }
  13976. DayTimeColsView.prototype.render = function () {
  13977. var _this = this;
  13978. var _a = this.context, options = _a.options, dateEnv = _a.dateEnv, dateProfileGenerator = _a.dateProfileGenerator;
  13979. var props = this.props;
  13980. var dateProfile = props.dateProfile;
  13981. var dayTableModel = this.buildTimeColsModel(dateProfile, dateProfileGenerator);
  13982. var splitProps = this.allDaySplitter.splitProps(props);
  13983. var slatMetas = this.buildSlatMetas(dateProfile.slotMinTime, dateProfile.slotMaxTime, options.slotLabelInterval, options.slotDuration, dateEnv);
  13984. var dayMinWidth = options.dayMinWidth;
  13985. var hasAttachedAxis = !dayMinWidth;
  13986. var hasDetachedAxis = dayMinWidth;
  13987. var headerContent = options.dayHeaders && (createElement(DayHeader, { dates: dayTableModel.headerDates, dateProfile: dateProfile, datesRepDistinctDays: true, renderIntro: hasAttachedAxis ? this.renderHeadAxis : null }));
  13988. 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()))); });
  13989. 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 }))); };
  13990. return hasDetachedAxis
  13991. ? this.renderHScrollLayout(headerContent, allDayContent, timeGridContent, dayTableModel.colCnt, dayMinWidth, slatMetas, this.state.slatCoords)
  13992. : this.renderSimpleLayout(headerContent, allDayContent, timeGridContent);
  13993. };
  13994. return DayTimeColsView;
  13995. }(TimeColsView));
  13996. function buildTimeColsModel(dateProfile, dateProfileGenerator) {
  13997. var daySeries = new DaySeriesModel(dateProfile.renderRange, dateProfileGenerator);
  13998. return new DayTableModel(daySeries, false);
  13999. }
  14000. var OPTION_REFINERS$2 = {
  14001. allDaySlot: Boolean,
  14002. };
  14003. var timeGridPlugin = createPlugin({
  14004. initialView: 'timeGridWeek',
  14005. optionRefiners: OPTION_REFINERS$2,
  14006. views: {
  14007. timeGrid: {
  14008. component: DayTimeColsView,
  14009. usesMinMaxTime: true,
  14010. allDaySlot: true,
  14011. slotDuration: '00:30:00',
  14012. slotEventOverlap: true, // a bad name. confused with overlap/constraint system
  14013. },
  14014. timeGridDay: {
  14015. type: 'timeGrid',
  14016. duration: { days: 1 },
  14017. },
  14018. timeGridWeek: {
  14019. type: 'timeGrid',
  14020. duration: { weeks: 1 },
  14021. },
  14022. },
  14023. });
  14024. var ListViewHeaderRow = /** @class */ (function (_super) {
  14025. __extends(ListViewHeaderRow, _super);
  14026. function ListViewHeaderRow() {
  14027. var _this = _super !== null && _super.apply(this, arguments) || this;
  14028. _this.state = {
  14029. textId: getUniqueDomId(),
  14030. };
  14031. return _this;
  14032. }
  14033. ListViewHeaderRow.prototype.render = function () {
  14034. var _a = this.context, theme = _a.theme, dateEnv = _a.dateEnv, options = _a.options, viewApi = _a.viewApi;
  14035. var _b = this.props, cellId = _b.cellId, dayDate = _b.dayDate, todayRange = _b.todayRange;
  14036. var textId = this.state.textId;
  14037. var dayMeta = getDateMeta(dayDate, todayRange);
  14038. // will ever be falsy?
  14039. var text = options.listDayFormat ? dateEnv.format(dayDate, options.listDayFormat) : '';
  14040. // will ever be falsy? also, BAD NAME "alt"
  14041. var sideText = options.listDaySideFormat ? dateEnv.format(dayDate, options.listDaySideFormat) : '';
  14042. var hookProps = __assign({ date: dateEnv.toDate(dayDate), view: viewApi, textId: textId,
  14043. text: text,
  14044. sideText: sideText, navLinkAttrs: buildNavLinkAttrs(this.context, dayDate), sideNavLinkAttrs: buildNavLinkAttrs(this.context, dayDate, 'day', false) }, dayMeta);
  14045. var classNames = ['fc-list-day'].concat(getDayClassNames(dayMeta, theme));
  14046. // TODO: make a reusable HOC for dayHeader (used in daygrid/timegrid too)
  14047. return (createElement(RenderHook, { hookProps: hookProps, classNames: options.dayHeaderClassNames, content: options.dayHeaderContent, defaultContent: renderInnerContent, didMount: options.dayHeaderDidMount, willUnmount: options.dayHeaderWillUnmount }, function (rootElRef, customClassNames, innerElRef, innerContent) { return (createElement("tr", { ref: rootElRef, className: classNames.concat(customClassNames).join(' '), "data-date": formatDayString(dayDate) },
  14048. createElement("th", { scope: "colgroup", colSpan: 3, id: cellId, "aria-labelledby": textId },
  14049. createElement("div", { className: 'fc-list-day-cushion ' + theme.getClass('tableCellShaded'), ref: innerElRef }, innerContent)))); }));
  14050. };
  14051. return ListViewHeaderRow;
  14052. }(BaseComponent));
  14053. function renderInnerContent(props) {
  14054. return (createElement(Fragment, null,
  14055. props.text && (createElement("a", __assign({ id: props.textId, className: "fc-list-day-text" }, props.navLinkAttrs), props.text)),
  14056. props.sideText && ( /* not keyboard tabbable */createElement("a", __assign({ "aria-hidden": true, className: "fc-list-day-side-text" }, props.sideNavLinkAttrs), props.sideText))));
  14057. }
  14058. var DEFAULT_TIME_FORMAT = createFormatter({
  14059. hour: 'numeric',
  14060. minute: '2-digit',
  14061. meridiem: 'short',
  14062. });
  14063. var ListViewEventRow = /** @class */ (function (_super) {
  14064. __extends(ListViewEventRow, _super);
  14065. function ListViewEventRow() {
  14066. return _super !== null && _super.apply(this, arguments) || this;
  14067. }
  14068. ListViewEventRow.prototype.render = function () {
  14069. var _a = this, props = _a.props, context = _a.context;
  14070. var seg = props.seg, timeHeaderId = props.timeHeaderId, eventHeaderId = props.eventHeaderId, dateHeaderId = props.dateHeaderId;
  14071. var timeFormat = context.options.eventTimeFormat || DEFAULT_TIME_FORMAT;
  14072. return (createElement(EventRoot, { seg: seg, timeText: "" // BAD. because of all-day content
  14073. , disableDragging: true, disableResizing: true, defaultContent: function () { return renderEventInnerContent(seg, context); } /* weird */, isPast: props.isPast, isFuture: props.isFuture, isToday: props.isToday, isSelected: props.isSelected, isDragging: props.isDragging, isResizing: props.isResizing, isDateSelecting: props.isDateSelecting }, function (rootElRef, classNames, innerElRef, innerContent, hookProps) { return (createElement("tr", { className: ['fc-list-event', hookProps.event.url ? 'fc-event-forced-url' : ''].concat(classNames).join(' '), ref: rootElRef },
  14074. buildTimeContent(seg, timeFormat, context, timeHeaderId, dateHeaderId),
  14075. createElement("td", { "aria-hidden": true, className: "fc-list-event-graphic" },
  14076. createElement("span", { className: "fc-list-event-dot", style: { borderColor: hookProps.borderColor || hookProps.backgroundColor } })),
  14077. createElement("td", { ref: innerElRef, headers: eventHeaderId + " " + dateHeaderId, className: "fc-list-event-title" }, innerContent))); }));
  14078. };
  14079. return ListViewEventRow;
  14080. }(BaseComponent));
  14081. function renderEventInnerContent(seg, context) {
  14082. var interactiveAttrs = getSegAnchorAttrs(seg, context);
  14083. return (createElement("a", __assign({}, interactiveAttrs), seg.eventRange.def.title));
  14084. }
  14085. function buildTimeContent(seg, timeFormat, context, timeHeaderId, dateHeaderId) {
  14086. var options = context.options;
  14087. if (options.displayEventTime !== false) {
  14088. var eventDef = seg.eventRange.def;
  14089. var eventInstance = seg.eventRange.instance;
  14090. var doAllDay = false;
  14091. var timeText = void 0;
  14092. if (eventDef.allDay) {
  14093. doAllDay = true;
  14094. }
  14095. else if (isMultiDayRange(seg.eventRange.range)) { // TODO: use (!isStart || !isEnd) instead?
  14096. if (seg.isStart) {
  14097. timeText = buildSegTimeText(seg, timeFormat, context, null, null, eventInstance.range.start, seg.end);
  14098. }
  14099. else if (seg.isEnd) {
  14100. timeText = buildSegTimeText(seg, timeFormat, context, null, null, seg.start, eventInstance.range.end);
  14101. }
  14102. else {
  14103. doAllDay = true;
  14104. }
  14105. }
  14106. else {
  14107. timeText = buildSegTimeText(seg, timeFormat, context);
  14108. }
  14109. if (doAllDay) {
  14110. var hookProps = {
  14111. text: context.options.allDayText,
  14112. view: context.viewApi,
  14113. };
  14114. return (createElement(RenderHook, { hookProps: hookProps, classNames: options.allDayClassNames, content: options.allDayContent, defaultContent: renderAllDayInner, didMount: options.allDayDidMount, willUnmount: options.allDayWillUnmount }, function (rootElRef, classNames, innerElRef, innerContent) { return (createElement("td", { ref: rootElRef, headers: timeHeaderId + " " + dateHeaderId, className: ['fc-list-event-time'].concat(classNames).join(' ') }, innerContent)); }));
  14115. }
  14116. return (createElement("td", { className: "fc-list-event-time" }, timeText));
  14117. }
  14118. return null;
  14119. }
  14120. function renderAllDayInner(hookProps) {
  14121. return hookProps.text;
  14122. }
  14123. /*
  14124. Responsible for the scroller, and forwarding event-related actions into the "grid".
  14125. */
  14126. var ListView = /** @class */ (function (_super) {
  14127. __extends(ListView, _super);
  14128. function ListView() {
  14129. var _this = _super !== null && _super.apply(this, arguments) || this;
  14130. _this.computeDateVars = memoize(computeDateVars);
  14131. _this.eventStoreToSegs = memoize(_this._eventStoreToSegs);
  14132. _this.state = {
  14133. timeHeaderId: getUniqueDomId(),
  14134. eventHeaderId: getUniqueDomId(),
  14135. dateHeaderIdRoot: getUniqueDomId(),
  14136. };
  14137. _this.setRootEl = function (rootEl) {
  14138. if (rootEl) {
  14139. _this.context.registerInteractiveComponent(_this, {
  14140. el: rootEl,
  14141. });
  14142. }
  14143. else {
  14144. _this.context.unregisterInteractiveComponent(_this);
  14145. }
  14146. };
  14147. return _this;
  14148. }
  14149. ListView.prototype.render = function () {
  14150. var _this = this;
  14151. var _a = this, props = _a.props, context = _a.context;
  14152. var extraClassNames = [
  14153. 'fc-list',
  14154. context.theme.getClass('table'),
  14155. context.options.stickyHeaderDates !== false ? 'fc-list-sticky' : '',
  14156. ];
  14157. var _b = this.computeDateVars(props.dateProfile), dayDates = _b.dayDates, dayRanges = _b.dayRanges;
  14158. var eventSegs = this.eventStoreToSegs(props.eventStore, props.eventUiBases, dayRanges);
  14159. return (createElement(ViewRoot, { viewSpec: context.viewSpec, elRef: this.setRootEl }, function (rootElRef, classNames) { return (createElement("div", { ref: rootElRef, className: extraClassNames.concat(classNames).join(' ') },
  14160. createElement(Scroller, { liquid: !props.isHeightAuto, overflowX: props.isHeightAuto ? 'visible' : 'hidden', overflowY: props.isHeightAuto ? 'visible' : 'auto' }, eventSegs.length > 0 ?
  14161. _this.renderSegList(eventSegs, dayDates) :
  14162. _this.renderEmptyMessage()))); }));
  14163. };
  14164. ListView.prototype.renderEmptyMessage = function () {
  14165. var _a = this.context, options = _a.options, viewApi = _a.viewApi;
  14166. var hookProps = {
  14167. text: options.noEventsText,
  14168. view: viewApi,
  14169. };
  14170. 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 },
  14171. createElement("div", { className: "fc-list-empty-cushion", ref: innerElRef }, innerContent))); }));
  14172. };
  14173. ListView.prototype.renderSegList = function (allSegs, dayDates) {
  14174. var _a = this.context, theme = _a.theme, options = _a.options;
  14175. var _b = this.state, timeHeaderId = _b.timeHeaderId, eventHeaderId = _b.eventHeaderId, dateHeaderIdRoot = _b.dateHeaderIdRoot;
  14176. var segsByDay = groupSegsByDay(allSegs); // sparse array
  14177. return (createElement(NowTimer, { unit: "day" }, function (nowDate, todayRange) {
  14178. var innerNodes = [];
  14179. for (var dayIndex = 0; dayIndex < segsByDay.length; dayIndex += 1) {
  14180. var daySegs = segsByDay[dayIndex];
  14181. if (daySegs) { // sparse array, so might be undefined
  14182. var dayStr = formatDayString(dayDates[dayIndex]);
  14183. var dateHeaderId = dateHeaderIdRoot + '-' + dayStr;
  14184. // append a day header
  14185. innerNodes.push(createElement(ListViewHeaderRow, { key: dayStr, cellId: dateHeaderId, dayDate: dayDates[dayIndex], todayRange: todayRange }));
  14186. daySegs = sortEventSegs(daySegs, options.eventOrder);
  14187. for (var _i = 0, daySegs_1 = daySegs; _i < daySegs_1.length; _i++) {
  14188. var seg = daySegs_1[_i];
  14189. innerNodes.push(createElement(ListViewEventRow, __assign({ key: dayStr + ':' + seg.eventRange.instance.instanceId /* are multiple segs for an instanceId */, seg: seg, isDragging: false, isResizing: false, isDateSelecting: false, isSelected: false, timeHeaderId: timeHeaderId, eventHeaderId: eventHeaderId, dateHeaderId: dateHeaderId }, getSegMeta(seg, todayRange, nowDate))));
  14190. }
  14191. }
  14192. }
  14193. return (createElement("table", { className: 'fc-list-table ' + theme.getClass('table') },
  14194. createElement("thead", null,
  14195. createElement("tr", null,
  14196. createElement("th", { scope: "col", id: timeHeaderId }, options.timeHint),
  14197. createElement("th", { scope: "col", "aria-hidden": true }),
  14198. createElement("th", { scope: "col", id: eventHeaderId }, options.eventHint))),
  14199. createElement("tbody", null, innerNodes)));
  14200. }));
  14201. };
  14202. ListView.prototype._eventStoreToSegs = function (eventStore, eventUiBases, dayRanges) {
  14203. return this.eventRangesToSegs(sliceEventStore(eventStore, eventUiBases, this.props.dateProfile.activeRange, this.context.options.nextDayThreshold).fg, dayRanges);
  14204. };
  14205. ListView.prototype.eventRangesToSegs = function (eventRanges, dayRanges) {
  14206. var segs = [];
  14207. for (var _i = 0, eventRanges_1 = eventRanges; _i < eventRanges_1.length; _i++) {
  14208. var eventRange = eventRanges_1[_i];
  14209. segs.push.apply(segs, this.eventRangeToSegs(eventRange, dayRanges));
  14210. }
  14211. return segs;
  14212. };
  14213. ListView.prototype.eventRangeToSegs = function (eventRange, dayRanges) {
  14214. var dateEnv = this.context.dateEnv;
  14215. var nextDayThreshold = this.context.options.nextDayThreshold;
  14216. var range = eventRange.range;
  14217. var allDay = eventRange.def.allDay;
  14218. var dayIndex;
  14219. var segRange;
  14220. var seg;
  14221. var segs = [];
  14222. for (dayIndex = 0; dayIndex < dayRanges.length; dayIndex += 1) {
  14223. segRange = intersectRanges(range, dayRanges[dayIndex]);
  14224. if (segRange) {
  14225. seg = {
  14226. component: this,
  14227. eventRange: eventRange,
  14228. start: segRange.start,
  14229. end: segRange.end,
  14230. isStart: eventRange.isStart && segRange.start.valueOf() === range.start.valueOf(),
  14231. isEnd: eventRange.isEnd && segRange.end.valueOf() === range.end.valueOf(),
  14232. dayIndex: dayIndex,
  14233. };
  14234. segs.push(seg);
  14235. // detect when range won't go fully into the next day,
  14236. // and mutate the latest seg to the be the end.
  14237. if (!seg.isEnd && !allDay &&
  14238. dayIndex + 1 < dayRanges.length &&
  14239. range.end <
  14240. dateEnv.add(dayRanges[dayIndex + 1].start, nextDayThreshold)) {
  14241. seg.end = range.end;
  14242. seg.isEnd = true;
  14243. break;
  14244. }
  14245. }
  14246. }
  14247. return segs;
  14248. };
  14249. return ListView;
  14250. }(DateComponent));
  14251. function renderNoEventsInner(hookProps) {
  14252. return hookProps.text;
  14253. }
  14254. function computeDateVars(dateProfile) {
  14255. var dayStart = startOfDay(dateProfile.renderRange.start);
  14256. var viewEnd = dateProfile.renderRange.end;
  14257. var dayDates = [];
  14258. var dayRanges = [];
  14259. while (dayStart < viewEnd) {
  14260. dayDates.push(dayStart);
  14261. dayRanges.push({
  14262. start: dayStart,
  14263. end: addDays(dayStart, 1),
  14264. });
  14265. dayStart = addDays(dayStart, 1);
  14266. }
  14267. return { dayDates: dayDates, dayRanges: dayRanges };
  14268. }
  14269. // Returns a sparse array of arrays, segs grouped by their dayIndex
  14270. function groupSegsByDay(segs) {
  14271. var segsByDay = []; // sparse array
  14272. var i;
  14273. var seg;
  14274. for (i = 0; i < segs.length; i += 1) {
  14275. seg = segs[i];
  14276. (segsByDay[seg.dayIndex] || (segsByDay[seg.dayIndex] = []))
  14277. .push(seg);
  14278. }
  14279. return segsByDay;
  14280. }
  14281. var OPTION_REFINERS$1 = {
  14282. listDayFormat: createFalsableFormatter,
  14283. listDaySideFormat: createFalsableFormatter,
  14284. noEventsClassNames: identity,
  14285. noEventsContent: identity,
  14286. noEventsDidMount: identity,
  14287. noEventsWillUnmount: identity,
  14288. // noEventsText is defined in base options
  14289. };
  14290. function createFalsableFormatter(input) {
  14291. return input === false ? null : createFormatter(input);
  14292. }
  14293. var listPlugin = createPlugin({
  14294. optionRefiners: OPTION_REFINERS$1,
  14295. views: {
  14296. list: {
  14297. component: ListView,
  14298. buttonTextKey: 'list',
  14299. listDayFormat: { month: 'long', day: 'numeric', year: 'numeric' }, // like "January 1, 2016"
  14300. },
  14301. listDay: {
  14302. type: 'list',
  14303. duration: { days: 1 },
  14304. listDayFormat: { weekday: 'long' }, // day-of-week is all we need. full date is probably in headerToolbar
  14305. },
  14306. listWeek: {
  14307. type: 'list',
  14308. duration: { weeks: 1 },
  14309. listDayFormat: { weekday: 'long' },
  14310. listDaySideFormat: { month: 'long', day: 'numeric', year: 'numeric' },
  14311. },
  14312. listMonth: {
  14313. type: 'list',
  14314. duration: { month: 1 },
  14315. listDaySideFormat: { weekday: 'long' }, // day-of-week is nice-to-have
  14316. },
  14317. listYear: {
  14318. type: 'list',
  14319. duration: { year: 1 },
  14320. listDaySideFormat: { weekday: 'long' }, // day-of-week is nice-to-have
  14321. },
  14322. },
  14323. });
  14324. var BootstrapTheme$1 = /** @class */ (function (_super) {
  14325. __extends(BootstrapTheme, _super);
  14326. function BootstrapTheme() {
  14327. return _super !== null && _super.apply(this, arguments) || this;
  14328. }
  14329. return BootstrapTheme;
  14330. }(Theme));
  14331. BootstrapTheme$1.prototype.classes = {
  14332. root: 'fc-theme-bootstrap',
  14333. table: 'table-bordered',
  14334. tableCellShaded: 'table-active',
  14335. buttonGroup: 'btn-group',
  14336. button: 'btn btn-primary',
  14337. buttonActive: 'active',
  14338. popover: 'popover',
  14339. popoverHeader: 'popover-header',
  14340. popoverContent: 'popover-body',
  14341. };
  14342. BootstrapTheme$1.prototype.baseIconClass = 'fa';
  14343. BootstrapTheme$1.prototype.iconClasses = {
  14344. close: 'fa-times',
  14345. prev: 'fa-chevron-left',
  14346. next: 'fa-chevron-right',
  14347. prevYear: 'fa-angle-double-left',
  14348. nextYear: 'fa-angle-double-right',
  14349. };
  14350. BootstrapTheme$1.prototype.rtlIconClasses = {
  14351. prev: 'fa-chevron-right',
  14352. next: 'fa-chevron-left',
  14353. prevYear: 'fa-angle-double-right',
  14354. nextYear: 'fa-angle-double-left',
  14355. };
  14356. BootstrapTheme$1.prototype.iconOverrideOption = 'bootstrapFontAwesome'; // TODO: make TS-friendly. move the option-processing into this plugin
  14357. BootstrapTheme$1.prototype.iconOverrideCustomButtonOption = 'bootstrapFontAwesome';
  14358. BootstrapTheme$1.prototype.iconOverridePrefix = 'fa-';
  14359. var plugin$1 = createPlugin({
  14360. themeClasses: {
  14361. bootstrap: BootstrapTheme$1,
  14362. },
  14363. });
  14364. var BootstrapTheme = /** @class */ (function (_super) {
  14365. __extends(BootstrapTheme, _super);
  14366. function BootstrapTheme() {
  14367. return _super !== null && _super.apply(this, arguments) || this;
  14368. }
  14369. return BootstrapTheme;
  14370. }(Theme));
  14371. BootstrapTheme.prototype.classes = {
  14372. root: 'fc-theme-bootstrap5',
  14373. tableCellShaded: 'fc-theme-bootstrap5-shaded',
  14374. buttonGroup: 'btn-group',
  14375. button: 'btn btn-primary',
  14376. buttonActive: 'active',
  14377. popover: 'popover',
  14378. popoverHeader: 'popover-header',
  14379. popoverContent: 'popover-body',
  14380. };
  14381. BootstrapTheme.prototype.baseIconClass = 'bi';
  14382. BootstrapTheme.prototype.iconClasses = {
  14383. close: 'bi-x-lg',
  14384. prev: 'bi-chevron-left',
  14385. next: 'bi-chevron-right',
  14386. prevYear: 'bi-chevron-double-left',
  14387. nextYear: 'bi-chevron-double-right',
  14388. };
  14389. BootstrapTheme.prototype.rtlIconClasses = {
  14390. prev: 'bi-chevron-right',
  14391. next: 'bi-chevron-left',
  14392. prevYear: 'bi-chevron-double-right',
  14393. nextYear: 'bi-chevron-double-left',
  14394. };
  14395. // wtf
  14396. BootstrapTheme.prototype.iconOverrideOption = 'buttonIcons'; // TODO: make TS-friendly
  14397. BootstrapTheme.prototype.iconOverrideCustomButtonOption = 'icon';
  14398. BootstrapTheme.prototype.iconOverridePrefix = 'bi-';
  14399. var plugin = createPlugin({
  14400. themeClasses: {
  14401. bootstrap5: BootstrapTheme,
  14402. },
  14403. });
  14404. // rename this file to options.ts like other packages?
  14405. var OPTION_REFINERS = {
  14406. googleCalendarApiKey: String,
  14407. };
  14408. var EVENT_SOURCE_REFINERS = {
  14409. googleCalendarApiKey: String,
  14410. googleCalendarId: String,
  14411. googleCalendarApiBase: String,
  14412. extraParams: identity,
  14413. };
  14414. // TODO: expose somehow
  14415. var API_BASE = 'https://www.googleapis.com/calendar/v3/calendars';
  14416. var eventSourceDef = {
  14417. parseMeta: function (refined) {
  14418. var googleCalendarId = refined.googleCalendarId;
  14419. if (!googleCalendarId && refined.url) {
  14420. googleCalendarId = parseGoogleCalendarId(refined.url);
  14421. }
  14422. if (googleCalendarId) {
  14423. return {
  14424. googleCalendarId: googleCalendarId,
  14425. googleCalendarApiKey: refined.googleCalendarApiKey,
  14426. googleCalendarApiBase: refined.googleCalendarApiBase,
  14427. extraParams: refined.extraParams,
  14428. };
  14429. }
  14430. return null;
  14431. },
  14432. fetch: function (arg, onSuccess, onFailure) {
  14433. var _a = arg.context, dateEnv = _a.dateEnv, options = _a.options;
  14434. var meta = arg.eventSource.meta;
  14435. var apiKey = meta.googleCalendarApiKey || options.googleCalendarApiKey;
  14436. if (!apiKey) {
  14437. onFailure({
  14438. message: 'Specify a googleCalendarApiKey. See http://fullcalendar.io/docs/google_calendar/',
  14439. });
  14440. }
  14441. else {
  14442. var url = buildUrl(meta);
  14443. // TODO: make DRY with json-feed-event-source
  14444. var extraParams = meta.extraParams;
  14445. var extraParamsObj = typeof extraParams === 'function' ? extraParams() : extraParams;
  14446. var requestParams_1 = buildRequestParams(arg.range, apiKey, extraParamsObj, dateEnv);
  14447. requestJson('GET', url, requestParams_1, function (body, xhr) {
  14448. if (body.error) {
  14449. onFailure({
  14450. message: 'Google Calendar API: ' + body.error.message,
  14451. errors: body.error.errors,
  14452. xhr: xhr,
  14453. });
  14454. }
  14455. else {
  14456. onSuccess({
  14457. rawEvents: gcalItemsToRawEventDefs(body.items, requestParams_1.timeZone),
  14458. xhr: xhr,
  14459. });
  14460. }
  14461. }, function (message, xhr) {
  14462. onFailure({ message: message, xhr: xhr });
  14463. });
  14464. }
  14465. },
  14466. };
  14467. function parseGoogleCalendarId(url) {
  14468. var match;
  14469. // detect if the ID was specified as a single string.
  14470. // will match calendars like "asdf1234@calendar.google.com" in addition to person email calendars.
  14471. if (/^[^/]+@([^/.]+\.)*(google|googlemail|gmail)\.com$/.test(url)) {
  14472. return url;
  14473. }
  14474. if ((match = /^https:\/\/www.googleapis.com\/calendar\/v3\/calendars\/([^/]*)/.exec(url)) ||
  14475. (match = /^https?:\/\/www.google.com\/calendar\/feeds\/([^/]*)/.exec(url))) {
  14476. return decodeURIComponent(match[1]);
  14477. }
  14478. return null;
  14479. }
  14480. function buildUrl(meta) {
  14481. var apiBase = meta.googleCalendarApiBase;
  14482. if (!apiBase) {
  14483. apiBase = API_BASE;
  14484. }
  14485. return apiBase + '/' + encodeURIComponent(meta.googleCalendarId) + '/events';
  14486. }
  14487. function buildRequestParams(range, apiKey, extraParams, dateEnv) {
  14488. var params;
  14489. var startStr;
  14490. var endStr;
  14491. if (dateEnv.canComputeOffset) {
  14492. // strings will naturally have offsets, which GCal needs
  14493. startStr = dateEnv.formatIso(range.start);
  14494. endStr = dateEnv.formatIso(range.end);
  14495. }
  14496. else {
  14497. // when timezone isn't known, we don't know what the UTC offset should be, so ask for +/- 1 day
  14498. // from the UTC day-start to guarantee we're getting all the events
  14499. // (start/end will be UTC-coerced dates, so toISOString is okay)
  14500. startStr = addDays(range.start, -1).toISOString();
  14501. endStr = addDays(range.end, 1).toISOString();
  14502. }
  14503. params = __assign(__assign({}, (extraParams || {})), { key: apiKey, timeMin: startStr, timeMax: endStr, singleEvents: true, maxResults: 9999 });
  14504. if (dateEnv.timeZone !== 'local') {
  14505. params.timeZone = dateEnv.timeZone;
  14506. }
  14507. return params;
  14508. }
  14509. function gcalItemsToRawEventDefs(items, gcalTimezone) {
  14510. return items.map(function (item) { return gcalItemToRawEventDef(item, gcalTimezone); });
  14511. }
  14512. function gcalItemToRawEventDef(item, gcalTimezone) {
  14513. var url = item.htmlLink || null;
  14514. // make the URLs for each event show times in the correct timezone
  14515. if (url && gcalTimezone) {
  14516. url = injectQsComponent(url, 'ctz=' + gcalTimezone);
  14517. }
  14518. return {
  14519. id: item.id,
  14520. title: item.summary,
  14521. start: item.start.dateTime || item.start.date,
  14522. end: item.end.dateTime || item.end.date,
  14523. url: url,
  14524. location: item.location,
  14525. description: item.description,
  14526. attachments: item.attachments || [],
  14527. extendedProps: (item.extendedProperties || {}).shared || {},
  14528. };
  14529. }
  14530. // Injects a string like "arg=value" into the querystring of a URL
  14531. // TODO: move to a general util file?
  14532. function injectQsComponent(url, component) {
  14533. // inject it after the querystring but before the fragment
  14534. return url.replace(/(\?.*?)?(#|$)/, function (whole, qs, hash) { return (qs ? qs + '&' : '?') + component + hash; });
  14535. }
  14536. var googleCalendarPlugin = createPlugin({
  14537. eventSourceDefs: [eventSourceDef],
  14538. optionRefiners: OPTION_REFINERS,
  14539. eventSourceRefiners: EVENT_SOURCE_REFINERS,
  14540. });
  14541. globalPlugins.push(interactionPlugin, dayGridPlugin, timeGridPlugin, listPlugin, plugin$1, plugin, googleCalendarPlugin);
  14542. exports.BASE_OPTION_DEFAULTS = BASE_OPTION_DEFAULTS;
  14543. exports.BASE_OPTION_REFINERS = BASE_OPTION_REFINERS;
  14544. exports.BaseComponent = BaseComponent;
  14545. exports.BgEvent = BgEvent;
  14546. exports.BootstrapTheme = BootstrapTheme$1;
  14547. exports.Calendar = Calendar;
  14548. exports.CalendarApi = CalendarApi;
  14549. exports.CalendarContent = CalendarContent;
  14550. exports.CalendarDataManager = CalendarDataManager;
  14551. exports.CalendarDataProvider = CalendarDataProvider;
  14552. exports.CalendarRoot = CalendarRoot;
  14553. exports.Component = Component;
  14554. exports.ContentHook = ContentHook;
  14555. exports.CustomContentRenderContext = CustomContentRenderContext;
  14556. exports.DateComponent = DateComponent;
  14557. exports.DateEnv = DateEnv;
  14558. exports.DateProfileGenerator = DateProfileGenerator;
  14559. exports.DayCellContent = DayCellContent;
  14560. exports.DayCellRoot = DayCellRoot;
  14561. exports.DayGridView = DayTableView;
  14562. exports.DayHeader = DayHeader;
  14563. exports.DaySeriesModel = DaySeriesModel;
  14564. exports.DayTable = DayTable;
  14565. exports.DayTableModel = DayTableModel;
  14566. exports.DayTableSlicer = DayTableSlicer;
  14567. exports.DayTimeCols = DayTimeCols;
  14568. exports.DayTimeColsSlicer = DayTimeColsSlicer;
  14569. exports.DayTimeColsView = DayTimeColsView;
  14570. exports.DelayedRunner = DelayedRunner;
  14571. exports.Draggable = ExternalDraggable;
  14572. exports.ElementDragging = ElementDragging;
  14573. exports.ElementScrollController = ElementScrollController;
  14574. exports.Emitter = Emitter;
  14575. exports.EventApi = EventApi;
  14576. exports.EventRoot = EventRoot;
  14577. exports.EventSourceApi = EventSourceApi;
  14578. exports.FeaturefulElementDragging = FeaturefulElementDragging;
  14579. exports.Fragment = Fragment;
  14580. exports.Interaction = Interaction;
  14581. exports.ListView = ListView;
  14582. exports.MoreLinkRoot = MoreLinkRoot;
  14583. exports.MountHook = MountHook;
  14584. exports.NamedTimeZoneImpl = NamedTimeZoneImpl;
  14585. exports.NowIndicatorRoot = NowIndicatorRoot;
  14586. exports.NowTimer = NowTimer;
  14587. exports.PointerDragging = PointerDragging;
  14588. exports.PositionCache = PositionCache;
  14589. exports.RefMap = RefMap;
  14590. exports.RenderHook = RenderHook;
  14591. exports.ScrollController = ScrollController;
  14592. exports.ScrollResponder = ScrollResponder;
  14593. exports.Scroller = Scroller;
  14594. exports.SegHierarchy = SegHierarchy;
  14595. exports.SimpleScrollGrid = SimpleScrollGrid;
  14596. exports.Slicer = Slicer;
  14597. exports.Splitter = Splitter;
  14598. exports.StandardEvent = StandardEvent;
  14599. exports.Table = Table;
  14600. exports.TableDateCell = TableDateCell;
  14601. exports.TableDowCell = TableDowCell;
  14602. exports.TableView = TableView;
  14603. exports.Theme = Theme;
  14604. exports.ThirdPartyDraggable = ThirdPartyDraggable;
  14605. exports.TimeCols = TimeCols;
  14606. exports.TimeColsSlatsCoords = TimeColsSlatsCoords;
  14607. exports.TimeColsView = TimeColsView;
  14608. exports.ViewApi = ViewApi;
  14609. exports.ViewContextType = ViewContextType;
  14610. exports.ViewRoot = ViewRoot;
  14611. exports.WeekNumberRoot = WeekNumberRoot;
  14612. exports.WindowScrollController = WindowScrollController;
  14613. exports.addDays = addDays;
  14614. exports.addDurations = addDurations;
  14615. exports.addMs = addMs;
  14616. exports.addWeeks = addWeeks;
  14617. exports.allowContextMenu = allowContextMenu;
  14618. exports.allowSelection = allowSelection;
  14619. exports.applyMutationToEventStore = applyMutationToEventStore;
  14620. exports.applyStyle = applyStyle;
  14621. exports.applyStyleProp = applyStyleProp;
  14622. exports.asCleanDays = asCleanDays;
  14623. exports.asRoughMinutes = asRoughMinutes;
  14624. exports.asRoughMs = asRoughMs;
  14625. exports.asRoughSeconds = asRoughSeconds;
  14626. exports.binarySearch = binarySearch;
  14627. exports.buildClassNameNormalizer = buildClassNameNormalizer;
  14628. exports.buildDayRanges = buildDayRanges;
  14629. exports.buildDayTableModel = buildDayTableModel;
  14630. exports.buildEntryKey = buildEntryKey;
  14631. exports.buildEventApis = buildEventApis;
  14632. exports.buildEventRangeKey = buildEventRangeKey;
  14633. exports.buildHashFromArray = buildHashFromArray;
  14634. exports.buildIsoString = buildIsoString;
  14635. exports.buildNavLinkAttrs = buildNavLinkAttrs;
  14636. exports.buildSegCompareObj = buildSegCompareObj;
  14637. exports.buildSegTimeText = buildSegTimeText;
  14638. exports.buildSlatMetas = buildSlatMetas;
  14639. exports.buildTimeColsModel = buildTimeColsModel;
  14640. exports.collectFromHash = collectFromHash;
  14641. exports.combineEventUis = combineEventUis;
  14642. exports.compareByFieldSpec = compareByFieldSpec;
  14643. exports.compareByFieldSpecs = compareByFieldSpecs;
  14644. exports.compareNumbers = compareNumbers;
  14645. exports.compareObjs = compareObjs;
  14646. exports.computeEarliestSegStart = computeEarliestSegStart;
  14647. exports.computeEdges = computeEdges;
  14648. exports.computeFallbackHeaderFormat = computeFallbackHeaderFormat;
  14649. exports.computeHeightAndMargins = computeHeightAndMargins;
  14650. exports.computeInnerRect = computeInnerRect;
  14651. exports.computeRect = computeRect;
  14652. exports.computeSegDraggable = computeSegDraggable;
  14653. exports.computeSegEndResizable = computeSegEndResizable;
  14654. exports.computeSegStartResizable = computeSegStartResizable;
  14655. exports.computeShrinkWidth = computeShrinkWidth;
  14656. exports.computeSmallestCellWidth = computeSmallestCellWidth;
  14657. exports.computeVisibleDayRange = computeVisibleDayRange;
  14658. exports.config = config;
  14659. exports.constrainPoint = constrainPoint;
  14660. exports.createAriaClickAttrs = createAriaClickAttrs;
  14661. exports.createContext = createContext;
  14662. exports.createDuration = createDuration;
  14663. exports.createElement = createElement;
  14664. exports.createEmptyEventStore = createEmptyEventStore;
  14665. exports.createEventInstance = createEventInstance;
  14666. exports.createEventUi = createEventUi;
  14667. exports.createFormatter = createFormatter;
  14668. exports.createPlugin = createPlugin;
  14669. exports.createPortal = createPortal;
  14670. exports.createRef = createRef;
  14671. exports.diffDates = diffDates;
  14672. exports.diffDayAndTime = diffDayAndTime;
  14673. exports.diffDays = diffDays;
  14674. exports.diffPoints = diffPoints;
  14675. exports.diffWeeks = diffWeeks;
  14676. exports.diffWholeDays = diffWholeDays;
  14677. exports.diffWholeWeeks = diffWholeWeeks;
  14678. exports.disableCursor = disableCursor;
  14679. exports.elementClosest = elementClosest;
  14680. exports.elementMatches = elementMatches;
  14681. exports.enableCursor = enableCursor;
  14682. exports.eventTupleToStore = eventTupleToStore;
  14683. exports.filterEventStoreDefs = filterEventStoreDefs;
  14684. exports.filterHash = filterHash;
  14685. exports.findDirectChildren = findDirectChildren;
  14686. exports.findElements = findElements;
  14687. exports.flexibleCompare = flexibleCompare;
  14688. exports.flushSync = flushSync;
  14689. exports.formatDate = formatDate;
  14690. exports.formatDayString = formatDayString;
  14691. exports.formatIsoTimeString = formatIsoTimeString;
  14692. exports.formatRange = formatRange;
  14693. exports.getAllowYScrolling = getAllowYScrolling;
  14694. exports.getCanVGrowWithinCell = getCanVGrowWithinCell;
  14695. exports.getClippingParents = getClippingParents;
  14696. exports.getDateMeta = getDateMeta;
  14697. exports.getDayClassNames = getDayClassNames;
  14698. exports.getDefaultEventEnd = getDefaultEventEnd;
  14699. exports.getElRoot = getElRoot;
  14700. exports.getElSeg = getElSeg;
  14701. exports.getEntrySpanEnd = getEntrySpanEnd;
  14702. exports.getEventClassNames = getEventClassNames;
  14703. exports.getEventTargetViaRoot = getEventTargetViaRoot;
  14704. exports.getIsRtlScrollbarOnLeft = getIsRtlScrollbarOnLeft;
  14705. exports.getRectCenter = getRectCenter;
  14706. exports.getRelevantEvents = getRelevantEvents;
  14707. exports.getScrollGridClassNames = getScrollGridClassNames;
  14708. exports.getScrollbarWidths = getScrollbarWidths;
  14709. exports.getSectionClassNames = getSectionClassNames;
  14710. exports.getSectionHasLiquidHeight = getSectionHasLiquidHeight;
  14711. exports.getSegAnchorAttrs = getSegAnchorAttrs;
  14712. exports.getSegMeta = getSegMeta;
  14713. exports.getSlotClassNames = getSlotClassNames;
  14714. exports.getStickyFooterScrollbar = getStickyFooterScrollbar;
  14715. exports.getStickyHeaderDates = getStickyHeaderDates;
  14716. exports.getUnequalProps = getUnequalProps;
  14717. exports.getUniqueDomId = getUniqueDomId;
  14718. exports.globalLocales = globalLocales;
  14719. exports.globalPlugins = globalPlugins;
  14720. exports.greatestDurationDenominator = greatestDurationDenominator;
  14721. exports.groupIntersectingEntries = groupIntersectingEntries;
  14722. exports.guid = guid;
  14723. exports.hasBgRendering = hasBgRendering;
  14724. exports.hasShrinkWidth = hasShrinkWidth;
  14725. exports.identity = identity;
  14726. exports.interactionSettingsStore = interactionSettingsStore;
  14727. exports.interactionSettingsToStore = interactionSettingsToStore;
  14728. exports.intersectRanges = intersectRanges;
  14729. exports.intersectRects = intersectRects;
  14730. exports.intersectSpans = intersectSpans;
  14731. exports.isArraysEqual = isArraysEqual;
  14732. exports.isColPropsEqual = isColPropsEqual;
  14733. exports.isDateSelectionValid = isDateSelectionValid;
  14734. exports.isDateSpansEqual = isDateSpansEqual;
  14735. exports.isInt = isInt;
  14736. exports.isInteractionValid = isInteractionValid;
  14737. exports.isMultiDayRange = isMultiDayRange;
  14738. exports.isPropsEqual = isPropsEqual;
  14739. exports.isPropsValid = isPropsValid;
  14740. exports.isValidDate = isValidDate;
  14741. exports.joinSpans = joinSpans;
  14742. exports.listenBySelector = listenBySelector;
  14743. exports.mapHash = mapHash;
  14744. exports.memoize = memoize;
  14745. exports.memoizeArraylike = memoizeArraylike;
  14746. exports.memoizeHashlike = memoizeHashlike;
  14747. exports.memoizeObjArg = memoizeObjArg;
  14748. exports.mergeEventStores = mergeEventStores;
  14749. exports.multiplyDuration = multiplyDuration;
  14750. exports.padStart = padStart;
  14751. exports.parseBusinessHours = parseBusinessHours;
  14752. exports.parseClassNames = parseClassNames;
  14753. exports.parseDragMeta = parseDragMeta;
  14754. exports.parseEventDef = parseEventDef;
  14755. exports.parseFieldSpecs = parseFieldSpecs;
  14756. exports.parseMarker = parse;
  14757. exports.pointInsideRect = pointInsideRect;
  14758. exports.preventContextMenu = preventContextMenu;
  14759. exports.preventDefault = preventDefault;
  14760. exports.preventSelection = preventSelection;
  14761. exports.rangeContainsMarker = rangeContainsMarker;
  14762. exports.rangeContainsRange = rangeContainsRange;
  14763. exports.rangesEqual = rangesEqual;
  14764. exports.rangesIntersect = rangesIntersect;
  14765. exports.refineEventDef = refineEventDef;
  14766. exports.refineProps = refineProps;
  14767. exports.removeElement = removeElement;
  14768. exports.removeExact = removeExact;
  14769. exports.render = render;
  14770. exports.renderChunkContent = renderChunkContent;
  14771. exports.renderFill = renderFill;
  14772. exports.renderMicroColGroup = renderMicroColGroup;
  14773. exports.renderScrollShim = renderScrollShim;
  14774. exports.requestJson = requestJson;
  14775. exports.sanitizeShrinkWidth = sanitizeShrinkWidth;
  14776. exports.setElSeg = setElSeg;
  14777. exports.setRef = setRef;
  14778. exports.sliceEventStore = sliceEventStore;
  14779. exports.sliceEvents = sliceEvents;
  14780. exports.sortEventSegs = sortEventSegs;
  14781. exports.startOfDay = startOfDay;
  14782. exports.translateRect = translateRect;
  14783. exports.triggerDateSelect = triggerDateSelect;
  14784. exports.unmountComponentAtNode = unmountComponentAtNode;
  14785. exports.unpromisify = unpromisify;
  14786. exports.version = version;
  14787. exports.whenTransitionDone = whenTransitionDone;
  14788. exports.wholeDivideDurations = wholeDivideDurations;
  14789. Object.defineProperty(exports, '__esModule', { value: true });
  14790. return exports;
  14791. }({}));