ag-grid-community.cjs.js 1.9 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477
  1. /**
  2. * ag-grid-community - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components * @version v23.2.1
  3. * @link http://www.ag-grid.com/
  4. ' * @license MIT
  5. */
  6. 'use strict';
  7. Object.defineProperty(exports, '__esModule', { value: true });
  8. /**
  9. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  10. * @version v23.2.1
  11. * @link http://www.ag-grid.com/
  12. * @license MIT
  13. */
  14. var Color = /** @class */ (function () {
  15. /**
  16. * Every color component should be in the [0, 1] range.
  17. * Some easing functions (such as elastic easing) can overshoot the target value by some amount.
  18. * So, when animating colors, if the source or target color components are already near
  19. * or at the edge of the allowed [0, 1] range, it is possible for the intermediate color
  20. * component value to end up outside of that range mid-animation. For this reason the constructor
  21. * performs range checking/constraining.
  22. * @param r Red component.
  23. * @param g Green component.
  24. * @param b Blue component.
  25. * @param a Alpha (opacity) component.
  26. */
  27. function Color(r, g, b, a) {
  28. if (a === void 0) { a = 1; }
  29. // NaN is treated as 0.
  30. this.r = Math.min(1, Math.max(0, r || 0));
  31. this.g = Math.min(1, Math.max(0, g || 0));
  32. this.b = Math.min(1, Math.max(0, b || 0));
  33. this.a = Math.min(1, Math.max(0, a || 0));
  34. }
  35. /**
  36. * The given string can be in one of the following formats:
  37. * - #rgb
  38. * - #rrggbb
  39. * - rgb(r, g, b)
  40. * - rgba(r, g, b, a)
  41. * - CSS color name such as 'white', 'orange', 'cyan', etc.
  42. * @param str
  43. */
  44. Color.fromString = function (str) {
  45. // hexadecimal notation
  46. if (str.indexOf('#') >= 0) { // there can be some leading whitespace
  47. return Color.fromHexString(str);
  48. }
  49. // color name
  50. var hex = Color.nameToHex[str];
  51. if (hex) {
  52. return Color.fromHexString(hex);
  53. }
  54. // rgb(a) notation
  55. if (str.indexOf('rgb') >= 0) {
  56. return Color.fromRgbaString(str);
  57. }
  58. throw new Error("Invalid color string: '" + str + "'");
  59. };
  60. // Using separate RegExp for the short hex notation because strings like `#abcd`
  61. // are matched as ['#abcd', 'ab', 'c', 'd', undefined] when the `{1,2}` quantifier is used.
  62. Color.fromHexString = function (str) {
  63. var values = str.match(Color.hexRe);
  64. if (values) {
  65. var r = parseInt(values[1], 16);
  66. var g = parseInt(values[2], 16);
  67. var b = parseInt(values[3], 16);
  68. var a = values[4] !== undefined ? parseInt(values[4], 16) : 255;
  69. return new Color(r / 255, g / 255, b / 255, a / 255);
  70. }
  71. values = str.match(Color.shortHexRe);
  72. if (values) {
  73. var r = parseInt(values[1], 16);
  74. var g = parseInt(values[2], 16);
  75. var b = parseInt(values[3], 16);
  76. var a = values[4] !== undefined ? parseInt(values[4], 16) : 15;
  77. r += r * 16;
  78. g += g * 16;
  79. b += b * 16;
  80. a += a * 16;
  81. return new Color(r / 255, g / 255, b / 255, a / 255);
  82. }
  83. throw new Error("Malformed hexadecimal color string: '" + str + "'");
  84. };
  85. Color.fromRgbaString = function (str) {
  86. var values = str.match(Color.rgbRe);
  87. if (values) {
  88. return new Color(+values[1] / 255, +values[2] / 255, +values[3] / 255);
  89. }
  90. values = str.match(Color.rgbaRe);
  91. if (values) {
  92. return new Color(+values[1] / 255, +values[2] / 255, +values[3] / 255, +values[4]);
  93. }
  94. throw new Error("Malformed rgb/rgba color string: '" + str + "'");
  95. };
  96. Color.fromArray = function (arr) {
  97. if (arr.length === 4) {
  98. return new Color(arr[0], arr[1], arr[2], arr[3]);
  99. }
  100. if (arr.length === 3) {
  101. return new Color(arr[0], arr[1], arr[2]);
  102. }
  103. throw new Error('The given array should contain 3 or 4 color components (numbers).');
  104. };
  105. /**
  106. * Creates an instance of the Color class from the given HSB(A) components.
  107. * @param h Hue in the [0, 360) range.
  108. * @param s Saturation in the [0, 1] range.
  109. * @param b Brightness in the [0, 1] range.
  110. * @param alpha Opacity in the [0, 1] range. Defaults to 1 (completely opaque).
  111. */
  112. Color.fromHSB = function (h, s, b, alpha) {
  113. if (alpha === void 0) { alpha = 1; }
  114. var rgb = Color.HSBtoRGB(h, s, b);
  115. return new Color(rgb[0], rgb[1], rgb[2], alpha);
  116. };
  117. Color.padHex = function (str) {
  118. // Can't use `padStart(2, '0')` here because of IE.
  119. return str.length === 1 ? '0' + str : str;
  120. };
  121. Color.prototype.toHexString = function () {
  122. var hex = '#'
  123. + Color.padHex(Math.round(this.r * 255).toString(16))
  124. + Color.padHex(Math.round(this.g * 255).toString(16))
  125. + Color.padHex(Math.round(this.b * 255).toString(16));
  126. if (this.a < 1) {
  127. hex += Color.padHex(Math.round(this.a * 255).toString(16));
  128. }
  129. return hex;
  130. };
  131. Color.prototype.toRgbaString = function (fractionDigits) {
  132. if (fractionDigits === void 0) { fractionDigits = 3; }
  133. var components = [
  134. Math.round(this.r * 255),
  135. Math.round(this.g * 255),
  136. Math.round(this.b * 255)
  137. ];
  138. var k = Math.pow(10, fractionDigits);
  139. if (this.a !== 1) {
  140. components.push(Math.round(this.a * k) / k);
  141. return "rgba(" + components.join(', ') + ")";
  142. }
  143. return "rgb(" + components.join(', ') + ")";
  144. };
  145. Color.prototype.toString = function () {
  146. if (this.a === 1) {
  147. return this.toHexString();
  148. }
  149. return this.toRgbaString();
  150. };
  151. Color.prototype.toHSB = function () {
  152. return Color.RGBtoHSB(this.r, this.g, this.b);
  153. };
  154. /**
  155. * Converts the given RGB triple to an array of HSB (HSV) components.
  156. * The hue component will be `NaN` for achromatic colors.
  157. */
  158. Color.RGBtoHSB = function (r, g, b) {
  159. var min = Math.min(r, g, b);
  160. var max = Math.max(r, g, b);
  161. var S = max !== 0 ? (max - min) / max : 0;
  162. var H = NaN;
  163. // min == max, means all components are the same
  164. // and the color is a shade of gray with no hue (H is NaN)
  165. if (min !== max) {
  166. var delta = max - min;
  167. var rc = (max - r) / delta;
  168. var gc = (max - g) / delta;
  169. var bc = (max - b) / delta;
  170. if (r === max) {
  171. H = bc - gc;
  172. }
  173. else if (g === max) {
  174. H = 2.0 + rc - bc;
  175. }
  176. else {
  177. H = 4.0 + gc - rc;
  178. }
  179. H /= 6.0;
  180. if (H < 0) {
  181. H = H + 1.0;
  182. }
  183. }
  184. return [H * 360, S, max];
  185. };
  186. /**
  187. * Converts the given HSB (HSV) triple to an array of RGB components.
  188. */
  189. Color.HSBtoRGB = function (H, S, B) {
  190. if (isNaN(H)) {
  191. H = 0;
  192. }
  193. H = (((H % 360) + 360) % 360) / 360; // normalize hue to [0, 360] interval, then scale to [0, 1]
  194. var r = 0;
  195. var g = 0;
  196. var b = 0;
  197. if (S === 0) {
  198. r = g = b = B;
  199. }
  200. else {
  201. var h = (H - Math.floor(H)) * 6;
  202. var f = h - Math.floor(h);
  203. var p = B * (1 - S);
  204. var q = B * (1 - S * f);
  205. var t = B * (1 - (S * (1 - f)));
  206. switch (h >> 0) { // discard the floating point part of the number
  207. case 0:
  208. r = B;
  209. g = t;
  210. b = p;
  211. break;
  212. case 1:
  213. r = q;
  214. g = B;
  215. b = p;
  216. break;
  217. case 2:
  218. r = p;
  219. g = B;
  220. b = t;
  221. break;
  222. case 3:
  223. r = p;
  224. g = q;
  225. b = B;
  226. break;
  227. case 4:
  228. r = t;
  229. g = p;
  230. b = B;
  231. break;
  232. case 5:
  233. r = B;
  234. g = p;
  235. b = q;
  236. break;
  237. }
  238. }
  239. return [r, g, b];
  240. };
  241. Color.prototype.derive = function (hueShift, saturationFactor, brightnessFactor, opacityFactor) {
  242. var hsb = Color.RGBtoHSB(this.r, this.g, this.b);
  243. var b = hsb[2];
  244. if (b == 0 && brightnessFactor > 1.0) {
  245. b = 0.05;
  246. }
  247. var h = (((hsb[0] + hueShift) % 360) + 360) % 360;
  248. var s = Math.max(Math.min(hsb[1] * saturationFactor, 1.0), 0.0);
  249. b = Math.max(Math.min(b * brightnessFactor, 1.0), 0.0);
  250. var a = Math.max(Math.min(this.a * opacityFactor, 1.0), 0.0);
  251. var rgba = Color.HSBtoRGB(h, s, b);
  252. rgba.push(a);
  253. return Color.fromArray(rgba);
  254. };
  255. Color.prototype.brighter = function () {
  256. return this.derive(0, 1.0, 1.0 / 0.7, 1.0);
  257. };
  258. Color.prototype.darker = function () {
  259. return this.derive(0, 1.0, 0.7, 1.0);
  260. };
  261. // See https://drafts.csswg.org/css-color/#hex-notation
  262. Color.hexRe = /\s*#([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})?\s*$/;
  263. Color.shortHexRe = /\s*#([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])?\s*$/;
  264. Color.rgbRe = /\s*rgb\((\d+),\s*(\d+),\s*(\d+)\)\s*/;
  265. Color.rgbaRe = /\s*rgba\((\d+),\s*(\d+),\s*(\d+),\s*([.\d]+)\)\s*/;
  266. /**
  267. * CSS Color Module Level 4:
  268. * https://drafts.csswg.org/css-color/#named-colors
  269. */
  270. Color.nameToHex = Object.freeze({
  271. aliceblue: '#F0F8FF',
  272. antiquewhite: '#FAEBD7',
  273. aqua: '#00FFFF',
  274. aquamarine: '#7FFFD4',
  275. azure: '#F0FFFF',
  276. beige: '#F5F5DC',
  277. bisque: '#FFE4C4',
  278. black: '#000000',
  279. blanchedalmond: '#FFEBCD',
  280. blue: '#0000FF',
  281. blueviolet: '#8A2BE2',
  282. brown: '#A52A2A',
  283. burlywood: '#DEB887',
  284. cadetblue: '#5F9EA0',
  285. chartreuse: '#7FFF00',
  286. chocolate: '#D2691E',
  287. coral: '#FF7F50',
  288. cornflowerblue: '#6495ED',
  289. cornsilk: '#FFF8DC',
  290. crimson: '#DC143C',
  291. cyan: '#00FFFF',
  292. darkblue: '#00008B',
  293. darkcyan: '#008B8B',
  294. darkgoldenrod: '#B8860B',
  295. darkgray: '#A9A9A9',
  296. darkgreen: '#006400',
  297. darkgrey: '#A9A9A9',
  298. darkkhaki: '#BDB76B',
  299. darkmagenta: '#8B008B',
  300. darkolivegreen: '#556B2F',
  301. darkorange: '#FF8C00',
  302. darkorchid: '#9932CC',
  303. darkred: '#8B0000',
  304. darksalmon: '#E9967A',
  305. darkseagreen: '#8FBC8F',
  306. darkslateblue: '#483D8B',
  307. darkslategray: '#2F4F4F',
  308. darkslategrey: '#2F4F4F',
  309. darkturquoise: '#00CED1',
  310. darkviolet: '#9400D3',
  311. deeppink: '#FF1493',
  312. deepskyblue: '#00BFFF',
  313. dimgray: '#696969',
  314. dimgrey: '#696969',
  315. dodgerblue: '#1E90FF',
  316. firebrick: '#B22222',
  317. floralwhite: '#FFFAF0',
  318. forestgreen: '#228B22',
  319. fuchsia: '#FF00FF',
  320. gainsboro: '#DCDCDC',
  321. ghostwhite: '#F8F8FF',
  322. gold: '#FFD700',
  323. goldenrod: '#DAA520',
  324. gray: '#808080',
  325. green: '#008000',
  326. greenyellow: '#ADFF2F',
  327. grey: '#808080',
  328. honeydew: '#F0FFF0',
  329. hotpink: '#FF69B4',
  330. indianred: '#CD5C5C',
  331. indigo: '#4B0082',
  332. ivory: '#FFFFF0',
  333. khaki: '#F0E68C',
  334. lavender: '#E6E6FA',
  335. lavenderblush: '#FFF0F5',
  336. lawngreen: '#7CFC00',
  337. lemonchiffon: '#FFFACD',
  338. lightblue: '#ADD8E6',
  339. lightcoral: '#F08080',
  340. lightcyan: '#E0FFFF',
  341. lightgoldenrodyellow: '#FAFAD2',
  342. lightgray: '#D3D3D3',
  343. lightgreen: '#90EE90',
  344. lightgrey: '#D3D3D3',
  345. lightpink: '#FFB6C1',
  346. lightsalmon: '#FFA07A',
  347. lightseagreen: '#20B2AA',
  348. lightskyblue: '#87CEFA',
  349. lightslategray: '#778899',
  350. lightslategrey: '#778899',
  351. lightsteelblue: '#B0C4DE',
  352. lightyellow: '#FFFFE0',
  353. lime: '#00FF00',
  354. limegreen: '#32CD32',
  355. linen: '#FAF0E6',
  356. magenta: '#FF00FF',
  357. maroon: '#800000',
  358. mediumaquamarine: '#66CDAA',
  359. mediumblue: '#0000CD',
  360. mediumorchid: '#BA55D3',
  361. mediumpurple: '#9370DB',
  362. mediumseagreen: '#3CB371',
  363. mediumslateblue: '#7B68EE',
  364. mediumspringgreen: '#00FA9A',
  365. mediumturquoise: '#48D1CC',
  366. mediumvioletred: '#C71585',
  367. midnightblue: '#191970',
  368. mintcream: '#F5FFFA',
  369. mistyrose: '#FFE4E1',
  370. moccasin: '#FFE4B5',
  371. navajowhite: '#FFDEAD',
  372. navy: '#000080',
  373. oldlace: '#FDF5E6',
  374. olive: '#808000',
  375. olivedrab: '#6B8E23',
  376. orange: '#FFA500',
  377. orangered: '#FF4500',
  378. orchid: '#DA70D6',
  379. palegoldenrod: '#EEE8AA',
  380. palegreen: '#98FB98',
  381. paleturquoise: '#AFEEEE',
  382. palevioletred: '#DB7093',
  383. papayawhip: '#FFEFD5',
  384. peachpuff: '#FFDAB9',
  385. peru: '#CD853F',
  386. pink: '#FFC0CB',
  387. plum: '#DDA0DD',
  388. powderblue: '#B0E0E6',
  389. purple: '#800080',
  390. rebeccapurple: '#663399',
  391. red: '#FF0000',
  392. rosybrown: '#BC8F8F',
  393. royalblue: '#4169E1',
  394. saddlebrown: '#8B4513',
  395. salmon: '#FA8072',
  396. sandybrown: '#F4A460',
  397. seagreen: '#2E8B57',
  398. seashell: '#FFF5EE',
  399. sienna: '#A0522D',
  400. silver: '#C0C0C0',
  401. skyblue: '#87CEEB',
  402. slateblue: '#6A5ACD',
  403. slategray: '#708090',
  404. slategrey: '#708090',
  405. snow: '#FFFAFA',
  406. springgreen: '#00FF7F',
  407. steelblue: '#4682B4',
  408. tan: '#D2B48C',
  409. teal: '#008080',
  410. thistle: '#D8BFD8',
  411. tomato: '#FF6347',
  412. turquoise: '#40E0D0',
  413. violet: '#EE82EE',
  414. wheat: '#F5DEB3',
  415. white: '#FFFFFF',
  416. whitesmoke: '#F5F5F5',
  417. yellow: '#FFFF00',
  418. yellowgreen: '#9ACD32'
  419. });
  420. return Color;
  421. }());
  422. /**
  423. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  424. * @version v23.2.1
  425. * @link http://www.ag-grid.com/
  426. * @license MIT
  427. */
  428. // Based on https://stackoverflow.com/a/14991797
  429. // This will parse a delimited string into an array of arrays.
  430. function stringToArray(strData, delimiter) {
  431. if (delimiter === void 0) { delimiter = ','; }
  432. var data = [];
  433. var isNewline = function (char) { return char === '\r' || char === '\n'; };
  434. var insideQuotedField = false;
  435. var _loop_1 = function (row, column, position) {
  436. var previousChar = strData[position - 1];
  437. var currentChar = strData[position];
  438. var nextChar = strData[position + 1];
  439. var ensureDataExists = function () {
  440. if (!data[row]) {
  441. // create row if it doesn't exist
  442. data[row] = [];
  443. }
  444. if (!data[row][column]) {
  445. // create column if it doesn't exist
  446. data[row][column] = '';
  447. }
  448. };
  449. ensureDataExists();
  450. if (currentChar === '"') {
  451. if (insideQuotedField) {
  452. if (nextChar === '"') {
  453. // unescape double quote
  454. data[row][column] += '"';
  455. position++;
  456. }
  457. else {
  458. // exit quoted field
  459. insideQuotedField = false;
  460. }
  461. return out_row_1 = row, out_column_1 = column, out_position_1 = position, "continue";
  462. }
  463. else if (previousChar === undefined || previousChar === delimiter || isNewline(previousChar)) {
  464. // enter quoted field
  465. insideQuotedField = true;
  466. return out_row_1 = row, out_column_1 = column, out_position_1 = position, "continue";
  467. }
  468. }
  469. if (!insideQuotedField) {
  470. if (currentChar === delimiter) {
  471. // move to next column
  472. column++;
  473. ensureDataExists();
  474. return out_row_1 = row, out_column_1 = column, out_position_1 = position, "continue";
  475. }
  476. else if (isNewline(currentChar)) {
  477. // move to next row
  478. column = 0;
  479. row++;
  480. ensureDataExists();
  481. if (currentChar === '\r' && nextChar === '\n') {
  482. // skip over second newline character if it exists
  483. position++;
  484. }
  485. return out_row_1 = row, out_column_1 = column, out_position_1 = position, "continue";
  486. }
  487. }
  488. // add current character to current column
  489. data[row][column] += currentChar;
  490. out_row_1 = row;
  491. out_column_1 = column;
  492. out_position_1 = position;
  493. };
  494. var out_row_1, out_column_1, out_position_1;
  495. // iterate over each character, keep track of current row and column (of the returned array)
  496. for (var row = 0, column = 0, position = 0; position < strData.length; position++) {
  497. _loop_1(row, column, position);
  498. row = out_row_1;
  499. column = out_column_1;
  500. position = out_position_1;
  501. }
  502. return data;
  503. }
  504. var CsvUtils = /*#__PURE__*/Object.freeze({
  505. __proto__: null,
  506. stringToArray: stringToArray
  507. });
  508. /**
  509. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  510. * @version v23.2.1
  511. * @link http://www.ag-grid.com/
  512. * @license MIT
  513. */
  514. /**
  515. * These variables are lazy loaded, as otherwise they try and get initialised when we are loading
  516. * unit tests and we don't have references to window or document in the unit tests
  517. * from http://stackoverflow.com/questions/9847580/how-to-detect-safari-chrome-ie-firefox-and-opera-browser
  518. */
  519. var isSafari;
  520. var isIE;
  521. var isEdge;
  522. var isChrome;
  523. var isFirefox;
  524. var isIOS;
  525. function isBrowserIE() {
  526. if (isIE === undefined) {
  527. isIE = /*@cc_on!@*/ !!document.documentMode; // At least IE6
  528. }
  529. return isIE;
  530. }
  531. function isBrowserEdge() {
  532. if (isEdge === undefined) {
  533. isEdge = !isBrowserIE() && !!window.StyleMedia;
  534. }
  535. return isEdge;
  536. }
  537. function isBrowserSafari() {
  538. if (isSafari === undefined) {
  539. // taken from https://github.com/ag-grid/ag-grid/issues/550
  540. var anyWindow = window;
  541. var hasNotification = function (p) { return p && p.toString() === '[object SafariRemoteNotification]'; };
  542. isSafari = Object.prototype.toString.call(anyWindow.HTMLElement).indexOf('Constructor') > 0
  543. || hasNotification(anyWindow.safari && anyWindow.safari.pushNotification);
  544. }
  545. return isSafari;
  546. }
  547. function isBrowserChrome() {
  548. if (isChrome === undefined) {
  549. var win = window;
  550. isChrome = (!!win.chrome && (!!win.chrome.webstore || !!win.chrome.runtime)) ||
  551. (/Chrome/.test(navigator.userAgent) && /Google Inc/.test(navigator.vendor));
  552. }
  553. return isChrome;
  554. }
  555. function isBrowserFirefox() {
  556. if (isFirefox === undefined) {
  557. var win = window;
  558. isFirefox = typeof win.InstallTrigger !== 'undefined';
  559. }
  560. return isFirefox;
  561. }
  562. function isIOSUserAgent() {
  563. if (isIOS === undefined) {
  564. // taken from https://stackoverflow.com/a/58064481/1388233
  565. isIOS = (/iPad|iPhone|iPod/.test(navigator.platform) ||
  566. // eslint-disable-next-line
  567. (navigator.platform === 'MacIntel' && navigator.maxTouchPoints > 1)) &&
  568. !window.MSStream;
  569. }
  570. return isIOS;
  571. }
  572. function getTabIndex(el) {
  573. if (!el) {
  574. return null;
  575. }
  576. var numberTabIndex = el.tabIndex;
  577. var tabIndex = el.getAttribute('tabIndex');
  578. if (isBrowserIE() && numberTabIndex === 0 && el.getAttribute('tabIndex') === null) {
  579. var map = {
  580. a: true,
  581. body: true,
  582. button: true,
  583. frame: true,
  584. iframe: true,
  585. img: true,
  586. input: true,
  587. isindex: true,
  588. object: true,
  589. select: true,
  590. textarea: true
  591. };
  592. return map[el.nodeName.toLowerCase()] === true ? '0' : null;
  593. }
  594. if (numberTabIndex === -1 && (tabIndex === null || (tabIndex === '' && !isBrowserFirefox()))) {
  595. return null;
  596. }
  597. return numberTabIndex.toString();
  598. }
  599. function getMaxDivHeight() {
  600. if (!document.body) {
  601. return -1;
  602. }
  603. var res = 1000000;
  604. // FF reports the height back but still renders blank after ~6M px
  605. var testUpTo = navigator.userAgent.toLowerCase().match(/firefox/) ? 6000000 : 1000000000;
  606. var div = document.createElement('div');
  607. document.body.appendChild(div);
  608. while (true) {
  609. var test_1 = res * 2;
  610. div.style.height = test_1 + 'px';
  611. if (test_1 > testUpTo || div.clientHeight !== test_1) {
  612. break;
  613. }
  614. else {
  615. res = test_1;
  616. }
  617. }
  618. document.body.removeChild(div);
  619. return res;
  620. }
  621. function getScrollbarWidth() {
  622. var body = document.body;
  623. var div = document.createElement('div');
  624. div.style.width = div.style.height = '100px';
  625. div.style.opacity = '0';
  626. div.style.overflow = 'scroll';
  627. div.style.msOverflowStyle = 'scrollbar'; // needed for WinJS apps
  628. div.style.position = 'absolute';
  629. body.appendChild(div);
  630. var width = div.offsetWidth - div.clientWidth;
  631. // remove divs
  632. if (div.parentNode) {
  633. div.parentNode.removeChild(div);
  634. }
  635. return width;
  636. }
  637. /** @deprecated */
  638. function hasOverflowScrolling() {
  639. var prefixes = ['webkit', 'moz', 'o', 'ms'];
  640. var div = document.createElement('div');
  641. var body = document.getElementsByTagName('body')[0];
  642. var found = false;
  643. var p;
  644. body.appendChild(div);
  645. div.setAttribute('style', prefixes.map(function (prefix) { return "-" + prefix + "-overflow-scrolling: touch"; }).concat('overflow-scrolling: touch').join(';'));
  646. var computedStyle = window.getComputedStyle(div);
  647. if (computedStyle.overflowScrolling === 'touch') {
  648. found = true;
  649. }
  650. if (!found) {
  651. for (var _i = 0, prefixes_1 = prefixes; _i < prefixes_1.length; _i++) {
  652. p = prefixes_1[_i];
  653. if (computedStyle[p + "OverflowScrolling"] === 'touch') {
  654. found = true;
  655. break;
  656. }
  657. }
  658. }
  659. if (div.parentNode) {
  660. div.parentNode.removeChild(div);
  661. }
  662. return found;
  663. }
  664. /**
  665. * Gets the document body width
  666. * from: http://stackoverflow.com/questions/1038727/how-to-get-browser-width-using-javascript-code
  667. * @returns {number}
  668. */
  669. function getBodyWidth() {
  670. if (document.body) {
  671. return document.body.clientWidth;
  672. }
  673. if (window.innerHeight) {
  674. return window.innerWidth;
  675. }
  676. if (document.documentElement && document.documentElement.clientWidth) {
  677. return document.documentElement.clientWidth;
  678. }
  679. return -1;
  680. }
  681. /**
  682. * Gets the body height
  683. * from: http://stackoverflow.com/questions/1038727/how-to-get-browser-width-using-javascript-code
  684. * @returns {number}
  685. */
  686. function getBodyHeight() {
  687. if (document.body) {
  688. return document.body.clientHeight;
  689. }
  690. if (window.innerHeight) {
  691. return window.innerHeight;
  692. }
  693. if (document.documentElement && document.documentElement.clientHeight) {
  694. return document.documentElement.clientHeight;
  695. }
  696. return -1;
  697. }
  698. var BrowserUtils = /*#__PURE__*/Object.freeze({
  699. __proto__: null,
  700. isBrowserIE: isBrowserIE,
  701. isBrowserEdge: isBrowserEdge,
  702. isBrowserSafari: isBrowserSafari,
  703. isBrowserChrome: isBrowserChrome,
  704. isBrowserFirefox: isBrowserFirefox,
  705. isIOSUserAgent: isIOSUserAgent,
  706. getTabIndex: getTabIndex,
  707. getMaxDivHeight: getMaxDivHeight,
  708. getScrollbarWidth: getScrollbarWidth,
  709. hasOverflowScrolling: hasOverflowScrolling,
  710. getBodyWidth: getBodyWidth,
  711. getBodyHeight: getBodyHeight
  712. });
  713. /**
  714. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  715. * @version v23.2.1
  716. * @link http://www.ag-grid.com/
  717. * @license MIT
  718. */
  719. /**
  720. * If value is undefined, null or blank, returns null, otherwise returns the value
  721. * @param {T} value
  722. * @returns {T | null}
  723. */
  724. function makeNull(value) {
  725. return value == null || value === '' ? null : value;
  726. }
  727. function exists(value, allowEmptyString) {
  728. if (allowEmptyString === void 0) { allowEmptyString = false; }
  729. return value != null && (allowEmptyString || value !== '');
  730. }
  731. function missing(value) {
  732. return !exists(value);
  733. }
  734. function missingOrEmpty(value) {
  735. return !value || missing(value) || value.length === 0;
  736. }
  737. function toStringOrNull(value) {
  738. return exists(value) && value.toString ? value.toString() : null;
  739. }
  740. /** @deprecated */
  741. function referenceCompare(left, right) {
  742. if (left == null && right == null) {
  743. return true;
  744. }
  745. if (left == null && right != null) {
  746. return false;
  747. }
  748. if (left != null && right == null) {
  749. return false;
  750. }
  751. return left === right;
  752. }
  753. function jsonEquals(val1, val2) {
  754. var val1Json = val1 ? JSON.stringify(val1) : null;
  755. var val2Json = val2 ? JSON.stringify(val2) : null;
  756. return val1Json === val2Json;
  757. }
  758. function defaultComparator(valueA, valueB, accentedCompare) {
  759. if (accentedCompare === void 0) { accentedCompare = false; }
  760. var valueAMissing = valueA == null;
  761. var valueBMissing = valueB == null;
  762. // this is for aggregations sum and avg, where the result can be a number that is wrapped.
  763. // if we didn't do this, then the toString() value would be used, which would result in
  764. // the strings getting used instead of the numbers.
  765. if (valueA && valueA.toNumber) {
  766. valueA = valueA.toNumber();
  767. }
  768. if (valueB && valueB.toNumber) {
  769. valueB = valueB.toNumber();
  770. }
  771. if (valueAMissing && valueBMissing) {
  772. return 0;
  773. }
  774. if (valueAMissing) {
  775. return -1;
  776. }
  777. if (valueBMissing) {
  778. return 1;
  779. }
  780. function doQuickCompare(a, b) {
  781. return (a > b ? 1 : (a < b ? -1 : 0));
  782. }
  783. if (typeof valueA === 'string') {
  784. if (!accentedCompare) {
  785. return doQuickCompare(valueA, valueB);
  786. }
  787. try {
  788. // using local compare also allows chinese comparisons
  789. return valueA.localeCompare(valueB);
  790. }
  791. catch (e) {
  792. // if something wrong with localeCompare, eg not supported
  793. // by browser, then just continue with the quick one
  794. return doQuickCompare(valueA, valueB);
  795. }
  796. }
  797. return doQuickCompare(valueA, valueB);
  798. }
  799. function find(collection, predicate, value) {
  800. if (collection === null || collection === undefined) {
  801. return null;
  802. }
  803. if (!Array.isArray(collection)) {
  804. var objToArray = values(collection);
  805. return find(objToArray, predicate, value);
  806. }
  807. var collectionAsArray = collection;
  808. var firstMatchingItem = null;
  809. for (var i = 0; i < collectionAsArray.length; i++) {
  810. var item = collectionAsArray[i];
  811. if (typeof predicate === 'string') {
  812. if (item[predicate] === value) {
  813. firstMatchingItem = item;
  814. break;
  815. }
  816. }
  817. else {
  818. var callback = predicate;
  819. if (callback(item)) {
  820. firstMatchingItem = item;
  821. break;
  822. }
  823. }
  824. }
  825. return firstMatchingItem;
  826. }
  827. function values(object) {
  828. if (object instanceof Set || object instanceof Map) {
  829. var values_1 = [];
  830. object.forEach(function (value) { return values_1.push(value); });
  831. return values_1;
  832. }
  833. return Object.keys(object).map(function (key) { return object[key]; });
  834. }
  835. var GenericUtils = /*#__PURE__*/Object.freeze({
  836. __proto__: null,
  837. makeNull: makeNull,
  838. exists: exists,
  839. missing: missing,
  840. missingOrEmpty: missingOrEmpty,
  841. toStringOrNull: toStringOrNull,
  842. referenceCompare: referenceCompare,
  843. jsonEquals: jsonEquals,
  844. defaultComparator: defaultComparator,
  845. find: find,
  846. values: values
  847. });
  848. /**
  849. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  850. * @version v23.2.1
  851. * @link http://www.ag-grid.com/
  852. * @license MIT
  853. */
  854. var reUnescapedHtml = /[&<>"']/g;
  855. /**
  856. * HTML Escapes.
  857. */
  858. var HTML_ESCAPES = {
  859. '&': '&amp;',
  860. '<': '&lt;',
  861. '>': '&gt;',
  862. '"': '&quot;',
  863. "'": '&#39;'
  864. };
  865. /**
  866. * It encodes any string in UTF-8 format
  867. * taken from https://github.com/mathiasbynens/utf8.js
  868. * @param {string} s
  869. * @returns {string}
  870. */
  871. function utf8_encode(s) {
  872. var stringFromCharCode = String.fromCharCode;
  873. function ucs2decode(string) {
  874. var output = [];
  875. var counter = 0;
  876. var length = string.length;
  877. var value;
  878. var extra;
  879. while (counter < length) {
  880. value = string.charCodeAt(counter++);
  881. if (value >= 0xD800 && value <= 0xDBFF && counter < length) {
  882. // high surrogate, and there is a next character
  883. extra = string.charCodeAt(counter++);
  884. if ((extra & 0xFC00) == 0xDC00) { // low surrogate
  885. output.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000);
  886. }
  887. else {
  888. // unmatched surrogate; only append this code unit, in case the next
  889. // code unit is the high surrogate of a surrogate pair
  890. output.push(value);
  891. counter--;
  892. }
  893. }
  894. else {
  895. output.push(value);
  896. }
  897. }
  898. return output;
  899. }
  900. function checkScalarValue(codePoint) {
  901. if (codePoint >= 0xD800 && codePoint <= 0xDFFF) {
  902. throw Error('Lone surrogate U+' + codePoint.toString(16).toUpperCase() +
  903. ' is not a scalar value');
  904. }
  905. }
  906. function createByte(codePoint, shift) {
  907. return stringFromCharCode(((codePoint >> shift) & 0x3F) | 0x80);
  908. }
  909. function encodeCodePoint(codePoint) {
  910. if ((codePoint & 0xFFFFFF80) == 0) { // 1-byte sequence
  911. return stringFromCharCode(codePoint);
  912. }
  913. var symbol = '';
  914. if ((codePoint & 0xFFFFF800) == 0) { // 2-byte sequence
  915. symbol = stringFromCharCode(((codePoint >> 6) & 0x1F) | 0xC0);
  916. }
  917. else if ((codePoint & 0xFFFF0000) == 0) { // 3-byte sequence
  918. checkScalarValue(codePoint);
  919. symbol = stringFromCharCode(((codePoint >> 12) & 0x0F) | 0xE0);
  920. symbol += createByte(codePoint, 6);
  921. }
  922. else if ((codePoint & 0xFFE00000) == 0) { // 4-byte sequence
  923. symbol = stringFromCharCode(((codePoint >> 18) & 0x07) | 0xF0);
  924. symbol += createByte(codePoint, 12);
  925. symbol += createByte(codePoint, 6);
  926. }
  927. symbol += stringFromCharCode((codePoint & 0x3F) | 0x80);
  928. return symbol;
  929. }
  930. var codePoints = ucs2decode(s);
  931. var length = codePoints.length;
  932. var index = -1;
  933. var codePoint;
  934. var byteString = '';
  935. while (++index < length) {
  936. codePoint = codePoints[index];
  937. byteString += encodeCodePoint(codePoint);
  938. }
  939. return byteString;
  940. }
  941. /**
  942. * Converts a camelCase string into hyphenated string
  943. * from https://gist.github.com/youssman/745578062609e8acac9f
  944. * @param {string} str
  945. * @return {string}
  946. */
  947. function camelCaseToHyphen(str) {
  948. if (str === null || str === undefined) {
  949. return null;
  950. }
  951. return str.replace(/([A-Z])/g, function (g) { return '-' + g[0].toLowerCase(); });
  952. }
  953. /**
  954. * Converts a hyphenated string into camelCase string
  955. * from https://stackoverflow.com/questions/6660977/convert-hyphens-to-camel-case-camelcase
  956. * @param {string} str
  957. * @return {string}
  958. */
  959. function hyphenToCamelCase(str) {
  960. if (str === null || str === undefined) {
  961. return null;
  962. }
  963. return str.replace(/-([a-z])/g, function (g) { return g[1].toUpperCase(); });
  964. }
  965. function capitalise(str) {
  966. return str[0].toUpperCase() + str.substr(1).toLowerCase();
  967. }
  968. function escape(toEscape) {
  969. return toEscape == null || !toEscape.replace ? toEscape : toEscape.replace(reUnescapedHtml, function (chr) { return HTML_ESCAPES[chr]; });
  970. }
  971. /**
  972. * Converts a camelCase string into regular text
  973. * from: https://stackoverflow.com/questions/15369566/putting-space-in-camel-case-string-using-regular-expression
  974. * @param {string} camelCase
  975. * @return {string}
  976. */
  977. function camelCaseToHumanText(camelCase) {
  978. if (!camelCase || camelCase == null) {
  979. return null;
  980. }
  981. var rex = /([A-Z])([A-Z])([a-z])|([a-z])([A-Z])/g;
  982. var words = camelCase.replace(rex, '$1$4 $2$3$5').replace('.', ' ').split(' ');
  983. return words.map(function (word) { return word.substring(0, 1).toUpperCase() + ((word.length > 1) ? word.substring(1, word.length) : ''); }).join(' ');
  984. }
  985. var StringUtils = /*#__PURE__*/Object.freeze({
  986. __proto__: null,
  987. utf8_encode: utf8_encode,
  988. camelCaseToHyphen: camelCaseToHyphen,
  989. hyphenToCamelCase: hyphenToCamelCase,
  990. capitalise: capitalise,
  991. escape: escape,
  992. camelCaseToHumanText: camelCaseToHumanText
  993. });
  994. /**
  995. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  996. * @version v23.2.1
  997. * @link http://www.ag-grid.com/
  998. * @license MIT
  999. */
  1000. function addCssClass(element, className) {
  1001. if (!className || className.length === 0) {
  1002. return;
  1003. }
  1004. if (className.indexOf(' ') >= 0) {
  1005. className.split(' ').forEach(function (value) { return addCssClass(element, value); });
  1006. return;
  1007. }
  1008. if (element.classList) {
  1009. element.classList.add(className);
  1010. }
  1011. else if (element.className && element.className.length > 0) {
  1012. var cssClasses = element.className.split(' ');
  1013. if (cssClasses.indexOf(className) < 0) {
  1014. cssClasses.push(className);
  1015. element.setAttribute('class', cssClasses.join(' '));
  1016. }
  1017. }
  1018. else {
  1019. // do not use element.classList = className here, it will cause
  1020. // a read-only assignment error on some browsers (IE/Edge).
  1021. element.setAttribute('class', className);
  1022. }
  1023. return element;
  1024. }
  1025. function removeCssClass(element, className) {
  1026. if (element.classList) {
  1027. element.classList.remove(className);
  1028. }
  1029. else if (element.className && element.className.length > 0) {
  1030. var newClassName = element.className.split(' ').filter(function (c) { return c !== className; }).join(' ');
  1031. element.setAttribute('class', newClassName);
  1032. }
  1033. }
  1034. function addOrRemoveCssClass(element, className, addOrRemove) {
  1035. if (addOrRemove) {
  1036. addCssClass(element, className);
  1037. }
  1038. else {
  1039. removeCssClass(element, className);
  1040. }
  1041. }
  1042. /**
  1043. * This method adds a class to an element and remove that class from all siblings.
  1044. * Useful for toggling state.
  1045. * @param {HTMLElement} element The element to receive the class
  1046. * @param {string} elementClass The class to be assigned to the element
  1047. * @param {boolean} otherElementClass The class to be assigned to siblings of the element, but not the element itself
  1048. */
  1049. function radioCssClass(element, elementClass, otherElementClass) {
  1050. var parent = element.parentElement;
  1051. var sibling = parent.firstChild;
  1052. while (sibling) {
  1053. if (elementClass) {
  1054. addOrRemoveCssClass(sibling, elementClass, sibling === element);
  1055. }
  1056. if (otherElementClass) {
  1057. addOrRemoveCssClass(sibling, otherElementClass, sibling !== element);
  1058. }
  1059. sibling = sibling.nextSibling;
  1060. }
  1061. }
  1062. function containsClass(element, className) {
  1063. if (element.classList) {
  1064. // for modern browsers
  1065. return element.classList.contains(className);
  1066. }
  1067. if (element.className) {
  1068. // for older browsers, check against the string of class names
  1069. // if only one class, can check for exact match
  1070. var onlyClass = element.className === className;
  1071. // if many classes, check for class name, we have to pad with ' ' to stop other
  1072. // class names that are a substring of this class
  1073. var contains = element.className.indexOf(' ' + className + ' ') >= 0;
  1074. // the padding above then breaks when it's the first or last class names
  1075. var startsWithClass = element.className.indexOf(className + ' ') === 0;
  1076. var endsWithClass = element.className.lastIndexOf(' ' + className) === (element.className.length - className.length - 1);
  1077. return onlyClass || contains || startsWithClass || endsWithClass;
  1078. }
  1079. // if item is not a node
  1080. return false;
  1081. }
  1082. function setDisplayed(element, displayed) {
  1083. addOrRemoveCssClass(element, 'ag-hidden', !displayed);
  1084. }
  1085. function setVisible(element, visible) {
  1086. addOrRemoveCssClass(element, 'ag-invisible', !visible);
  1087. }
  1088. function setDisabled(element, disabled) {
  1089. var attributeName = 'disabled';
  1090. if (disabled) {
  1091. element.setAttribute(attributeName, '');
  1092. }
  1093. else {
  1094. element.removeAttribute(attributeName);
  1095. }
  1096. }
  1097. function isElementChildOfClass(element, cls, maxNest) {
  1098. var counter = 0;
  1099. while (element) {
  1100. if (containsClass(element, cls)) {
  1101. return true;
  1102. }
  1103. element = element.parentElement;
  1104. if (maxNest && ++counter > maxNest) {
  1105. break;
  1106. }
  1107. }
  1108. return false;
  1109. }
  1110. function getElementSize(el) {
  1111. var _a = window.getComputedStyle(el), height = _a.height, width = _a.width, paddingTop = _a.paddingTop, paddingRight = _a.paddingRight, paddingBottom = _a.paddingBottom, paddingLeft = _a.paddingLeft, marginTop = _a.marginTop, marginRight = _a.marginRight, marginBottom = _a.marginBottom, marginLeft = _a.marginLeft, boxSizing = _a.boxSizing;
  1112. return {
  1113. height: parseFloat(height),
  1114. width: parseFloat(width),
  1115. paddingTop: parseFloat(paddingTop),
  1116. paddingRight: parseFloat(paddingRight),
  1117. paddingBottom: parseFloat(paddingBottom),
  1118. paddingLeft: parseFloat(paddingLeft),
  1119. marginTop: parseFloat(marginTop),
  1120. marginRight: parseFloat(marginRight),
  1121. marginBottom: parseFloat(marginBottom),
  1122. marginLeft: parseFloat(marginLeft),
  1123. boxSizing: boxSizing
  1124. };
  1125. }
  1126. function getInnerHeight(el) {
  1127. var size = getElementSize(el);
  1128. if (size.boxSizing === 'border-box') {
  1129. return size.height - size.paddingTop - size.paddingBottom;
  1130. }
  1131. return size.height;
  1132. }
  1133. function getInnerWidth(el) {
  1134. var size = getElementSize(el);
  1135. if (size.boxSizing === 'border-box') {
  1136. return size.width - size.paddingLeft - size.paddingRight;
  1137. }
  1138. return size.width;
  1139. }
  1140. function getAbsoluteHeight(el) {
  1141. var size = getElementSize(el);
  1142. var marginRight = size.marginBottom + size.marginTop;
  1143. return Math.ceil(el.offsetHeight + marginRight);
  1144. }
  1145. function getAbsoluteWidth(el) {
  1146. var size = getElementSize(el);
  1147. var marginWidth = size.marginLeft + size.marginRight;
  1148. return Math.ceil(el.offsetWidth + marginWidth);
  1149. }
  1150. function getScrollLeft(element, rtl) {
  1151. var scrollLeft = element.scrollLeft;
  1152. if (rtl) {
  1153. // Absolute value - for FF that reports RTL scrolls in negative numbers
  1154. scrollLeft = Math.abs(scrollLeft);
  1155. // Get Chrome to return the same value as well
  1156. if (isBrowserChrome()) {
  1157. scrollLeft = element.scrollWidth - element.clientWidth - scrollLeft;
  1158. }
  1159. }
  1160. return scrollLeft;
  1161. }
  1162. function setScrollLeft(element, value, rtl) {
  1163. if (rtl) {
  1164. // Chrome and Safari when doing RTL have the END position of the scroll as zero, not the start
  1165. if (isBrowserSafari() || isBrowserChrome()) {
  1166. value = element.scrollWidth - element.clientWidth - value;
  1167. }
  1168. // Firefox uses negative numbers when doing RTL scrolling
  1169. if (isBrowserFirefox()) {
  1170. value *= -1;
  1171. }
  1172. }
  1173. element.scrollLeft = value;
  1174. }
  1175. function clearElement(el) {
  1176. while (el && el.firstChild) {
  1177. el.removeChild(el.firstChild);
  1178. }
  1179. }
  1180. /** @deprecated */
  1181. function removeElement(parent, cssSelector) {
  1182. removeFromParent(parent.querySelector(cssSelector));
  1183. }
  1184. function removeFromParent(node) {
  1185. if (node && node.parentNode) {
  1186. node.parentNode.removeChild(node);
  1187. }
  1188. }
  1189. function isVisible(element) {
  1190. return element.offsetParent !== null;
  1191. }
  1192. /**
  1193. * Loads the template and returns it as an element. makes up for no simple way in
  1194. * the dom api to load html directly, eg we cannot do this: document.createElement(template)
  1195. * @param {string} template
  1196. * @returns {HTMLElement}
  1197. */
  1198. function loadTemplate(template) {
  1199. var tempDiv = document.createElement('div');
  1200. tempDiv.innerHTML = (template || '').trim();
  1201. return tempDiv.firstChild;
  1202. }
  1203. function appendHtml(eContainer, htmlTemplate) {
  1204. if (eContainer.lastChild) {
  1205. // https://developer.mozilla.org/en-US/docs/Web/API/Element/insertAdjacentHTML
  1206. // we put the items at the start, so new items appear underneath old items,
  1207. // so when expanding/collapsing groups, the new rows don't go on top of the
  1208. // rows below that are moving our of the way
  1209. eContainer.insertAdjacentHTML('afterbegin', htmlTemplate);
  1210. }
  1211. else {
  1212. eContainer.innerHTML = htmlTemplate;
  1213. }
  1214. }
  1215. /** @deprecated */
  1216. function getElementAttribute(element, attributeName) {
  1217. if (element.attributes && element.attributes[attributeName]) {
  1218. var attribute = element.attributes[attributeName];
  1219. return attribute.value;
  1220. }
  1221. return null;
  1222. }
  1223. function offsetHeight(element) {
  1224. return element && element.clientHeight ? element.clientHeight : 0;
  1225. }
  1226. function offsetWidth(element) {
  1227. return element && element.clientWidth ? element.clientWidth : 0;
  1228. }
  1229. function ensureDomOrder(eContainer, eChild, eChildBefore) {
  1230. // if already in right order, do nothing
  1231. if (eChildBefore && eChildBefore.nextSibling === eChild) {
  1232. return;
  1233. }
  1234. if (eChildBefore) {
  1235. if (eChildBefore.nextSibling) {
  1236. // insert between the eRowBefore and the row after it
  1237. eContainer.insertBefore(eChild, eChildBefore.nextSibling);
  1238. }
  1239. else {
  1240. // if nextSibling is missing, means other row is at end, so just append new row at the end
  1241. eContainer.appendChild(eChild);
  1242. }
  1243. }
  1244. else {
  1245. // otherwise put at start
  1246. if (eContainer.firstChild && eContainer.firstChild !== eChild) {
  1247. // insert it at the first location
  1248. eContainer.insertAdjacentElement('afterbegin', eChild);
  1249. }
  1250. }
  1251. }
  1252. function setDomChildOrder(eContainer, orderedChildren) {
  1253. for (var i = 0; i < orderedChildren.length; i++) {
  1254. var correctCellAtIndex = orderedChildren[i];
  1255. var actualCellAtIndex = eContainer.children[i];
  1256. if (actualCellAtIndex !== correctCellAtIndex) {
  1257. eContainer.insertBefore(correctCellAtIndex, actualCellAtIndex);
  1258. }
  1259. }
  1260. }
  1261. function insertTemplateWithDomOrder(eContainer, htmlTemplate, eChildBefore) {
  1262. var res;
  1263. if (eChildBefore) {
  1264. // if previous element exists, just slot in after the previous element
  1265. eChildBefore.insertAdjacentHTML('afterend', htmlTemplate);
  1266. res = eChildBefore.nextSibling;
  1267. }
  1268. else {
  1269. if (eContainer.firstChild) {
  1270. // insert it at the first location
  1271. eContainer.insertAdjacentHTML('afterbegin', htmlTemplate);
  1272. }
  1273. else {
  1274. // otherwise eContainer is empty, so just append it
  1275. eContainer.innerHTML = htmlTemplate;
  1276. }
  1277. res = eContainer.firstChild;
  1278. }
  1279. return res;
  1280. }
  1281. /** @deprecated */
  1282. function prependDC(parent, documentFragment) {
  1283. if (exists(parent.firstChild)) {
  1284. parent.insertBefore(documentFragment, parent.firstChild);
  1285. }
  1286. else {
  1287. parent.appendChild(documentFragment);
  1288. }
  1289. }
  1290. function addStylesToElement(eElement, styles) {
  1291. if (!styles) {
  1292. return;
  1293. }
  1294. Object.keys(styles).forEach(function (key) {
  1295. var keyCamelCase = hyphenToCamelCase(key);
  1296. if (keyCamelCase) {
  1297. eElement.style[keyCamelCase] = styles[key];
  1298. }
  1299. });
  1300. }
  1301. function isHorizontalScrollShowing(element) {
  1302. return element.clientWidth < element.scrollWidth;
  1303. }
  1304. function isVerticalScrollShowing(element) {
  1305. return element.clientHeight < element.scrollHeight;
  1306. }
  1307. function setElementWidth(element, width) {
  1308. if (width === 'flex') {
  1309. element.style.width = null;
  1310. element.style.minWidth = null;
  1311. element.style.maxWidth = null;
  1312. element.style.flex = '1 1 auto';
  1313. }
  1314. else {
  1315. setFixedWidth(element, width);
  1316. }
  1317. }
  1318. function setFixedWidth(element, width) {
  1319. width = formatSize(width);
  1320. element.style.width = width.toString();
  1321. element.style.maxWidth = width.toString();
  1322. element.style.minWidth = width.toString();
  1323. }
  1324. function setElementHeight(element, height) {
  1325. if (height === 'flex') {
  1326. element.style.height = null;
  1327. element.style.minHeight = null;
  1328. element.style.maxHeight = null;
  1329. element.style.flex = '1 1 auto';
  1330. }
  1331. else {
  1332. setFixedHeight(element, height);
  1333. }
  1334. }
  1335. function setFixedHeight(element, height) {
  1336. height = formatSize(height);
  1337. element.style.height = height.toString();
  1338. element.style.maxHeight = height.toString();
  1339. element.style.minHeight = height.toString();
  1340. }
  1341. function formatSize(size) {
  1342. if (typeof size === 'number') {
  1343. return size + "px";
  1344. }
  1345. return size;
  1346. }
  1347. /**
  1348. * Returns true if it is a DOM node
  1349. * taken from: http://stackoverflow.com/questions/384286/javascript-isdom-how-do-you-check-if-a-javascript-object-is-a-dom-object
  1350. * @param {any} o
  1351. * @return {boolean}
  1352. */
  1353. function isNode(o) {
  1354. return (typeof Node === 'function'
  1355. ? o instanceof Node
  1356. : o && typeof o === 'object' && typeof o.nodeType === 'number' && typeof o.nodeName === 'string');
  1357. }
  1358. //
  1359. /**
  1360. * Returns true if it is a DOM element
  1361. * taken from: http://stackoverflow.com/questions/384286/javascript-isdom-how-do-you-check-if-a-javascript-object-is-a-dom-object
  1362. * @param {any} o
  1363. * @returns {boolean}
  1364. */
  1365. function isElement(o) {
  1366. return (typeof HTMLElement === 'function'
  1367. ? o instanceof HTMLElement //DOM2
  1368. : o && typeof o === 'object' && o !== null && o.nodeType === 1 && typeof o.nodeName === 'string');
  1369. }
  1370. function isNodeOrElement(o) {
  1371. return isNode(o) || isElement(o);
  1372. }
  1373. /**
  1374. * Makes a copy of a node list into a list
  1375. * @param {NodeList} nodeList
  1376. * @returns {Node[]}
  1377. */
  1378. function copyNodeList(nodeList) {
  1379. var childCount = nodeList ? nodeList.length : 0;
  1380. var res = [];
  1381. for (var i = 0; i < childCount; i++) {
  1382. res.push(nodeList[i]);
  1383. }
  1384. return res;
  1385. }
  1386. function iterateNamedNodeMap(map, callback) {
  1387. if (!map) {
  1388. return;
  1389. }
  1390. for (var i = 0; i < map.length; i++) {
  1391. var attr = map[i];
  1392. callback(attr.name, attr.value);
  1393. }
  1394. }
  1395. /** @deprecated */
  1396. function setCheckboxState(eCheckbox, state) {
  1397. if (typeof state === 'boolean') {
  1398. eCheckbox.checked = state;
  1399. eCheckbox.indeterminate = false;
  1400. }
  1401. else {
  1402. // isNodeSelected returns back undefined if it's a group and the children
  1403. // are a mix of selected and unselected
  1404. eCheckbox.indeterminate = true;
  1405. }
  1406. }
  1407. var DomUtils = /*#__PURE__*/Object.freeze({
  1408. __proto__: null,
  1409. addCssClass: addCssClass,
  1410. removeCssClass: removeCssClass,
  1411. addOrRemoveCssClass: addOrRemoveCssClass,
  1412. radioCssClass: radioCssClass,
  1413. containsClass: containsClass,
  1414. setDisplayed: setDisplayed,
  1415. setVisible: setVisible,
  1416. setDisabled: setDisabled,
  1417. isElementChildOfClass: isElementChildOfClass,
  1418. getElementSize: getElementSize,
  1419. getInnerHeight: getInnerHeight,
  1420. getInnerWidth: getInnerWidth,
  1421. getAbsoluteHeight: getAbsoluteHeight,
  1422. getAbsoluteWidth: getAbsoluteWidth,
  1423. getScrollLeft: getScrollLeft,
  1424. setScrollLeft: setScrollLeft,
  1425. clearElement: clearElement,
  1426. removeElement: removeElement,
  1427. removeFromParent: removeFromParent,
  1428. isVisible: isVisible,
  1429. loadTemplate: loadTemplate,
  1430. appendHtml: appendHtml,
  1431. getElementAttribute: getElementAttribute,
  1432. offsetHeight: offsetHeight,
  1433. offsetWidth: offsetWidth,
  1434. ensureDomOrder: ensureDomOrder,
  1435. setDomChildOrder: setDomChildOrder,
  1436. insertTemplateWithDomOrder: insertTemplateWithDomOrder,
  1437. prependDC: prependDC,
  1438. addStylesToElement: addStylesToElement,
  1439. isHorizontalScrollShowing: isHorizontalScrollShowing,
  1440. isVerticalScrollShowing: isVerticalScrollShowing,
  1441. setElementWidth: setElementWidth,
  1442. setFixedWidth: setFixedWidth,
  1443. setElementHeight: setElementHeight,
  1444. setFixedHeight: setFixedHeight,
  1445. formatSize: formatSize,
  1446. isNode: isNode,
  1447. isElement: isElement,
  1448. isNodeOrElement: isNodeOrElement,
  1449. copyNodeList: copyNodeList,
  1450. iterateNamedNodeMap: iterateNamedNodeMap,
  1451. setCheckboxState: setCheckboxState
  1452. });
  1453. /**
  1454. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  1455. * @version v23.2.1
  1456. * @link http://www.ag-grid.com/
  1457. * @license MIT
  1458. */
  1459. function firstExistingValue() {
  1460. var values = [];
  1461. for (var _i = 0; _i < arguments.length; _i++) {
  1462. values[_i] = arguments[_i];
  1463. }
  1464. for (var i = 0; i < values.length; i++) {
  1465. var value = values[i];
  1466. if (exists(value)) {
  1467. return value;
  1468. }
  1469. }
  1470. return null;
  1471. }
  1472. /** @deprecated */
  1473. function anyExists(values) {
  1474. return values && firstExistingValue(values) != null;
  1475. }
  1476. function existsAndNotEmpty(value) {
  1477. return value != null && value.length > 0;
  1478. }
  1479. function last(arr) {
  1480. if (!arr || !arr.length) {
  1481. return undefined;
  1482. }
  1483. return arr[arr.length - 1];
  1484. }
  1485. function areEqual(a, b, comparator) {
  1486. if (a == null && b == null) {
  1487. return true;
  1488. }
  1489. return a != null &&
  1490. b != null &&
  1491. a.length === b.length &&
  1492. every(a, function (value, index) { return comparator ? comparator(value, b[index]) : b[index] === value; });
  1493. }
  1494. /** @deprecated */
  1495. function compareArrays(array1, array2) {
  1496. return areEqual(array1, array2);
  1497. }
  1498. /** @deprecated */
  1499. function shallowCompare(arr1, arr2) {
  1500. return areEqual(arr1, arr2);
  1501. }
  1502. function sortNumerically(array) {
  1503. return array.sort(function (a, b) { return a - b; });
  1504. }
  1505. function removeRepeatsFromArray(array, object) {
  1506. if (!array) {
  1507. return;
  1508. }
  1509. for (var index = array.length - 2; index >= 0; index--) {
  1510. var thisOneMatches = array[index] === object;
  1511. var nextOneMatches = array[index + 1] === object;
  1512. if (thisOneMatches && nextOneMatches) {
  1513. array.splice(index + 1, 1);
  1514. }
  1515. }
  1516. }
  1517. function removeFromArray(array, object) {
  1518. var index = array.indexOf(object);
  1519. if (index >= 0) {
  1520. array.splice(index, 1);
  1521. }
  1522. }
  1523. function removeAllFromArray(array, toRemove) {
  1524. forEach(toRemove, function (item) { return removeFromArray(array, item); });
  1525. }
  1526. function insertIntoArray(array, object, toIndex) {
  1527. array.splice(toIndex, 0, object);
  1528. }
  1529. function insertArrayIntoArray(dest, src, toIndex) {
  1530. if (dest == null || src == null) {
  1531. return;
  1532. }
  1533. // put items in backwards, otherwise inserted items end up in reverse order
  1534. for (var i = src.length - 1; i >= 0; i--) {
  1535. var item = src[i];
  1536. insertIntoArray(dest, item, toIndex);
  1537. }
  1538. }
  1539. function moveInArray(array, objectsToMove, toIndex) {
  1540. // first take out items from the array
  1541. removeAllFromArray(array, objectsToMove);
  1542. // now add the objects, in same order as provided to us, that means we start at the end
  1543. // as the objects will be pushed to the right as they are inserted
  1544. forEach(objectsToMove.slice().reverse(), function (obj) { return insertIntoArray(array, obj, toIndex); });
  1545. }
  1546. function includes(array, value) {
  1547. return array.indexOf(value) > -1;
  1548. }
  1549. function flatten(arrayOfArrays) {
  1550. return [].concat.apply([], arrayOfArrays);
  1551. }
  1552. function pushAll(target, source) {
  1553. if (source == null || target == null) {
  1554. return;
  1555. }
  1556. forEach(source, function (value) { return target.push(value); });
  1557. }
  1558. function toStrings(array) {
  1559. return map(array, toStringOrNull);
  1560. }
  1561. function findIndex(collection, predicate) {
  1562. for (var i = 0; i < collection.length; i++) {
  1563. if (predicate(collection[i], i, collection)) {
  1564. return i;
  1565. }
  1566. }
  1567. return -1;
  1568. }
  1569. /**
  1570. * The implementation of Array.prototype.every in browsers is always slower than just using a simple for loop, so
  1571. * use this for improved performance.
  1572. * https://jsbench.me/bek91dtit8/
  1573. */
  1574. function every(list, predicate) {
  1575. if (list == null) {
  1576. return true;
  1577. }
  1578. for (var i = 0; i < list.length; i++) {
  1579. if (!predicate(list[i], i)) {
  1580. return false;
  1581. }
  1582. }
  1583. return true;
  1584. }
  1585. /**
  1586. * The implementation of Array.prototype.some in browsers is always slower than just using a simple for loop, so
  1587. * use this for improved performance.
  1588. * https://jsbench.me/5dk91e4tmt/
  1589. */
  1590. function some(list, predicate) {
  1591. if (list == null) {
  1592. return false;
  1593. }
  1594. for (var i = 0; i < list.length; i++) {
  1595. if (predicate(list[i], i)) {
  1596. return true;
  1597. }
  1598. }
  1599. return false;
  1600. }
  1601. /**
  1602. * The implementation of Array.prototype.forEach in browsers is often slower than just using a simple for loop, so
  1603. * use this for improved performance.
  1604. * https://jsbench.me/apk91elt8a/
  1605. */
  1606. function forEach(list, action) {
  1607. if (list == null) {
  1608. return;
  1609. }
  1610. for (var i = 0; i < list.length; i++) {
  1611. action(list[i], i);
  1612. }
  1613. }
  1614. /**
  1615. * The implementation of Array.prototype.map in browsers is generally the same as just using a simple for loop. However,
  1616. * Firefox does exhibit some difference, and this performs no worse in other browsers, so use this if you want improved
  1617. * performance.
  1618. * https://jsbench.me/njk91ez8pc/
  1619. */
  1620. function map(list, process) {
  1621. if (list == null) {
  1622. return null;
  1623. }
  1624. var mapped = [];
  1625. for (var i = 0; i < list.length; i++) {
  1626. mapped.push(process(list[i], i));
  1627. }
  1628. return mapped;
  1629. }
  1630. /**
  1631. * The implementation of Array.prototype.filter in browsers is always slower than just using a simple for loop, so
  1632. * use this for improved performance.
  1633. * https://jsbench.me/7bk91fk08c/
  1634. */
  1635. function filter(list, predicate) {
  1636. if (list == null) {
  1637. return null;
  1638. }
  1639. var filtered = [];
  1640. for (var i = 0; i < list.length; i++) {
  1641. if (predicate(list[i], i)) {
  1642. filtered.push(list[i]);
  1643. }
  1644. }
  1645. return filtered;
  1646. }
  1647. /**
  1648. * The implementation of Array.prototype.reduce in browsers is generally the same as just using a simple for loop. However,
  1649. * Chrome does exhibit some difference, and this performs no worse in other browsers, so use this if you want improved
  1650. * performance.
  1651. * https://jsbench.me/7vk92n6u1f/
  1652. */
  1653. function reduce(list, step, initial) {
  1654. if (list == null || initial == null) {
  1655. return null;
  1656. }
  1657. var result = initial;
  1658. for (var i = 0; i < list.length; i++) {
  1659. result = step(result, list[i], i);
  1660. }
  1661. return result;
  1662. }
  1663. /** @deprecated */
  1664. function forEachSnapshotFirst(list, callback) {
  1665. if (!list) {
  1666. return;
  1667. }
  1668. var arrayCopy = list.slice(0);
  1669. arrayCopy.forEach(callback);
  1670. }
  1671. var ArrayUtils = /*#__PURE__*/Object.freeze({
  1672. __proto__: null,
  1673. firstExistingValue: firstExistingValue,
  1674. anyExists: anyExists,
  1675. existsAndNotEmpty: existsAndNotEmpty,
  1676. last: last,
  1677. areEqual: areEqual,
  1678. compareArrays: compareArrays,
  1679. shallowCompare: shallowCompare,
  1680. sortNumerically: sortNumerically,
  1681. removeRepeatsFromArray: removeRepeatsFromArray,
  1682. removeFromArray: removeFromArray,
  1683. removeAllFromArray: removeAllFromArray,
  1684. insertIntoArray: insertIntoArray,
  1685. insertArrayIntoArray: insertArrayIntoArray,
  1686. moveInArray: moveInArray,
  1687. includes: includes,
  1688. flatten: flatten,
  1689. pushAll: pushAll,
  1690. toStrings: toStrings,
  1691. findIndex: findIndex,
  1692. every: every,
  1693. some: some,
  1694. forEach: forEach,
  1695. map: map,
  1696. filter: filter,
  1697. reduce: reduce,
  1698. forEachSnapshotFirst: forEachSnapshotFirst
  1699. });
  1700. /**
  1701. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  1702. * @version v23.2.1
  1703. * @link http://www.ag-grid.com/
  1704. * @license MIT
  1705. */
  1706. function iterateObject(object, callback) {
  1707. if (object == null) {
  1708. return;
  1709. }
  1710. if (Array.isArray(object)) {
  1711. forEach(object, function (value, index) { return callback("" + index, value); });
  1712. }
  1713. else {
  1714. forEach(Object.keys(object), function (key) { return callback(key, object[key]); });
  1715. }
  1716. }
  1717. function cloneObject(object) {
  1718. var copy = {};
  1719. var keys = Object.keys(object);
  1720. for (var i = 0; i < keys.length; i++) {
  1721. var key = keys[i];
  1722. var value = object[key];
  1723. copy[key] = value;
  1724. }
  1725. return copy;
  1726. }
  1727. function deepCloneObject(object) {
  1728. return JSON.parse(JSON.stringify(object));
  1729. }
  1730. function getProperty(object, key) {
  1731. return object[key];
  1732. }
  1733. function setProperty(object, key, value) {
  1734. object[key] = value;
  1735. }
  1736. /**
  1737. * Will copy the specified properties from `source` into the equivalent properties on `target`, ignoring properties with
  1738. * a value of `undefined`.
  1739. */
  1740. function copyPropertiesIfPresent(source, target) {
  1741. var properties = [];
  1742. for (var _i = 2; _i < arguments.length; _i++) {
  1743. properties[_i - 2] = arguments[_i];
  1744. }
  1745. forEach(properties, function (p) { return copyPropertyIfPresent(source, target, p); });
  1746. }
  1747. /**
  1748. * Will copy the specified property from `source` into the equivalent property on `target`, unless the property has a
  1749. * value of `undefined`. If a transformation is provided, it will be applied to the value before being set on `target`.
  1750. */
  1751. function copyPropertyIfPresent(source, target, property, transform) {
  1752. var value = getProperty(source, property);
  1753. if (value !== undefined) {
  1754. setProperty(target, property, transform ? transform(value) : value);
  1755. }
  1756. }
  1757. function getAllKeysInObjects(objects) {
  1758. var allValues = {};
  1759. objects.filter(function (obj) { return obj != null; }).forEach(function (obj) {
  1760. forEach(Object.keys(obj), function (key) { return allValues[key] = null; });
  1761. });
  1762. return Object.keys(allValues);
  1763. }
  1764. function mergeDeep(dest, source, copyUndefined) {
  1765. if (copyUndefined === void 0) { copyUndefined = true; }
  1766. if (!exists(source)) {
  1767. return;
  1768. }
  1769. iterateObject(source, function (key, newValue) {
  1770. var oldValue = dest[key];
  1771. if (oldValue === newValue) {
  1772. return;
  1773. }
  1774. if (typeof oldValue === 'object' && typeof newValue === 'object' && !Array.isArray(oldValue)) {
  1775. mergeDeep(oldValue, newValue);
  1776. }
  1777. else if (copyUndefined || newValue !== undefined) {
  1778. dest[key] = newValue;
  1779. }
  1780. });
  1781. }
  1782. function assign(object) {
  1783. var sources = [];
  1784. for (var _i = 1; _i < arguments.length; _i++) {
  1785. sources[_i - 1] = arguments[_i];
  1786. }
  1787. forEach(sources, function (source) { return iterateObject(source, function (key, value) { return object[key] = value; }); });
  1788. return object;
  1789. }
  1790. function missingOrEmptyObject(value) {
  1791. return missing(value) || Object.keys(value).length === 0;
  1792. }
  1793. function get(source, expression, defaultValue) {
  1794. if (source == null) {
  1795. return defaultValue;
  1796. }
  1797. var keys = expression.split('.');
  1798. var objectToRead = source;
  1799. while (keys.length > 1) {
  1800. objectToRead = objectToRead[keys.shift()];
  1801. if (objectToRead == null) {
  1802. return defaultValue;
  1803. }
  1804. }
  1805. var value = objectToRead[keys[0]];
  1806. return value != null ? value : defaultValue;
  1807. }
  1808. function set(target, expression, value) {
  1809. if (target == null) {
  1810. return;
  1811. }
  1812. var keys = expression.split('.');
  1813. var objectToUpdate = target;
  1814. while (keys.length > 1) {
  1815. objectToUpdate = objectToUpdate[keys.shift()];
  1816. if (objectToUpdate == null) {
  1817. return;
  1818. }
  1819. }
  1820. objectToUpdate[keys[0]] = value;
  1821. }
  1822. function deepFreeze(object) {
  1823. Object.freeze(object);
  1824. forEach(values(object), function (v) {
  1825. if (v != null && (typeof v === 'object' || typeof v === 'function')) {
  1826. deepFreeze(v);
  1827. }
  1828. });
  1829. return object;
  1830. }
  1831. function getValueUsingField(data, field, fieldContainsDots) {
  1832. if (!field || !data) {
  1833. return;
  1834. }
  1835. // if no '.', then it's not a deep value
  1836. if (!fieldContainsDots) {
  1837. return data[field];
  1838. }
  1839. // otherwise it is a deep value, so need to dig for it
  1840. var fields = field.split('.');
  1841. var currentObject = data;
  1842. for (var i = 0; i < fields.length; i++) {
  1843. currentObject = currentObject[fields[i]];
  1844. if (missing(currentObject)) {
  1845. return null;
  1846. }
  1847. }
  1848. return currentObject;
  1849. }
  1850. var ObjectUtils = /*#__PURE__*/Object.freeze({
  1851. __proto__: null,
  1852. iterateObject: iterateObject,
  1853. cloneObject: cloneObject,
  1854. deepCloneObject: deepCloneObject,
  1855. getProperty: getProperty,
  1856. setProperty: setProperty,
  1857. copyPropertiesIfPresent: copyPropertiesIfPresent,
  1858. copyPropertyIfPresent: copyPropertyIfPresent,
  1859. getAllKeysInObjects: getAllKeysInObjects,
  1860. mergeDeep: mergeDeep,
  1861. assign: assign,
  1862. missingOrEmptyObject: missingOrEmptyObject,
  1863. get: get,
  1864. set: set,
  1865. deepFreeze: deepFreeze,
  1866. getValueUsingField: getValueUsingField
  1867. });
  1868. /**
  1869. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  1870. * @version v23.2.1
  1871. * @link http://www.ag-grid.com/
  1872. * @license MIT
  1873. */
  1874. /** @deprecated */
  1875. function getNameOfClass(theClass) {
  1876. var funcNameRegex = /function (.{1,})\(/;
  1877. var funcAsString = theClass.toString();
  1878. var results = funcNameRegex.exec(funcAsString);
  1879. return results && results.length > 1 ? results[1] : "";
  1880. }
  1881. function findLineByLeastSquares(values) {
  1882. var len = values.length;
  1883. var maxDecimals = 0;
  1884. if (len <= 1) {
  1885. return values;
  1886. }
  1887. for (var i = 0; i < values.length; i++) {
  1888. var value = values[i];
  1889. if (Math.floor(value) === value) {
  1890. continue;
  1891. }
  1892. maxDecimals = Math.max(maxDecimals, value.toString().split('.')[1].length);
  1893. }
  1894. var sum_x = 0;
  1895. var sum_y = 0;
  1896. var sum_xy = 0;
  1897. var sum_xx = 0;
  1898. var y = 0;
  1899. for (var x = 0; x < len; x++) {
  1900. y = values[x];
  1901. sum_x += x;
  1902. sum_y += y;
  1903. sum_xx += x * x;
  1904. sum_xy += x * y;
  1905. }
  1906. var m = (len * sum_xy - sum_x * sum_y) / (len * sum_xx - sum_x * sum_x);
  1907. var b = (sum_y / len) - (m * sum_x) / len;
  1908. var result = [];
  1909. for (var x = 0; x <= len; x++) {
  1910. result.push(parseFloat((x * m + b).toFixed(maxDecimals)));
  1911. }
  1912. return result;
  1913. }
  1914. /**
  1915. * Converts a CSS object into string
  1916. * @param {Object} stylesToUse an object eg: {color: 'black', top: '25px'}
  1917. * @return {string} A string like "color: black; top: 25px;" for html
  1918. */
  1919. function cssStyleObjectToMarkup(stylesToUse) {
  1920. if (!stylesToUse) {
  1921. return '';
  1922. }
  1923. var resParts = [];
  1924. iterateObject(stylesToUse, function (styleKey, styleValue) {
  1925. var styleKeyDashed = camelCaseToHyphen(styleKey);
  1926. resParts.push(styleKeyDashed + ": " + styleValue + ";");
  1927. });
  1928. return resParts.join(' ');
  1929. }
  1930. /**
  1931. * Displays a message to the browser. this is useful in iPad, where you can't easily see the console.
  1932. * so the javascript code can use this to give feedback. this is NOT intended to be called in production.
  1933. * it is intended the ag-Grid developer calls this to troubleshoot, but then takes out the calls before
  1934. * checking in.
  1935. * @param {string} msg
  1936. */
  1937. function message(msg) {
  1938. var eMessage = document.createElement('div');
  1939. var eBox = document.querySelector('#__ag__message');
  1940. eMessage.innerHTML = msg;
  1941. if (!eBox) {
  1942. var template = "<div id=\"__ag__message\" style=\"display: inline-block; position: absolute; top: 0px; left: 0px; color: white; background-color: black; z-index: 20; padding: 2px; border: 1px solid darkred; height: 200px; overflow-y: auto;\"></div>";
  1943. eBox = loadTemplate(template);
  1944. if (document.body) {
  1945. document.body.appendChild(eBox);
  1946. }
  1947. }
  1948. eBox.insertBefore(eMessage, eBox.children[0]);
  1949. }
  1950. /**
  1951. * cell renderers are used in a few places. they bind to dom slightly differently to other cell renderes as they
  1952. * can return back strings (instead of html elemnt) in the getGui() method. common code placed here to handle that.
  1953. * @param {Promise<ICellRendererComp>} cellRendererPromise
  1954. * @param {HTMLElement} eTarget
  1955. */
  1956. function bindCellRendererToHtmlElement(cellRendererPromise, eTarget) {
  1957. cellRendererPromise.then(function (cellRenderer) {
  1958. var gui = cellRenderer.getGui();
  1959. if (gui != null) {
  1960. if (typeof gui === 'object') {
  1961. eTarget.appendChild(gui);
  1962. }
  1963. else {
  1964. eTarget.innerHTML = gui;
  1965. }
  1966. }
  1967. });
  1968. }
  1969. var GeneralUtils = /*#__PURE__*/Object.freeze({
  1970. __proto__: null,
  1971. getNameOfClass: getNameOfClass,
  1972. findLineByLeastSquares: findLineByLeastSquares,
  1973. cssStyleObjectToMarkup: cssStyleObjectToMarkup,
  1974. message: message,
  1975. bindCellRendererToHtmlElement: bindCellRendererToHtmlElement
  1976. });
  1977. /**
  1978. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  1979. * @version v23.2.1
  1980. * @link http://www.ag-grid.com/
  1981. * @license MIT
  1982. */
  1983. function padStart(value, totalStringSize) {
  1984. var asString = "" + value;
  1985. while (asString.length < totalStringSize) {
  1986. asString = "0" + asString;
  1987. }
  1988. return asString;
  1989. }
  1990. function createArrayOfNumbers(first, last) {
  1991. var result = [];
  1992. for (var i = first; i <= last; i++) {
  1993. result.push(i);
  1994. }
  1995. return result;
  1996. }
  1997. /**
  1998. * Check if a value is numeric
  1999. * from http://stackoverflow.com/questions/9716468/is-there-any-function-like-isnumeric-in-javascript-to-validate-numbers
  2000. * @param {any} value
  2001. * @return {boolean}
  2002. */
  2003. function isNumeric(value) {
  2004. return value !== '' && !isNaN(parseFloat(value)) && isFinite(value);
  2005. }
  2006. function getMaxSafeInteger() {
  2007. // eslint-disable-next-line
  2008. return Number.MAX_SAFE_INTEGER || 9007199254740991;
  2009. }
  2010. function cleanNumber(value) {
  2011. if (typeof value === 'string') {
  2012. value = parseInt(value, 10);
  2013. }
  2014. if (typeof value === 'number') {
  2015. return Math.floor(value);
  2016. }
  2017. else {
  2018. return null;
  2019. }
  2020. }
  2021. function decToHex(number, bytes) {
  2022. var hex = '';
  2023. for (var i = 0; i < bytes; i++) {
  2024. hex += String.fromCharCode(number & 0xff);
  2025. number >>>= 8;
  2026. }
  2027. return hex;
  2028. }
  2029. function formatNumberTwoDecimalPlacesAndCommas(value) {
  2030. if (typeof value !== 'number') {
  2031. return '';
  2032. }
  2033. return formatNumberCommas(Math.round(value * 100) / 100);
  2034. }
  2035. /**
  2036. * the native method number.toLocaleString(undefined, {minimumFractionDigits: 0})
  2037. * puts in decimal places in IE, so we use this method instead
  2038. * from: http://blog.tompawlak.org/number-currency-formatting-javascript
  2039. * @param {number} value
  2040. * @returns {string}
  2041. */
  2042. function formatNumberCommas(value) {
  2043. if (typeof value !== 'number') {
  2044. return '';
  2045. }
  2046. return value.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g, "$1,");
  2047. }
  2048. function sum(values) {
  2049. return values == null ? null : values.reduce(function (total, value) { return total + value; }, 0);
  2050. }
  2051. var NumberUtils = /*#__PURE__*/Object.freeze({
  2052. __proto__: null,
  2053. padStart: padStart,
  2054. createArrayOfNumbers: createArrayOfNumbers,
  2055. isNumeric: isNumeric,
  2056. getMaxSafeInteger: getMaxSafeInteger,
  2057. cleanNumber: cleanNumber,
  2058. decToHex: decToHex,
  2059. formatNumberTwoDecimalPlacesAndCommas: formatNumberTwoDecimalPlacesAndCommas,
  2060. formatNumberCommas: formatNumberCommas,
  2061. sum: sum
  2062. });
  2063. /**
  2064. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  2065. * @version v23.2.1
  2066. * @link http://www.ag-grid.com/
  2067. * @license MIT
  2068. */
  2069. /**
  2070. * Serialises a Date to a string of format `yyyy-MM-dd HH:mm:ss`.
  2071. * An alternative separator can be provided to be used instead of hyphens.
  2072. * @param date The date to serialise
  2073. * @param includeTime Whether to include the time in the serialised string
  2074. * @param separator The separator to use between date parts
  2075. */
  2076. function serialiseDate(date, includeTime, separator) {
  2077. if (includeTime === void 0) { includeTime = true; }
  2078. if (separator === void 0) { separator = '-'; }
  2079. if (!date) {
  2080. return null;
  2081. }
  2082. var serialised = [date.getFullYear(), date.getMonth() + 1, date.getDate()].map(function (part) { return padStart(part, 2); }).join(separator);
  2083. if (includeTime) {
  2084. serialised += ' ' + [date.getHours(), date.getMinutes(), date.getSeconds()].map(function (part) { return padStart(part, 2); }).join(':');
  2085. }
  2086. return serialised;
  2087. }
  2088. /**
  2089. * Parses a date and time from a string in the format `yyyy-MM-dd HH:mm:ss`
  2090. */
  2091. function parseDateTimeFromString(value) {
  2092. if (!value) {
  2093. return null;
  2094. }
  2095. var _a = value.split(' '), dateStr = _a[0], timeStr = _a[1];
  2096. if (!dateStr) {
  2097. return null;
  2098. }
  2099. var fields = dateStr.split('-').map(function (f) { return parseInt(f, 10); });
  2100. if (fields.filter(function (f) { return !isNaN(f); }).length !== 3) {
  2101. return null;
  2102. }
  2103. var year = fields[0], month = fields[1], day = fields[2];
  2104. var date = new Date(year, month - 1, day);
  2105. if (date.getFullYear() !== year ||
  2106. date.getMonth() !== month - 1 ||
  2107. date.getDate() !== day) {
  2108. // date was not parsed as expected so must have been invalid
  2109. return null;
  2110. }
  2111. if (!timeStr || timeStr === '00:00:00') {
  2112. return date;
  2113. }
  2114. var _b = timeStr.split(':').map(function (part) { return parseInt(part, 10); }), hours = _b[0], minutes = _b[1], seconds = _b[2];
  2115. if (hours >= 0 && hours < 24) {
  2116. date.setHours(hours);
  2117. }
  2118. if (minutes >= 0 && minutes < 60) {
  2119. date.setMinutes(minutes);
  2120. }
  2121. if (seconds >= 0 && seconds < 60) {
  2122. date.setSeconds(seconds);
  2123. }
  2124. return date;
  2125. }
  2126. var DateUtils = /*#__PURE__*/Object.freeze({
  2127. __proto__: null,
  2128. serialiseDate: serialiseDate,
  2129. parseDateTimeFromString: parseDateTimeFromString
  2130. });
  2131. /**
  2132. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  2133. * @version v23.2.1
  2134. * @link http://www.ag-grid.com/
  2135. * @license MIT
  2136. */
  2137. var AG_GRID_STOP_PROPAGATION = '__ag_Grid_Stop_Propagation';
  2138. var PASSIVE_EVENTS = ['touchstart', 'touchend', 'touchmove', 'touchcancel'];
  2139. var OUTSIDE_ANGULAR_EVENTS = ['mouseover', 'mouseout', 'mouseenter', 'mouseleave'];
  2140. var supports = {};
  2141. /**
  2142. * a user once raised an issue - they said that when you opened a popup (eg context menu)
  2143. * and then clicked on a selection checkbox, the popup wasn't closed. this is because the
  2144. * popup listens for clicks on the body, however ag-grid WAS stopping propagation on the
  2145. * checkbox clicks (so the rows didn't pick them up as row selection selection clicks).
  2146. * to get around this, we have a pattern to stop propagation for the purposes of ag-Grid,
  2147. * but we still let the event pass back to the body.
  2148. * @param {Event} event
  2149. */
  2150. function stopPropagationForAgGrid(event) {
  2151. event[AG_GRID_STOP_PROPAGATION] = true;
  2152. }
  2153. function isStopPropagationForAgGrid(event) {
  2154. return event[AG_GRID_STOP_PROPAGATION] === true;
  2155. }
  2156. var isEventSupported = (function () {
  2157. var tags = {
  2158. select: 'input',
  2159. change: 'input',
  2160. submit: 'form',
  2161. reset: 'form',
  2162. error: 'img',
  2163. load: 'img',
  2164. abort: 'img'
  2165. };
  2166. var isEventSupported = function (eventName) {
  2167. if (typeof supports[eventName] === 'boolean') {
  2168. return supports[eventName];
  2169. }
  2170. var el = document.createElement(tags[eventName] || 'div');
  2171. eventName = 'on' + eventName;
  2172. var isSupported = (eventName in el);
  2173. if (!isSupported) {
  2174. el.setAttribute(eventName, 'return;');
  2175. isSupported = typeof el[eventName] == 'function';
  2176. }
  2177. el = null;
  2178. return supports[eventName] = isSupported;
  2179. };
  2180. return isEventSupported;
  2181. })();
  2182. function getCellCompForEvent(gridOptionsWrapper, event) {
  2183. var sourceElement = getTarget(event);
  2184. while (sourceElement) {
  2185. var renderedCell = gridOptionsWrapper.getDomData(sourceElement, 'cellComp');
  2186. if (renderedCell) {
  2187. return renderedCell;
  2188. }
  2189. sourceElement = sourceElement.parentElement;
  2190. }
  2191. return null;
  2192. }
  2193. /**
  2194. * @deprecated
  2195. * Adds all type of change listeners to an element, intended to be a text field
  2196. * @param {HTMLElement} element
  2197. * @param {EventListener} listener
  2198. */
  2199. function addChangeListener(element, listener) {
  2200. element.addEventListener('changed', listener);
  2201. element.addEventListener('paste', listener);
  2202. element.addEventListener('input', listener);
  2203. // IE doesn't fire changed for special keys (eg delete, backspace), so need to
  2204. // listen for this further ones
  2205. element.addEventListener('keydown', listener);
  2206. element.addEventListener('keyup', listener);
  2207. }
  2208. /**
  2209. * srcElement is only available in IE. In all other browsers it is target
  2210. * http://stackoverflow.com/questions/5301643/how-can-i-make-event-srcelement-work-in-firefox-and-what-does-it-mean
  2211. * @param {Event} event
  2212. * @returns {Element}
  2213. */
  2214. function getTarget(event) {
  2215. var eventNoType = event;
  2216. return eventNoType.target || eventNoType.srcElement;
  2217. }
  2218. function isElementInEventPath(element, event) {
  2219. if (!event || !element) {
  2220. return false;
  2221. }
  2222. return getEventPath(event).indexOf(element) >= 0;
  2223. }
  2224. function createEventPath(event) {
  2225. var res = [];
  2226. var pointer = getTarget(event);
  2227. while (pointer) {
  2228. res.push(pointer);
  2229. pointer = pointer.parentElement;
  2230. }
  2231. return res;
  2232. }
  2233. /**
  2234. * firefox doesn't have event.path set, or any alternative to it, so we hack
  2235. * it in. this is needed as it's to late to work out the path when the item is
  2236. * removed from the dom. used by MouseEventService, where it works out if a click
  2237. * was from the current grid, or a detail grid (master / detail).
  2238. * @param {Event} event
  2239. */
  2240. function addAgGridEventPath(event) {
  2241. event.__agGridEventPath = getEventPath(event);
  2242. }
  2243. /**
  2244. * Gets the path for an Event.
  2245. * https://stackoverflow.com/questions/39245488/event-path-undefined-with-firefox-and-vue-js
  2246. * https://developer.mozilla.org/en-US/docs/Web/API/Event
  2247. * @param {Event} event
  2248. * @returns {EventTarget[]}
  2249. */
  2250. function getEventPath(event) {
  2251. var eventNoType = event;
  2252. if (eventNoType.deepPath) {
  2253. // IE supports deep path
  2254. return eventNoType.deepPath();
  2255. }
  2256. if (eventNoType.path) {
  2257. // Chrome supports path
  2258. return eventNoType.path;
  2259. }
  2260. if (eventNoType.composedPath) {
  2261. // Firefox supports composePath
  2262. return eventNoType.composedPath();
  2263. }
  2264. if (eventNoType.__agGridEventPath) {
  2265. // Firefox supports composePath
  2266. return eventNoType.__agGridEventPath;
  2267. }
  2268. // and finally, if none of the above worked,
  2269. // we create the path ourselves
  2270. return createEventPath(event);
  2271. }
  2272. function addSafePassiveEventListener(frameworkOverrides, eElement, event, listener) {
  2273. var isPassive = includes(PASSIVE_EVENTS, event);
  2274. var isOutsideAngular = includes(OUTSIDE_ANGULAR_EVENTS, event);
  2275. var options = isPassive ? { passive: true } : undefined;
  2276. if (isOutsideAngular) {
  2277. // this happens in certain scenarios where I believe the user must be destroying the grid somehow but continuing
  2278. // for it to be used
  2279. // don't fall through to the else part either - just don't add the listener
  2280. if (frameworkOverrides && frameworkOverrides.addEventListenerOutsideAngular) {
  2281. frameworkOverrides.addEventListenerOutsideAngular(eElement, event, listener, options);
  2282. }
  2283. }
  2284. else {
  2285. eElement.addEventListener(event, listener, options);
  2286. }
  2287. }
  2288. var EventUtils = /*#__PURE__*/Object.freeze({
  2289. __proto__: null,
  2290. stopPropagationForAgGrid: stopPropagationForAgGrid,
  2291. isStopPropagationForAgGrid: isStopPropagationForAgGrid,
  2292. isEventSupported: isEventSupported,
  2293. getCellCompForEvent: getCellCompForEvent,
  2294. addChangeListener: addChangeListener,
  2295. getTarget: getTarget,
  2296. isElementInEventPath: isElementInEventPath,
  2297. createEventPath: createEventPath,
  2298. addAgGridEventPath: addAgGridEventPath,
  2299. getEventPath: getEventPath,
  2300. addSafePassiveEventListener: addSafePassiveEventListener
  2301. });
  2302. /**
  2303. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  2304. * @version v23.2.1
  2305. * @link http://www.ag-grid.com/
  2306. * @license MIT
  2307. */
  2308. var FUNCTION_STRIP_COMMENTS = /((\/\/.*$)|(\/\*[\s\S]*?\*\/))/mg;
  2309. var FUNCTION_ARGUMENT_NAMES = /([^\s,]+)/g;
  2310. var doOnceFlags = {};
  2311. /**
  2312. * If the key was passed before, then doesn't execute the func
  2313. * @param {Function} func
  2314. * @param {string} key
  2315. */
  2316. function doOnce(func, key) {
  2317. if (doOnceFlags[key]) {
  2318. return;
  2319. }
  2320. func();
  2321. doOnceFlags[key] = true;
  2322. }
  2323. /** @deprecated */
  2324. function getFunctionParameters(func) {
  2325. var fnStr = func.toString().replace(FUNCTION_STRIP_COMMENTS, '');
  2326. return fnStr.slice(fnStr.indexOf('(') + 1, fnStr.indexOf(')')).match(FUNCTION_ARGUMENT_NAMES) || [];
  2327. }
  2328. function isFunction(val) {
  2329. return !!(val && val.constructor && val.call && val.apply);
  2330. }
  2331. function executeInAWhile(funcs) {
  2332. executeAfter(funcs, 400);
  2333. }
  2334. function executeNextVMTurn(funcs) {
  2335. executeAfter(funcs, 0);
  2336. }
  2337. function executeAfter(funcs, milliseconds) {
  2338. if (milliseconds === void 0) { milliseconds = 0; }
  2339. if (funcs.length > 0) {
  2340. window.setTimeout(function () { return funcs.forEach(function (func) { return func(); }); }, milliseconds);
  2341. }
  2342. }
  2343. /**
  2344. * from https://stackoverflow.com/questions/24004791/can-someone-explain-the-debounce-function-in-javascript
  2345. * @param {Function} func The function to be debounced
  2346. * @param {number} wait The time in ms to debounce
  2347. * @param {boolean} immediate If it should run immediately or wait for the initial debounce delay
  2348. * @return {Function} The debounced function
  2349. */
  2350. function debounce(func, wait, immediate) {
  2351. if (immediate === void 0) { immediate = false; }
  2352. // 'private' variable for instance
  2353. // The returned function will be able to reference this due to closure.
  2354. // Each call to the returned function will share this common timer.
  2355. var timeout;
  2356. // Calling debounce returns a new anonymous function
  2357. return function () {
  2358. var args = [];
  2359. for (var _i = 0; _i < arguments.length; _i++) {
  2360. args[_i] = arguments[_i];
  2361. }
  2362. // reference the context and args for the setTimeout function
  2363. var context = this;
  2364. // Should the function be called now? If immediate is true
  2365. // and not already in a timeout then the answer is: Yes
  2366. var callNow = immediate && !timeout;
  2367. // This is the basic debounce behaviour where you can call this
  2368. // function several times, but it will only execute once
  2369. // [before or after imposing a delay].
  2370. // Each time the returned function is called, the timer starts over.
  2371. window.clearTimeout(timeout);
  2372. // Set the new timeout
  2373. timeout = window.setTimeout(function () {
  2374. // Inside the timeout function, clear the timeout variable
  2375. // which will let the next execution run when in 'immediate' mode
  2376. timeout = null;
  2377. // Check if the function already ran with the immediate flag
  2378. if (!immediate) {
  2379. // Call the original function with apply
  2380. // apply lets you define the 'this' object as well as the arguments
  2381. // (both captured before setTimeout)
  2382. func.apply(context, args);
  2383. }
  2384. }, wait);
  2385. // Immediate mode and no wait timer? Execute the function..
  2386. if (callNow) {
  2387. func.apply(context, args);
  2388. }
  2389. };
  2390. }
  2391. function compose() {
  2392. var fns = [];
  2393. for (var _i = 0; _i < arguments.length; _i++) {
  2394. fns[_i] = arguments[_i];
  2395. }
  2396. return function (arg) { return fns.reduce(function (composed, f) { return f(composed); }, arg); };
  2397. }
  2398. function callIfPresent(func) {
  2399. if (func) {
  2400. func();
  2401. }
  2402. }
  2403. var FunctionUtils = /*#__PURE__*/Object.freeze({
  2404. __proto__: null,
  2405. doOnce: doOnce,
  2406. getFunctionParameters: getFunctionParameters,
  2407. isFunction: isFunction,
  2408. executeInAWhile: executeInAWhile,
  2409. executeNextVMTurn: executeNextVMTurn,
  2410. executeAfter: executeAfter,
  2411. debounce: debounce,
  2412. compose: compose,
  2413. callIfPresent: callIfPresent
  2414. });
  2415. /**
  2416. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  2417. * @version v23.2.1
  2418. * @link http://www.ag-grid.com/
  2419. * @license MIT
  2420. */
  2421. function fuzzyCheckStrings(inputValues, validValues, allSuggestions) {
  2422. var fuzzyMatches = {};
  2423. var invalidInputs = inputValues.filter(function (inputValue) {
  2424. return !validValues.some(function (validValue) { return validValue === inputValue; });
  2425. });
  2426. if (invalidInputs.length > 0) {
  2427. invalidInputs.forEach(function (invalidInput) {
  2428. return fuzzyMatches[invalidInput] = fuzzySuggestions(invalidInput, allSuggestions);
  2429. });
  2430. }
  2431. return fuzzyMatches;
  2432. }
  2433. /**
  2434. *
  2435. * @param {String} inputValue The value to be compared against a list of strings
  2436. * @param allSuggestions The list of strings to be compared against
  2437. * @param hideIrrelevant By default, fuzzy suggestions will just sort the allSuggestions list, set this to true
  2438. * to filter out the irrelevant values
  2439. * @param weighted Set this to true, to make letters matched in the order they were typed have priority in the results.
  2440. */
  2441. function fuzzySuggestions(inputValue, allSuggestions, hideIrrelevant, weighted) {
  2442. var search = weighted ? string_weighted_distances : string_distances;
  2443. var thisSuggestions = allSuggestions.map(function (text) { return ({
  2444. value: text,
  2445. relevance: search(inputValue.toLowerCase(), text.toLocaleLowerCase())
  2446. }); });
  2447. thisSuggestions.sort(function (a, b) { return b.relevance - a.relevance; });
  2448. if (hideIrrelevant) {
  2449. thisSuggestions = thisSuggestions.filter(function (suggestion) { return suggestion.relevance !== 0; });
  2450. }
  2451. return thisSuggestions.map(function (suggestion) { return suggestion.value; });
  2452. }
  2453. /**
  2454. * Algorithm to do fuzzy search
  2455. * from https://stackoverflow.com/questions/23305000/javascript-fuzzy-search-that-makes-sense
  2456. * @param {string} from
  2457. * @return {[]}
  2458. */
  2459. function get_bigrams(from) {
  2460. var s = from.toLowerCase();
  2461. var v = new Array(s.length - 1);
  2462. var i;
  2463. var j;
  2464. var ref;
  2465. for (i = j = 0, ref = v.length; j <= ref; i = j += 1) {
  2466. v[i] = s.slice(i, i + 2);
  2467. }
  2468. return v;
  2469. }
  2470. function string_distances(str1, str2) {
  2471. if (str1.length === 0 && str2.length === 0) {
  2472. return 0;
  2473. }
  2474. var pairs1 = get_bigrams(str1);
  2475. var pairs2 = get_bigrams(str2);
  2476. var union = pairs1.length + pairs2.length;
  2477. var hit_count = 0;
  2478. var j;
  2479. var len;
  2480. for (j = 0, len = pairs1.length; j < len; j++) {
  2481. var x = pairs1[j];
  2482. var k = void 0;
  2483. var len1 = void 0;
  2484. for (k = 0, len1 = pairs2.length; k < len1; k++) {
  2485. var y = pairs2[k];
  2486. if (x === y) {
  2487. hit_count++;
  2488. }
  2489. }
  2490. }
  2491. return hit_count > 0 ? (2 * hit_count) / union : 0;
  2492. }
  2493. function string_weighted_distances(str1, str2) {
  2494. var a = str1.replace(/\s/g, '');
  2495. var b = str2.replace(/\s/g, '');
  2496. var weight = 0;
  2497. var lastIndex = 0;
  2498. for (var i = 0; i < a.length; i++) {
  2499. var idx = b.indexOf(a[i]);
  2500. if (idx === -1) {
  2501. continue;
  2502. }
  2503. lastIndex = idx;
  2504. weight += ((b.length - lastIndex) * 100) / b.length;
  2505. weight *= weight;
  2506. }
  2507. return weight;
  2508. }
  2509. var FuzzyMatchUtils = /*#__PURE__*/Object.freeze({
  2510. __proto__: null,
  2511. fuzzyCheckStrings: fuzzyCheckStrings,
  2512. fuzzySuggestions: fuzzySuggestions,
  2513. get_bigrams: get_bigrams,
  2514. string_distances: string_distances,
  2515. string_weighted_distances: string_weighted_distances
  2516. });
  2517. /**
  2518. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  2519. * @version v23.2.1
  2520. * @link http://www.ag-grid.com/
  2521. * @license MIT
  2522. */
  2523. //
  2524. // IMPORTANT NOTE!
  2525. //
  2526. // If you change the list below, copy/paste the new content into the docs page javascript-grid-icons
  2527. //
  2528. var iconNameClassMap = {
  2529. // header column group shown when expanded (click to contract)
  2530. columnGroupOpened: 'expanded',
  2531. // header column group shown when contracted (click to expand)
  2532. columnGroupClosed: 'contracted',
  2533. // tool panel column group contracted (click to expand)
  2534. columnSelectClosed: 'tree-closed',
  2535. // tool panel column group expanded (click to contract)
  2536. columnSelectOpen: 'tree-open',
  2537. // column tool panel header expand/collapse all button, shown when some children are expanded and
  2538. // others are collapsed
  2539. columnSelectIndeterminate: 'tree-indeterminate',
  2540. // shown on ghost icon while dragging column to the side of the grid to pin
  2541. columnMovePin: 'pin',
  2542. // shown on ghost icon while dragging over part of the page that is not a drop zone
  2543. columnMoveHide: 'eye-slash',
  2544. // shown on ghost icon while dragging columns to reorder
  2545. columnMoveMove: 'arrows',
  2546. // animating icon shown when dragging a column to the right of the grid causes horizontal scrolling
  2547. columnMoveLeft: 'left',
  2548. // animating icon shown when dragging a column to the left of the grid causes horizontal scrolling
  2549. columnMoveRight: 'right',
  2550. // shown on ghost icon while dragging over Row Groups drop zone
  2551. columnMoveGroup: 'group',
  2552. // shown on ghost icon while dragging over Values drop zone
  2553. columnMoveValue: 'aggregation',
  2554. // shown on ghost icon while dragging over pivot drop zone
  2555. columnMovePivot: 'pivot',
  2556. // shown on ghost icon while dragging over drop zone that doesn't support it, e.g.
  2557. // string column over aggregation drop zone
  2558. dropNotAllowed: 'not-allowed',
  2559. // shown on row group when contracted (click to expand)
  2560. groupContracted: 'tree-closed',
  2561. // shown on row group when expanded (click to contract)
  2562. groupExpanded: 'tree-open',
  2563. // context menu chart item
  2564. chart: 'chart',
  2565. // chart window title bar
  2566. close: 'cross',
  2567. // X (remove) on column 'pill' after adding it to a drop zone list
  2568. cancel: 'cancel',
  2569. // indicates the currently active pin state in the "Pin column" sub-menu of the column menu
  2570. check: 'tick',
  2571. // "go to first" button in pagination controls
  2572. first: 'first',
  2573. // "go to previous" button in pagination controls
  2574. previous: 'previous',
  2575. // "go to next" button in pagination controls
  2576. next: 'next',
  2577. // "go to last" button in pagination controls
  2578. last: 'last',
  2579. // shown on top right of chart when chart is linked to range data (click to unlink)
  2580. linked: 'linked',
  2581. // shown on top right of chart when chart is not linked to range data (click to link)
  2582. unlinked: 'unlinked',
  2583. // "Choose colour" button on chart settings tab
  2584. colorPicker: 'color-picker',
  2585. // rotating spinner shown by the loading cell renderer
  2586. groupLoading: 'loading',
  2587. // button to launch enterprise column menu
  2588. menu: 'menu',
  2589. // filter tool panel tab
  2590. filter: 'filter',
  2591. // column tool panel tab
  2592. columns: 'columns',
  2593. // button in chart regular size window title bar (click to maximise)
  2594. maximize: 'maximize',
  2595. // button in chart maximised window title bar (click to make regular size)
  2596. minimize: 'minimize',
  2597. // "Pin column" item in column header menu
  2598. menuPin: 'pin',
  2599. // "Value aggregation" column menu item (shown on numeric columns when grouping is active)"
  2600. menuValue: 'aggregation',
  2601. // "Group by {column-name}" item in column header menu
  2602. menuAddRowGroup: 'group',
  2603. // "Un-Group by {column-name}" item in column header menu
  2604. menuRemoveRowGroup: 'group',
  2605. // context menu copy item
  2606. clipboardCopy: 'copy',
  2607. // context menu paste item
  2608. clipboardPaste: 'paste',
  2609. // identifies the pivot drop zone
  2610. pivotPanel: 'pivot',
  2611. // "Row groups" drop zone in column tool panel
  2612. rowGroupPanel: 'group',
  2613. // columns tool panel Values drop zone
  2614. valuePanel: 'aggregation',
  2615. // drag handle used to pick up draggable columns
  2616. columnDrag: 'grip',
  2617. // drag handle used to pick up draggable rows
  2618. rowDrag: 'grip',
  2619. // context menu export item
  2620. save: 'save',
  2621. // icon on dropdown editors
  2622. smallDown: 'small-down',
  2623. // version of small-right used in RTL mode
  2624. smallLeft: 'small-left',
  2625. // separater between column 'pills' when you add multiple columns to the header drop zone
  2626. smallRight: 'small-right',
  2627. smallUp: 'small-up',
  2628. // show on column header when column is sorted ascending
  2629. sortAscending: 'asc',
  2630. // show on column header when column is sorted descending
  2631. sortDescending: 'desc',
  2632. // show on column header when column has no sort, only when enabled with gridOptions.unSortIcon=true
  2633. sortUnSort: 'none'
  2634. };
  2635. /**
  2636. * If icon provided, use this (either a string, or a function callback).
  2637. * if not, then use the default icon from the theme
  2638. * @param {string} iconName
  2639. * @param {GridOptionsWrapper} gridOptionsWrapper
  2640. * @param {Column | null} [column]
  2641. * @returns {HTMLElement}
  2642. */
  2643. function createIcon(iconName, gridOptionsWrapper, column) {
  2644. var iconContents = createIconNoSpan(iconName, gridOptionsWrapper, column);
  2645. if (iconContents.className.indexOf('ag-icon') > -1) {
  2646. return iconContents;
  2647. }
  2648. var eResult = document.createElement('span');
  2649. eResult.appendChild(iconContents);
  2650. return eResult;
  2651. }
  2652. function createIconNoSpan(iconName, gridOptionsWrapper, column, forceCreate) {
  2653. var userProvidedIcon = null;
  2654. // check col for icon first
  2655. var icons = column && column.getColDef().icons;
  2656. if (icons) {
  2657. userProvidedIcon = icons[iconName];
  2658. }
  2659. // if not in col, try grid options
  2660. if (gridOptionsWrapper && !userProvidedIcon) {
  2661. var optionsIcons = gridOptionsWrapper.getIcons();
  2662. if (optionsIcons) {
  2663. userProvidedIcon = optionsIcons[iconName];
  2664. }
  2665. }
  2666. // now if user provided, use it
  2667. if (userProvidedIcon) {
  2668. var rendererResult = void 0;
  2669. if (typeof userProvidedIcon === 'function') {
  2670. rendererResult = userProvidedIcon();
  2671. }
  2672. else if (typeof userProvidedIcon === 'string') {
  2673. rendererResult = userProvidedIcon;
  2674. }
  2675. else {
  2676. throw new Error('icon from grid options needs to be a string or a function');
  2677. }
  2678. if (typeof rendererResult === 'string') {
  2679. return loadTemplate(rendererResult);
  2680. }
  2681. else if (isNodeOrElement(rendererResult)) {
  2682. return rendererResult;
  2683. }
  2684. else {
  2685. console.warn('ag-Grid: iconRenderer should return back a string or a dom object');
  2686. }
  2687. }
  2688. else {
  2689. var span = document.createElement('span');
  2690. var cssClass = iconNameClassMap[iconName];
  2691. if (!cssClass) {
  2692. if (!forceCreate) {
  2693. console.warn("ag-Grid: Did not find icon " + iconName);
  2694. cssClass = '';
  2695. }
  2696. else {
  2697. cssClass = iconName;
  2698. }
  2699. }
  2700. span.setAttribute('class', "ag-icon ag-icon-" + cssClass);
  2701. span.setAttribute("unselectable", "on");
  2702. return span;
  2703. }
  2704. }
  2705. var IconUtils = /*#__PURE__*/Object.freeze({
  2706. __proto__: null,
  2707. iconNameClassMap: iconNameClassMap,
  2708. createIcon: createIcon,
  2709. createIconNoSpan: createIconNoSpan
  2710. });
  2711. /**
  2712. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  2713. * @version v23.2.1
  2714. * @link http://www.ag-grid.com/
  2715. * @license MIT
  2716. */
  2717. var Constants = /** @class */ (function () {
  2718. function Constants() {
  2719. }
  2720. Constants.STEP_EVERYTHING = 0;
  2721. Constants.STEP_FILTER = 1;
  2722. Constants.STEP_SORT = 2;
  2723. Constants.STEP_MAP = 3;
  2724. Constants.STEP_AGGREGATE = 4;
  2725. Constants.STEP_PIVOT = 5;
  2726. Constants.ROW_BUFFER_SIZE = 10;
  2727. Constants.LAYOUT_INTERVAL = 500;
  2728. Constants.BATCH_WAIT_MILLIS = 50;
  2729. Constants.EXPORT_TYPE_DRAG_COPY = 'dragCopy';
  2730. Constants.EXPORT_TYPE_CLIPBOARD = 'clipboard';
  2731. Constants.EXPORT_TYPE_EXCEL = 'excel';
  2732. Constants.EXPORT_TYPE_CSV = 'csv';
  2733. Constants.KEY_BACKSPACE = 8;
  2734. Constants.KEY_TAB = 9;
  2735. Constants.KEY_NEW_LINE = 10;
  2736. Constants.KEY_ENTER = 13;
  2737. Constants.KEY_SHIFT = 16;
  2738. Constants.KEY_ESCAPE = 27;
  2739. Constants.KEY_SPACE = 32;
  2740. Constants.KEY_LEFT = 37;
  2741. Constants.KEY_UP = 38;
  2742. Constants.KEY_RIGHT = 39;
  2743. Constants.KEY_DOWN = 40;
  2744. Constants.KEY_DELETE = 46;
  2745. Constants.KEY_A = 65;
  2746. Constants.KEY_C = 67;
  2747. Constants.KEY_V = 86;
  2748. Constants.KEY_D = 68;
  2749. Constants.KEY_Z = 90;
  2750. Constants.KEY_Y = 89;
  2751. Constants.KEY_F2 = 113;
  2752. Constants.KEY_PAGE_UP = 33;
  2753. Constants.KEY_PAGE_DOWN = 34;
  2754. Constants.KEY_PAGE_HOME = 36;
  2755. Constants.KEY_PAGE_END = 35;
  2756. Constants.ROW_MODEL_TYPE_INFINITE = 'infinite';
  2757. Constants.ROW_MODEL_TYPE_VIEWPORT = 'viewport';
  2758. Constants.ROW_MODEL_TYPE_CLIENT_SIDE = 'clientSide';
  2759. Constants.ROW_MODEL_TYPE_SERVER_SIDE = 'serverSide';
  2760. Constants.DEPRECATED_ROW_MODEL_TYPE_NORMAL = 'normal';
  2761. Constants.ALWAYS = 'always';
  2762. Constants.ONLY_WHEN_GROUPING = 'onlyWhenGrouping';
  2763. Constants.PINNED_TOP = 'top';
  2764. Constants.PINNED_BOTTOM = 'bottom';
  2765. Constants.DOM_LAYOUT_NORMAL = 'normal';
  2766. Constants.DOM_LAYOUT_PRINT = 'print';
  2767. Constants.DOM_LAYOUT_AUTO_HEIGHT = 'autoHeight';
  2768. Constants.GROUP_AUTO_COLUMN_ID = 'ag-Grid-AutoColumn';
  2769. Constants.SOURCE_PASTE = 'paste';
  2770. Constants.PINNED_RIGHT = 'right';
  2771. Constants.PINNED_LEFT = 'left';
  2772. Constants.SORT_ASC = 'asc';
  2773. Constants.SORT_DESC = 'desc';
  2774. return Constants;
  2775. }());
  2776. /**
  2777. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  2778. * @version v23.2.1
  2779. * @link http://www.ag-grid.com/
  2780. * @license MIT
  2781. */
  2782. var PRINTABLE_CHARACTERS = 'qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM1234567890!"£$%^&*()_+-=[];\'#,./\\|<>?:@~{}';
  2783. var NUMPAD_DEL_NUMLOCK_ON_KEY = 'Del';
  2784. var NUMPAD_DEL_NUMLOCK_ON_CHARCODE = 46;
  2785. function isKeyPressed(event, keyToCheck) {
  2786. return (event.which || event.keyCode) === keyToCheck;
  2787. }
  2788. function isCharacterKey(event) {
  2789. // from: https://stackoverflow.com/questions/4179708/how-to-detect-if-the-pressed-key-will-produce-a-character-inside-an-input-text
  2790. var which = event.which;
  2791. if (typeof which === 'number' && which) {
  2792. return !event.ctrlKey && !event.metaKey && !event.altKey && event.which !== 8 && event.which !== 16;
  2793. }
  2794. return which === undefined;
  2795. }
  2796. function isEventFromPrintableCharacter(event) {
  2797. var pressedChar = String.fromCharCode(event.charCode);
  2798. // newline is an exception, as it counts as a printable character, but we don't
  2799. // want to start editing when it is pressed. without this check, if user is in chrome
  2800. // and editing a cell, and they press ctrl+enter, the cell stops editing, and then
  2801. // starts editing again with a blank value (two 'key down' events are fired). to
  2802. // test this, remove the line below, edit a cell in chrome and hit ctrl+enter while editing.
  2803. // https://ag-grid.atlassian.net/browse/AG-605
  2804. if (isKeyPressed(event, Constants.KEY_NEW_LINE)) {
  2805. return false;
  2806. }
  2807. // no allowed printable chars have alt or ctrl key combinations
  2808. if (event.altKey || event.ctrlKey) {
  2809. return false;
  2810. }
  2811. if (exists(event.key)) {
  2812. // modern browser will implement key, so we return if key is length 1, eg if it is 'a' for the
  2813. // a key, or '2' for the '2' key. non-printable characters have names, eg 'Enter' or 'Backspace'.
  2814. var printableCharacter = event.key.length === 1;
  2815. // IE11 & Edge treat the numpad del key differently - with numlock on we get "Del" for key,
  2816. // so this addition checks if its IE11/Edge and handles that specific case the same was as all other browsers
  2817. var numpadDelWithNumlockOnForEdgeOrIe = isNumpadDelWithNumlockOnForEdgeOrIe(event);
  2818. return printableCharacter || numpadDelWithNumlockOnForEdgeOrIe;
  2819. }
  2820. // otherwise, for older browsers, we test against a list of characters, which doesn't include
  2821. // accents for non-English, but don't care much, as most users are on modern browsers
  2822. return PRINTABLE_CHARACTERS.indexOf(pressedChar) >= 0;
  2823. }
  2824. /**
  2825. * Allows user to tell the grid to skip specific keyboard events
  2826. * @param {GridOptionsWrapper} gridOptionsWrapper
  2827. * @param {KeyboardEvent} keyboardEvent
  2828. * @param {RowNode} rowNode
  2829. * @param {Column} column
  2830. * @param {boolean} editing
  2831. * @returns {boolean}
  2832. */
  2833. function isUserSuppressingKeyboardEvent(gridOptionsWrapper, keyboardEvent, rowNode, column, editing) {
  2834. var gridOptionsFunc = gridOptionsWrapper.getSuppressKeyboardEventFunc();
  2835. var colDefFunc = column.getColDef().suppressKeyboardEvent;
  2836. // if no callbacks provided by user, then do nothing
  2837. if (!gridOptionsFunc && !colDefFunc) {
  2838. return false;
  2839. }
  2840. var params = {
  2841. event: keyboardEvent,
  2842. editing: editing,
  2843. column: column,
  2844. api: gridOptionsWrapper.getApi(),
  2845. node: rowNode,
  2846. data: rowNode.data,
  2847. colDef: column.getColDef(),
  2848. context: gridOptionsWrapper.getContext(),
  2849. columnApi: gridOptionsWrapper.getColumnApi()
  2850. };
  2851. // colDef get first preference on suppressing events
  2852. if (colDefFunc) {
  2853. var colDefFuncResult = colDefFunc(params);
  2854. // if colDef func suppressed, then return now, no need to call gridOption func
  2855. if (colDefFuncResult) {
  2856. return true;
  2857. }
  2858. }
  2859. if (gridOptionsFunc) {
  2860. // if gridOption func, return the result
  2861. return gridOptionsFunc(params);
  2862. }
  2863. // otherwise return false, don't suppress, as colDef didn't suppress and no func on gridOptions
  2864. return false;
  2865. }
  2866. function isNumpadDelWithNumlockOnForEdgeOrIe(event) {
  2867. return (isBrowserEdge() || isBrowserIE()) &&
  2868. event.key === NUMPAD_DEL_NUMLOCK_ON_KEY &&
  2869. event.charCode === NUMPAD_DEL_NUMLOCK_ON_CHARCODE;
  2870. }
  2871. var KeyboardUtils = /*#__PURE__*/Object.freeze({
  2872. __proto__: null,
  2873. isKeyPressed: isKeyPressed,
  2874. isCharacterKey: isCharacterKey,
  2875. isEventFromPrintableCharacter: isEventFromPrintableCharacter,
  2876. isUserSuppressingKeyboardEvent: isUserSuppressingKeyboardEvent
  2877. });
  2878. /**
  2879. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  2880. * @version v23.2.1
  2881. * @link http://www.ag-grid.com/
  2882. * @license MIT
  2883. */
  2884. function keys(map) {
  2885. var keys = [];
  2886. map.forEach(function (_, key) { return keys.push(key); });
  2887. return keys;
  2888. }
  2889. var MapUtils = /*#__PURE__*/Object.freeze({
  2890. __proto__: null,
  2891. keys: keys
  2892. });
  2893. /**
  2894. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  2895. * @version v23.2.1
  2896. * @link http://www.ag-grid.com/
  2897. * @license MIT
  2898. */
  2899. /**
  2900. * @deprecated
  2901. * Mouse wheel (and 2-finger trackpad) support on the web sucks. It is
  2902. * complicated, thus this doc is long and (hopefully) detailed enough to answer
  2903. * your questions.
  2904. *
  2905. * If you need to react to the mouse wheel in a predictable way, this code is
  2906. * like your bestest friend. * hugs *
  2907. *
  2908. * As of today, there are 4 DOM event types you can listen to:
  2909. *
  2910. * 'wheel' -- Chrome(31+), FF(17+), IE(9+)
  2911. * 'mousewheel' -- Chrome, IE(6+), Opera, Safari
  2912. * 'MozMousePixelScroll' -- FF(3.5 only!) (2010-2013) -- don't bother!
  2913. * 'DOMMouseScroll' -- FF(0.9.7+) since 2003
  2914. *
  2915. * So what to do? The is the best:
  2916. *
  2917. * normalizeWheel.getEventType();
  2918. *
  2919. * In your event callback, use this code to get sane interpretation of the
  2920. * deltas. This code will return an object with properties:
  2921. *
  2922. * spinX -- normalized spin speed (use for zoom) - x plane
  2923. * spinY -- " - y plane
  2924. * pixelX -- normalized distance (to pixels) - x plane
  2925. * pixelY -- " - y plane
  2926. *
  2927. * Wheel values are provided by the browser assuming you are using the wheel to
  2928. * scroll a web page by a number of lines or pixels (or pages). Values can vary
  2929. * significantly on different platforms and browsers, forgetting that you can
  2930. * scroll at different speeds. Some devices (like trackpads) emit more events
  2931. * at smaller increments with fine granularity, and some emit massive jumps with
  2932. * linear speed or acceleration.
  2933. *
  2934. * This code does its best to normalize the deltas for you:
  2935. *
  2936. * - spin is trying to normalize how far the wheel was spun (or trackpad
  2937. * dragged). This is super useful for zoom support where you want to
  2938. * throw away the chunky scroll steps on the PC and make those equal to
  2939. * the slow and smooth tiny steps on the Mac. Key data: This code tries to
  2940. * resolve a single slow step on a wheel to 1.
  2941. *
  2942. * - pixel is normalizing the desired scroll delta in pixel units. You'll
  2943. * get the crazy differences between browsers, but at least it'll be in
  2944. * pixels!
  2945. *
  2946. * - positive value indicates scrolling DOWN/RIGHT, negative UP/LEFT. This
  2947. * should translate to positive value zooming IN, negative zooming OUT.
  2948. * This matches the newer 'wheel' event.
  2949. *
  2950. * Why are there spinX, spinY (or pixels)?
  2951. *
  2952. * - spinX is a 2-finger side drag on the trackpad, and a shift + wheel turn
  2953. * with a mouse. It results in side-scrolling in the browser by default.
  2954. *
  2955. * - spinY is what you expect -- it's the classic axis of a mouse wheel.
  2956. *
  2957. * - I dropped spinZ/pixelZ. It is supported by the DOM 3 'wheel' event and
  2958. * probably is by browsers in conjunction with fancy 3D controllers .. but
  2959. * you know.
  2960. *
  2961. * Implementation info:
  2962. *
  2963. * Examples of 'wheel' event if you scroll slowly (down) by one step with an
  2964. * average mouse:
  2965. *
  2966. * OS X + Chrome (mouse) - 4 pixel delta (wheelDelta -120)
  2967. * OS X + Safari (mouse) - N/A pixel delta (wheelDelta -12)
  2968. * OS X + Firefox (mouse) - 0.1 line delta (wheelDelta N/A)
  2969. * Win8 + Chrome (mouse) - 100 pixel delta (wheelDelta -120)
  2970. * Win8 + Firefox (mouse) - 3 line delta (wheelDelta -120)
  2971. *
  2972. * On the trackpad:
  2973. *
  2974. * OS X + Chrome (trackpad) - 2 pixel delta (wheelDelta -6)
  2975. * OS X + Firefox (trackpad) - 1 pixel delta (wheelDelta N/A)
  2976. *
  2977. * On other/older browsers.. it's more complicated as there can be multiple and
  2978. * also missing delta values.
  2979. *
  2980. * The 'wheel' event is more standard:
  2981. *
  2982. * http://www.w3.org/TR/DOM-Level-3-Events/#events-wheelevents
  2983. *
  2984. * The basics is that it includes a unit, deltaMode (pixels, lines, pages), and
  2985. * deltaX, deltaY and deltaZ. Some browsers provide other values to maintain
  2986. * backward compatibility with older events. Those other values help us
  2987. * better normalize spin speed. Example of what the browsers provide:
  2988. *
  2989. * | event.wheelDelta | event.detail
  2990. * ------------------+------------------+--------------
  2991. * Safari v5/OS X | -120 | 0
  2992. * Safari v5/Win7 | -120 | 0
  2993. * Chrome v17/OS X | -120 | 0
  2994. * Chrome v17/Win7 | -120 | 0
  2995. * IE9/Win7 | -120 | undefined
  2996. * Firefox v4/OS X | undefined | 1
  2997. * Firefox v4/Win7 | undefined | 3
  2998. *
  2999. * from: https://github.com/facebook/fixed-data-table/blob/master/src/vendor_upstream/dom/normalizeWheel.js
  3000. * @param {any} event
  3001. * @return {any}
  3002. */
  3003. function normalizeWheel(event) {
  3004. var PIXEL_STEP = 10;
  3005. var LINE_HEIGHT = 40;
  3006. var PAGE_HEIGHT = 800;
  3007. // spinX, spinY
  3008. var sX = 0;
  3009. var sY = 0;
  3010. // pixelX, pixelY
  3011. var pX = 0;
  3012. var pY = 0;
  3013. // Legacy
  3014. if ('detail' in event) {
  3015. sY = event.detail;
  3016. }
  3017. if ('wheelDelta' in event) {
  3018. sY = -event.wheelDelta / 120;
  3019. }
  3020. if ('wheelDeltaY' in event) {
  3021. sY = -event.wheelDeltaY / 120;
  3022. }
  3023. if ('wheelDeltaX' in event) {
  3024. sX = -event.wheelDeltaX / 120;
  3025. }
  3026. // side scrolling on FF with DOMMouseScroll
  3027. if ('axis' in event && event.axis === event.HORIZONTAL_AXIS) {
  3028. sX = sY;
  3029. sY = 0;
  3030. }
  3031. pX = sX * PIXEL_STEP;
  3032. pY = sY * PIXEL_STEP;
  3033. if ('deltaY' in event) {
  3034. pY = event.deltaY;
  3035. }
  3036. if ('deltaX' in event) {
  3037. pX = event.deltaX;
  3038. }
  3039. if ((pX || pY) && event.deltaMode) {
  3040. if (event.deltaMode == 1) { // delta in LINE units
  3041. pX *= LINE_HEIGHT;
  3042. pY *= LINE_HEIGHT;
  3043. }
  3044. else { // delta in PAGE units
  3045. pX *= PAGE_HEIGHT;
  3046. pY *= PAGE_HEIGHT;
  3047. }
  3048. }
  3049. // Fall-back if spin cannot be determined
  3050. if (pX && !sX) {
  3051. sX = (pX < 1) ? -1 : 1;
  3052. }
  3053. if (pY && !sY) {
  3054. sY = (pY < 1) ? -1 : 1;
  3055. }
  3056. return {
  3057. spinX: sX,
  3058. spinY: sY,
  3059. pixelX: pX,
  3060. pixelY: pY
  3061. };
  3062. }
  3063. /**
  3064. * @deprecated
  3065. * Checks if event was issued by a left click
  3066. * from https://stackoverflow.com/questions/3944122/detect-left-mouse-button-press
  3067. * @param {MouseEvent} mouseEvent
  3068. * @returns {boolean}
  3069. */
  3070. function isLeftClick(mouseEvent) {
  3071. if ('buttons' in mouseEvent) {
  3072. return mouseEvent.buttons == 1;
  3073. }
  3074. var button = mouseEvent.which || mouseEvent.button;
  3075. return button == 1;
  3076. }
  3077. /**
  3078. * `True` if the event is close to the original event by X pixels either vertically or horizontally.
  3079. * we only start dragging after X pixels so this allows us to know if we should start dragging yet.
  3080. * @param {MouseEvent | TouchEvent} e1
  3081. * @param {MouseEvent | TouchEvent} e2
  3082. * @param {number} pixelCount
  3083. * @returns {boolean}
  3084. */
  3085. function areEventsNear(e1, e2, pixelCount) {
  3086. // by default, we wait 4 pixels before starting the drag
  3087. if (pixelCount === 0) {
  3088. return false;
  3089. }
  3090. var diffX = Math.abs(e1.clientX - e2.clientX);
  3091. var diffY = Math.abs(e1.clientY - e2.clientY);
  3092. return Math.max(diffX, diffY) <= pixelCount;
  3093. }
  3094. var MouseUtils = /*#__PURE__*/Object.freeze({
  3095. __proto__: null,
  3096. normalizeWheel: normalizeWheel,
  3097. isLeftClick: isLeftClick,
  3098. areEventsNear: areEventsNear
  3099. });
  3100. /**
  3101. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  3102. * @version v23.2.1
  3103. * @link http://www.ag-grid.com/
  3104. * @license MIT
  3105. */
  3106. /**
  3107. * Gets called by: a) ClientSideNodeManager and b) GroupStage to do sorting.
  3108. * when in ClientSideNodeManager we always have indexes (as this sorts the items the
  3109. * user provided) but when in GroupStage, the nodes can contain filler nodes that
  3110. * don't have order id's
  3111. * @param {RowNode[]} rowNodes
  3112. * @param {Object} rowNodeOrder
  3113. */
  3114. function sortRowNodesByOrder(rowNodes, rowNodeOrder) {
  3115. if (!rowNodes) {
  3116. return;
  3117. }
  3118. var comparator = function (nodeA, nodeB) {
  3119. var positionA = rowNodeOrder[nodeA.id];
  3120. var positionB = rowNodeOrder[nodeB.id];
  3121. var aHasIndex = positionA !== undefined;
  3122. var bHasIndex = positionB !== undefined;
  3123. var bothNodesAreUserNodes = aHasIndex && bHasIndex;
  3124. var bothNodesAreFillerNodes = !aHasIndex && !bHasIndex;
  3125. if (bothNodesAreUserNodes) {
  3126. // when comparing two nodes the user has provided, they always
  3127. // have indexes
  3128. return positionA - positionB;
  3129. }
  3130. if (bothNodesAreFillerNodes) {
  3131. // when comparing two filler nodes, we have no index to compare them
  3132. // against, however we want this sorting to be deterministic, so that
  3133. // the rows don't jump around as the user does delta updates. so we
  3134. // want the same sort result. so we use the __objectId - which doesn't make sense
  3135. // from a sorting point of view, but does give consistent behaviour between
  3136. // calls. otherwise groups jump around as delta updates are done.
  3137. // note: previously here we used nodeId, however this gave a strange order
  3138. // as string ordering of numbers is wrong, so using id based on creation order
  3139. // as least gives better looking order.
  3140. return nodeA.__objectId - nodeB.__objectId;
  3141. }
  3142. if (aHasIndex) {
  3143. return 1;
  3144. }
  3145. return -1;
  3146. };
  3147. // check if the list first needs sorting
  3148. var rowNodeA;
  3149. var rowNodeB;
  3150. var atLeastOneOutOfOrder = false;
  3151. for (var i = 0; i < rowNodes.length - 1; i++) {
  3152. rowNodeA = rowNodes[i];
  3153. rowNodeB = rowNodes[i + 1];
  3154. if (comparator(rowNodeA, rowNodeB) > 0) {
  3155. atLeastOneOutOfOrder = true;
  3156. break;
  3157. }
  3158. }
  3159. if (atLeastOneOutOfOrder) {
  3160. rowNodes.sort(comparator);
  3161. }
  3162. }
  3163. function traverseNodesWithKey(nodes, callback) {
  3164. var keyParts = [];
  3165. recursiveSearchNodes(nodes);
  3166. function recursiveSearchNodes(currentNodes) {
  3167. currentNodes.forEach(function (node) {
  3168. // also checking for children for tree data
  3169. if (node.group || node.hasChildren()) {
  3170. keyParts.push(node.key);
  3171. var key = keyParts.join('|');
  3172. callback(node, key);
  3173. recursiveSearchNodes(node.childrenAfterGroup);
  3174. keyParts.pop();
  3175. }
  3176. });
  3177. }
  3178. }
  3179. var RowNodeUtils = /*#__PURE__*/Object.freeze({
  3180. __proto__: null,
  3181. sortRowNodesByOrder: sortRowNodesByOrder,
  3182. traverseNodesWithKey: traverseNodesWithKey
  3183. });
  3184. /**
  3185. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  3186. * @version v23.2.1
  3187. * @link http://www.ag-grid.com/
  3188. * @license MIT
  3189. */
  3190. function convertToSet(list) {
  3191. var set = new Set();
  3192. list.forEach(function (x) { return set.add(x); });
  3193. return set;
  3194. }
  3195. var SetUtils = /*#__PURE__*/Object.freeze({
  3196. __proto__: null,
  3197. convertToSet: convertToSet
  3198. });
  3199. /**
  3200. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  3201. * @version v23.2.1
  3202. * @link http://www.ag-grid.com/
  3203. * @license MIT
  3204. */
  3205. var __assign = (undefined && undefined.__assign) || function () {
  3206. __assign = Object.assign || function(t) {
  3207. for (var s, i = 1, n = arguments.length; i < n; i++) {
  3208. s = arguments[i];
  3209. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
  3210. t[p] = s[p];
  3211. }
  3212. return t;
  3213. };
  3214. return __assign.apply(this, arguments);
  3215. };
  3216. var utils = __assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign({}, GeneralUtils), ArrayUtils), BrowserUtils), CsvUtils), DateUtils), DomUtils), EventUtils), FunctionUtils), FuzzyMatchUtils), GenericUtils), IconUtils), KeyboardUtils), MapUtils), MouseUtils), NumberUtils), ObjectUtils), RowNodeUtils), SetUtils), StringUtils);
  3217. var _ = utils;
  3218. /**
  3219. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  3220. * @version v23.2.1
  3221. * @link http://www.ag-grid.com/
  3222. * @license MIT
  3223. */
  3224. var NumberSequence = /** @class */ (function () {
  3225. function NumberSequence(initValue, step) {
  3226. if (initValue === void 0) { initValue = 0; }
  3227. if (step === void 0) { step = 1; }
  3228. this.nextValue = initValue;
  3229. this.step = step;
  3230. }
  3231. NumberSequence.prototype.next = function () {
  3232. var valToReturn = this.nextValue;
  3233. this.nextValue += this.step;
  3234. return valToReturn;
  3235. };
  3236. NumberSequence.prototype.peek = function () {
  3237. return this.nextValue;
  3238. };
  3239. NumberSequence.prototype.skip = function (count) {
  3240. this.nextValue += count;
  3241. };
  3242. return NumberSequence;
  3243. }());
  3244. /**
  3245. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  3246. * @version v23.2.1
  3247. * @link http://www.ag-grid.com/
  3248. * @license MIT
  3249. */
  3250. (function (PromiseStatus) {
  3251. PromiseStatus[PromiseStatus["IN_PROGRESS"] = 0] = "IN_PROGRESS";
  3252. PromiseStatus[PromiseStatus["RESOLVED"] = 1] = "RESOLVED";
  3253. })(exports.PromiseStatus || (exports.PromiseStatus = {}));
  3254. var Promise = /** @class */ (function () {
  3255. function Promise(callback) {
  3256. var _this = this;
  3257. this.status = exports.PromiseStatus.IN_PROGRESS;
  3258. this.resolution = null;
  3259. this.waiters = [];
  3260. callback(function (value) { return _this.onDone(value); }, function (params) { return _this.onReject(params); });
  3261. }
  3262. Promise.all = function (promises) {
  3263. return new Promise(function (resolve) {
  3264. var remainingToResolve = promises.length;
  3265. var combinedValues = new Array(remainingToResolve);
  3266. forEach(promises, function (promise, index) {
  3267. promise.then(function (value) {
  3268. combinedValues[index] = value;
  3269. remainingToResolve--;
  3270. if (remainingToResolve === 0) {
  3271. resolve(combinedValues);
  3272. }
  3273. });
  3274. });
  3275. });
  3276. };
  3277. Promise.resolve = function (value) {
  3278. if (value === void 0) { value = null; }
  3279. return new Promise(function (resolve) { return resolve(value); });
  3280. };
  3281. Promise.prototype.then = function (func) {
  3282. var _this = this;
  3283. return new Promise(function (resolve) {
  3284. if (_this.status === exports.PromiseStatus.RESOLVED) {
  3285. resolve(func(_this.resolution));
  3286. }
  3287. else {
  3288. _this.waiters.push(function (value) { return resolve(func(value)); });
  3289. }
  3290. });
  3291. };
  3292. Promise.prototype.resolveNow = function (ifNotResolvedValue, ifResolved) {
  3293. return this.status === exports.PromiseStatus.RESOLVED ? ifResolved(this.resolution) : ifNotResolvedValue;
  3294. };
  3295. Promise.prototype.onDone = function (value) {
  3296. this.status = exports.PromiseStatus.RESOLVED;
  3297. this.resolution = value;
  3298. forEach(this.waiters, function (waiter) { return waiter(value); });
  3299. };
  3300. Promise.prototype.onReject = function (params) {
  3301. console.warn('TBI');
  3302. };
  3303. return Promise;
  3304. }());
  3305. /**
  3306. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  3307. * @version v23.2.1
  3308. * @link http://www.ag-grid.com/
  3309. * @license MIT
  3310. */
  3311. /**
  3312. * A Util Class only used when debugging for printing time to console
  3313. */
  3314. var Timer = /** @class */ (function () {
  3315. function Timer() {
  3316. this.timestamp = new Date().getTime();
  3317. }
  3318. Timer.prototype.print = function (msg) {
  3319. var duration = (new Date().getTime()) - this.timestamp;
  3320. console.info(msg + " = " + duration);
  3321. this.timestamp = new Date().getTime();
  3322. };
  3323. return Timer;
  3324. }());
  3325. /**
  3326. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  3327. * @version v23.2.1
  3328. * @link http://www.ag-grid.com/
  3329. * @license MIT
  3330. */
  3331. var ColumnKeyCreator = /** @class */ (function () {
  3332. function ColumnKeyCreator() {
  3333. this.existingKeys = {};
  3334. }
  3335. ColumnKeyCreator.prototype.addExistingKeys = function (keys) {
  3336. for (var i = 0; i < keys.length; i++) {
  3337. this.existingKeys[keys[i]] = true;
  3338. }
  3339. };
  3340. ColumnKeyCreator.prototype.getUniqueKey = function (colId, colField) {
  3341. // in case user passed in number for colId, convert to string
  3342. colId = _.toStringOrNull(colId);
  3343. var count = 0;
  3344. while (true) {
  3345. var idToTry = void 0;
  3346. if (colId) {
  3347. idToTry = colId;
  3348. if (count !== 0) {
  3349. idToTry += '_' + count;
  3350. }
  3351. }
  3352. else if (colField) {
  3353. idToTry = colField;
  3354. if (count !== 0) {
  3355. idToTry += '_' + count;
  3356. }
  3357. }
  3358. else {
  3359. idToTry = '' + count;
  3360. }
  3361. if (!this.existingKeys[idToTry]) {
  3362. this.existingKeys[idToTry] = true;
  3363. return idToTry;
  3364. }
  3365. count++;
  3366. }
  3367. };
  3368. return ColumnKeyCreator;
  3369. }());
  3370. /**
  3371. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  3372. * @version v23.2.1
  3373. * @link http://www.ag-grid.com/
  3374. * @license MIT
  3375. */
  3376. var Context = /** @class */ (function () {
  3377. function Context(params, logger) {
  3378. this.beanWrappers = {};
  3379. this.destroyed = false;
  3380. if (!params || !params.beanClasses) {
  3381. return;
  3382. }
  3383. this.contextParams = params;
  3384. this.logger = logger;
  3385. this.logger.log(">> creating ag-Application Context");
  3386. this.createBeans();
  3387. var beanInstances = this.getBeanInstances();
  3388. this.wireBeans(beanInstances);
  3389. this.logger.log(">> ag-Application Context ready - component is alive");
  3390. }
  3391. Context.prototype.getBeanInstances = function () {
  3392. return _.values(this.beanWrappers).map(function (beanEntry) { return beanEntry.beanInstance; });
  3393. };
  3394. Context.prototype.createBean = function (bean, afterPreCreateCallback) {
  3395. if (!bean) {
  3396. throw Error("Can't wire to bean since it is null");
  3397. }
  3398. this.wireBeans([bean], afterPreCreateCallback);
  3399. return bean;
  3400. };
  3401. Context.prototype.wireBeans = function (beanInstances, afterPreCreateCallback) {
  3402. this.autoWireBeans(beanInstances);
  3403. this.methodWireBeans(beanInstances);
  3404. this.callLifeCycleMethods(beanInstances, 'preConstructMethods');
  3405. // the callback sets the attributes, so the component has access to attributes
  3406. // before postConstruct methods in the component are executed
  3407. if (_.exists(afterPreCreateCallback)) {
  3408. beanInstances.forEach(afterPreCreateCallback);
  3409. }
  3410. this.callLifeCycleMethods(beanInstances, 'postConstructMethods');
  3411. };
  3412. Context.prototype.createBeans = function () {
  3413. var _this = this;
  3414. // register all normal beans
  3415. this.contextParams.beanClasses.forEach(this.createBeanWrapper.bind(this));
  3416. // register override beans, these will overwrite beans above of same name
  3417. // instantiate all beans - overridden beans will be left out
  3418. _.iterateObject(this.beanWrappers, function (key, beanEntry) {
  3419. var constructorParamsMeta;
  3420. if (beanEntry.bean.__agBeanMetaData && beanEntry.bean.__agBeanMetaData.autowireMethods && beanEntry.bean.__agBeanMetaData.autowireMethods.agConstructor) {
  3421. constructorParamsMeta = beanEntry.bean.__agBeanMetaData.autowireMethods.agConstructor;
  3422. }
  3423. var constructorParams = _this.getBeansForParameters(constructorParamsMeta, beanEntry.bean.name);
  3424. var newInstance = applyToConstructor(beanEntry.bean, constructorParams);
  3425. beanEntry.beanInstance = newInstance;
  3426. });
  3427. var createdBeanNames = Object.keys(this.beanWrappers).join(', ');
  3428. this.logger.log("created beans: " + createdBeanNames);
  3429. };
  3430. // tslint:disable-next-line
  3431. Context.prototype.createBeanWrapper = function (Bean) {
  3432. var metaData = Bean.__agBeanMetaData;
  3433. if (!metaData) {
  3434. var beanName = void 0;
  3435. if (Bean.prototype.constructor) {
  3436. beanName = Bean.prototype.constructor.name;
  3437. }
  3438. else {
  3439. beanName = "" + Bean;
  3440. }
  3441. console.error("context item " + beanName + " is not a bean");
  3442. return;
  3443. }
  3444. var beanEntry = {
  3445. bean: Bean,
  3446. beanInstance: null,
  3447. beanName: metaData.beanName
  3448. };
  3449. this.beanWrappers[metaData.beanName] = beanEntry;
  3450. };
  3451. Context.prototype.autoWireBeans = function (beanInstances) {
  3452. var _this = this;
  3453. beanInstances.forEach(function (beanInstance) {
  3454. _this.forEachMetaDataInHierarchy(beanInstance, function (metaData, beanName) {
  3455. var attributes = metaData.agClassAttributes;
  3456. if (!attributes) {
  3457. return;
  3458. }
  3459. attributes.forEach(function (attribute) {
  3460. var otherBean = _this.lookupBeanInstance(beanName, attribute.beanName, attribute.optional);
  3461. beanInstance[attribute.attributeName] = otherBean;
  3462. });
  3463. });
  3464. });
  3465. };
  3466. Context.prototype.methodWireBeans = function (beanInstances) {
  3467. var _this = this;
  3468. beanInstances.forEach(function (beanInstance) {
  3469. _this.forEachMetaDataInHierarchy(beanInstance, function (metaData, beanName) {
  3470. _.iterateObject(metaData.autowireMethods, function (methodName, wireParams) {
  3471. // skip constructor, as this is dealt with elsewhere
  3472. if (methodName === "agConstructor") {
  3473. return;
  3474. }
  3475. var initParams = _this.getBeansForParameters(wireParams, beanName);
  3476. beanInstance[methodName].apply(beanInstance, initParams);
  3477. });
  3478. });
  3479. });
  3480. };
  3481. Context.prototype.forEachMetaDataInHierarchy = function (beanInstance, callback) {
  3482. var prototype = Object.getPrototypeOf(beanInstance);
  3483. while (prototype != null) {
  3484. var constructor = prototype.constructor;
  3485. if (constructor.hasOwnProperty('__agBeanMetaData')) {
  3486. var metaData = constructor.__agBeanMetaData;
  3487. var beanName = this.getBeanName(constructor);
  3488. callback(metaData, beanName);
  3489. }
  3490. prototype = Object.getPrototypeOf(prototype);
  3491. }
  3492. };
  3493. Context.prototype.getBeanName = function (constructor) {
  3494. if (constructor.__agBeanMetaData && constructor.__agBeanMetaData.beanName) {
  3495. return constructor.__agBeanMetaData.beanName;
  3496. }
  3497. var constructorString = constructor.toString();
  3498. var beanName = constructorString.substring(9, constructorString.indexOf("("));
  3499. return beanName;
  3500. };
  3501. Context.prototype.getBeansForParameters = function (parameters, beanName) {
  3502. var _this = this;
  3503. var beansList = [];
  3504. if (parameters) {
  3505. _.iterateObject(parameters, function (paramIndex, otherBeanName) {
  3506. var otherBean = _this.lookupBeanInstance(beanName, otherBeanName);
  3507. beansList[Number(paramIndex)] = otherBean;
  3508. });
  3509. }
  3510. return beansList;
  3511. };
  3512. Context.prototype.lookupBeanInstance = function (wiringBean, beanName, optional) {
  3513. if (optional === void 0) { optional = false; }
  3514. if (beanName === "context") {
  3515. return this;
  3516. }
  3517. else if (this.contextParams.providedBeanInstances && this.contextParams.providedBeanInstances.hasOwnProperty(beanName)) {
  3518. return this.contextParams.providedBeanInstances[beanName];
  3519. }
  3520. else {
  3521. var beanEntry = this.beanWrappers[beanName];
  3522. if (beanEntry) {
  3523. return beanEntry.beanInstance;
  3524. }
  3525. if (!optional) {
  3526. console.error("ag-Grid: unable to find bean reference " + beanName + " while initialising " + wiringBean);
  3527. }
  3528. return null;
  3529. }
  3530. };
  3531. Context.prototype.callLifeCycleMethods = function (beanInstances, lifeCycleMethod) {
  3532. var _this = this;
  3533. beanInstances.forEach(function (beanInstance) {
  3534. _this.callLifeCycleMethodsOneBean(beanInstance, lifeCycleMethod);
  3535. });
  3536. };
  3537. Context.prototype.callLifeCycleMethodsOneBean = function (beanInstance, lifeCycleMethod, methodToIgnore) {
  3538. // putting all methods into a map removes duplicates
  3539. var allMethods = {};
  3540. // dump methods from each level of the metadata hierarchy
  3541. this.forEachMetaDataInHierarchy(beanInstance, function (metaData) {
  3542. var methods = metaData[lifeCycleMethod];
  3543. if (methods) {
  3544. methods.forEach(function (methodName) {
  3545. if (methodName != methodToIgnore) {
  3546. allMethods[methodName] = true;
  3547. }
  3548. });
  3549. }
  3550. });
  3551. var allMethodsList = Object.keys(allMethods);
  3552. allMethodsList.forEach(function (methodName) { return beanInstance[methodName](); });
  3553. };
  3554. Context.prototype.getBean = function (name) {
  3555. return this.lookupBeanInstance("getBean", name, true);
  3556. };
  3557. Context.prototype.destroy = function () {
  3558. // should only be able to destroy once
  3559. if (this.destroyed) {
  3560. return;
  3561. }
  3562. this.logger.log(">> Shutting down ag-Application Context");
  3563. var beanInstances = this.getBeanInstances();
  3564. this.destroyBeans(beanInstances);
  3565. this.contextParams.providedBeanInstances = null;
  3566. this.destroyed = true;
  3567. this.logger.log(">> ag-Application Context shut down - component is dead");
  3568. };
  3569. Context.prototype.destroyBean = function (bean) {
  3570. if (!bean) {
  3571. return undefined;
  3572. }
  3573. this.destroyBeans([bean]);
  3574. return undefined;
  3575. };
  3576. Context.prototype.destroyBeans = function (beans) {
  3577. var _this = this;
  3578. if (!beans) {
  3579. return [];
  3580. }
  3581. beans.forEach(function (bean) {
  3582. _this.callLifeCycleMethodsOneBean(bean, 'preDestroyMethods', 'destroy');
  3583. // call destroy() explicitly if it exists
  3584. if (bean.destroy) {
  3585. bean.destroy();
  3586. }
  3587. });
  3588. return [];
  3589. };
  3590. return Context;
  3591. }());
  3592. // taken from: http://stackoverflow.com/questions/3362471/how-can-i-call-a-javascript-constructor-using-call-or-apply
  3593. // allows calling 'apply' on a constructor
  3594. function applyToConstructor(constructor, argArray) {
  3595. var args = [null].concat(argArray);
  3596. var factoryFunction = constructor.bind.apply(constructor, args);
  3597. return new factoryFunction();
  3598. }
  3599. function PreConstruct(target, methodName, descriptor) {
  3600. var props = getOrCreateProps(target.constructor);
  3601. if (!props.preConstructMethods) {
  3602. props.preConstructMethods = [];
  3603. }
  3604. props.preConstructMethods.push(methodName);
  3605. }
  3606. function PostConstruct(target, methodName, descriptor) {
  3607. var props = getOrCreateProps(target.constructor);
  3608. if (!props.postConstructMethods) {
  3609. props.postConstructMethods = [];
  3610. }
  3611. props.postConstructMethods.push(methodName);
  3612. }
  3613. function PreDestroy(target, methodName, descriptor) {
  3614. var props = getOrCreateProps(target.constructor);
  3615. if (!props.preDestroyMethods) {
  3616. props.preDestroyMethods = [];
  3617. }
  3618. props.preDestroyMethods.push(methodName);
  3619. }
  3620. function Bean(beanName) {
  3621. return function (classConstructor) {
  3622. var props = getOrCreateProps(classConstructor);
  3623. props.beanName = beanName;
  3624. };
  3625. }
  3626. function Autowired(name) {
  3627. return function (target, propertyKey, descriptor) {
  3628. autowiredFunc(target, name, false, target, propertyKey, null);
  3629. };
  3630. }
  3631. function Optional(name) {
  3632. return function (target, propertyKey, descriptor) {
  3633. autowiredFunc(target, name, true, target, propertyKey, null);
  3634. };
  3635. }
  3636. function autowiredFunc(target, name, optional, classPrototype, methodOrAttributeName, index) {
  3637. if (name === null) {
  3638. console.error("ag-Grid: Autowired name should not be null");
  3639. return;
  3640. }
  3641. if (typeof index === "number") {
  3642. console.error("ag-Grid: Autowired should be on an attribute");
  3643. return;
  3644. }
  3645. // it's an attribute on the class
  3646. var props = getOrCreateProps(target.constructor);
  3647. if (!props.agClassAttributes) {
  3648. props.agClassAttributes = [];
  3649. }
  3650. props.agClassAttributes.push({
  3651. attributeName: methodOrAttributeName,
  3652. beanName: name,
  3653. optional: optional
  3654. });
  3655. }
  3656. function Qualifier(name) {
  3657. return function (classPrototype, methodOrAttributeName, index) {
  3658. var constructor = typeof classPrototype == "function" ? classPrototype : classPrototype.constructor;
  3659. var props;
  3660. if (typeof index === "number") {
  3661. // it's a parameter on a method
  3662. var methodName = void 0;
  3663. if (methodOrAttributeName) {
  3664. props = getOrCreateProps(constructor);
  3665. methodName = methodOrAttributeName;
  3666. }
  3667. else {
  3668. props = getOrCreateProps(constructor);
  3669. methodName = "agConstructor";
  3670. }
  3671. if (!props.autowireMethods) {
  3672. props.autowireMethods = {};
  3673. }
  3674. if (!props.autowireMethods[methodName]) {
  3675. props.autowireMethods[methodName] = {};
  3676. }
  3677. props.autowireMethods[methodName][index] = name;
  3678. }
  3679. };
  3680. }
  3681. function getOrCreateProps(target) {
  3682. if (!target.hasOwnProperty("__agBeanMetaData")) {
  3683. target.__agBeanMetaData = {};
  3684. }
  3685. return target.__agBeanMetaData;
  3686. }
  3687. /**
  3688. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  3689. * @version v23.2.1
  3690. * @link http://www.ag-grid.com/
  3691. * @license MIT
  3692. */
  3693. var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  3694. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  3695. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  3696. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  3697. return c > 3 && r && Object.defineProperty(target, key, r), r;
  3698. };
  3699. var __param = (undefined && undefined.__param) || function (paramIndex, decorator) {
  3700. return function (target, key) { decorator(target, key, paramIndex); }
  3701. };
  3702. var EventService = /** @class */ (function () {
  3703. function EventService() {
  3704. this.allSyncListeners = new Map();
  3705. this.allAsyncListeners = new Map();
  3706. this.globalSyncListeners = new Set();
  3707. this.globalAsyncListeners = new Set();
  3708. this.asyncFunctionsQueue = [];
  3709. this.scheduled = false;
  3710. // using an object performs better than a Set for the number of different events we have
  3711. this.firedEvents = {};
  3712. }
  3713. // because this class is used both inside the context and outside the context, we do not
  3714. // use autowired attributes, as that would be confusing, as sometimes the attributes
  3715. // would be wired, and sometimes not.
  3716. //
  3717. // the global event servers used by ag-Grid is autowired by the context once, and this
  3718. // setBeans method gets called once.
  3719. //
  3720. // the times when this class is used outside of the context (eg RowNode has an instance of this
  3721. // class) then it is not a bean, and this setBeans method is not called.
  3722. EventService.prototype.setBeans = function (loggerFactory, gridOptionsWrapper, globalEventListener) {
  3723. if (globalEventListener === void 0) { globalEventListener = null; }
  3724. this.logger = loggerFactory.create('EventService');
  3725. if (globalEventListener) {
  3726. var async = gridOptionsWrapper.useAsyncEvents();
  3727. this.addGlobalListener(globalEventListener, async);
  3728. }
  3729. };
  3730. EventService.prototype.getListeners = function (eventType, async) {
  3731. var listenerMap = async ? this.allAsyncListeners : this.allSyncListeners;
  3732. var listeners = listenerMap.get(eventType);
  3733. if (!listeners) {
  3734. listeners = new Set();
  3735. listenerMap.set(eventType, listeners);
  3736. }
  3737. return listeners;
  3738. };
  3739. EventService.prototype.addEventListener = function (eventType, listener, async) {
  3740. if (async === void 0) { async = false; }
  3741. this.getListeners(eventType, async).add(listener);
  3742. };
  3743. EventService.prototype.removeEventListener = function (eventType, listener, async) {
  3744. if (async === void 0) { async = false; }
  3745. this.getListeners(eventType, async).delete(listener);
  3746. };
  3747. EventService.prototype.addGlobalListener = function (listener, async) {
  3748. if (async === void 0) { async = false; }
  3749. (async ? this.globalAsyncListeners : this.globalSyncListeners).add(listener);
  3750. };
  3751. EventService.prototype.removeGlobalListener = function (listener, async) {
  3752. if (async === void 0) { async = false; }
  3753. (async ? this.globalAsyncListeners : this.globalSyncListeners).delete(listener);
  3754. };
  3755. EventService.prototype.dispatchEvent = function (event) {
  3756. this.dispatchToListeners(event, true);
  3757. this.dispatchToListeners(event, false);
  3758. this.firedEvents[event.type] = true;
  3759. };
  3760. EventService.prototype.dispatchEventOnce = function (event) {
  3761. if (!this.firedEvents[event.type]) {
  3762. this.dispatchEvent(event);
  3763. }
  3764. };
  3765. EventService.prototype.dispatchToListeners = function (event, async) {
  3766. var _this = this;
  3767. var eventType = event.type;
  3768. var processEventListeners = function (listeners) { return listeners.forEach(function (listener) {
  3769. if (async) {
  3770. _this.dispatchAsync(function () { return listener(event); });
  3771. }
  3772. else {
  3773. listener(event);
  3774. }
  3775. }); };
  3776. processEventListeners(this.getListeners(eventType, async));
  3777. var globalListeners = async ? this.globalAsyncListeners : this.globalSyncListeners;
  3778. globalListeners.forEach(function (listener) {
  3779. if (async) {
  3780. _this.dispatchAsync(function () { return listener(eventType, event); });
  3781. }
  3782. else {
  3783. listener(eventType, event);
  3784. }
  3785. });
  3786. };
  3787. // this gets called inside the grid's thread, for each event that it
  3788. // wants to set async. the grid then batches the events into one setTimeout()
  3789. // because setTimeout() is an expensive operation. ideally we would have
  3790. // each event in it's own setTimeout(), but we batch for performance.
  3791. EventService.prototype.dispatchAsync = function (func) {
  3792. // add to the queue for executing later in the next VM turn
  3793. this.asyncFunctionsQueue.push(func);
  3794. // check if timeout is already scheduled. the first time the grid calls
  3795. // this within it's thread turn, this should be false, so it will schedule
  3796. // the 'flush queue' method the first time it comes here. then the flag is
  3797. // set to 'true' so it will know it's already scheduled for subsequent calls.
  3798. if (!this.scheduled) {
  3799. // if not scheduled, schedule one
  3800. window.setTimeout(this.flushAsyncQueue.bind(this), 0);
  3801. // mark that it is scheduled
  3802. this.scheduled = true;
  3803. }
  3804. };
  3805. // this happens in the next VM turn only, and empties the queue of events
  3806. EventService.prototype.flushAsyncQueue = function () {
  3807. this.scheduled = false;
  3808. // we take a copy, because the event listener could be using
  3809. // the grid, which would cause more events, which would be potentially
  3810. // added to the queue, so safe to take a copy, the new events will
  3811. // get executed in a later VM turn rather than risk updating the
  3812. // queue as we are flushing it.
  3813. var queueCopy = this.asyncFunctionsQueue.slice();
  3814. this.asyncFunctionsQueue = [];
  3815. // execute the queue
  3816. queueCopy.forEach(function (func) { return func(); });
  3817. };
  3818. __decorate([
  3819. __param(0, Qualifier('loggerFactory')),
  3820. __param(1, Qualifier('gridOptionsWrapper')),
  3821. __param(2, Qualifier('globalEventListener'))
  3822. ], EventService.prototype, "setBeans", null);
  3823. EventService = __decorate([
  3824. Bean('eventService')
  3825. ], EventService);
  3826. return EventService;
  3827. }());
  3828. /**
  3829. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  3830. * @version v23.2.1
  3831. * @link http://www.ag-grid.com/
  3832. * @license MIT
  3833. */
  3834. (function (ModuleNames) {
  3835. // when using modules, user references this
  3836. ModuleNames["CommunityCoreModule"] = "@ag-grid-community/core";
  3837. // when not using modules, user references this
  3838. ModuleNames["CommunityAllModules"] = "@ag-grid-community/all";
  3839. // community modules
  3840. ModuleNames["InfiniteRowModelModule"] = "@ag-grid-community/infinite-row-model";
  3841. ModuleNames["ClientSideRowModelModule"] = "@ag-grid-community/client-side-row-model";
  3842. ModuleNames["CsvExportModule"] = "@ag-grid-community/csv-export";
  3843. ModuleNames["RowNodeCache"] = "@ag-grid-community/row-node-cache";
  3844. // enterprise core - users never import on this, but other enterprise modules do
  3845. ModuleNames["EnterpriseCoreModule"] = "@ag-grid-enterprise/core";
  3846. // when not using modules, user references this
  3847. ModuleNames["EnterpriseAllModules"] = "@ag-grid-enterprise/all";
  3848. // enterprise modules
  3849. ModuleNames["RowGroupingModule"] = "@ag-grid-enterprise/row-grouping";
  3850. ModuleNames["ColumnToolPanelModule"] = "@ag-grid-enterprise/column-tool-panel";
  3851. ModuleNames["FiltersToolPanelModule"] = "@ag-grid-enterprise/filters-tool-panel";
  3852. ModuleNames["MenuModule"] = "@ag-grid-enterprise/menu";
  3853. ModuleNames["SetFilterModule"] = "@ag-grid-enterprise/set-filter";
  3854. ModuleNames["StatusBarModule"] = "@ag-grid-enterprise/status-bar";
  3855. ModuleNames["SideBarModule"] = "@ag-grid-enterprise/side-bar";
  3856. ModuleNames["RangeSelectionModule"] = "@ag-grid-enterprise/range-selection";
  3857. ModuleNames["MasterDetailModule"] = "@ag-grid-enterprise/master-detail";
  3858. ModuleNames["RichSelectModule"] = "@ag-grid-enterprise/rich-select";
  3859. ModuleNames["GridChartsModule"] = "@ag-grid-enterprise/charts";
  3860. ModuleNames["ViewportRowModelModule"] = "@ag-grid-enterprise/viewport-row-model";
  3861. ModuleNames["ServerSideRowModelModule"] = "@ag-grid-enterprise/server-side-row-model";
  3862. ModuleNames["ExcelExportModule"] = "@ag-grid-enterprise/excel-export";
  3863. ModuleNames["ClipboardModule"] = "@ag-grid-enterprise/clipboard";
  3864. ModuleNames["DateTimeCellEditorModule"] = "@ag-grid-enterprise/date-time-cell-editor";
  3865. // framework wrappers currently don't provide beans, comps etc, so no need to be modules,
  3866. // however i argue they should be as in theory they 'could' provide beans etc
  3867. ModuleNames["AngularModule"] = "@ag-grid-community/angular";
  3868. ModuleNames["ReactModule"] = "@ag-grid-community/react";
  3869. ModuleNames["VueModule"] = "@ag-grid-community/vue";
  3870. ModuleNames["PolymerModule"] = "@ag-grid-community/polymer";
  3871. // and then this, which is definitely not a grid module, as it should not have any dependency
  3872. // on the grid (ie shouldn't even reference the Module interface)
  3873. // ChartsModule = "@ag-grid-community/charts-core",
  3874. })(exports.ModuleNames || (exports.ModuleNames = {}));
  3875. /**
  3876. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  3877. * @version v23.2.1
  3878. * @link http://www.ag-grid.com/
  3879. * @license MIT
  3880. */
  3881. var ModuleRegistry = /** @class */ (function () {
  3882. function ModuleRegistry() {
  3883. }
  3884. ModuleRegistry.register = function (module, moduleBased) {
  3885. if (moduleBased === void 0) { moduleBased = true; }
  3886. ModuleRegistry.modulesMap[module.moduleName] = module;
  3887. if (ModuleRegistry.moduleBased === undefined) {
  3888. ModuleRegistry.moduleBased = moduleBased;
  3889. }
  3890. else {
  3891. if (ModuleRegistry.moduleBased !== moduleBased) {
  3892. _.doOnce(function () {
  3893. console.warn("ag-Grid: You are mixing modules (i.e. @ag-grid-community/core) and packages (ag-grid-community) - you can only use one or the other of these mechanisms.");
  3894. console.warn('Please see https://www.ag-grid.com/javascript-grid-packages-modules/ for more information.');
  3895. }, 'ModulePackageCheck');
  3896. }
  3897. }
  3898. };
  3899. // noinspection JSUnusedGlobalSymbols
  3900. ModuleRegistry.registerModules = function (modules, moduleBased) {
  3901. if (moduleBased === void 0) { moduleBased = true; }
  3902. if (!modules) {
  3903. return;
  3904. }
  3905. modules.forEach(function (module) { return ModuleRegistry.register(module, moduleBased); });
  3906. };
  3907. ModuleRegistry.assertRegistered = function (moduleName, reason) {
  3908. if (this.isRegistered(moduleName)) {
  3909. return true;
  3910. }
  3911. var warningKey = reason + moduleName;
  3912. var warningMessage = "ag-Grid: unable to use " + reason + " as module " + moduleName + " is not present. Please see: https://www.ag-grid.com/javascript-grid-modules/";
  3913. _.doOnce(function () {
  3914. console.warn(warningMessage);
  3915. }, warningKey);
  3916. return false;
  3917. };
  3918. ModuleRegistry.isRegistered = function (moduleName) {
  3919. return !!ModuleRegistry.modulesMap[moduleName];
  3920. };
  3921. ModuleRegistry.getRegisteredModules = function () {
  3922. return _.values(ModuleRegistry.modulesMap);
  3923. };
  3924. ModuleRegistry.isPackageBased = function () {
  3925. return !ModuleRegistry.moduleBased;
  3926. };
  3927. // having in a map a) removes duplicates and b) allows fast lookup
  3928. ModuleRegistry.modulesMap = {};
  3929. return ModuleRegistry;
  3930. }());
  3931. /**
  3932. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  3933. * @version v23.2.1
  3934. * @link http://www.ag-grid.com/
  3935. * @license MIT
  3936. */
  3937. var __decorate$1 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  3938. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  3939. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  3940. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  3941. return c > 3 && r && Object.defineProperty(target, key, r), r;
  3942. };
  3943. // Wrapper around a user provide column definition. The grid treats the column definition as ready only.
  3944. // This class contains all the runtime information about a column, plus some logic (the definition has no logic).
  3945. // This class implements both interfaces ColumnGroupChild and OriginalColumnGroupChild as the class can
  3946. // appear as a child of either the original tree or the displayed tree. However the relevant group classes
  3947. // for each type only implements one, as each group can only appear in it's associated tree (eg OriginalColumnGroup
  3948. // can only appear in OriginalColumn tree).
  3949. var Column = /** @class */ (function () {
  3950. function Column(colDef, userProvidedColDef, colId, primary) {
  3951. this.moving = false;
  3952. this.menuVisible = false;
  3953. this.filterActive = false;
  3954. this.eventService = new EventService();
  3955. this.rowGroupActive = false;
  3956. this.pivotActive = false;
  3957. this.aggregationActive = false;
  3958. this.colDef = colDef;
  3959. this.userProvidedColDef = userProvidedColDef;
  3960. this.visible = !colDef.hide;
  3961. this.sort = colDef.sort;
  3962. this.sortedAt = colDef.sortedAt;
  3963. this.colId = colId;
  3964. this.primary = primary;
  3965. }
  3966. // gets called when user provides an alternative colDef, eg
  3967. Column.prototype.setColDef = function (colDef, userProvidedColDef) {
  3968. this.colDef = colDef;
  3969. this.userProvidedColDef = userProvidedColDef;
  3970. };
  3971. Column.prototype.getUserProvidedColDef = function () {
  3972. return this.userProvidedColDef;
  3973. };
  3974. Column.prototype.setParent = function (parent) {
  3975. this.parent = parent;
  3976. };
  3977. Column.prototype.getParent = function () {
  3978. return this.parent;
  3979. };
  3980. Column.prototype.setOriginalParent = function (originalParent) {
  3981. this.originalParent = originalParent;
  3982. };
  3983. Column.prototype.getOriginalParent = function () {
  3984. return this.originalParent;
  3985. };
  3986. // this is done after constructor as it uses gridOptionsWrapper
  3987. Column.prototype.initialise = function () {
  3988. this.setPinned(this.colDef.pinned);
  3989. var minColWidth = this.gridOptionsWrapper.getMinColWidth();
  3990. var maxColWidth = this.gridOptionsWrapper.getMaxColWidth();
  3991. if (this.colDef.minWidth) {
  3992. this.minWidth = this.colDef.minWidth;
  3993. }
  3994. else {
  3995. this.minWidth = minColWidth;
  3996. }
  3997. if (this.colDef.maxWidth) {
  3998. this.maxWidth = this.colDef.maxWidth;
  3999. }
  4000. else {
  4001. this.maxWidth = maxColWidth;
  4002. }
  4003. if (this.colDef.flex) {
  4004. this.flex = this.colDef.flex;
  4005. }
  4006. this.resetActualWidth();
  4007. var suppressDotNotation = this.gridOptionsWrapper.isSuppressFieldDotNotation();
  4008. this.fieldContainsDots = _.exists(this.colDef.field) && this.colDef.field.indexOf('.') >= 0 && !suppressDotNotation;
  4009. this.tooltipFieldContainsDots = _.exists(this.colDef.tooltipField) && this.colDef.tooltipField.indexOf('.') >= 0 && !suppressDotNotation;
  4010. this.validate();
  4011. };
  4012. Column.prototype.resetActualWidth = function () {
  4013. this.actualWidth = this.columnUtils.calculateColInitialWidth(this.colDef);
  4014. };
  4015. Column.prototype.isEmptyGroup = function () {
  4016. return false;
  4017. };
  4018. Column.prototype.isRowGroupDisplayed = function (colId) {
  4019. if (_.missing(this.colDef) || _.missing(this.colDef.showRowGroup)) {
  4020. return false;
  4021. }
  4022. var showingAllGroups = this.colDef.showRowGroup === true;
  4023. var showingThisGroup = this.colDef.showRowGroup === colId;
  4024. return showingAllGroups || showingThisGroup;
  4025. };
  4026. Column.prototype.getUniqueId = function () {
  4027. return this.getId();
  4028. };
  4029. Column.prototype.isPrimary = function () {
  4030. return this.primary;
  4031. };
  4032. Column.prototype.isFilterAllowed = function () {
  4033. // filter defined means it's a string, class or true.
  4034. // if its false, null or undefined then it's false.
  4035. var filterDefined = !!this.colDef.filter || !!this.colDef.filterFramework;
  4036. return this.primary && filterDefined;
  4037. };
  4038. Column.prototype.isFieldContainsDots = function () {
  4039. return this.fieldContainsDots;
  4040. };
  4041. Column.prototype.isTooltipFieldContainsDots = function () {
  4042. return this.tooltipFieldContainsDots;
  4043. };
  4044. Column.prototype.validate = function () {
  4045. var colDefAny = this.colDef;
  4046. function warnOnce(msg, key, obj) {
  4047. _.doOnce(function () {
  4048. if (obj) {
  4049. console.warn(msg, obj);
  4050. }
  4051. else {
  4052. _.doOnce(function () { return console.warn(msg); }, key);
  4053. }
  4054. }, key);
  4055. }
  4056. if (!ModuleRegistry.isRegistered(exports.ModuleNames.RowGroupingModule)) {
  4057. var rowGroupingItems = ['enableRowGroup', 'rowGroup', 'rowGroupIndex', 'enablePivot', 'enableValue', 'pivot', 'pivotIndex', 'aggFunc'];
  4058. rowGroupingItems.forEach(function (item) {
  4059. if (_.exists(colDefAny[item])) {
  4060. if (ModuleRegistry.isPackageBased()) {
  4061. warnOnce("ag-Grid: " + item + " is only valid in ag-grid-enterprise, your column definition should not have " + item, 'ColumnRowGroupingMissing' + item);
  4062. }
  4063. else {
  4064. warnOnce("ag-Grid: " + item + " is only valid with ag-Grid Enterprise Module " + exports.ModuleNames.RowGroupingModule + " - your column definition should not have " + item, 'ColumnRowGroupingMissing' + item);
  4065. }
  4066. }
  4067. });
  4068. }
  4069. if (!ModuleRegistry.isRegistered(exports.ModuleNames.RichSelectModule)) {
  4070. if (this.colDef.cellEditor === 'agRichSelect' || this.colDef.cellEditor === 'agRichSelectCellEditor') {
  4071. if (ModuleRegistry.isPackageBased()) {
  4072. warnOnce("ag-Grid: " + this.colDef.cellEditor + " can only be used with ag-grid-enterprise", 'ColumnRichSelectMissing');
  4073. }
  4074. else {
  4075. warnOnce("ag-Grid: " + this.colDef.cellEditor + " can only be used with ag-Grid Enterprise Module " + exports.ModuleNames.RichSelectModule, 'ColumnRichSelectMissing');
  4076. }
  4077. }
  4078. }
  4079. if (!ModuleRegistry.isRegistered(exports.ModuleNames.DateTimeCellEditorModule)) {
  4080. if (this.colDef.cellEditor === 'agRichSelect' || this.colDef.cellEditor === 'agDateTimeCellEditor') {
  4081. if (ModuleRegistry.isPackageBased()) {
  4082. warnOnce("ag-Grid: " + this.colDef.cellEditor + " can only be used with ag-grid-enterprise", 'ColumnDateTimeMissing');
  4083. }
  4084. else {
  4085. warnOnce("ag-Grid: " + this.colDef.cellEditor + " can only be used with ag-Grid Enterprise Module " + exports.ModuleNames.DateTimeCellEditorModule, 'ColumnDateTimeMissing');
  4086. }
  4087. }
  4088. }
  4089. if (this.gridOptionsWrapper.isTreeData()) {
  4090. var itemsNotAllowedWithTreeData = ['rowGroup', 'rowGroupIndex', 'pivot', 'pivotIndex'];
  4091. itemsNotAllowedWithTreeData.forEach(function (item) {
  4092. if (_.exists(colDefAny[item])) {
  4093. warnOnce("ag-Grid: " + item + " is not possible when doing tree data, your column definition should not have " + item, 'TreeDataCannotRowGroup');
  4094. }
  4095. });
  4096. }
  4097. if (_.exists(this.colDef.width) && typeof this.colDef.width !== 'number') {
  4098. warnOnce('ag-Grid: colDef.width should be a number, not ' + typeof this.colDef.width, 'ColumnCheck_asdfawef');
  4099. }
  4100. if (_.get(this, 'colDef.cellRendererParams.restrictToOneGroup', null)) {
  4101. warnOnce('ag-Grid: Since ag-grid 11.0.0 cellRendererParams.restrictToOneGroup is deprecated. You should use showRowGroup', 'ColumnCheck_sksldjf');
  4102. }
  4103. if (_.get(this, 'colDef.cellRendererParams.keyMap', null)) {
  4104. warnOnce('ag-Grid: Since ag-grid 11.0.0 cellRendererParams.keyMap is deprecated. You should use colDef.keyCreator', 'ColumnCheck_ieiruhgdf');
  4105. }
  4106. if (_.get(this, 'colDef.cellRendererParams.keyMap', null)) {
  4107. warnOnce('ag-Grid: Since ag-grid 11.0.0 cellRendererParams.keyMap is deprecated. You should use colDef.keyCreator', 'ColumnCheck_uitolghj');
  4108. }
  4109. if (colDefAny.floatingCellRenderer) {
  4110. warnOnce('ag-Grid: since v11, floatingCellRenderer is now pinnedRowCellRenderer', 'ColumnCheck_soihwewe');
  4111. this.colDef.pinnedRowCellRenderer = colDefAny.floatingCellRenderer;
  4112. }
  4113. if (colDefAny.floatingRendererFramework) {
  4114. warnOnce('ag-Grid: since v11, floatingRendererFramework is now pinnedRowCellRendererFramework', 'ColumnCheck_zdkiouhwer');
  4115. this.colDef.pinnedRowCellRendererFramework = colDefAny.floatingRendererFramework;
  4116. }
  4117. if (colDefAny.floatingRendererParams) {
  4118. console.warn('ag-Grid: since v11, floatingRendererParams is now pinnedRowCellRendererParams', 'ColumnCheck_retiuhjs');
  4119. this.colDef.pinnedRowCellRendererParams = colDefAny.floatingRendererParams;
  4120. }
  4121. if (colDefAny.floatingValueFormatter) {
  4122. warnOnce('ag-Grid: since v11, floatingValueFormatter is now pinnedRowValueFormatter', 'ColumnCheck_qwroeihjdf');
  4123. this.colDef.pinnedRowValueFormatter = colDefAny.floatingValueFormatter;
  4124. }
  4125. if (colDefAny.cellFormatter) {
  4126. warnOnce('ag-Grid: since v12, cellFormatter is now valueFormatter', 'ColumnCheck_eoireknml');
  4127. if (_.missing(this.colDef.valueFormatter)) {
  4128. this.colDef.valueFormatter = colDefAny.cellFormatter;
  4129. }
  4130. }
  4131. if (colDefAny.headerCellTemplate) {
  4132. warnOnce('ag-Grid: since v15, headerCellTemplate is gone, use header component instead.', 'ColumnCheck_eroihxcm');
  4133. }
  4134. if (colDefAny.headerCellRenderer) {
  4135. warnOnce('ag-Grid: since v15, headerCellRenderer is gone, use header component instead.', 'ColumnCheck_terteuh');
  4136. }
  4137. if (colDefAny.volatile) {
  4138. warnOnce('ag-Grid: since v16, colDef.volatile is gone, please check refresh docs on how to refresh specific cells.', 'ColumnCheck_weoihjxcv');
  4139. }
  4140. if (colDefAny.suppressSorting) {
  4141. warnOnce("ag-Grid: since v20, colDef.suppressSorting is gone, instead use colDef.sortable=false.", 'ColumnCheck_43ljrer', this.colDef);
  4142. this.colDef.sortable = false;
  4143. }
  4144. if (colDefAny.suppressFilter) {
  4145. warnOnce("ag-Grid: since v20, colDef.suppressFilter is gone, instead use colDef.filter=false.", 'ColumnCheck_erlkhfdm', this.colDef);
  4146. this.colDef.filter = false;
  4147. }
  4148. if (colDefAny.suppressResize) {
  4149. warnOnce("ag-Grid: since v20, colDef.suppressResize is gone, instead use colDef.resizable=false.", 'ColumnCheck_weoihjxcv', this.colDef);
  4150. this.colDef.resizable = false;
  4151. }
  4152. if (colDefAny.tooltip) {
  4153. warnOnce("ag-Grid: since v20.1, colDef.tooltip is gone, instead use colDef.tooltipValueGetter.", 'ColumnCheck_adslknjwef', this.colDef);
  4154. this.colDef.tooltipValueGetter = colDefAny.tooltip;
  4155. }
  4156. if (colDefAny.suppressToolPanel) {
  4157. warnOnce("ag-Grid: since v22, colDef.suppressToolPanel is gone, instead use suppressColumnsToolPanel / suppressFiltersToolPanel.", 'ColumnCheck_weihjlsjkdf', this.colDef);
  4158. this.colDef.suppressColumnsToolPanel = true;
  4159. }
  4160. };
  4161. Column.prototype.addEventListener = function (eventType, listener) {
  4162. this.eventService.addEventListener(eventType, listener);
  4163. };
  4164. Column.prototype.removeEventListener = function (eventType, listener) {
  4165. this.eventService.removeEventListener(eventType, listener);
  4166. };
  4167. Column.prototype.createIsColumnFuncParams = function (rowNode) {
  4168. return {
  4169. node: rowNode,
  4170. data: rowNode.data,
  4171. column: this,
  4172. colDef: this.colDef,
  4173. context: this.gridOptionsWrapper.getContext(),
  4174. api: this.gridOptionsWrapper.getApi(),
  4175. columnApi: this.gridOptionsWrapper.getColumnApi()
  4176. };
  4177. };
  4178. Column.prototype.isSuppressNavigable = function (rowNode) {
  4179. // if boolean set, then just use it
  4180. if (typeof this.colDef.suppressNavigable === 'boolean') {
  4181. return this.colDef.suppressNavigable;
  4182. }
  4183. // if function, then call the function to find out
  4184. if (typeof this.colDef.suppressNavigable === 'function') {
  4185. var params = this.createIsColumnFuncParams(rowNode);
  4186. var userFunc = this.colDef.suppressNavigable;
  4187. return userFunc(params);
  4188. }
  4189. return false;
  4190. };
  4191. Column.prototype.isCellEditable = function (rowNode) {
  4192. // only allow editing of groups if the user has this option enabled
  4193. if (rowNode.group && !this.gridOptionsWrapper.isEnableGroupEdit()) {
  4194. return false;
  4195. }
  4196. return this.isColumnFunc(rowNode, this.colDef.editable);
  4197. };
  4198. Column.prototype.isRowDrag = function (rowNode) {
  4199. return this.isColumnFunc(rowNode, this.colDef.rowDrag);
  4200. };
  4201. Column.prototype.isDndSource = function (rowNode) {
  4202. return this.isColumnFunc(rowNode, this.colDef.dndSource);
  4203. };
  4204. Column.prototype.isCellCheckboxSelection = function (rowNode) {
  4205. return this.isColumnFunc(rowNode, this.colDef.checkboxSelection);
  4206. };
  4207. Column.prototype.isSuppressPaste = function (rowNode) {
  4208. return this.isColumnFunc(rowNode, this.colDef ? this.colDef.suppressPaste : null);
  4209. };
  4210. Column.prototype.isResizable = function () {
  4211. return this.colDef.resizable === true;
  4212. };
  4213. Column.prototype.isColumnFunc = function (rowNode, value) {
  4214. // if boolean set, then just use it
  4215. if (typeof value === 'boolean') {
  4216. return value;
  4217. }
  4218. // if function, then call the function to find out
  4219. if (typeof value === 'function') {
  4220. var params = this.createIsColumnFuncParams(rowNode);
  4221. var editableFunc = value;
  4222. return editableFunc(params);
  4223. }
  4224. return false;
  4225. };
  4226. Column.prototype.setMoving = function (moving, source) {
  4227. if (source === void 0) { source = "api"; }
  4228. this.moving = moving;
  4229. this.eventService.dispatchEvent(this.createColumnEvent(Column.EVENT_MOVING_CHANGED, source));
  4230. };
  4231. Column.prototype.createColumnEvent = function (type, source) {
  4232. return {
  4233. api: this.gridApi,
  4234. columnApi: this.columnApi,
  4235. type: type,
  4236. column: this,
  4237. columns: [this],
  4238. source: source
  4239. };
  4240. };
  4241. Column.prototype.isMoving = function () {
  4242. return this.moving;
  4243. };
  4244. Column.prototype.getSort = function () {
  4245. return this.sort;
  4246. };
  4247. Column.prototype.setSort = function (sort, source) {
  4248. if (source === void 0) { source = "api"; }
  4249. if (this.sort !== sort) {
  4250. this.sort = sort;
  4251. this.eventService.dispatchEvent(this.createColumnEvent(Column.EVENT_SORT_CHANGED, source));
  4252. }
  4253. };
  4254. Column.prototype.setMenuVisible = function (visible, source) {
  4255. if (source === void 0) { source = "api"; }
  4256. if (this.menuVisible !== visible) {
  4257. this.menuVisible = visible;
  4258. this.eventService.dispatchEvent(this.createColumnEvent(Column.EVENT_MENU_VISIBLE_CHANGED, source));
  4259. }
  4260. };
  4261. Column.prototype.isMenuVisible = function () {
  4262. return this.menuVisible;
  4263. };
  4264. Column.prototype.isSortAscending = function () {
  4265. return this.sort === Constants.SORT_ASC;
  4266. };
  4267. Column.prototype.isSortDescending = function () {
  4268. return this.sort === Constants.SORT_DESC;
  4269. };
  4270. Column.prototype.isSortNone = function () {
  4271. return _.missing(this.sort);
  4272. };
  4273. Column.prototype.isSorting = function () {
  4274. return _.exists(this.sort);
  4275. };
  4276. Column.prototype.getSortedAt = function () {
  4277. return this.sortedAt;
  4278. };
  4279. Column.prototype.setSortedAt = function (sortedAt) {
  4280. this.sortedAt = sortedAt;
  4281. };
  4282. Column.prototype.setAggFunc = function (aggFunc) {
  4283. this.aggFunc = aggFunc;
  4284. };
  4285. Column.prototype.getAggFunc = function () {
  4286. return this.aggFunc;
  4287. };
  4288. Column.prototype.getLeft = function () {
  4289. return this.left;
  4290. };
  4291. Column.prototype.getOldLeft = function () {
  4292. return this.oldLeft;
  4293. };
  4294. Column.prototype.getRight = function () {
  4295. return this.left + this.actualWidth;
  4296. };
  4297. Column.prototype.setLeft = function (left, source) {
  4298. if (source === void 0) { source = "api"; }
  4299. this.oldLeft = this.left;
  4300. if (this.left !== left) {
  4301. this.left = left;
  4302. this.eventService.dispatchEvent(this.createColumnEvent(Column.EVENT_LEFT_CHANGED, source));
  4303. }
  4304. };
  4305. Column.prototype.isFilterActive = function () {
  4306. return this.filterActive;
  4307. };
  4308. // additionalEventAttributes is used by provided simple floating filter, so it can add 'floatingFilter=true' to the event
  4309. Column.prototype.setFilterActive = function (active, source, additionalEventAttributes) {
  4310. if (source === void 0) { source = "api"; }
  4311. if (this.filterActive !== active) {
  4312. this.filterActive = active;
  4313. this.eventService.dispatchEvent(this.createColumnEvent(Column.EVENT_FILTER_ACTIVE_CHANGED, source));
  4314. }
  4315. var filterChangedEvent = this.createColumnEvent(Column.EVENT_FILTER_CHANGED, source);
  4316. if (additionalEventAttributes) {
  4317. _.mergeDeep(filterChangedEvent, additionalEventAttributes);
  4318. }
  4319. this.eventService.dispatchEvent(filterChangedEvent);
  4320. };
  4321. Column.prototype.setPinned = function (pinned) {
  4322. if (pinned === true || pinned === Constants.PINNED_LEFT) {
  4323. this.pinned = Constants.PINNED_LEFT;
  4324. }
  4325. else if (pinned === Constants.PINNED_RIGHT) {
  4326. this.pinned = Constants.PINNED_RIGHT;
  4327. }
  4328. else {
  4329. this.pinned = null;
  4330. }
  4331. };
  4332. Column.prototype.setFirstRightPinned = function (firstRightPinned, source) {
  4333. if (source === void 0) { source = "api"; }
  4334. if (this.firstRightPinned !== firstRightPinned) {
  4335. this.firstRightPinned = firstRightPinned;
  4336. this.eventService.dispatchEvent(this.createColumnEvent(Column.EVENT_FIRST_RIGHT_PINNED_CHANGED, source));
  4337. }
  4338. };
  4339. Column.prototype.setLastLeftPinned = function (lastLeftPinned, source) {
  4340. if (source === void 0) { source = "api"; }
  4341. if (this.lastLeftPinned !== lastLeftPinned) {
  4342. this.lastLeftPinned = lastLeftPinned;
  4343. this.eventService.dispatchEvent(this.createColumnEvent(Column.EVENT_LAST_LEFT_PINNED_CHANGED, source));
  4344. }
  4345. };
  4346. Column.prototype.isFirstRightPinned = function () {
  4347. return this.firstRightPinned;
  4348. };
  4349. Column.prototype.isLastLeftPinned = function () {
  4350. return this.lastLeftPinned;
  4351. };
  4352. Column.prototype.isPinned = function () {
  4353. return this.pinned === Constants.PINNED_LEFT || this.pinned === Constants.PINNED_RIGHT;
  4354. };
  4355. Column.prototype.isPinnedLeft = function () {
  4356. return this.pinned === Constants.PINNED_LEFT;
  4357. };
  4358. Column.prototype.isPinnedRight = function () {
  4359. return this.pinned === Constants.PINNED_RIGHT;
  4360. };
  4361. Column.prototype.getPinned = function () {
  4362. return this.pinned;
  4363. };
  4364. Column.prototype.setVisible = function (visible, source) {
  4365. if (source === void 0) { source = "api"; }
  4366. var newValue = visible === true;
  4367. if (this.visible !== newValue) {
  4368. this.visible = newValue;
  4369. this.eventService.dispatchEvent(this.createColumnEvent(Column.EVENT_VISIBLE_CHANGED, source));
  4370. }
  4371. };
  4372. Column.prototype.isVisible = function () {
  4373. return this.visible;
  4374. };
  4375. Column.prototype.getColDef = function () {
  4376. return this.colDef;
  4377. };
  4378. Column.prototype.getColumnGroupShow = function () {
  4379. return this.colDef.columnGroupShow;
  4380. };
  4381. Column.prototype.getColId = function () {
  4382. return this.colId;
  4383. };
  4384. Column.prototype.getId = function () {
  4385. return this.getColId();
  4386. };
  4387. Column.prototype.getDefinition = function () {
  4388. return this.colDef;
  4389. };
  4390. Column.prototype.getActualWidth = function () {
  4391. return this.actualWidth;
  4392. };
  4393. Column.prototype.createBaseColDefParams = function (rowNode) {
  4394. var params = {
  4395. node: rowNode,
  4396. data: rowNode.data,
  4397. colDef: this.colDef,
  4398. column: this,
  4399. api: this.gridOptionsWrapper.getApi(),
  4400. columnApi: this.gridOptionsWrapper.getColumnApi(),
  4401. context: this.gridOptionsWrapper.getContext()
  4402. };
  4403. return params;
  4404. };
  4405. Column.prototype.getColSpan = function (rowNode) {
  4406. if (_.missing(this.colDef.colSpan)) {
  4407. return 1;
  4408. }
  4409. var params = this.createBaseColDefParams(rowNode);
  4410. var colSpan = this.colDef.colSpan(params);
  4411. // colSpan must be number equal to or greater than 1
  4412. return Math.max(colSpan, 1);
  4413. };
  4414. Column.prototype.getRowSpan = function (rowNode) {
  4415. if (_.missing(this.colDef.rowSpan)) {
  4416. return 1;
  4417. }
  4418. var params = this.createBaseColDefParams(rowNode);
  4419. var rowSpan = this.colDef.rowSpan(params);
  4420. // rowSpan must be number equal to or greater than 1
  4421. return Math.max(rowSpan, 1);
  4422. };
  4423. Column.prototype.setActualWidth = function (actualWidth, source) {
  4424. if (source === void 0) { source = "api"; }
  4425. if (this.minWidth != null) {
  4426. actualWidth = Math.max(actualWidth, this.minWidth);
  4427. }
  4428. if (this.maxWidth != null) {
  4429. actualWidth = Math.min(actualWidth, this.maxWidth);
  4430. }
  4431. if (this.actualWidth !== actualWidth) {
  4432. // disable flex for this column if it was manually resized.
  4433. if (this.flex && source !== 'flex') {
  4434. this.flex = 0;
  4435. }
  4436. this.actualWidth = actualWidth;
  4437. this.eventService.dispatchEvent(this.createColumnEvent(Column.EVENT_WIDTH_CHANGED, source));
  4438. }
  4439. };
  4440. Column.prototype.isGreaterThanMax = function (width) {
  4441. if (this.maxWidth != null) {
  4442. return width > this.maxWidth;
  4443. }
  4444. return false;
  4445. };
  4446. Column.prototype.getMinWidth = function () {
  4447. return this.minWidth;
  4448. };
  4449. Column.prototype.getMaxWidth = function () {
  4450. return this.maxWidth;
  4451. };
  4452. Column.prototype.getFlex = function () {
  4453. return this.flex || 0;
  4454. };
  4455. // this method should only be used by the columnController to
  4456. // change flex when required by the setColumnState method.
  4457. Column.prototype.setFlex = function (flex) {
  4458. if (this.flex !== flex) {
  4459. this.flex = flex;
  4460. }
  4461. };
  4462. Column.prototype.setMinimum = function (source) {
  4463. if (source === void 0) { source = "api"; }
  4464. this.setActualWidth(this.minWidth, source);
  4465. };
  4466. Column.prototype.setRowGroupActive = function (rowGroup, source) {
  4467. if (source === void 0) { source = "api"; }
  4468. if (this.rowGroupActive !== rowGroup) {
  4469. this.rowGroupActive = rowGroup;
  4470. this.eventService.dispatchEvent(this.createColumnEvent(Column.EVENT_ROW_GROUP_CHANGED, source));
  4471. }
  4472. };
  4473. Column.prototype.isRowGroupActive = function () {
  4474. return this.rowGroupActive;
  4475. };
  4476. Column.prototype.setPivotActive = function (pivot, source) {
  4477. if (source === void 0) { source = "api"; }
  4478. if (this.pivotActive !== pivot) {
  4479. this.pivotActive = pivot;
  4480. this.eventService.dispatchEvent(this.createColumnEvent(Column.EVENT_PIVOT_CHANGED, source));
  4481. }
  4482. };
  4483. Column.prototype.isPivotActive = function () {
  4484. return this.pivotActive;
  4485. };
  4486. Column.prototype.isAnyFunctionActive = function () {
  4487. return this.isPivotActive() || this.isRowGroupActive() || this.isValueActive();
  4488. };
  4489. Column.prototype.isAnyFunctionAllowed = function () {
  4490. return this.isAllowPivot() || this.isAllowRowGroup() || this.isAllowValue();
  4491. };
  4492. Column.prototype.setValueActive = function (value, source) {
  4493. if (source === void 0) { source = "api"; }
  4494. if (this.aggregationActive !== value) {
  4495. this.aggregationActive = value;
  4496. this.eventService.dispatchEvent(this.createColumnEvent(Column.EVENT_VALUE_CHANGED, source));
  4497. }
  4498. };
  4499. Column.prototype.isValueActive = function () {
  4500. return this.aggregationActive;
  4501. };
  4502. Column.prototype.isAllowPivot = function () {
  4503. return this.colDef.enablePivot === true;
  4504. };
  4505. Column.prototype.isAllowValue = function () {
  4506. return this.colDef.enableValue === true;
  4507. };
  4508. Column.prototype.isAllowRowGroup = function () {
  4509. return this.colDef.enableRowGroup === true;
  4510. };
  4511. Column.prototype.getMenuTabs = function (defaultValues) {
  4512. var menuTabs = this.getColDef().menuTabs;
  4513. if (menuTabs == null) {
  4514. menuTabs = defaultValues;
  4515. }
  4516. return menuTabs;
  4517. };
  4518. // this used to be needed, as previous version of ag-grid had lockPosition as column state,
  4519. // so couldn't depend on colDef version.
  4520. Column.prototype.isLockPosition = function () {
  4521. console.warn('ag-Grid: since v21, col.isLockPosition() should not be used, please use col.getColDef().lockPosition instead.');
  4522. return this.colDef ? !!this.colDef.lockPosition : false;
  4523. };
  4524. // this used to be needed, as previous version of ag-grid had lockVisible as column state,
  4525. // so couldn't depend on colDef version.
  4526. Column.prototype.isLockVisible = function () {
  4527. console.warn('ag-Grid: since v21, col.isLockVisible() should not be used, please use col.getColDef().lockVisible instead.');
  4528. return this.colDef ? !!this.colDef.lockVisible : false;
  4529. };
  4530. // this used to be needed, as previous version of ag-grid had lockPinned as column state,
  4531. // so couldn't depend on colDef version.
  4532. Column.prototype.isLockPinned = function () {
  4533. console.warn('ag-Grid: since v21, col.isLockPinned() should not be used, please use col.getColDef().lockPinned instead.');
  4534. return this.colDef ? !!this.colDef.lockPinned : false;
  4535. };
  4536. // + renderedHeaderCell - for making header cell transparent when moving
  4537. Column.EVENT_MOVING_CHANGED = 'movingChanged';
  4538. // + renderedCell - changing left position
  4539. Column.EVENT_LEFT_CHANGED = 'leftChanged';
  4540. // + renderedCell - changing width
  4541. Column.EVENT_WIDTH_CHANGED = 'widthChanged';
  4542. // + renderedCell - for changing pinned classes
  4543. Column.EVENT_LAST_LEFT_PINNED_CHANGED = 'lastLeftPinnedChanged';
  4544. Column.EVENT_FIRST_RIGHT_PINNED_CHANGED = 'firstRightPinnedChanged';
  4545. // + renderedColumn - for changing visibility icon
  4546. Column.EVENT_VISIBLE_CHANGED = 'visibleChanged';
  4547. // + every time the filter changes, used in the floating filters
  4548. Column.EVENT_FILTER_CHANGED = 'filterChanged';
  4549. // + renderedHeaderCell - marks the header with filter icon
  4550. Column.EVENT_FILTER_ACTIVE_CHANGED = 'filterActiveChanged';
  4551. // + renderedHeaderCell - marks the header with sort icon
  4552. Column.EVENT_SORT_CHANGED = 'sortChanged';
  4553. Column.EVENT_MENU_VISIBLE_CHANGED = 'menuVisibleChanged';
  4554. // + toolpanel, for gui updates
  4555. Column.EVENT_ROW_GROUP_CHANGED = 'columnRowGroupChanged';
  4556. // + toolpanel, for gui updates
  4557. Column.EVENT_PIVOT_CHANGED = 'columnPivotChanged';
  4558. // + toolpanel, for gui updates
  4559. Column.EVENT_VALUE_CHANGED = 'columnValueChanged';
  4560. __decorate$1([
  4561. Autowired('gridOptionsWrapper')
  4562. ], Column.prototype, "gridOptionsWrapper", void 0);
  4563. __decorate$1([
  4564. Autowired('columnUtils')
  4565. ], Column.prototype, "columnUtils", void 0);
  4566. __decorate$1([
  4567. Autowired('columnApi')
  4568. ], Column.prototype, "columnApi", void 0);
  4569. __decorate$1([
  4570. Autowired('gridApi')
  4571. ], Column.prototype, "gridApi", void 0);
  4572. __decorate$1([
  4573. Autowired('context')
  4574. ], Column.prototype, "context", void 0);
  4575. __decorate$1([
  4576. PostConstruct
  4577. ], Column.prototype, "initialise", null);
  4578. return Column;
  4579. }());
  4580. /**
  4581. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  4582. * @version v23.2.1
  4583. * @link http://www.ag-grid.com/
  4584. * @license MIT
  4585. */
  4586. var __decorate$2 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  4587. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  4588. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  4589. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  4590. return c > 3 && r && Object.defineProperty(target, key, r), r;
  4591. };
  4592. var ColumnGroup = /** @class */ (function () {
  4593. function ColumnGroup(originalColumnGroup, groupId, instanceId, pinned) {
  4594. // depends on the open/closed state of the group, only displaying columns are stored here
  4595. this.displayedChildren = [];
  4596. this.localEventService = new EventService();
  4597. this.groupId = groupId;
  4598. this.instanceId = instanceId;
  4599. this.originalColumnGroup = originalColumnGroup;
  4600. this.pinned = pinned;
  4601. }
  4602. // this is static, a it is used outside of this class
  4603. ColumnGroup.createUniqueId = function (groupId, instanceId) {
  4604. return groupId + '_' + instanceId;
  4605. };
  4606. // as the user is adding and removing columns, the groups are recalculated.
  4607. // this reset clears out all children, ready for children to be added again
  4608. ColumnGroup.prototype.reset = function () {
  4609. this.parent = null;
  4610. this.children = null;
  4611. this.displayedChildren = null;
  4612. };
  4613. ColumnGroup.prototype.getParent = function () {
  4614. return this.parent;
  4615. };
  4616. ColumnGroup.prototype.setParent = function (parent) {
  4617. this.parent = parent;
  4618. };
  4619. ColumnGroup.prototype.getUniqueId = function () {
  4620. return ColumnGroup.createUniqueId(this.groupId, this.instanceId);
  4621. };
  4622. ColumnGroup.prototype.isEmptyGroup = function () {
  4623. return this.displayedChildren.length === 0;
  4624. };
  4625. ColumnGroup.prototype.isMoving = function () {
  4626. var allLeafColumns = this.getOriginalColumnGroup().getLeafColumns();
  4627. if (!allLeafColumns || allLeafColumns.length === 0) {
  4628. return false;
  4629. }
  4630. return allLeafColumns.every(function (col) { return col.isMoving(); });
  4631. };
  4632. ColumnGroup.prototype.checkLeft = function () {
  4633. // first get all children to setLeft, as it impacts our decision below
  4634. this.displayedChildren.forEach(function (child) {
  4635. if (child instanceof ColumnGroup) {
  4636. child.checkLeft();
  4637. }
  4638. });
  4639. // set our left based on first displayed column
  4640. if (this.displayedChildren.length > 0) {
  4641. if (this.gridOptionsWrapper.isEnableRtl()) {
  4642. var lastChild = _.last(this.displayedChildren);
  4643. var lastChildLeft = lastChild.getLeft();
  4644. this.setLeft(lastChildLeft);
  4645. }
  4646. else {
  4647. var firstChildLeft = this.displayedChildren[0].getLeft();
  4648. this.setLeft(firstChildLeft);
  4649. }
  4650. }
  4651. else {
  4652. // this should never happen, as if we have no displayed columns, then
  4653. // this groups should not even exist.
  4654. this.setLeft(null);
  4655. }
  4656. };
  4657. ColumnGroup.prototype.getLeft = function () {
  4658. return this.left;
  4659. };
  4660. ColumnGroup.prototype.getOldLeft = function () {
  4661. return this.oldLeft;
  4662. };
  4663. ColumnGroup.prototype.setLeft = function (left) {
  4664. this.oldLeft = left;
  4665. if (this.left !== left) {
  4666. this.left = left;
  4667. this.localEventService.dispatchEvent(this.createAgEvent(ColumnGroup.EVENT_LEFT_CHANGED));
  4668. }
  4669. };
  4670. ColumnGroup.prototype.getPinned = function () {
  4671. return this.pinned;
  4672. };
  4673. ColumnGroup.prototype.createAgEvent = function (type) {
  4674. return { type: type };
  4675. };
  4676. ColumnGroup.prototype.addEventListener = function (eventType, listener) {
  4677. this.localEventService.addEventListener(eventType, listener);
  4678. };
  4679. ColumnGroup.prototype.removeEventListener = function (eventType, listener) {
  4680. this.localEventService.removeEventListener(eventType, listener);
  4681. };
  4682. ColumnGroup.prototype.getGroupId = function () {
  4683. return this.groupId;
  4684. };
  4685. ColumnGroup.prototype.getInstanceId = function () {
  4686. return this.instanceId;
  4687. };
  4688. ColumnGroup.prototype.isChildInThisGroupDeepSearch = function (wantedChild) {
  4689. var result = false;
  4690. this.children.forEach(function (foundChild) {
  4691. if (wantedChild === foundChild) {
  4692. result = true;
  4693. }
  4694. if (foundChild instanceof ColumnGroup) {
  4695. if (foundChild.isChildInThisGroupDeepSearch(wantedChild)) {
  4696. result = true;
  4697. }
  4698. }
  4699. });
  4700. return result;
  4701. };
  4702. ColumnGroup.prototype.getActualWidth = function () {
  4703. var groupActualWidth = 0;
  4704. if (this.displayedChildren) {
  4705. this.displayedChildren.forEach(function (child) {
  4706. groupActualWidth += child.getActualWidth();
  4707. });
  4708. }
  4709. return groupActualWidth;
  4710. };
  4711. ColumnGroup.prototype.isResizable = function () {
  4712. if (!this.displayedChildren) {
  4713. return false;
  4714. }
  4715. // if at least one child is resizable, then the group is resizable
  4716. var result = false;
  4717. this.displayedChildren.forEach(function (child) {
  4718. if (child.isResizable()) {
  4719. result = true;
  4720. }
  4721. });
  4722. return result;
  4723. };
  4724. ColumnGroup.prototype.getMinWidth = function () {
  4725. var result = 0;
  4726. this.displayedChildren.forEach(function (groupChild) {
  4727. result += groupChild.getMinWidth();
  4728. });
  4729. return result;
  4730. };
  4731. ColumnGroup.prototype.addChild = function (child) {
  4732. if (!this.children) {
  4733. this.children = [];
  4734. }
  4735. this.children.push(child);
  4736. };
  4737. ColumnGroup.prototype.getDisplayedChildren = function () {
  4738. return this.displayedChildren;
  4739. };
  4740. ColumnGroup.prototype.getLeafColumns = function () {
  4741. var result = [];
  4742. this.addLeafColumns(result);
  4743. return result;
  4744. };
  4745. ColumnGroup.prototype.getDisplayedLeafColumns = function () {
  4746. var result = [];
  4747. this.addDisplayedLeafColumns(result);
  4748. return result;
  4749. };
  4750. // why two methods here doing the same thing?
  4751. ColumnGroup.prototype.getDefinition = function () {
  4752. return this.originalColumnGroup.getColGroupDef();
  4753. };
  4754. ColumnGroup.prototype.getColGroupDef = function () {
  4755. return this.originalColumnGroup.getColGroupDef();
  4756. };
  4757. ColumnGroup.prototype.isPadding = function () {
  4758. return this.originalColumnGroup.isPadding();
  4759. };
  4760. ColumnGroup.prototype.isExpandable = function () {
  4761. return this.originalColumnGroup.isExpandable();
  4762. };
  4763. ColumnGroup.prototype.isExpanded = function () {
  4764. return this.originalColumnGroup.isExpanded();
  4765. };
  4766. ColumnGroup.prototype.setExpanded = function (expanded) {
  4767. this.originalColumnGroup.setExpanded(expanded);
  4768. };
  4769. ColumnGroup.prototype.addDisplayedLeafColumns = function (leafColumns) {
  4770. this.displayedChildren.forEach(function (child) {
  4771. if (child instanceof Column) {
  4772. leafColumns.push(child);
  4773. }
  4774. else if (child instanceof ColumnGroup) {
  4775. child.addDisplayedLeafColumns(leafColumns);
  4776. }
  4777. });
  4778. };
  4779. ColumnGroup.prototype.addLeafColumns = function (leafColumns) {
  4780. this.children.forEach(function (child) {
  4781. if (child instanceof Column) {
  4782. leafColumns.push(child);
  4783. }
  4784. else if (child instanceof ColumnGroup) {
  4785. child.addLeafColumns(leafColumns);
  4786. }
  4787. });
  4788. };
  4789. ColumnGroup.prototype.getChildren = function () {
  4790. return this.children;
  4791. };
  4792. ColumnGroup.prototype.getColumnGroupShow = function () {
  4793. return this.originalColumnGroup.getColumnGroupShow();
  4794. };
  4795. ColumnGroup.prototype.getOriginalColumnGroup = function () {
  4796. return this.originalColumnGroup;
  4797. };
  4798. ColumnGroup.prototype.getPaddingLevel = function () {
  4799. var parent = this.getParent();
  4800. if (!this.isPadding() || !parent || !parent.isPadding()) {
  4801. return 0;
  4802. }
  4803. return 1 + parent.getPaddingLevel();
  4804. };
  4805. ColumnGroup.prototype.calculateDisplayedColumns = function () {
  4806. var _this = this;
  4807. // clear out last time we calculated
  4808. this.displayedChildren = [];
  4809. var topLevelGroup = this;
  4810. // find the column group that is controlling expandable. this is relevant when we have padding (empty)
  4811. // groups, where the expandable is actually the first parent that is not a padding group.
  4812. if (this.isPadding()) {
  4813. while (topLevelGroup.getParent() && topLevelGroup.isPadding()) {
  4814. topLevelGroup = topLevelGroup.getParent();
  4815. }
  4816. }
  4817. var isExpandable = topLevelGroup.originalColumnGroup.isExpandable();
  4818. // it not expandable, everything is visible
  4819. if (!isExpandable) {
  4820. this.displayedChildren = this.children;
  4821. }
  4822. else {
  4823. // Add cols based on columnGroupShow
  4824. // Note - the below also adds padding groups, these are always added because they never have
  4825. // colDef.columnGroupShow set.
  4826. this.children.forEach(function (abstractColumn) {
  4827. var headerGroupShow = abstractColumn.getColumnGroupShow();
  4828. switch (headerGroupShow) {
  4829. case ColumnGroup.HEADER_GROUP_SHOW_OPEN:
  4830. // when set to open, only show col if group is open
  4831. if (topLevelGroup.originalColumnGroup.isExpanded()) {
  4832. _this.displayedChildren.push(abstractColumn);
  4833. }
  4834. break;
  4835. case ColumnGroup.HEADER_GROUP_SHOW_CLOSED:
  4836. // when set to open, only show col if group is open
  4837. if (!topLevelGroup.originalColumnGroup.isExpanded()) {
  4838. _this.displayedChildren.push(abstractColumn);
  4839. }
  4840. break;
  4841. default:
  4842. // if this abstractColumn is padding, we just want to add it
  4843. // to the displayedChildren list if it has displayedChildren itself.
  4844. if (!(abstractColumn instanceof ColumnGroup &&
  4845. abstractColumn.isPadding() &&
  4846. !abstractColumn.displayedChildren.length)) {
  4847. _this.displayedChildren.push(abstractColumn);
  4848. }
  4849. break;
  4850. }
  4851. });
  4852. }
  4853. this.localEventService.dispatchEvent(this.createAgEvent(ColumnGroup.EVENT_DISPLAYED_CHILDREN_CHANGED));
  4854. };
  4855. ColumnGroup.HEADER_GROUP_SHOW_OPEN = 'open';
  4856. ColumnGroup.HEADER_GROUP_SHOW_CLOSED = 'closed';
  4857. ColumnGroup.HEADER_GROUP_PADDING = 'padding';
  4858. ColumnGroup.EVENT_LEFT_CHANGED = 'leftChanged';
  4859. ColumnGroup.EVENT_DISPLAYED_CHILDREN_CHANGED = 'displayedChildrenChanged';
  4860. __decorate$2([
  4861. Autowired('gridOptionsWrapper')
  4862. ], ColumnGroup.prototype, "gridOptionsWrapper", void 0);
  4863. return ColumnGroup;
  4864. }());
  4865. /**
  4866. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  4867. * @version v23.2.1
  4868. * @link http://www.ag-grid.com/
  4869. * @license MIT
  4870. */
  4871. var OriginalColumnGroup = /** @class */ (function () {
  4872. function OriginalColumnGroup(colGroupDef, groupId, padding, level) {
  4873. this.localEventService = new EventService();
  4874. this.expandable = false;
  4875. this.colGroupDef = colGroupDef;
  4876. this.groupId = groupId;
  4877. this.expanded = colGroupDef && !!colGroupDef.openByDefault;
  4878. this.padding = padding;
  4879. this.level = level;
  4880. }
  4881. OriginalColumnGroup.prototype.setOriginalParent = function (originalParent) {
  4882. this.originalParent = originalParent;
  4883. };
  4884. OriginalColumnGroup.prototype.getOriginalParent = function () {
  4885. return this.originalParent;
  4886. };
  4887. OriginalColumnGroup.prototype.getLevel = function () {
  4888. return this.level;
  4889. };
  4890. OriginalColumnGroup.prototype.isVisible = function () {
  4891. // return true if at least one child is visible
  4892. if (this.children) {
  4893. return this.children.some(function (child) { return child.isVisible(); });
  4894. }
  4895. return false;
  4896. };
  4897. OriginalColumnGroup.prototype.isPadding = function () {
  4898. return this.padding;
  4899. };
  4900. OriginalColumnGroup.prototype.setExpanded = function (expanded) {
  4901. this.expanded = expanded === undefined ? false : expanded;
  4902. var event = {
  4903. type: OriginalColumnGroup.EVENT_EXPANDED_CHANGED
  4904. };
  4905. this.localEventService.dispatchEvent(event);
  4906. };
  4907. OriginalColumnGroup.prototype.isExpandable = function () {
  4908. return this.expandable;
  4909. };
  4910. OriginalColumnGroup.prototype.isExpanded = function () {
  4911. return this.expanded;
  4912. };
  4913. OriginalColumnGroup.prototype.getGroupId = function () {
  4914. return this.groupId;
  4915. };
  4916. OriginalColumnGroup.prototype.getId = function () {
  4917. return this.getGroupId();
  4918. };
  4919. OriginalColumnGroup.prototype.setChildren = function (children) {
  4920. this.children = children;
  4921. };
  4922. OriginalColumnGroup.prototype.getChildren = function () {
  4923. return this.children;
  4924. };
  4925. OriginalColumnGroup.prototype.getColGroupDef = function () {
  4926. return this.colGroupDef;
  4927. };
  4928. OriginalColumnGroup.prototype.getLeafColumns = function () {
  4929. var result = [];
  4930. this.addLeafColumns(result);
  4931. return result;
  4932. };
  4933. OriginalColumnGroup.prototype.addLeafColumns = function (leafColumns) {
  4934. if (!this.children) {
  4935. return;
  4936. }
  4937. this.children.forEach(function (child) {
  4938. if (child instanceof Column) {
  4939. leafColumns.push(child);
  4940. }
  4941. else if (child instanceof OriginalColumnGroup) {
  4942. child.addLeafColumns(leafColumns);
  4943. }
  4944. });
  4945. };
  4946. OriginalColumnGroup.prototype.getColumnGroupShow = function () {
  4947. return this.padding ? ColumnGroup.HEADER_GROUP_PADDING : this.colGroupDef.columnGroupShow;
  4948. };
  4949. // need to check that this group has at least one col showing when both expanded and contracted.
  4950. // if not, then we don't allow expanding and contracting on this group
  4951. OriginalColumnGroup.prototype.setupExpandable = function () {
  4952. var _this = this;
  4953. this.setExpandable();
  4954. // note - we should be removing this event listener
  4955. this.getLeafColumns().forEach(function (col) { return col.addEventListener(Column.EVENT_VISIBLE_CHANGED, _this.onColumnVisibilityChanged.bind(_this)); });
  4956. };
  4957. OriginalColumnGroup.prototype.setExpandable = function () {
  4958. if (this.isPadding()) {
  4959. return;
  4960. }
  4961. // want to make sure the group doesn't disappear when it's open
  4962. var atLeastOneShowingWhenOpen = false;
  4963. // want to make sure the group doesn't disappear when it's closed
  4964. var atLeastOneShowingWhenClosed = false;
  4965. // want to make sure the group has something to show / hide
  4966. var atLeastOneChangeable = false;
  4967. var children = this.findChildren();
  4968. for (var i = 0, j = children.length; i < j; i++) {
  4969. var abstractColumn = children[i];
  4970. if (!abstractColumn.isVisible()) {
  4971. continue;
  4972. }
  4973. // if the abstractColumn is a grid generated group, there will be no colDef
  4974. var headerGroupShow = abstractColumn.getColumnGroupShow();
  4975. if (headerGroupShow === ColumnGroup.HEADER_GROUP_SHOW_OPEN) {
  4976. atLeastOneShowingWhenOpen = true;
  4977. atLeastOneChangeable = true;
  4978. }
  4979. else if (headerGroupShow === ColumnGroup.HEADER_GROUP_SHOW_CLOSED) {
  4980. atLeastOneShowingWhenClosed = true;
  4981. atLeastOneChangeable = true;
  4982. }
  4983. else {
  4984. atLeastOneShowingWhenOpen = true;
  4985. atLeastOneShowingWhenClosed = true;
  4986. if (headerGroupShow === ColumnGroup.HEADER_GROUP_PADDING) {
  4987. var column = abstractColumn;
  4988. atLeastOneChangeable = atLeastOneChangeable || column.children.some(function (child) { return child.getColumnGroupShow() !== undefined; });
  4989. }
  4990. }
  4991. }
  4992. var expandable = atLeastOneShowingWhenOpen && atLeastOneShowingWhenClosed && atLeastOneChangeable;
  4993. if (this.expandable !== expandable) {
  4994. this.expandable = expandable;
  4995. var event_1 = {
  4996. type: OriginalColumnGroup.EVENT_EXPANDABLE_CHANGED
  4997. };
  4998. this.localEventService.dispatchEvent(event_1);
  4999. }
  5000. };
  5001. OriginalColumnGroup.prototype.findChildren = function () {
  5002. var children = this.children;
  5003. var firstChild = children[0];
  5004. if (firstChild && (!firstChild.isPadding || !firstChild.isPadding())) {
  5005. return children;
  5006. }
  5007. while (children.length === 1 && children[0] instanceof OriginalColumnGroup) {
  5008. children = children[0].children;
  5009. }
  5010. return children;
  5011. };
  5012. OriginalColumnGroup.prototype.onColumnVisibilityChanged = function () {
  5013. this.setExpandable();
  5014. };
  5015. OriginalColumnGroup.prototype.addEventListener = function (eventType, listener) {
  5016. this.localEventService.addEventListener(eventType, listener);
  5017. };
  5018. OriginalColumnGroup.prototype.removeEventListener = function (eventType, listener) {
  5019. this.localEventService.removeEventListener(eventType, listener);
  5020. };
  5021. OriginalColumnGroup.EVENT_EXPANDED_CHANGED = 'expandedChanged';
  5022. OriginalColumnGroup.EVENT_EXPANDABLE_CHANGED = 'expandableChanged';
  5023. return OriginalColumnGroup;
  5024. }());
  5025. /**
  5026. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  5027. * @version v23.2.1
  5028. * @link http://www.ag-grid.com/
  5029. * @license MIT
  5030. */
  5031. var DefaultColumnTypes = {
  5032. numericColumn: {
  5033. headerClass: 'ag-right-aligned-header',
  5034. cellClass: 'ag-right-aligned-cell'
  5035. },
  5036. rightAligned: {
  5037. headerClass: 'ag-right-aligned-header',
  5038. cellClass: 'ag-right-aligned-cell'
  5039. }
  5040. };
  5041. /**
  5042. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  5043. * @version v23.2.1
  5044. * @link http://www.ag-grid.com/
  5045. * @license MIT
  5046. */
  5047. var __decorate$3 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  5048. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  5049. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  5050. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  5051. return c > 3 && r && Object.defineProperty(target, key, r), r;
  5052. };
  5053. var BeanStub = /** @class */ (function () {
  5054. function BeanStub() {
  5055. var _this = this;
  5056. this.destroyFunctions = [];
  5057. this.destroyed = false;
  5058. this.getContext = function () { return _this.context; };
  5059. this.isAlive = function () { return !_this.destroyed; };
  5060. }
  5061. // this was a test constructor niall built, when active, it prints after 5 seconds all beans/components that are
  5062. // not destroyed. to use, create a new grid, then api.destroy() before 5 seconds. then anything that gets printed
  5063. // points to a bean or component that was not properly disposed of.
  5064. // constructor() {
  5065. // setTimeout(()=> {
  5066. // if (this.isAlive()) {
  5067. // let prototype: any = Object.getPrototypeOf(this);
  5068. // const constructor: any = prototype.constructor;
  5069. // const constructorString = constructor.toString();
  5070. // const beanName = constructorString.substring(9, constructorString.indexOf("("));
  5071. // console.log('is alive ' + beanName);
  5072. // }
  5073. // }, 5000);
  5074. // }
  5075. // CellComp and GridComp and override this because they get the FrameworkOverrides from the Beans bean
  5076. BeanStub.prototype.getFrameworkOverrides = function () {
  5077. return this.frameworkOverrides;
  5078. };
  5079. BeanStub.prototype.destroy = function () {
  5080. // let prototype: any = Object.getPrototypeOf(this);
  5081. // const constructor: any = prototype.constructor;
  5082. // const constructorString = constructor.toString();
  5083. // const beanName = constructorString.substring(9, constructorString.indexOf("("));
  5084. this.destroyFunctions.forEach(function (func) { return func(); });
  5085. this.destroyFunctions.length = 0;
  5086. this.destroyed = true;
  5087. this.dispatchEvent({ type: BeanStub.EVENT_DESTROYED });
  5088. };
  5089. BeanStub.prototype.addEventListener = function (eventType, listener) {
  5090. if (!this.localEventService) {
  5091. this.localEventService = new EventService();
  5092. }
  5093. this.localEventService.addEventListener(eventType, listener);
  5094. };
  5095. BeanStub.prototype.removeEventListener = function (eventType, listener) {
  5096. if (this.localEventService) {
  5097. this.localEventService.removeEventListener(eventType, listener);
  5098. }
  5099. };
  5100. BeanStub.prototype.dispatchEventAsync = function (event) {
  5101. var _this = this;
  5102. window.setTimeout(function () { return _this.dispatchEvent(event); }, 0);
  5103. };
  5104. BeanStub.prototype.dispatchEvent = function (event) {
  5105. if (this.localEventService) {
  5106. this.localEventService.dispatchEvent(event);
  5107. }
  5108. };
  5109. BeanStub.prototype.addManagedListener = function (object, event, listener) {
  5110. var _this = this;
  5111. if (this.destroyed) {
  5112. return;
  5113. }
  5114. if (object instanceof HTMLElement) {
  5115. _.addSafePassiveEventListener(this.getFrameworkOverrides(), object, event, listener);
  5116. }
  5117. else {
  5118. object.addEventListener(event, listener);
  5119. }
  5120. var destroyFunc = function () {
  5121. object.removeEventListener(event, listener);
  5122. _this.destroyFunctions = _this.destroyFunctions.filter(function (fn) { return fn !== destroyFunc; });
  5123. return null;
  5124. };
  5125. this.destroyFunctions.push(destroyFunc);
  5126. return destroyFunc;
  5127. };
  5128. BeanStub.prototype.addDestroyFunc = function (func) {
  5129. // if we are already destroyed, we execute the func now
  5130. if (this.isAlive()) {
  5131. this.destroyFunctions.push(func);
  5132. }
  5133. else {
  5134. func();
  5135. }
  5136. };
  5137. BeanStub.prototype.createManagedBean = function (bean, context) {
  5138. var res = this.createBean(bean, context);
  5139. this.addDestroyFunc(this.destroyBean.bind(this, bean, context));
  5140. return res;
  5141. };
  5142. BeanStub.prototype.createBean = function (bean, context, afterPreCreateCallback) {
  5143. return (context || this.getContext()).createBean(bean, afterPreCreateCallback);
  5144. };
  5145. BeanStub.prototype.destroyBean = function (bean, context) {
  5146. return (context || this.getContext()).destroyBean(bean);
  5147. };
  5148. BeanStub.prototype.destroyBeans = function (beans, context) {
  5149. var _this = this;
  5150. if (beans) {
  5151. beans.forEach(function (bean) { return _this.destroyBean(bean, context); });
  5152. }
  5153. return [];
  5154. };
  5155. BeanStub.EVENT_DESTROYED = 'destroyed';
  5156. __decorate$3([
  5157. Autowired('frameworkOverrides')
  5158. ], BeanStub.prototype, "frameworkOverrides", void 0);
  5159. __decorate$3([
  5160. Autowired('context')
  5161. ], BeanStub.prototype, "context", void 0);
  5162. __decorate$3([
  5163. Autowired('eventService')
  5164. ], BeanStub.prototype, "eventService", void 0);
  5165. __decorate$3([
  5166. PreDestroy
  5167. ], BeanStub.prototype, "destroy", null);
  5168. return BeanStub;
  5169. }());
  5170. /**
  5171. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  5172. * @version v23.2.1
  5173. * @link http://www.ag-grid.com/
  5174. * @license MIT
  5175. */
  5176. var __extends = (undefined && undefined.__extends) || (function () {
  5177. var extendStatics = function (d, b) {
  5178. extendStatics = Object.setPrototypeOf ||
  5179. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  5180. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  5181. return extendStatics(d, b);
  5182. };
  5183. return function (d, b) {
  5184. extendStatics(d, b);
  5185. function __() { this.constructor = d; }
  5186. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  5187. };
  5188. })();
  5189. var __decorate$4 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  5190. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  5191. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  5192. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  5193. return c > 3 && r && Object.defineProperty(target, key, r), r;
  5194. };
  5195. var __param$1 = (undefined && undefined.__param) || function (paramIndex, decorator) {
  5196. return function (target, key) { decorator(target, key, paramIndex); }
  5197. };
  5198. // takes ColDefs and ColGroupDefs and turns them into Columns and OriginalGroups
  5199. var ColumnFactory = /** @class */ (function (_super) {
  5200. __extends(ColumnFactory, _super);
  5201. function ColumnFactory() {
  5202. return _super !== null && _super.apply(this, arguments) || this;
  5203. }
  5204. ColumnFactory.prototype.setBeans = function (loggerFactory) {
  5205. this.logger = loggerFactory.create('ColumnFactory');
  5206. };
  5207. ColumnFactory.prototype.createColumnTree = function (defs, primaryColumns, existingColumns) {
  5208. // column key creator dishes out unique column id's in a deterministic way,
  5209. // so if we have two grids (that could be master/slave) with same column definitions,
  5210. // then this ensures the two grids use identical id's.
  5211. var columnKeyCreator = new ColumnKeyCreator();
  5212. if (existingColumns) {
  5213. var existingKeys = existingColumns.map(function (col) { return col.getId(); });
  5214. columnKeyCreator.addExistingKeys(existingKeys);
  5215. }
  5216. // we take a copy of the columns as we are going to be removing from them
  5217. var existingColsCopy = existingColumns ? existingColumns.slice() : null;
  5218. // create am unbalanced tree that maps the provided definitions
  5219. var unbalancedTree = this.recursivelyCreateColumns(defs, 0, primaryColumns, existingColsCopy, columnKeyCreator, null);
  5220. var treeDept = this.findMaxDept(unbalancedTree, 0);
  5221. this.logger.log('Number of levels for grouped columns is ' + treeDept);
  5222. var columnTree = this.balanceColumnTree(unbalancedTree, 0, treeDept, columnKeyCreator);
  5223. var deptFirstCallback = function (child, parent) {
  5224. if (child instanceof OriginalColumnGroup) {
  5225. child.setupExpandable();
  5226. }
  5227. // we set the original parents at the end, rather than when we go along, as balancing the tree
  5228. // adds extra levels into the tree. so we can only set parents when balancing is done.
  5229. child.setOriginalParent(parent);
  5230. };
  5231. this.columnUtils.depthFirstOriginalTreeSearch(null, columnTree, deptFirstCallback);
  5232. return {
  5233. columnTree: columnTree,
  5234. treeDept: treeDept
  5235. };
  5236. };
  5237. ColumnFactory.prototype.createForAutoGroups = function (autoGroupCols, gridBalancedTree) {
  5238. var _this = this;
  5239. var autoColBalancedTree = [];
  5240. autoGroupCols.forEach(function (col) {
  5241. var fakeTreeItem = _this.createAutoGroupTreeItem(gridBalancedTree, col);
  5242. autoColBalancedTree.push(fakeTreeItem);
  5243. });
  5244. return autoColBalancedTree;
  5245. };
  5246. ColumnFactory.prototype.createAutoGroupTreeItem = function (balancedColumnTree, column) {
  5247. var dept = this.findDepth(balancedColumnTree);
  5248. // at the end, this will be the top of the tree item.
  5249. var nextChild = column;
  5250. for (var i = dept - 1; i >= 0; i--) {
  5251. var autoGroup = new OriginalColumnGroup(null, "FAKE_PATH_" + column.getId() + "}_" + i, true, i);
  5252. this.context.createBean(autoGroup);
  5253. autoGroup.setChildren([nextChild]);
  5254. nextChild.setOriginalParent(autoGroup);
  5255. nextChild = autoGroup;
  5256. }
  5257. // at this point, the nextChild is the top most item in the tree
  5258. return nextChild;
  5259. };
  5260. ColumnFactory.prototype.findDepth = function (balancedColumnTree) {
  5261. var dept = 0;
  5262. var pointer = balancedColumnTree;
  5263. while (pointer && pointer[0] && pointer[0] instanceof OriginalColumnGroup) {
  5264. dept++;
  5265. pointer = pointer[0].getChildren();
  5266. }
  5267. return dept;
  5268. };
  5269. ColumnFactory.prototype.balanceColumnTree = function (unbalancedTree, currentDept, columnDept, columnKeyCreator) {
  5270. var result = [];
  5271. // go through each child, for groups, recurse a level deeper,
  5272. // for columns we need to pad
  5273. for (var i = 0; i < unbalancedTree.length; i++) {
  5274. var child = unbalancedTree[i];
  5275. if (child instanceof OriginalColumnGroup) {
  5276. // child is a group, all we do is go to the next level of recursion
  5277. var originalGroup = child;
  5278. var newChildren = this.balanceColumnTree(originalGroup.getChildren(), currentDept + 1, columnDept, columnKeyCreator);
  5279. originalGroup.setChildren(newChildren);
  5280. result.push(originalGroup);
  5281. }
  5282. else {
  5283. // child is a column - so here we add in the padded column groups if needed
  5284. var firstPaddedGroup = void 0;
  5285. var currentPaddedGroup = void 0;
  5286. // this for loop will NOT run any loops if no padded column groups are needed
  5287. for (var j = columnDept - 1; j >= currentDept; j--) {
  5288. var newColId = columnKeyCreator.getUniqueKey(null, null);
  5289. var colGroupDefMerged = this.createMergedColGroupDef(null);
  5290. var paddedGroup = new OriginalColumnGroup(colGroupDefMerged, newColId, true, currentDept);
  5291. this.context.createBean(paddedGroup);
  5292. if (currentPaddedGroup) {
  5293. currentPaddedGroup.setChildren([paddedGroup]);
  5294. }
  5295. currentPaddedGroup = paddedGroup;
  5296. if (!firstPaddedGroup) {
  5297. firstPaddedGroup = currentPaddedGroup;
  5298. }
  5299. }
  5300. // likewise this if statement will not run if no padded groups
  5301. if (firstPaddedGroup) {
  5302. result.push(firstPaddedGroup);
  5303. var hasGroups = unbalancedTree.some(function (child) { return child instanceof OriginalColumnGroup; });
  5304. if (hasGroups) {
  5305. currentPaddedGroup.setChildren([child]);
  5306. continue;
  5307. }
  5308. else {
  5309. currentPaddedGroup.setChildren(unbalancedTree);
  5310. break;
  5311. }
  5312. }
  5313. result.push(child);
  5314. }
  5315. }
  5316. return result;
  5317. };
  5318. ColumnFactory.prototype.findMaxDept = function (treeChildren, dept) {
  5319. var maxDeptThisLevel = dept;
  5320. for (var i = 0; i < treeChildren.length; i++) {
  5321. var abstractColumn = treeChildren[i];
  5322. if (abstractColumn instanceof OriginalColumnGroup) {
  5323. var originalGroup = abstractColumn;
  5324. var newDept = this.findMaxDept(originalGroup.getChildren(), dept + 1);
  5325. if (maxDeptThisLevel < newDept) {
  5326. maxDeptThisLevel = newDept;
  5327. }
  5328. }
  5329. }
  5330. return maxDeptThisLevel;
  5331. };
  5332. ColumnFactory.prototype.recursivelyCreateColumns = function (defs, level, primaryColumns, existingColsCopy, columnKeyCreator, parent) {
  5333. var _this = this;
  5334. var result = [];
  5335. if (!defs) {
  5336. return result;
  5337. }
  5338. defs.forEach(function (def) {
  5339. var newGroupOrColumn;
  5340. if (_this.isColumnGroup(def)) {
  5341. newGroupOrColumn = _this.createColumnGroup(primaryColumns, def, level, existingColsCopy, columnKeyCreator, parent);
  5342. }
  5343. else {
  5344. newGroupOrColumn = _this.createColumn(primaryColumns, def, existingColsCopy, columnKeyCreator, parent);
  5345. }
  5346. result.push(newGroupOrColumn);
  5347. });
  5348. return result;
  5349. };
  5350. ColumnFactory.prototype.createColumnGroup = function (primaryColumns, colGroupDef, level, existingColumns, columnKeyCreator, parent) {
  5351. var colGroupDefMerged = this.createMergedColGroupDef(colGroupDef);
  5352. var groupId = columnKeyCreator.getUniqueKey(colGroupDefMerged.groupId, null);
  5353. var originalGroup = new OriginalColumnGroup(colGroupDefMerged, groupId, false, level);
  5354. this.context.createBean(originalGroup);
  5355. var children = this.recursivelyCreateColumns(colGroupDefMerged.children, level + 1, primaryColumns, existingColumns, columnKeyCreator, originalGroup);
  5356. originalGroup.setChildren(children);
  5357. return originalGroup;
  5358. };
  5359. ColumnFactory.prototype.createMergedColGroupDef = function (colGroupDef) {
  5360. var colGroupDefMerged = {};
  5361. _.assign(colGroupDefMerged, this.gridOptionsWrapper.getDefaultColGroupDef());
  5362. _.assign(colGroupDefMerged, colGroupDef);
  5363. this.checkForDeprecatedItems(colGroupDefMerged);
  5364. return colGroupDefMerged;
  5365. };
  5366. ColumnFactory.prototype.createColumn = function (primaryColumns, colDef, existingColsCopy, columnKeyCreator, parent) {
  5367. var colDefMerged = this.mergeColDefs(colDef);
  5368. this.checkForDeprecatedItems(colDefMerged);
  5369. // see if column already exists
  5370. var column = this.findExistingColumn(colDef, existingColsCopy);
  5371. if (!column) {
  5372. // no existing column, need to create one
  5373. var colId = columnKeyCreator.getUniqueKey(colDefMerged.colId, colDefMerged.field);
  5374. column = new Column(colDefMerged, colDef, colId, primaryColumns);
  5375. this.context.createBean(column);
  5376. }
  5377. else {
  5378. column.setColDef(colDefMerged, colDef);
  5379. }
  5380. return column;
  5381. };
  5382. ColumnFactory.prototype.findExistingColumn = function (colDef, existingColsCopy) {
  5383. var res = _.find(existingColsCopy, function (col) {
  5384. var oldColDef = col.getUserProvidedColDef();
  5385. if (!oldColDef) {
  5386. return false;
  5387. }
  5388. // first check object references
  5389. if (oldColDef === colDef) {
  5390. return true;
  5391. }
  5392. // second check id's
  5393. var oldColHadId = oldColDef.colId !== null && oldColDef.colId !== undefined;
  5394. if (oldColHadId) {
  5395. return oldColDef.colId === colDef.colId;
  5396. }
  5397. return false;
  5398. });
  5399. // make sure we remove, so if user provided duplicate id, then we don't have more than
  5400. // one column instance for colDef with common id
  5401. if (res) {
  5402. _.removeFromArray(existingColsCopy, res);
  5403. }
  5404. return res;
  5405. };
  5406. ColumnFactory.prototype.mergeColDefs = function (colDef) {
  5407. // start with empty merged definition
  5408. var colDefMerged = {};
  5409. // merge properties from default column definitions
  5410. _.assign(colDefMerged, this.gridOptionsWrapper.getDefaultColDef());
  5411. // merge properties from column type properties
  5412. if (colDef.type) {
  5413. this.assignColumnTypes(colDef, colDefMerged);
  5414. }
  5415. // merge properties from column definitions
  5416. _.assign(colDefMerged, colDef);
  5417. return colDefMerged;
  5418. };
  5419. ColumnFactory.prototype.assignColumnTypes = function (colDef, colDefMerged) {
  5420. var typeKeys;
  5421. if (colDef.type instanceof Array) {
  5422. var invalidArray = colDef.type.some(function (a) { return typeof a !== 'string'; });
  5423. if (invalidArray) {
  5424. console.warn("ag-grid: if colDef.type is supplied an array it should be of type 'string[]'");
  5425. }
  5426. else {
  5427. typeKeys = colDef.type;
  5428. }
  5429. }
  5430. else if (typeof colDef.type === 'string') {
  5431. typeKeys = colDef.type.split(',');
  5432. }
  5433. else {
  5434. console.warn("ag-grid: colDef.type should be of type 'string' | 'string[]'");
  5435. return;
  5436. }
  5437. // merge user defined with default column types
  5438. var allColumnTypes = _.assign({}, DefaultColumnTypes);
  5439. var userTypes = this.gridOptionsWrapper.getColumnTypes() || {};
  5440. _.iterateObject(userTypes, function (key, value) {
  5441. if (key in allColumnTypes) {
  5442. console.warn("ag-Grid: the column type '" + key + "' is a default column type and cannot be overridden.");
  5443. }
  5444. else {
  5445. allColumnTypes[key] = value;
  5446. }
  5447. });
  5448. typeKeys.forEach(function (t) {
  5449. var typeColDef = allColumnTypes[t.trim()];
  5450. if (typeColDef) {
  5451. _.assign(colDefMerged, typeColDef);
  5452. }
  5453. else {
  5454. console.warn("ag-grid: colDef.type '" + t + "' does not correspond to defined gridOptions.columnTypes");
  5455. }
  5456. });
  5457. };
  5458. ColumnFactory.prototype.checkForDeprecatedItems = function (colDef) {
  5459. if (colDef) {
  5460. var colDefNoType = colDef; // take out the type, so we can access attributes not defined in the type
  5461. if (colDefNoType.group !== undefined) {
  5462. console.warn('ag-grid: colDef.group is invalid, please check documentation on how to do grouping as it changed in version 3');
  5463. }
  5464. if (colDefNoType.headerGroup !== undefined) {
  5465. console.warn('ag-grid: colDef.headerGroup is invalid, please check documentation on how to do grouping as it changed in version 3');
  5466. }
  5467. if (colDefNoType.headerGroupShow !== undefined) {
  5468. console.warn('ag-grid: colDef.headerGroupShow is invalid, should be columnGroupShow, please check documentation on how to do grouping as it changed in version 3');
  5469. }
  5470. if (colDefNoType.suppressRowGroup !== undefined) {
  5471. console.warn('ag-grid: colDef.suppressRowGroup is deprecated, please use colDef.type instead');
  5472. }
  5473. if (colDefNoType.suppressAggregation !== undefined) {
  5474. console.warn('ag-grid: colDef.suppressAggregation is deprecated, please use colDef.type instead');
  5475. }
  5476. if (colDefNoType.suppressRowGroup || colDefNoType.suppressAggregation) {
  5477. console.warn('ag-grid: colDef.suppressAggregation and colDef.suppressRowGroup are deprecated, use allowRowGroup, allowPivot and allowValue instead');
  5478. }
  5479. if (colDefNoType.displayName) {
  5480. console.warn("ag-grid: Found displayName " + colDefNoType.displayName + ", please use headerName instead, displayName is deprecated.");
  5481. colDefNoType.headerName = colDefNoType.displayName;
  5482. }
  5483. }
  5484. };
  5485. // if object has children, we assume it's a group
  5486. ColumnFactory.prototype.isColumnGroup = function (abstractColDef) {
  5487. return abstractColDef.children !== undefined;
  5488. };
  5489. __decorate$4([
  5490. Autowired('gridOptionsWrapper')
  5491. ], ColumnFactory.prototype, "gridOptionsWrapper", void 0);
  5492. __decorate$4([
  5493. Autowired('columnUtils')
  5494. ], ColumnFactory.prototype, "columnUtils", void 0);
  5495. __decorate$4([
  5496. __param$1(0, Qualifier('loggerFactory'))
  5497. ], ColumnFactory.prototype, "setBeans", null);
  5498. ColumnFactory = __decorate$4([
  5499. Bean('columnFactory')
  5500. ], ColumnFactory);
  5501. return ColumnFactory;
  5502. }(BeanStub));
  5503. /**
  5504. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  5505. * @version v23.2.1
  5506. * @link http://www.ag-grid.com/
  5507. * @license MIT
  5508. */
  5509. var Events = /** @class */ (function () {
  5510. function Events() {
  5511. }
  5512. /** Everything has changed with the columns. Either complete new set of columns set, or user called setState()*/
  5513. Events.EVENT_COLUMN_EVERYTHING_CHANGED = 'columnEverythingChanged';
  5514. /** User has set in new columns. */
  5515. Events.EVENT_NEW_COLUMNS_LOADED = 'newColumnsLoaded';
  5516. /** The pivot mode flag was changed */
  5517. Events.EVENT_COLUMN_PIVOT_MODE_CHANGED = 'columnPivotModeChanged';
  5518. /** A row group column was added, removed or order changed. */
  5519. Events.EVENT_COLUMN_ROW_GROUP_CHANGED = 'columnRowGroupChanged';
  5520. /** expandAll / collapseAll was called from the api. */
  5521. Events.EVENT_EXPAND_COLLAPSE_ALL = 'expandOrCollapseAll';
  5522. /** A pivot column was added, removed or order changed. */
  5523. Events.EVENT_COLUMN_PIVOT_CHANGED = 'columnPivotChanged';
  5524. /** The list of grid columns has changed. */
  5525. Events.EVENT_GRID_COLUMNS_CHANGED = 'gridColumnsChanged';
  5526. /** A value column was added, removed or agg function was changed. */
  5527. Events.EVENT_COLUMN_VALUE_CHANGED = 'columnValueChanged';
  5528. /** A column was moved */
  5529. Events.EVENT_COLUMN_MOVED = 'columnMoved';
  5530. /** One or more columns was shown / hidden */
  5531. Events.EVENT_COLUMN_VISIBLE = 'columnVisible';
  5532. /** One or more columns was pinned / unpinned*/
  5533. Events.EVENT_COLUMN_PINNED = 'columnPinned';
  5534. /** A column group was opened / closed */
  5535. Events.EVENT_COLUMN_GROUP_OPENED = 'columnGroupOpened';
  5536. /** One or more columns was resized. If just one, the column in the event is set. */
  5537. Events.EVENT_COLUMN_RESIZED = 'columnResized';
  5538. /** The list of displayed columns has changed, can result from columns open / close, column move, pivot, group, etc */
  5539. Events.EVENT_DISPLAYED_COLUMNS_CHANGED = 'displayedColumnsChanged';
  5540. /** The list of virtual columns has changed, results from viewport changing */
  5541. Events.EVENT_VIRTUAL_COLUMNS_CHANGED = 'virtualColumnsChanged';
  5542. /** A row group was opened / closed */
  5543. Events.EVENT_ROW_GROUP_OPENED = 'rowGroupOpened';
  5544. /** The client has set new data into the grid */
  5545. Events.EVENT_ROW_DATA_CHANGED = 'rowDataChanged';
  5546. /** The client has updated data for the grid */
  5547. Events.EVENT_ROW_DATA_UPDATED = 'rowDataUpdated';
  5548. /** The client has set new floating data into the grid */
  5549. Events.EVENT_PINNED_ROW_DATA_CHANGED = 'pinnedRowDataChanged';
  5550. /** Range selection has changed */
  5551. Events.EVENT_RANGE_SELECTION_CHANGED = 'rangeSelectionChanged';
  5552. /** Chart was created */
  5553. Events.EVENT_CHART_CREATED = 'chartCreated';
  5554. /** Chart Range selection has changed */
  5555. Events.EVENT_CHART_RANGE_SELECTION_CHANGED = 'chartRangeSelectionChanged';
  5556. /** Chart Options have changed */
  5557. Events.EVENT_CHART_OPTIONS_CHANGED = 'chartOptionsChanged';
  5558. /** Chart was destroyed */
  5559. Events.EVENT_CHART_DESTROYED = 'chartDestroyed';
  5560. /** For when the tool panel is shown / hidden */
  5561. Events.EVENT_TOOL_PANEL_VISIBLE_CHANGED = 'toolPanelVisibleChanged';
  5562. /** Model was updated - grid updates the drawn rows when this happens */
  5563. Events.EVENT_MODEL_UPDATED = 'modelUpdated';
  5564. Events.EVENT_PASTE_START = 'pasteStart';
  5565. Events.EVENT_PASTE_END = 'pasteEnd';
  5566. Events.EVENT_FILL_START = 'fillStart';
  5567. Events.EVENT_FILL_END = 'fillEnd';
  5568. Events.EVENT_CELL_CLICKED = 'cellClicked';
  5569. Events.EVENT_CELL_DOUBLE_CLICKED = 'cellDoubleClicked';
  5570. Events.EVENT_CELL_MOUSE_DOWN = 'cellMouseDown';
  5571. Events.EVENT_CELL_CONTEXT_MENU = 'cellContextMenu';
  5572. Events.EVENT_CELL_VALUE_CHANGED = 'cellValueChanged';
  5573. Events.EVENT_ROW_VALUE_CHANGED = 'rowValueChanged';
  5574. Events.EVENT_CELL_FOCUSED = 'cellFocused';
  5575. Events.EVENT_ROW_SELECTED = 'rowSelected';
  5576. Events.EVENT_SELECTION_CHANGED = 'selectionChanged';
  5577. Events.EVENT_CELL_KEY_DOWN = 'cellKeyDown';
  5578. Events.EVENT_CELL_KEY_PRESS = 'cellKeyPress';
  5579. Events.EVENT_CELL_MOUSE_OVER = 'cellMouseOver';
  5580. Events.EVENT_CELL_MOUSE_OUT = 'cellMouseOut';
  5581. /** 2 events for filtering. The grid LISTENS for filterChanged and afterFilterChanged */
  5582. Events.EVENT_FILTER_CHANGED = 'filterChanged';
  5583. /** Filter was change but not applied. Only useful if apply buttons are used in filters. */
  5584. Events.EVENT_FILTER_MODIFIED = 'filterModified';
  5585. Events.EVENT_FILTER_OPENED = 'filterOpened';
  5586. Events.EVENT_SORT_CHANGED = 'sortChanged';
  5587. /** A row was removed from the dom, for any reason. Use to clean up resources (if any) used by the row. */
  5588. Events.EVENT_VIRTUAL_ROW_REMOVED = 'virtualRowRemoved';
  5589. Events.EVENT_ROW_CLICKED = 'rowClicked';
  5590. Events.EVENT_ROW_DOUBLE_CLICKED = 'rowDoubleClicked';
  5591. /** Gets called once after the grid has finished initialising. */
  5592. Events.EVENT_GRID_READY = 'gridReady';
  5593. /** Width of height of the main grid div has changed. Grid listens for this and does layout of grid if it's
  5594. * changed, so always filling the space it was given. */
  5595. Events.EVENT_GRID_SIZE_CHANGED = 'gridSizeChanged';
  5596. /** The indexes of the rows rendered has changed, eg user has scrolled to a new vertical position. */
  5597. Events.EVENT_VIEWPORT_CHANGED = 'viewportChanged';
  5598. /** Rows were rendered for the first time (ie on async data load). */
  5599. Events.EVENT_FIRST_DATA_RENDERED = 'firstDataRendered';
  5600. /** A column drag has started, either resizing a column or moving a column. */
  5601. Events.EVENT_DRAG_STARTED = 'dragStarted';
  5602. /** A column drag has stopped */
  5603. Events.EVENT_DRAG_STOPPED = 'dragStopped';
  5604. Events.EVENT_CHECKBOX_CHANGED = 'checkboxChanged';
  5605. Events.EVENT_ROW_EDITING_STARTED = 'rowEditingStarted';
  5606. Events.EVENT_ROW_EDITING_STOPPED = 'rowEditingStopped';
  5607. Events.EVENT_CELL_EDITING_STARTED = 'cellEditingStarted';
  5608. Events.EVENT_CELL_EDITING_STOPPED = 'cellEditingStopped';
  5609. /** Main body of grid has scrolled, either horizontally or vertically */
  5610. Events.EVENT_BODY_SCROLL = 'bodyScroll';
  5611. Events.EVENT_ANIMATION_QUEUE_EMPTY = 'animationQueueEmpty';
  5612. Events.EVENT_HEIGHT_SCALE_CHANGED = 'heightScaleChanged';
  5613. /** The displayed page for pagination has changed. For example the data was filtered or sorted,
  5614. * or the user has moved to a different page. */
  5615. Events.EVENT_PAGINATION_CHANGED = 'paginationChanged';
  5616. /** Only used by React, Angular 2+, Web Components and VueJS ag-Grid components
  5617. * (not used if doing plain JavaScript or Angular 1.x). If the grid receives changes due
  5618. * to bound properties, this event fires after the grid has finished processing the change. */
  5619. Events.EVENT_COMPONENT_STATE_CHANGED = 'componentStateChanged';
  5620. /** All items from here down are used internally by the grid, not intended for external use. */
  5621. // not documented, either experimental, or we just don't want users using an depending on them
  5622. Events.EVENT_BODY_HEIGHT_CHANGED = 'bodyHeightChanged';
  5623. Events.EVENT_DISPLAYED_COLUMNS_WIDTH_CHANGED = 'displayedColumnsWidthChanged';
  5624. Events.EVENT_SCROLL_VISIBILITY_CHANGED = 'scrollVisibilityChanged';
  5625. Events.EVENT_COLUMN_HOVER_CHANGED = 'columnHoverChanged';
  5626. Events.EVENT_FLASH_CELLS = 'flashCells';
  5627. Events.EVENT_ROW_DRAG_ENTER = 'rowDragEnter';
  5628. Events.EVENT_ROW_DRAG_MOVE = 'rowDragMove';
  5629. Events.EVENT_ROW_DRAG_LEAVE = 'rowDragLeave';
  5630. Events.EVENT_ROW_DRAG_END = 'rowDragEnd';
  5631. // primarily for charts
  5632. Events.EVENT_POPUP_TO_FRONT = 'popupToFront';
  5633. // these are used for server side group and agg - only used by CS with Viewport Row Model - intention is
  5634. // to design these better around server side functions and then release to general public when fully working with
  5635. // all the row models.
  5636. Events.EVENT_COLUMN_ROW_GROUP_CHANGE_REQUEST = 'columnRowGroupChangeRequest';
  5637. Events.EVENT_COLUMN_PIVOT_CHANGE_REQUEST = 'columnPivotChangeRequest';
  5638. Events.EVENT_COLUMN_VALUE_CHANGE_REQUEST = 'columnValueChangeRequest';
  5639. Events.EVENT_COLUMN_AGG_FUNC_CHANGE_REQUEST = 'columnAggFuncChangeRequest';
  5640. Events.EVENT_KEYBOARD_FOCUS = 'keyboardFocus';
  5641. Events.EVENT_MOUSE_FOCUS = 'mouseFocus';
  5642. return Events;
  5643. }());
  5644. /**
  5645. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  5646. * @version v23.2.1
  5647. * @link http://www.ag-grid.com/
  5648. * @license MIT
  5649. */
  5650. // class returns unique instance id's for columns.
  5651. // eg, the following calls (in this order) will result in:
  5652. //
  5653. // getInstanceIdForKey('country') => 0
  5654. // getInstanceIdForKey('country') => 1
  5655. // getInstanceIdForKey('country') => 2
  5656. // getInstanceIdForKey('country') => 3
  5657. // getInstanceIdForKey('age') => 0
  5658. // getInstanceIdForKey('age') => 1
  5659. // getInstanceIdForKey('country') => 4
  5660. var GroupInstanceIdCreator = /** @class */ (function () {
  5661. function GroupInstanceIdCreator() {
  5662. // this map contains keys to numbers, so we remember what the last call was
  5663. this.existingIds = {};
  5664. }
  5665. GroupInstanceIdCreator.prototype.getInstanceIdForKey = function (key) {
  5666. var lastResult = this.existingIds[key];
  5667. var result;
  5668. if (typeof lastResult !== 'number') {
  5669. // first time this key
  5670. result = 0;
  5671. }
  5672. else {
  5673. result = lastResult + 1;
  5674. }
  5675. this.existingIds[key] = result;
  5676. return result;
  5677. };
  5678. return GroupInstanceIdCreator;
  5679. }());
  5680. /**
  5681. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  5682. * @version v23.2.1
  5683. * @link http://www.ag-grid.com/
  5684. * @license MIT
  5685. */
  5686. var __extends$1 = (undefined && undefined.__extends) || (function () {
  5687. var extendStatics = function (d, b) {
  5688. extendStatics = Object.setPrototypeOf ||
  5689. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  5690. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  5691. return extendStatics(d, b);
  5692. };
  5693. return function (d, b) {
  5694. extendStatics(d, b);
  5695. function __() { this.constructor = d; }
  5696. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  5697. };
  5698. })();
  5699. var __decorate$5 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  5700. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  5701. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  5702. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  5703. return c > 3 && r && Object.defineProperty(target, key, r), r;
  5704. };
  5705. var __param$2 = (undefined && undefined.__param) || function (paramIndex, decorator) {
  5706. return function (target, key) { decorator(target, key, paramIndex); }
  5707. };
  5708. var ColumnController = /** @class */ (function (_super) {
  5709. __extends$1(ColumnController, _super);
  5710. function ColumnController() {
  5711. var _this = _super !== null && _super.apply(this, arguments) || this;
  5712. // header row count, based on user provided columns
  5713. _this.primaryHeaderRowCount = 0;
  5714. _this.secondaryHeaderRowCount = 0;
  5715. _this.secondaryColumnsPresent = false;
  5716. // header row count, either above, or based on pivoting if we are pivoting
  5717. _this.gridHeaderRowCount = 0;
  5718. // these are the lists used by the rowRenderer to render nodes. almost the leaf nodes of the above
  5719. // displayed trees, however it also takes into account if the groups are open or not.
  5720. _this.displayedLeftColumns = [];
  5721. _this.displayedRightColumns = [];
  5722. _this.displayedCenterColumns = [];
  5723. // all three lists above combined
  5724. _this.allDisplayedColumns = [];
  5725. // same as above, except trimmed down to only columns within the viewport
  5726. _this.allDisplayedVirtualColumns = [];
  5727. _this.allDisplayedCenterVirtualColumns = [];
  5728. _this.rowGroupColumns = [];
  5729. _this.valueColumns = [];
  5730. _this.pivotColumns = [];
  5731. _this.ready = false;
  5732. _this.autoGroupsNeedBuilding = false;
  5733. _this.forceRecreateAutoGroups = false;
  5734. _this.pivotMode = false;
  5735. _this.bodyWidth = 0;
  5736. _this.leftWidth = 0;
  5737. _this.rightWidth = 0;
  5738. _this.bodyWidthDirty = true;
  5739. _this.flexActive = false;
  5740. return _this;
  5741. }
  5742. ColumnController.prototype.init = function () {
  5743. this.suppressColumnVirtualisation = this.gridOptionsWrapper.isSuppressColumnVirtualisation();
  5744. var pivotMode = this.gridOptionsWrapper.isPivotMode();
  5745. if (this.isPivotSettingAllowed(pivotMode)) {
  5746. this.pivotMode = pivotMode;
  5747. }
  5748. this.usingTreeData = this.gridOptionsWrapper.isTreeData();
  5749. this.addManagedListener(this.gridOptionsWrapper, 'autoGroupColumnDef', this.onAutoGroupColumnDefChanged.bind(this));
  5750. };
  5751. ColumnController.prototype.onAutoGroupColumnDefChanged = function () {
  5752. this.autoGroupsNeedBuilding = true;
  5753. this.forceRecreateAutoGroups = true;
  5754. this.updateGridColumns();
  5755. this.updateDisplayedColumns('gridOptionsChanged');
  5756. };
  5757. ColumnController.prototype.setColumnDefs = function (columnDefs, source) {
  5758. if (source === void 0) { source = 'api'; }
  5759. var colsPreviouslyExisted = !!this.columnDefs;
  5760. this.columnDefs = columnDefs;
  5761. // always invalidate cache on changing columns, as the column id's for the new columns
  5762. // could overlap with the old id's, so the cache would return old values for new columns.
  5763. this.valueCache.expire();
  5764. // NOTE ==================
  5765. // we should be destroying the existing columns and groups if they exist, for example, the original column
  5766. // group adds a listener to the columns, it should be also removing the listeners
  5767. this.autoGroupsNeedBuilding = true;
  5768. var oldPrimaryColumns = this.primaryColumns;
  5769. var balancedTreeResult = this.columnFactory.createColumnTree(columnDefs, true, oldPrimaryColumns);
  5770. this.primaryColumnTree = balancedTreeResult.columnTree;
  5771. this.primaryHeaderRowCount = balancedTreeResult.treeDept + 1;
  5772. this.primaryColumns = this.getColumnsFromTree(this.primaryColumnTree);
  5773. this.extractRowGroupColumns(source, oldPrimaryColumns);
  5774. this.extractPivotColumns(source, oldPrimaryColumns);
  5775. this.createValueColumns(source, oldPrimaryColumns);
  5776. this.ready = true;
  5777. this.updateGridColumns();
  5778. this.updateDisplayedColumns(source);
  5779. this.checkDisplayedVirtualColumns();
  5780. if (this.gridOptionsWrapper.isImmutableColumns() && colsPreviouslyExisted) {
  5781. this.resetColumnState(true, source);
  5782. }
  5783. var eventEverythingChanged = {
  5784. type: Events.EVENT_COLUMN_EVERYTHING_CHANGED,
  5785. api: this.gridApi,
  5786. columnApi: this.columnApi,
  5787. source: source
  5788. };
  5789. this.eventService.dispatchEvent(eventEverythingChanged);
  5790. var newColumnsLoadedEvent = {
  5791. type: Events.EVENT_NEW_COLUMNS_LOADED,
  5792. api: this.gridApi,
  5793. columnApi: this.columnApi
  5794. };
  5795. this.eventService.dispatchEvent(newColumnsLoadedEvent);
  5796. this.flexActive = this.getDisplayedCenterColumns().some(function (col) { return !!col.getFlex(); });
  5797. };
  5798. ColumnController.prototype.isAutoRowHeightActive = function () {
  5799. return this.autoRowHeightColumns && this.autoRowHeightColumns.length > 0;
  5800. };
  5801. ColumnController.prototype.getAllAutoRowHeightCols = function () {
  5802. return this.autoRowHeightColumns;
  5803. };
  5804. ColumnController.prototype.setVirtualViewportLeftAndRight = function () {
  5805. if (this.gridOptionsWrapper.isEnableRtl()) {
  5806. this.viewportLeft = this.bodyWidth - this.scrollPosition - this.scrollWidth;
  5807. this.viewportRight = this.bodyWidth - this.scrollPosition;
  5808. }
  5809. else {
  5810. this.viewportLeft = this.scrollPosition;
  5811. this.viewportRight = this.scrollWidth + this.scrollPosition;
  5812. }
  5813. };
  5814. // used by clipboard service, to know what columns to paste into
  5815. ColumnController.prototype.getDisplayedColumnsStartingAt = function (column) {
  5816. var currentColumn = column;
  5817. var columns = [];
  5818. while (currentColumn != null) {
  5819. columns.push(currentColumn);
  5820. currentColumn = this.getDisplayedColAfter(currentColumn);
  5821. }
  5822. return columns;
  5823. };
  5824. // checks what columns are currently displayed due to column virtualisation. fires an event
  5825. // if the list of columns has changed.
  5826. // + setColumnWidth(), setVirtualViewportPosition(), setColumnDefs(), sizeColumnsToFit()
  5827. ColumnController.prototype.checkDisplayedVirtualColumns = function () {
  5828. // check displayCenterColumnTree exists first, as it won't exist when grid is initialising
  5829. if (this.displayedCenterColumns == null) {
  5830. return;
  5831. }
  5832. var hashBefore = this.allDisplayedVirtualColumns.map(function (column) { return column.getId(); }).join('#');
  5833. this.updateVirtualSets();
  5834. var hashAfter = this.allDisplayedVirtualColumns.map(function (column) { return column.getId(); }).join('#');
  5835. if (hashBefore !== hashAfter) {
  5836. var event_1 = {
  5837. type: Events.EVENT_VIRTUAL_COLUMNS_CHANGED,
  5838. api: this.gridApi,
  5839. columnApi: this.columnApi
  5840. };
  5841. this.eventService.dispatchEvent(event_1);
  5842. }
  5843. };
  5844. ColumnController.prototype.setVirtualViewportPosition = function (scrollWidth, scrollPosition) {
  5845. if (scrollWidth !== this.scrollWidth || scrollPosition !== this.scrollPosition || this.bodyWidthDirty) {
  5846. this.scrollWidth = scrollWidth;
  5847. this.scrollPosition = scrollPosition;
  5848. // we need to call setVirtualViewportLeftAndRight() at least once after the body width changes,
  5849. // as the viewport can stay the same, but in RTL, if body width changes, we need to work out the
  5850. // virtual columns again
  5851. this.bodyWidthDirty = true;
  5852. this.setVirtualViewportLeftAndRight();
  5853. if (this.ready) {
  5854. this.checkDisplayedVirtualColumns();
  5855. }
  5856. }
  5857. };
  5858. ColumnController.prototype.isPivotMode = function () {
  5859. return this.pivotMode;
  5860. };
  5861. ColumnController.prototype.isPivotSettingAllowed = function (pivot) {
  5862. if (pivot && this.gridOptionsWrapper.isTreeData()) {
  5863. console.warn("ag-Grid: Pivot mode not available in conjunction Tree Data i.e. 'gridOptions.treeData: true'");
  5864. return false;
  5865. }
  5866. return true;
  5867. };
  5868. ColumnController.prototype.setPivotMode = function (pivotMode, source) {
  5869. if (source === void 0) { source = 'api'; }
  5870. if (pivotMode === this.pivotMode || !this.isPivotSettingAllowed(this.pivotMode)) {
  5871. return;
  5872. }
  5873. this.pivotMode = pivotMode;
  5874. // we need to update grid columns to cover the scenario where user has groupSuppressAutoColumn=true, as
  5875. // this means we don't use auto group column UNLESS we are in pivot mode (it's mandatory in pivot mode),
  5876. // so need to updateGridColumn() to check it autoGroupCol needs to be added / removed
  5877. this.autoGroupsNeedBuilding = true;
  5878. this.updateGridColumns();
  5879. this.updateDisplayedColumns(source);
  5880. var event = {
  5881. type: Events.EVENT_COLUMN_PIVOT_MODE_CHANGED,
  5882. api: this.gridApi,
  5883. columnApi: this.columnApi
  5884. };
  5885. this.eventService.dispatchEvent(event);
  5886. };
  5887. ColumnController.prototype.getSecondaryPivotColumn = function (pivotKeys, valueColKey) {
  5888. if (!this.secondaryColumnsPresent || !this.secondaryColumns) {
  5889. return null;
  5890. }
  5891. var valueColumnToFind = this.getPrimaryColumn(valueColKey);
  5892. var foundColumn = null;
  5893. this.secondaryColumns.forEach(function (column) {
  5894. var thisPivotKeys = column.getColDef().pivotKeys;
  5895. var pivotValueColumn = column.getColDef().pivotValueColumn;
  5896. var pivotKeyMatches = areEqual(thisPivotKeys, pivotKeys);
  5897. var pivotValueMatches = pivotValueColumn === valueColumnToFind;
  5898. if (pivotKeyMatches && pivotValueMatches) {
  5899. foundColumn = column;
  5900. }
  5901. });
  5902. return foundColumn;
  5903. };
  5904. ColumnController.prototype.setBeans = function (loggerFactory) {
  5905. this.logger = loggerFactory.create('ColumnController');
  5906. };
  5907. ColumnController.prototype.setFirstRightAndLastLeftPinned = function (source) {
  5908. var lastLeft;
  5909. var firstRight;
  5910. if (this.gridOptionsWrapper.isEnableRtl()) {
  5911. lastLeft = this.displayedLeftColumns ? this.displayedLeftColumns[0] : null;
  5912. firstRight = this.displayedRightColumns ? _.last(this.displayedRightColumns) : null;
  5913. }
  5914. else {
  5915. lastLeft = this.displayedLeftColumns ? _.last(this.displayedLeftColumns) : null;
  5916. firstRight = this.displayedRightColumns ? this.displayedRightColumns[0] : null;
  5917. }
  5918. this.gridColumns.forEach(function (column) {
  5919. column.setLastLeftPinned(column === lastLeft, source);
  5920. column.setFirstRightPinned(column === firstRight, source);
  5921. });
  5922. };
  5923. ColumnController.prototype.autoSizeColumns = function (keys, skipHeader, source) {
  5924. // because of column virtualisation, we can only do this function on columns that are
  5925. // actually rendered, as non-rendered columns (outside the viewport and not rendered
  5926. // due to column virtualisation) are not present. this can result in all rendered columns
  5927. // getting narrowed, which in turn introduces more rendered columns on the RHS which
  5928. // did not get autosized in the original run, leaving the visible grid with columns on
  5929. // the LHS sized, but RHS no. so we keep looping through the visible columns until
  5930. // no more cols are available (rendered) to be resized
  5931. var _this = this;
  5932. if (source === void 0) { source = "api"; }
  5933. // we autosize after animation frames finish in case any cell renderers need to complete first. this can
  5934. // happen eg if client code is calling api.autoSizeAllColumns() straight after grid is initialised, but grid
  5935. // hasn't fully drawn out all the cells yet (due to cell renderers in animation frames).
  5936. this.animationFrameService.flushAllFrames();
  5937. // keep track of which cols we have resized in here
  5938. var columnsAutosized = [];
  5939. // initialise with anything except 0 so that while loop executes at least once
  5940. var changesThisTimeAround = -1;
  5941. if (skipHeader == null) {
  5942. skipHeader = this.gridOptionsWrapper.isSkipHeaderOnAutoSize();
  5943. }
  5944. while (changesThisTimeAround !== 0) {
  5945. changesThisTimeAround = 0;
  5946. this.actionOnGridColumns(keys, function (column) {
  5947. // if already autosized, skip it
  5948. if (columnsAutosized.indexOf(column) >= 0) {
  5949. return false;
  5950. }
  5951. // get how wide this col should be
  5952. var preferredWidth = _this.autoWidthCalculator.getPreferredWidthForColumn(column, skipHeader);
  5953. // preferredWidth = -1 if this col is not on the screen
  5954. if (preferredWidth > 0) {
  5955. var newWidth = _this.normaliseColumnWidth(column, preferredWidth);
  5956. column.setActualWidth(newWidth, source);
  5957. columnsAutosized.push(column);
  5958. changesThisTimeAround++;
  5959. }
  5960. return true;
  5961. }, source);
  5962. }
  5963. if (columnsAutosized.length) {
  5964. var event_2 = {
  5965. type: Events.EVENT_COLUMN_RESIZED,
  5966. columns: columnsAutosized,
  5967. column: columnsAutosized.length === 1 ? columnsAutosized[0] : null,
  5968. finished: true,
  5969. api: this.gridApi,
  5970. columnApi: this.columnApi,
  5971. source: "autosizeColumns"
  5972. };
  5973. this.eventService.dispatchEvent(event_2);
  5974. }
  5975. };
  5976. ColumnController.prototype.autoSizeColumn = function (key, skipHeader, source) {
  5977. if (source === void 0) { source = "api"; }
  5978. if (key) {
  5979. this.autoSizeColumns([key], skipHeader, source);
  5980. }
  5981. };
  5982. ColumnController.prototype.autoSizeAllColumns = function (skipHeader, source) {
  5983. if (source === void 0) { source = "api"; }
  5984. var allDisplayedColumns = this.getAllDisplayedColumns();
  5985. this.autoSizeColumns(allDisplayedColumns, skipHeader, source);
  5986. };
  5987. ColumnController.prototype.getColumnsFromTree = function (rootColumns) {
  5988. var result = [];
  5989. var recursiveFindColumns = function (childColumns) {
  5990. for (var i = 0; i < childColumns.length; i++) {
  5991. var child = childColumns[i];
  5992. if (child instanceof Column) {
  5993. result.push(child);
  5994. }
  5995. else if (child instanceof OriginalColumnGroup) {
  5996. recursiveFindColumns(child.getChildren());
  5997. }
  5998. }
  5999. };
  6000. recursiveFindColumns(rootColumns);
  6001. return result;
  6002. };
  6003. ColumnController.prototype.getAllDisplayedColumnGroups = function () {
  6004. if (this.displayedLeftColumnTree && this.displayedRightColumnTree && this.displayedCentreColumnTree) {
  6005. return this.displayedLeftColumnTree
  6006. .concat(this.displayedCentreColumnTree)
  6007. .concat(this.displayedRightColumnTree);
  6008. }
  6009. return null;
  6010. };
  6011. // + columnSelectPanel
  6012. ColumnController.prototype.getPrimaryColumnTree = function () {
  6013. return this.primaryColumnTree;
  6014. };
  6015. // + gridPanel -> for resizing the body and setting top margin
  6016. ColumnController.prototype.getHeaderRowCount = function () {
  6017. return this.gridHeaderRowCount;
  6018. };
  6019. // + headerRenderer -> setting pinned body width
  6020. ColumnController.prototype.getLeftDisplayedColumnGroups = function () {
  6021. return this.displayedLeftColumnTree;
  6022. };
  6023. // + headerRenderer -> setting pinned body width
  6024. ColumnController.prototype.getRightDisplayedColumnGroups = function () {
  6025. return this.displayedRightColumnTree;
  6026. };
  6027. // + headerRenderer -> setting pinned body width
  6028. ColumnController.prototype.getCenterDisplayedColumnGroups = function () {
  6029. return this.displayedCentreColumnTree;
  6030. };
  6031. ColumnController.prototype.getDisplayedColumnGroups = function (type) {
  6032. switch (type) {
  6033. case Constants.PINNED_LEFT:
  6034. return this.getLeftDisplayedColumnGroups();
  6035. case Constants.PINNED_RIGHT:
  6036. return this.getRightDisplayedColumnGroups();
  6037. default:
  6038. return this.getCenterDisplayedColumnGroups();
  6039. }
  6040. };
  6041. // gridPanel -> ensureColumnVisible
  6042. ColumnController.prototype.isColumnDisplayed = function (column) {
  6043. return this.getAllDisplayedColumns().indexOf(column) >= 0;
  6044. };
  6045. // + csvCreator
  6046. ColumnController.prototype.getAllDisplayedColumns = function () {
  6047. return this.allDisplayedColumns;
  6048. };
  6049. ColumnController.prototype.getAllDisplayedVirtualColumns = function () {
  6050. return this.allDisplayedVirtualColumns;
  6051. };
  6052. ColumnController.prototype.getDisplayedLeftColumnsForRow = function (rowNode) {
  6053. if (!this.colSpanActive) {
  6054. return this.displayedLeftColumns;
  6055. }
  6056. return this.getDisplayedColumnsForRow(rowNode, this.displayedLeftColumns);
  6057. };
  6058. ColumnController.prototype.getDisplayedRightColumnsForRow = function (rowNode) {
  6059. if (!this.colSpanActive) {
  6060. return this.displayedRightColumns;
  6061. }
  6062. return this.getDisplayedColumnsForRow(rowNode, this.displayedRightColumns);
  6063. };
  6064. ColumnController.prototype.getDisplayedColumnsForRow = function (rowNode, displayedColumns, filterCallback, emptySpaceBeforeColumn) {
  6065. var result = [];
  6066. var lastConsideredCol = null;
  6067. var _loop_1 = function (i) {
  6068. var col = displayedColumns[i];
  6069. var maxAllowedColSpan = displayedColumns.length - i;
  6070. var colSpan = Math.min(col.getColSpan(rowNode), maxAllowedColSpan);
  6071. var columnsToCheckFilter = [col];
  6072. if (colSpan > 1) {
  6073. var colsToRemove = colSpan - 1;
  6074. for (var j = 1; j <= colsToRemove; j++) {
  6075. columnsToCheckFilter.push(displayedColumns[i + j]);
  6076. }
  6077. i += colsToRemove;
  6078. }
  6079. // see which cols we should take out for column virtualisation
  6080. var filterPasses;
  6081. if (filterCallback) {
  6082. // if user provided a callback, means some columns may not be in the viewport.
  6083. // the user will NOT provide a callback if we are talking about pinned areas,
  6084. // as pinned areas have no horizontal scroll and do not virtualise the columns.
  6085. // if lots of columns, that means column spanning, and we set filterPasses = true
  6086. // if one or more of the columns spanned pass the filter.
  6087. filterPasses = false;
  6088. columnsToCheckFilter.forEach(function (colForFilter) {
  6089. if (filterCallback(colForFilter)) {
  6090. filterPasses = true;
  6091. }
  6092. });
  6093. }
  6094. else {
  6095. filterPasses = true;
  6096. }
  6097. if (filterPasses) {
  6098. if (result.length === 0 && lastConsideredCol) {
  6099. var gapBeforeColumn = emptySpaceBeforeColumn ? emptySpaceBeforeColumn(col) : false;
  6100. if (gapBeforeColumn) {
  6101. result.push(lastConsideredCol);
  6102. }
  6103. }
  6104. result.push(col);
  6105. }
  6106. lastConsideredCol = col;
  6107. out_i_1 = i;
  6108. };
  6109. var out_i_1;
  6110. for (var i = 0; i < displayedColumns.length; i++) {
  6111. _loop_1(i);
  6112. i = out_i_1;
  6113. }
  6114. return result;
  6115. };
  6116. // + rowRenderer
  6117. // if we are not column spanning, this just returns back the virtual centre columns,
  6118. // however if we are column spanning, then different rows can have different virtual
  6119. // columns, so we have to work out the list for each individual row.
  6120. ColumnController.prototype.getAllDisplayedCenterVirtualColumnsForRow = function (rowNode) {
  6121. var _this = this;
  6122. if (!this.colSpanActive) {
  6123. return this.allDisplayedCenterVirtualColumns;
  6124. }
  6125. var emptySpaceBeforeColumn = function (col) { return col.getLeft() > _this.viewportLeft; };
  6126. // if doing column virtualisation, then we filter based on the viewport.
  6127. var filterCallback = this.suppressColumnVirtualisation ? null : this.isColumnInViewport.bind(this);
  6128. return this.getDisplayedColumnsForRow(rowNode, this.displayedCenterColumns, filterCallback, emptySpaceBeforeColumn);
  6129. };
  6130. ColumnController.prototype.isColumnInViewport = function (col) {
  6131. var columnLeft = col.getLeft();
  6132. var columnRight = col.getLeft() + col.getActualWidth();
  6133. // adding 200 for buffer size, so some cols off viewport are rendered.
  6134. // this helps horizontal scrolling so user rarely sees white space (unless
  6135. // they scroll horizontally fast). however we are conservative, as the more
  6136. // buffer the slower the vertical redraw speed
  6137. var leftBounds = this.viewportLeft - 200;
  6138. var rightBounds = this.viewportRight + 200;
  6139. var columnToMuchLeft = columnLeft < leftBounds && columnRight < leftBounds;
  6140. var columnToMuchRight = columnLeft > rightBounds && columnRight > rightBounds;
  6141. return !columnToMuchLeft && !columnToMuchRight;
  6142. };
  6143. // used by:
  6144. // + angularGrid -> setting pinned body width
  6145. // note: this should be cached
  6146. ColumnController.prototype.getPinnedLeftContainerWidth = function () {
  6147. return this.getWidthOfColsInList(this.displayedLeftColumns);
  6148. };
  6149. // note: this should be cached
  6150. ColumnController.prototype.getPinnedRightContainerWidth = function () {
  6151. return this.getWidthOfColsInList(this.displayedRightColumns);
  6152. };
  6153. ColumnController.prototype.updatePrimaryColumnList = function (keys, masterList, actionIsAdd, columnCallback, eventType, source) {
  6154. var _this = this;
  6155. if (source === void 0) { source = "api"; }
  6156. if (!keys || _.missingOrEmpty(keys)) {
  6157. return;
  6158. }
  6159. var atLeastOne = false;
  6160. keys.forEach(function (key) {
  6161. var columnToAdd = _this.getPrimaryColumn(key);
  6162. if (!columnToAdd) {
  6163. return;
  6164. }
  6165. if (actionIsAdd) {
  6166. if (masterList.indexOf(columnToAdd) >= 0) {
  6167. return;
  6168. }
  6169. masterList.push(columnToAdd);
  6170. }
  6171. else {
  6172. if (masterList.indexOf(columnToAdd) < 0) {
  6173. return;
  6174. }
  6175. _.removeFromArray(masterList, columnToAdd);
  6176. }
  6177. columnCallback(columnToAdd);
  6178. atLeastOne = true;
  6179. });
  6180. if (!atLeastOne) {
  6181. return;
  6182. }
  6183. if (this.autoGroupsNeedBuilding) {
  6184. this.updateGridColumns();
  6185. }
  6186. this.updateDisplayedColumns(source);
  6187. var event = {
  6188. type: eventType,
  6189. columns: masterList,
  6190. column: masterList.length === 1 ? masterList[0] : null,
  6191. api: this.gridApi,
  6192. columnApi: this.columnApi,
  6193. source: source
  6194. };
  6195. this.eventService.dispatchEvent(event);
  6196. };
  6197. ColumnController.prototype.setRowGroupColumns = function (colKeys, source) {
  6198. if (source === void 0) { source = "api"; }
  6199. this.autoGroupsNeedBuilding = true;
  6200. this.setPrimaryColumnList(colKeys, this.rowGroupColumns, Events.EVENT_COLUMN_ROW_GROUP_CHANGED, this.setRowGroupActive.bind(this), source);
  6201. };
  6202. ColumnController.prototype.setRowGroupActive = function (active, column, source) {
  6203. if (active === column.isRowGroupActive()) {
  6204. return;
  6205. }
  6206. column.setRowGroupActive(active, source);
  6207. if (!active && !this.gridOptionsWrapper.isSuppressMakeColumnVisibleAfterUnGroup()) {
  6208. column.setVisible(true, source);
  6209. }
  6210. };
  6211. ColumnController.prototype.addRowGroupColumn = function (key, source) {
  6212. if (source === void 0) { source = "api"; }
  6213. if (key) {
  6214. this.addRowGroupColumns([key], source);
  6215. }
  6216. };
  6217. ColumnController.prototype.addRowGroupColumns = function (keys, source) {
  6218. if (source === void 0) { source = "api"; }
  6219. this.autoGroupsNeedBuilding = true;
  6220. this.updatePrimaryColumnList(keys, this.rowGroupColumns, true, this.setRowGroupActive.bind(this, true), Events.EVENT_COLUMN_ROW_GROUP_CHANGED, source);
  6221. };
  6222. ColumnController.prototype.removeRowGroupColumns = function (keys, source) {
  6223. if (source === void 0) { source = "api"; }
  6224. this.autoGroupsNeedBuilding = true;
  6225. this.updatePrimaryColumnList(keys, this.rowGroupColumns, false, this.setRowGroupActive.bind(this, false), Events.EVENT_COLUMN_ROW_GROUP_CHANGED, source);
  6226. };
  6227. ColumnController.prototype.removeRowGroupColumn = function (key, source) {
  6228. if (source === void 0) { source = "api"; }
  6229. if (key) {
  6230. this.removeRowGroupColumns([key], source);
  6231. }
  6232. };
  6233. ColumnController.prototype.addPivotColumns = function (keys, source) {
  6234. if (source === void 0) { source = "api"; }
  6235. this.updatePrimaryColumnList(keys, this.pivotColumns, true, function (column) { return column.setPivotActive(true, source); }, Events.EVENT_COLUMN_PIVOT_CHANGED, source);
  6236. };
  6237. ColumnController.prototype.setPivotColumns = function (colKeys, source) {
  6238. if (source === void 0) { source = "api"; }
  6239. this.setPrimaryColumnList(colKeys, this.pivotColumns, Events.EVENT_COLUMN_PIVOT_CHANGED, function (added, column) {
  6240. column.setPivotActive(added, source);
  6241. }, source);
  6242. };
  6243. ColumnController.prototype.addPivotColumn = function (key, source) {
  6244. if (source === void 0) { source = "api"; }
  6245. this.addPivotColumns([key], source);
  6246. };
  6247. ColumnController.prototype.removePivotColumns = function (keys, source) {
  6248. if (source === void 0) { source = "api"; }
  6249. this.updatePrimaryColumnList(keys, this.pivotColumns, false, function (column) { return column.setPivotActive(false, source); }, Events.EVENT_COLUMN_PIVOT_CHANGED, source);
  6250. };
  6251. ColumnController.prototype.removePivotColumn = function (key, source) {
  6252. if (source === void 0) { source = "api"; }
  6253. this.removePivotColumns([key], source);
  6254. };
  6255. ColumnController.prototype.setPrimaryColumnList = function (colKeys, masterList, eventName, columnCallback, source) {
  6256. var _this = this;
  6257. masterList.length = 0;
  6258. if (_.exists(colKeys)) {
  6259. colKeys.forEach(function (key) {
  6260. var column = _this.getPrimaryColumn(key);
  6261. if (column) {
  6262. masterList.push(column);
  6263. }
  6264. });
  6265. }
  6266. this.primaryColumns.forEach(function (column) {
  6267. var added = masterList.indexOf(column) >= 0;
  6268. columnCallback(added, column);
  6269. });
  6270. if (this.autoGroupsNeedBuilding) {
  6271. this.updateGridColumns();
  6272. }
  6273. this.updateDisplayedColumns(source);
  6274. var event = {
  6275. type: eventName,
  6276. columns: masterList,
  6277. column: masterList.length === 1 ? masterList[0] : null,
  6278. api: this.gridApi,
  6279. columnApi: this.columnApi,
  6280. source: source
  6281. };
  6282. this.eventService.dispatchEvent(event);
  6283. };
  6284. ColumnController.prototype.setValueColumns = function (colKeys, source) {
  6285. if (source === void 0) { source = "api"; }
  6286. this.setPrimaryColumnList(colKeys, this.valueColumns, Events.EVENT_COLUMN_VALUE_CHANGED, this.setValueActive.bind(this), source);
  6287. };
  6288. ColumnController.prototype.setValueActive = function (active, column, source) {
  6289. if (active === column.isValueActive()) {
  6290. return;
  6291. }
  6292. column.setValueActive(active, source);
  6293. if (active && !column.getAggFunc()) {
  6294. var defaultAggFunc = this.aggFuncService.getDefaultAggFunc(column);
  6295. column.setAggFunc(defaultAggFunc);
  6296. }
  6297. };
  6298. ColumnController.prototype.addValueColumns = function (keys, source) {
  6299. if (source === void 0) { source = "api"; }
  6300. this.updatePrimaryColumnList(keys, this.valueColumns, true, this.setValueActive.bind(this, true), Events.EVENT_COLUMN_VALUE_CHANGED, source);
  6301. };
  6302. ColumnController.prototype.addValueColumn = function (colKey, source) {
  6303. if (source === void 0) { source = "api"; }
  6304. if (colKey) {
  6305. this.addValueColumns([colKey], source);
  6306. }
  6307. };
  6308. ColumnController.prototype.removeValueColumn = function (colKey, source) {
  6309. if (source === void 0) { source = "api"; }
  6310. this.removeValueColumns([colKey], source);
  6311. };
  6312. ColumnController.prototype.removeValueColumns = function (keys, source) {
  6313. if (source === void 0) { source = "api"; }
  6314. this.updatePrimaryColumnList(keys, this.valueColumns, false, this.setValueActive.bind(this, false), Events.EVENT_COLUMN_VALUE_CHANGED, source);
  6315. };
  6316. // returns the width we can set to this col, taking into consideration min and max widths
  6317. ColumnController.prototype.normaliseColumnWidth = function (column, newWidth) {
  6318. if (newWidth < column.getMinWidth()) {
  6319. newWidth = column.getMinWidth();
  6320. }
  6321. if (column.isGreaterThanMax(newWidth)) {
  6322. newWidth = column.getMaxWidth();
  6323. }
  6324. return newWidth;
  6325. };
  6326. ColumnController.prototype.getPrimaryOrGridColumn = function (key) {
  6327. var column = this.getPrimaryColumn(key);
  6328. return column || this.getGridColumn(key);
  6329. };
  6330. ColumnController.prototype.setColumnWidths = function (columnWidths, shiftKey, // @takeFromAdjacent - if user has 'shift' pressed, then pixels are taken from adjacent column
  6331. finished, // @finished - ends up in the event, tells the user if more events are to come
  6332. source) {
  6333. var _this = this;
  6334. if (source === void 0) { source = "api"; }
  6335. var sets = [];
  6336. columnWidths.forEach(function (columnWidth) {
  6337. var col = _this.getPrimaryOrGridColumn(columnWidth.key);
  6338. if (!col) {
  6339. return;
  6340. }
  6341. sets.push({
  6342. width: columnWidth.newWidth,
  6343. ratios: [1],
  6344. columns: [col]
  6345. });
  6346. // if user wants to do shift resize by default, then we invert the shift operation
  6347. var defaultIsShift = _this.gridOptionsWrapper.getColResizeDefault() === 'shift';
  6348. if (defaultIsShift) {
  6349. shiftKey = !shiftKey;
  6350. }
  6351. if (shiftKey) {
  6352. var otherCol = _this.getDisplayedColAfter(col);
  6353. if (!otherCol) {
  6354. return;
  6355. }
  6356. var widthDiff = col.getActualWidth() - columnWidth.newWidth;
  6357. var otherColWidth = otherCol.getActualWidth() + widthDiff;
  6358. sets.push({
  6359. width: otherColWidth,
  6360. ratios: [1],
  6361. columns: [otherCol]
  6362. });
  6363. }
  6364. });
  6365. if (sets.length === 0) {
  6366. return;
  6367. }
  6368. this.resizeColumnSets(sets, finished, source);
  6369. if (this.flexActive) {
  6370. this.refreshFlexedColumns();
  6371. }
  6372. };
  6373. ColumnController.prototype.checkMinAndMaxWidthsForSet = function (columnResizeSet) {
  6374. var columns = columnResizeSet.columns, width = columnResizeSet.width;
  6375. // every col has a min width, so sum them all up and see if we have enough room
  6376. // for all the min widths
  6377. var minWidthAccumulated = 0;
  6378. var maxWidthAccumulated = 0;
  6379. var maxWidthActive = true;
  6380. columns.forEach(function (col) {
  6381. minWidthAccumulated += col.getMinWidth();
  6382. if (col.getMaxWidth() > 0) {
  6383. maxWidthAccumulated += col.getMaxWidth();
  6384. }
  6385. else {
  6386. // if at least one columns has no max width, it means the group of columns
  6387. // then has no max width, as at least one column can take as much width as possible
  6388. maxWidthActive = false;
  6389. }
  6390. });
  6391. var minWidthPasses = width >= minWidthAccumulated;
  6392. var maxWidthPasses = !maxWidthActive || (width <= maxWidthAccumulated);
  6393. return minWidthPasses && maxWidthPasses;
  6394. };
  6395. // method takes sets of columns and resizes them. either all sets will be resized, or nothing
  6396. // be resized. this is used for example when user tries to resize a group and holds shift key,
  6397. // then both the current group (grows), and the adjacent group (shrinks), will get resized,
  6398. // so that's two sets for this method.
  6399. ColumnController.prototype.resizeColumnSets = function (resizeSets, finished, source) {
  6400. var passMinMaxCheck = !resizeSets || resizeSets.every(this.checkMinAndMaxWidthsForSet.bind(this));
  6401. if (!passMinMaxCheck) {
  6402. // even though we are not going to resize beyond min/max size, we still need to raise event when finished
  6403. if (finished) {
  6404. var columns = resizeSets && resizeSets.length > 0 ? resizeSets[0].columns : null;
  6405. var event_3 = {
  6406. type: Events.EVENT_COLUMN_RESIZED,
  6407. columns: columns,
  6408. column: columns && columns.length === 1 ? columns[0] : null,
  6409. finished: finished,
  6410. api: this.gridApi,
  6411. columnApi: this.columnApi,
  6412. source: source
  6413. };
  6414. this.eventService.dispatchEvent(event_3);
  6415. }
  6416. return; // don't resize!
  6417. }
  6418. var changedCols = [];
  6419. var allCols = [];
  6420. resizeSets.forEach(function (set) {
  6421. var width = set.width, columns = set.columns, ratios = set.ratios;
  6422. // keep track of pixels used, and last column gets the remaining,
  6423. // to cater for rounding errors, and min width adjustments
  6424. var newWidths = {};
  6425. var finishedCols = {};
  6426. columns.forEach(function (col) { return allCols.push(col); });
  6427. // the loop below goes through each col. if a col exceeds it's min/max width,
  6428. // it then gets set to its min/max width and the column is removed marked as 'finished'
  6429. // and the calculation is done again leaving this column out. take for example columns
  6430. // {A, width: 50, maxWidth: 100}
  6431. // {B, width: 50}
  6432. // {C, width: 50}
  6433. // and then the set is set to width 600 - on the first pass the grid tries to set each column
  6434. // to 200. it checks A and sees 200 > 100 and so sets the width to 100. col A is then marked
  6435. // as 'finished' and the calculation is done again with the remaining cols B and C, which end up
  6436. // splitting the remaining 500 pixels.
  6437. var finishedColsGrew = true;
  6438. var loopCount = 0;
  6439. var _loop_2 = function () {
  6440. loopCount++;
  6441. if (loopCount > 1000) {
  6442. // this should never happen, but in the future, someone might introduce a bug here,
  6443. // so we stop the browser from hanging and report bug properly
  6444. console.error('ag-Grid: infinite loop in resizeColumnSets');
  6445. return "break";
  6446. }
  6447. finishedColsGrew = false;
  6448. var subsetCols = [];
  6449. var subsetRatioTotal = 0;
  6450. var pixelsToDistribute = width;
  6451. columns.forEach(function (col, index) {
  6452. var thisColFinished = finishedCols[col.getId()];
  6453. if (thisColFinished) {
  6454. pixelsToDistribute -= newWidths[col.getId()];
  6455. }
  6456. else {
  6457. subsetCols.push(col);
  6458. var ratioThisCol = ratios[index];
  6459. subsetRatioTotal += ratioThisCol;
  6460. }
  6461. });
  6462. // because we are not using all of the ratios (cols can be missing),
  6463. // we scale the ratio. if all columns are included, then subsetRatioTotal=1,
  6464. // and so the ratioScale will be 1.
  6465. var ratioScale = 1 / subsetRatioTotal;
  6466. subsetCols.forEach(function (col, index) {
  6467. var lastCol = index === (subsetCols.length - 1);
  6468. var colNewWidth;
  6469. if (lastCol) {
  6470. colNewWidth = pixelsToDistribute;
  6471. }
  6472. else {
  6473. colNewWidth = Math.round(ratios[index] * width * ratioScale);
  6474. pixelsToDistribute -= colNewWidth;
  6475. }
  6476. if (colNewWidth < col.getMinWidth()) {
  6477. colNewWidth = col.getMinWidth();
  6478. finishedCols[col.getId()] = true;
  6479. finishedColsGrew = true;
  6480. }
  6481. else if (col.getMaxWidth() > 0 && colNewWidth > col.getMaxWidth()) {
  6482. colNewWidth = col.getMaxWidth();
  6483. finishedCols[col.getId()] = true;
  6484. finishedColsGrew = true;
  6485. }
  6486. newWidths[col.getId()] = colNewWidth;
  6487. });
  6488. };
  6489. while (finishedColsGrew) {
  6490. var state_1 = _loop_2();
  6491. if (state_1 === "break")
  6492. break;
  6493. }
  6494. columns.forEach(function (col) {
  6495. var newWidth = newWidths[col.getId()];
  6496. if (col.getActualWidth() !== newWidth) {
  6497. col.setActualWidth(newWidth, source);
  6498. changedCols.push(col);
  6499. }
  6500. });
  6501. });
  6502. // if no cols changed, then no need to update more or send event.
  6503. var atLeastOneColChanged = changedCols.length > 0;
  6504. if (atLeastOneColChanged) {
  6505. this.setLeftValues(source);
  6506. this.updateBodyWidths();
  6507. this.checkDisplayedVirtualColumns();
  6508. }
  6509. // check for change first, to avoid unnecessary firing of events
  6510. // however we always fire 'finished' events. this is important
  6511. // when groups are resized, as if the group is changing slowly,
  6512. // eg 1 pixel at a time, then each change will fire change events
  6513. // in all the columns in the group, but only one with get the pixel.
  6514. if (atLeastOneColChanged || finished) {
  6515. var event_4 = {
  6516. type: Events.EVENT_COLUMN_RESIZED,
  6517. columns: allCols,
  6518. column: allCols.length === 1 ? allCols[0] : null,
  6519. finished: finished,
  6520. api: this.gridApi,
  6521. columnApi: this.columnApi,
  6522. source: source
  6523. };
  6524. this.eventService.dispatchEvent(event_4);
  6525. }
  6526. };
  6527. ColumnController.prototype.setColumnAggFunc = function (column, aggFunc, source) {
  6528. if (source === void 0) { source = "api"; }
  6529. if (!column) {
  6530. return;
  6531. }
  6532. column.setAggFunc(aggFunc);
  6533. var event = {
  6534. type: Events.EVENT_COLUMN_VALUE_CHANGED,
  6535. columns: [column],
  6536. column: column,
  6537. api: this.gridApi,
  6538. columnApi: this.columnApi,
  6539. source: source
  6540. };
  6541. this.eventService.dispatchEvent(event);
  6542. };
  6543. ColumnController.prototype.moveRowGroupColumn = function (fromIndex, toIndex, source) {
  6544. if (source === void 0) { source = "api"; }
  6545. var column = this.rowGroupColumns[fromIndex];
  6546. this.rowGroupColumns.splice(fromIndex, 1);
  6547. this.rowGroupColumns.splice(toIndex, 0, column);
  6548. var event = {
  6549. type: Events.EVENT_COLUMN_ROW_GROUP_CHANGED,
  6550. columns: this.rowGroupColumns,
  6551. column: this.rowGroupColumns.length === 1 ? this.rowGroupColumns[0] : null,
  6552. api: this.gridApi,
  6553. columnApi: this.columnApi,
  6554. source: source
  6555. };
  6556. this.eventService.dispatchEvent(event);
  6557. };
  6558. ColumnController.prototype.moveColumns = function (columnsToMoveKeys, toIndex, source) {
  6559. if (source === void 0) { source = "api"; }
  6560. this.columnAnimationService.start();
  6561. if (toIndex > this.gridColumns.length - columnsToMoveKeys.length) {
  6562. console.warn('ag-Grid: tried to insert columns in invalid location, toIndex = ' + toIndex);
  6563. console.warn('ag-Grid: remember that you should not count the moving columns when calculating the new index');
  6564. return;
  6565. }
  6566. // we want to pull all the columns out first and put them into an ordered list
  6567. var columnsToMove = this.getGridColumns(columnsToMoveKeys);
  6568. var failedRules = !this.doesMovePassRules(columnsToMove, toIndex);
  6569. if (failedRules) {
  6570. return;
  6571. }
  6572. _.moveInArray(this.gridColumns, columnsToMove, toIndex);
  6573. this.updateDisplayedColumns(source);
  6574. var event = {
  6575. type: Events.EVENT_COLUMN_MOVED,
  6576. columns: columnsToMove,
  6577. column: columnsToMove.length === 1 ? columnsToMove[0] : null,
  6578. toIndex: toIndex,
  6579. api: this.gridApi,
  6580. columnApi: this.columnApi,
  6581. source: source
  6582. };
  6583. this.eventService.dispatchEvent(event);
  6584. this.columnAnimationService.finish();
  6585. };
  6586. ColumnController.prototype.doesMovePassRules = function (columnsToMove, toIndex) {
  6587. // make a copy of what the grid columns would look like after the move
  6588. var proposedColumnOrder = this.gridColumns.slice();
  6589. _.moveInArray(proposedColumnOrder, columnsToMove, toIndex);
  6590. // then check that the new proposed order of the columns passes all rules
  6591. if (!this.doesMovePassMarryChildren(proposedColumnOrder)) {
  6592. return false;
  6593. }
  6594. if (!this.doesMovePassLockedPositions(proposedColumnOrder)) {
  6595. return false;
  6596. }
  6597. return true;
  6598. };
  6599. ColumnController.prototype.doesMovePassLockedPositions = function (proposedColumnOrder) {
  6600. var foundNonLocked = false;
  6601. var rulePassed = true;
  6602. // go though the cols, see if any non-locked appear before any locked
  6603. proposedColumnOrder.forEach(function (col) {
  6604. if (col.getColDef().lockPosition) {
  6605. if (foundNonLocked) {
  6606. rulePassed = false;
  6607. }
  6608. }
  6609. else {
  6610. foundNonLocked = true;
  6611. }
  6612. });
  6613. return rulePassed;
  6614. };
  6615. ColumnController.prototype.doesMovePassMarryChildren = function (allColumnsCopy) {
  6616. var rulePassed = true;
  6617. this.columnUtils.depthFirstOriginalTreeSearch(null, this.gridBalancedTree, function (child) {
  6618. if (!(child instanceof OriginalColumnGroup)) {
  6619. return;
  6620. }
  6621. var columnGroup = child;
  6622. var marryChildren = columnGroup.getColGroupDef() && columnGroup.getColGroupDef().marryChildren;
  6623. if (!marryChildren) {
  6624. return;
  6625. }
  6626. var newIndexes = [];
  6627. columnGroup.getLeafColumns().forEach(function (col) {
  6628. var newColIndex = allColumnsCopy.indexOf(col);
  6629. newIndexes.push(newColIndex);
  6630. });
  6631. var maxIndex = Math.max.apply(Math, newIndexes);
  6632. var minIndex = Math.min.apply(Math, newIndexes);
  6633. // spread is how far the first column in this group is away from the last column
  6634. var spread = maxIndex - minIndex;
  6635. var maxSpread = columnGroup.getLeafColumns().length - 1;
  6636. // if the columns
  6637. if (spread > maxSpread) {
  6638. rulePassed = false;
  6639. }
  6640. // console.log(`maxIndex = ${maxIndex}, minIndex = ${minIndex}, spread = ${spread}, maxSpread = ${maxSpread}, fail = ${spread > (count-1)}`)
  6641. // console.log(allColumnsCopy.map( col => col.getColDef().field).join(','));
  6642. });
  6643. return rulePassed;
  6644. };
  6645. ColumnController.prototype.moveColumn = function (key, toIndex, source) {
  6646. if (source === void 0) { source = "api"; }
  6647. this.moveColumns([key], toIndex, source);
  6648. };
  6649. ColumnController.prototype.moveColumnByIndex = function (fromIndex, toIndex, source) {
  6650. if (source === void 0) { source = "api"; }
  6651. var column = this.gridColumns[fromIndex];
  6652. this.moveColumn(column, toIndex, source);
  6653. };
  6654. // used by:
  6655. // + angularGrid -> for setting body width
  6656. // + rowController -> setting main row widths (when inserting and resizing)
  6657. // need to cache this
  6658. ColumnController.prototype.getBodyContainerWidth = function () {
  6659. return this.bodyWidth;
  6660. };
  6661. ColumnController.prototype.getContainerWidth = function (pinned) {
  6662. switch (pinned) {
  6663. case Constants.PINNED_LEFT:
  6664. return this.leftWidth;
  6665. case Constants.PINNED_RIGHT:
  6666. return this.rightWidth;
  6667. default:
  6668. return this.bodyWidth;
  6669. }
  6670. };
  6671. // after setColumnWidth or updateGroupsAndDisplayedColumns
  6672. ColumnController.prototype.updateBodyWidths = function () {
  6673. var newBodyWidth = this.getWidthOfColsInList(this.displayedCenterColumns);
  6674. var newLeftWidth = this.getWidthOfColsInList(this.displayedLeftColumns);
  6675. var newRightWidth = this.getWidthOfColsInList(this.displayedRightColumns);
  6676. // this is used by virtual col calculation, for RTL only, as a change to body width can impact displayed
  6677. // columns, due to RTL inverting the y coordinates
  6678. this.bodyWidthDirty = this.bodyWidth !== newBodyWidth;
  6679. var atLeastOneChanged = this.bodyWidth !== newBodyWidth || this.leftWidth !== newLeftWidth || this.rightWidth !== newRightWidth;
  6680. if (atLeastOneChanged) {
  6681. this.bodyWidth = newBodyWidth;
  6682. this.leftWidth = newLeftWidth;
  6683. this.rightWidth = newRightWidth;
  6684. // when this fires, it is picked up by the gridPanel, which ends up in
  6685. // gridPanel calling setWidthAndScrollPosition(), which in turn calls setVirtualViewportPosition()
  6686. var event_5 = {
  6687. type: Events.EVENT_DISPLAYED_COLUMNS_WIDTH_CHANGED,
  6688. api: this.gridApi,
  6689. columnApi: this.columnApi
  6690. };
  6691. this.eventService.dispatchEvent(event_5);
  6692. }
  6693. };
  6694. // + rowController
  6695. ColumnController.prototype.getValueColumns = function () {
  6696. return this.valueColumns ? this.valueColumns : [];
  6697. };
  6698. // + rowController
  6699. ColumnController.prototype.getPivotColumns = function () {
  6700. return this.pivotColumns ? this.pivotColumns : [];
  6701. };
  6702. // + clientSideRowModel
  6703. ColumnController.prototype.isPivotActive = function () {
  6704. return this.pivotColumns && this.pivotColumns.length > 0 && this.pivotMode;
  6705. };
  6706. // + toolPanel
  6707. ColumnController.prototype.getRowGroupColumns = function () {
  6708. return this.rowGroupColumns ? this.rowGroupColumns : [];
  6709. };
  6710. // + rowController -> while inserting rows
  6711. ColumnController.prototype.getDisplayedCenterColumns = function () {
  6712. return this.displayedCenterColumns;
  6713. };
  6714. // + rowController -> while inserting rows
  6715. ColumnController.prototype.getDisplayedLeftColumns = function () {
  6716. return this.displayedLeftColumns;
  6717. };
  6718. ColumnController.prototype.getDisplayedRightColumns = function () {
  6719. return this.displayedRightColumns;
  6720. };
  6721. ColumnController.prototype.getDisplayedColumns = function (type) {
  6722. switch (type) {
  6723. case Constants.PINNED_LEFT:
  6724. return this.getDisplayedLeftColumns();
  6725. case Constants.PINNED_RIGHT:
  6726. return this.getDisplayedRightColumns();
  6727. default:
  6728. return this.getDisplayedCenterColumns();
  6729. }
  6730. };
  6731. // used by:
  6732. // + clientSideRowController -> sorting, building quick filter text
  6733. // + headerRenderer -> sorting (clearing icon)
  6734. ColumnController.prototype.getAllPrimaryColumns = function () {
  6735. return this.primaryColumns ? this.primaryColumns.slice() : null;
  6736. };
  6737. ColumnController.prototype.getSecondaryColumns = function () {
  6738. return this.secondaryColumns ? this.secondaryColumns.slice() : null;
  6739. };
  6740. ColumnController.prototype.getAllColumnsForQuickFilter = function () {
  6741. return this.columnsForQuickFilter;
  6742. };
  6743. // + moveColumnController
  6744. ColumnController.prototype.getAllGridColumns = function () {
  6745. return this.gridColumns;
  6746. };
  6747. ColumnController.prototype.isEmpty = function () {
  6748. return _.missingOrEmpty(this.gridColumns);
  6749. };
  6750. ColumnController.prototype.isRowGroupEmpty = function () {
  6751. return _.missingOrEmpty(this.rowGroupColumns);
  6752. };
  6753. ColumnController.prototype.setColumnVisible = function (key, visible, source) {
  6754. if (source === void 0) { source = "api"; }
  6755. this.setColumnsVisible([key], visible, source);
  6756. };
  6757. ColumnController.prototype.setColumnsVisible = function (keys, visible, source) {
  6758. var _this = this;
  6759. if (source === void 0) { source = "api"; }
  6760. this.columnAnimationService.start();
  6761. this.actionOnGridColumns(keys, function (column) {
  6762. if (column.isVisible() !== visible) {
  6763. column.setVisible(visible, source);
  6764. return true;
  6765. }
  6766. return false;
  6767. }, source, function () {
  6768. var event = {
  6769. type: Events.EVENT_COLUMN_VISIBLE,
  6770. visible: visible,
  6771. column: null,
  6772. columns: null,
  6773. api: _this.gridApi,
  6774. columnApi: _this.columnApi,
  6775. source: source
  6776. };
  6777. return event;
  6778. });
  6779. this.columnAnimationService.finish();
  6780. };
  6781. ColumnController.prototype.setColumnPinned = function (key, pinned, source) {
  6782. if (source === void 0) { source = "api"; }
  6783. if (key) {
  6784. this.setColumnsPinned([key], pinned, source);
  6785. }
  6786. };
  6787. ColumnController.prototype.setColumnsPinned = function (keys, pinned, source) {
  6788. var _this = this;
  6789. if (source === void 0) { source = "api"; }
  6790. if (this.gridOptionsWrapper.getDomLayout() === 'print') {
  6791. console.warn("Changing the column pinning status is not allowed with domLayout='print'");
  6792. return;
  6793. }
  6794. this.columnAnimationService.start();
  6795. var actualPinned;
  6796. if (pinned === true || pinned === Constants.PINNED_LEFT) {
  6797. actualPinned = Constants.PINNED_LEFT;
  6798. }
  6799. else if (pinned === Constants.PINNED_RIGHT) {
  6800. actualPinned = Constants.PINNED_RIGHT;
  6801. }
  6802. else {
  6803. actualPinned = null;
  6804. }
  6805. this.actionOnGridColumns(keys, function (col) {
  6806. if (col.getPinned() !== actualPinned) {
  6807. col.setPinned(actualPinned);
  6808. return true;
  6809. }
  6810. return false;
  6811. }, source, function () {
  6812. var event = {
  6813. type: Events.EVENT_COLUMN_PINNED,
  6814. pinned: actualPinned,
  6815. column: null,
  6816. columns: null,
  6817. api: _this.gridApi,
  6818. columnApi: _this.columnApi,
  6819. source: source
  6820. };
  6821. return event;
  6822. });
  6823. this.columnAnimationService.finish();
  6824. };
  6825. // does an action on a set of columns. provides common functionality for looking up the
  6826. // columns based on key, getting a list of effected columns, and then updated the event
  6827. // with either one column (if it was just one col) or a list of columns
  6828. // used by: autoResize, setVisible, setPinned
  6829. ColumnController.prototype.actionOnGridColumns = function (// the column keys this action will be on
  6830. keys,
  6831. // the action to do - if this returns false, the column was skipped
  6832. // and won't be included in the event
  6833. action,
  6834. // should return back a column event of the right type
  6835. source, createEvent) {
  6836. var _this = this;
  6837. if (_.missingOrEmpty(keys)) {
  6838. return;
  6839. }
  6840. var updatedColumns = [];
  6841. keys.forEach(function (key) {
  6842. var column = _this.getGridColumn(key);
  6843. if (!column) {
  6844. return;
  6845. }
  6846. // need to check for false with type (ie !== instead of !=)
  6847. // as not returning anything (undefined) would also be false
  6848. var resultOfAction = action(column);
  6849. if (resultOfAction !== false) {
  6850. updatedColumns.push(column);
  6851. }
  6852. });
  6853. if (!updatedColumns.length) {
  6854. return;
  6855. }
  6856. this.updateDisplayedColumns(source);
  6857. if (_.exists(createEvent) && createEvent) {
  6858. var event_6 = createEvent();
  6859. event_6.columns = updatedColumns;
  6860. event_6.column = updatedColumns.length === 1 ? updatedColumns[0] : null;
  6861. this.eventService.dispatchEvent(event_6);
  6862. }
  6863. };
  6864. ColumnController.prototype.getDisplayedColBefore = function (col) {
  6865. var allDisplayedColumns = this.getAllDisplayedColumns();
  6866. var oldIndex = allDisplayedColumns.indexOf(col);
  6867. if (oldIndex > 0) {
  6868. return allDisplayedColumns[oldIndex - 1];
  6869. }
  6870. return null;
  6871. };
  6872. // used by:
  6873. // + rowRenderer -> for navigation
  6874. ColumnController.prototype.getDisplayedColAfter = function (col) {
  6875. var allDisplayedColumns = this.getAllDisplayedColumns();
  6876. var oldIndex = allDisplayedColumns.indexOf(col);
  6877. if (oldIndex < (allDisplayedColumns.length - 1)) {
  6878. return allDisplayedColumns[oldIndex + 1];
  6879. }
  6880. return null;
  6881. };
  6882. ColumnController.prototype.getDisplayedGroupAfter = function (columnGroup) {
  6883. return this.getDisplayedGroupAtDirection(columnGroup, 'After');
  6884. };
  6885. ColumnController.prototype.getDisplayedGroupBefore = function (columnGroup) {
  6886. return this.getDisplayedGroupAtDirection(columnGroup, 'Before');
  6887. };
  6888. ColumnController.prototype.getDisplayedGroupAtDirection = function (columnGroup, direction) {
  6889. // pick the last displayed column in this group
  6890. var requiredLevel = columnGroup.getOriginalColumnGroup().getLevel() + columnGroup.getPaddingLevel();
  6891. var colGroupLeafColumns = columnGroup.getDisplayedLeafColumns();
  6892. var col = direction === 'After' ? _.last(colGroupLeafColumns) : colGroupLeafColumns[0];
  6893. var getDisplayColMethod = "getDisplayedCol" + direction;
  6894. while (true) {
  6895. // keep moving to the next col, until we get to another group
  6896. var column = this[getDisplayColMethod](col);
  6897. if (!column) {
  6898. return null;
  6899. }
  6900. var groupPointer = this.getColumnGroupAtLevel(column, requiredLevel);
  6901. if (groupPointer !== columnGroup) {
  6902. return groupPointer;
  6903. }
  6904. }
  6905. };
  6906. ColumnController.prototype.getColumnGroupAtLevel = function (column, level) {
  6907. // get group at same level as the one we are looking for
  6908. var groupPointer = column.getParent();
  6909. var originalGroupLevel;
  6910. var groupPointerLevel;
  6911. while (true) {
  6912. var groupPointerOriginalColumnGroup = groupPointer.getOriginalColumnGroup();
  6913. originalGroupLevel = groupPointerOriginalColumnGroup.getLevel();
  6914. groupPointerLevel = groupPointer.getPaddingLevel();
  6915. if (originalGroupLevel + groupPointerLevel <= level) {
  6916. break;
  6917. }
  6918. groupPointer = groupPointer.getParent();
  6919. }
  6920. return groupPointer;
  6921. };
  6922. ColumnController.prototype.isPinningLeft = function () {
  6923. return this.displayedLeftColumns.length > 0;
  6924. };
  6925. ColumnController.prototype.isPinningRight = function () {
  6926. return this.displayedRightColumns.length > 0;
  6927. };
  6928. ColumnController.prototype.getPrimaryAndSecondaryAndAutoColumns = function () {
  6929. var result = this.primaryColumns ? this.primaryColumns.slice(0) : [];
  6930. if (this.groupAutoColumns && _.exists(this.groupAutoColumns)) {
  6931. this.groupAutoColumns.forEach(function (col) { return result.push(col); });
  6932. }
  6933. if (this.secondaryColumnsPresent && this.secondaryColumns) {
  6934. this.secondaryColumns.forEach(function (column) { return result.push(column); });
  6935. }
  6936. return result;
  6937. };
  6938. ColumnController.prototype.createStateItemFromColumn = function (column) {
  6939. var rowGroupIndex = column.isRowGroupActive() ? this.rowGroupColumns.indexOf(column) : null;
  6940. var pivotIndex = column.isPivotActive() ? this.pivotColumns.indexOf(column) : null;
  6941. var aggFunc = column.isValueActive() ? column.getAggFunc() : null;
  6942. return {
  6943. colId: column.getColId(),
  6944. hide: !column.isVisible(),
  6945. aggFunc: aggFunc,
  6946. width: column.getActualWidth(),
  6947. pivotIndex: pivotIndex,
  6948. pinned: column.getPinned(),
  6949. rowGroupIndex: rowGroupIndex,
  6950. flex: column.getFlex()
  6951. };
  6952. };
  6953. ColumnController.prototype.getColumnState = function () {
  6954. if (_.missing(this.primaryColumns)) {
  6955. return [];
  6956. }
  6957. var primaryColumnState = this.primaryColumns.map(this.createStateItemFromColumn.bind(this));
  6958. var groupAutoColumnState = this.groupAutoColumns
  6959. // if groupAutoCols, then include them
  6960. ? this.groupAutoColumns.map(this.createStateItemFromColumn.bind(this))
  6961. // otherwise no
  6962. : [];
  6963. var columnStateList = groupAutoColumnState.concat(primaryColumnState);
  6964. if (!this.pivotMode) {
  6965. this.orderColumnStateList(columnStateList);
  6966. }
  6967. return columnStateList;
  6968. };
  6969. ColumnController.prototype.orderColumnStateList = function (columnStateList) {
  6970. var gridColumnIds = this.gridColumns.map(function (column) { return column.getColId(); });
  6971. columnStateList.sort(function (itemA, itemB) {
  6972. var posA = gridColumnIds.indexOf(itemA.colId);
  6973. var posB = gridColumnIds.indexOf(itemB.colId);
  6974. return posA - posB;
  6975. });
  6976. };
  6977. ColumnController.prototype.resetColumnState = function (suppressEverythingEvent, source) {
  6978. // NOTE = there is one bug here that no customer has noticed - if a column has colDef.lockPosition,
  6979. // this is ignored below when ordering the cols. to work, we should always put lockPosition cols first.
  6980. // As a work around, developers should just put lockPosition columns first in their colDef list.
  6981. if (suppressEverythingEvent === void 0) { suppressEverythingEvent = false; }
  6982. if (source === void 0) { source = "api"; }
  6983. // we can't use 'allColumns' as the order might of messed up, so get the primary ordered list
  6984. var primaryColumns = this.getColumnsFromTree(this.primaryColumnTree);
  6985. var columnStates = [];
  6986. // we start at 1000, so if user has mix of rowGroup and group specified, it will work with both.
  6987. // eg IF user has ColA.rowGroupIndex=0, ColB.rowGroupIndex=1, ColC.rowGroup=true,
  6988. // THEN result will be ColA.rowGroupIndex=0, ColB.rowGroupIndex=1, ColC.rowGroup=1000
  6989. var letRowGroupIndex = 1000;
  6990. var letPivotIndex = 1000;
  6991. if (primaryColumns) {
  6992. primaryColumns.forEach(function (column) {
  6993. var rowGroupIndex = column.getColDef().rowGroupIndex;
  6994. var rowGroup = column.getColDef().rowGroup;
  6995. var pivotIndex = column.getColDef().pivotIndex;
  6996. var pivot = column.getColDef().pivot;
  6997. var stateItem = {
  6998. colId: column.getColId(),
  6999. aggFunc: column.getColDef().aggFunc,
  7000. hide: column.getColDef().hide,
  7001. pinned: column.getColDef().pinned,
  7002. rowGroupIndex: rowGroupIndex,
  7003. pivotIndex: column.getColDef().pivotIndex,
  7004. width: column.getColDef().width
  7005. };
  7006. if (_.missing(rowGroupIndex) && rowGroup) {
  7007. stateItem.rowGroupIndex = letRowGroupIndex++;
  7008. }
  7009. if (_.missing(pivotIndex) && pivot) {
  7010. stateItem.pivotIndex = letPivotIndex++;
  7011. }
  7012. columnStates.push(stateItem);
  7013. });
  7014. }
  7015. this.setColumnState(columnStates, suppressEverythingEvent, source);
  7016. };
  7017. ColumnController.prototype.setColumnState = function (columnStates, suppressEverythingEvent, source) {
  7018. var _this = this;
  7019. if (suppressEverythingEvent === void 0) { suppressEverythingEvent = false; }
  7020. if (source === void 0) { source = "api"; }
  7021. if (_.missingOrEmpty(this.primaryColumns)) {
  7022. return false;
  7023. }
  7024. var columnStateBefore = this.getColumnState();
  7025. this.autoGroupsNeedBuilding = true;
  7026. // at the end below, this list will have all columns we got no state for
  7027. var columnsWithNoState = this.primaryColumns.slice();
  7028. this.rowGroupColumns = [];
  7029. this.valueColumns = [];
  7030. this.pivotColumns = [];
  7031. var success = true;
  7032. var rowGroupIndexes = {};
  7033. var pivotIndexes = {};
  7034. var autoGroupColumnStates = [];
  7035. if (columnStates) {
  7036. columnStates.forEach(function (state) {
  7037. // auto group columns are re-created so deferring syncing with ColumnState
  7038. if (_.exists(_this.getAutoColumn(state.colId))) {
  7039. autoGroupColumnStates.push(state);
  7040. return;
  7041. }
  7042. var column = _this.getPrimaryColumn(state.colId);
  7043. if (!column) {
  7044. console.warn('ag-grid: column ' + state.colId + ' not found');
  7045. success = false;
  7046. }
  7047. else {
  7048. _this.syncColumnWithStateItem(column, state, rowGroupIndexes, pivotIndexes, source);
  7049. _.removeFromArray(columnsWithNoState, column);
  7050. }
  7051. });
  7052. if (this.flexActive) {
  7053. this.refreshFlexedColumns(undefined, undefined, true);
  7054. }
  7055. }
  7056. // anything left over, we got no data for, so add in the column as non-value, non-rowGroup and hidden
  7057. columnsWithNoState.forEach(this.syncColumnWithNoState.bind(this));
  7058. // sort the lists according to the indexes that were provided
  7059. this.rowGroupColumns.sort(this.sortColumnListUsingIndexes.bind(this, rowGroupIndexes));
  7060. this.pivotColumns.sort(this.sortColumnListUsingIndexes.bind(this, pivotIndexes));
  7061. this.updateGridColumns();
  7062. // sync newly created auto group columns with ColumnState
  7063. autoGroupColumnStates.forEach(function (stateItem) {
  7064. var autoCol = _this.getAutoColumn(stateItem.colId);
  7065. _this.syncColumnWithStateItem(autoCol, stateItem, rowGroupIndexes, pivotIndexes, source);
  7066. });
  7067. if (columnStates) {
  7068. var orderOfColIds_1 = columnStates.map(function (stateItem) { return stateItem.colId; });
  7069. this.gridColumns.sort(function (colA, colB) {
  7070. var indexA = orderOfColIds_1.indexOf(colA.getId());
  7071. var indexB = orderOfColIds_1.indexOf(colB.getId());
  7072. return indexA - indexB;
  7073. });
  7074. }
  7075. // this is already done in updateGridColumns, however we changed the order above (to match the order of the state
  7076. // columns) so we need to do it again. we could of put logic into the order above to take into account fixed
  7077. // columns, however if we did then we would have logic for updating fixed columns twice. reusing the logic here
  7078. // is less sexy for the code here, but it keeps consistency.
  7079. this.putFixedColumnsFirst();
  7080. this.updateDisplayedColumns(source);
  7081. if (!suppressEverythingEvent) {
  7082. var event_7 = {
  7083. type: Events.EVENT_COLUMN_EVERYTHING_CHANGED,
  7084. api: this.gridApi,
  7085. columnApi: this.columnApi,
  7086. source: source
  7087. };
  7088. this.eventService.dispatchEvent(event_7);
  7089. }
  7090. this.raiseColumnEvents(columnStateBefore, source);
  7091. return success;
  7092. };
  7093. ColumnController.prototype.raiseColumnEvents = function (columnStateBefore, source) {
  7094. var _this = this;
  7095. if (this.gridOptionsWrapper.isSuppressSetColumnStateEvents()) {
  7096. return;
  7097. }
  7098. var columnStateAfter = this.getColumnState();
  7099. // raises generic ColumnEvents where all columns are returned rather than what has changed
  7100. var raiseEventWithAllColumns = function (eventType, idMapper, columns) {
  7101. var unchanged = areEqual(columnStateBefore.map(idMapper).sort(), columnStateAfter.map(idMapper).sort());
  7102. if (unchanged) {
  7103. return;
  7104. }
  7105. // returning all columns rather than what has changed!
  7106. var event = {
  7107. type: eventType,
  7108. columns: columns,
  7109. column: columns.length === 1 ? columns[0] : null,
  7110. api: _this.gridApi,
  7111. columnApi: _this.columnApi,
  7112. source: source
  7113. };
  7114. _this.eventService.dispatchEvent(event);
  7115. };
  7116. // determines which columns have changed according to supplied predicate
  7117. var getChangedColumns = function (changedPredicate) {
  7118. var changedColumns = [];
  7119. var columnStateBeforeMap = {};
  7120. columnStateBefore.forEach(function (col) {
  7121. columnStateBeforeMap[col.colId] = col;
  7122. });
  7123. _this.gridColumns.forEach(function (column) {
  7124. var colStateBefore = columnStateBeforeMap[column.getColId()];
  7125. if (!colStateBefore || changedPredicate(colStateBefore, column)) {
  7126. changedColumns.push(column);
  7127. }
  7128. });
  7129. return changedColumns;
  7130. };
  7131. // generic ColumnEvents which return current column list
  7132. var valueColumnIdMapper = function (cs) { return cs.colId + '-' + cs.aggFunc; };
  7133. raiseEventWithAllColumns(Events.EVENT_COLUMN_VALUE_CHANGED, valueColumnIdMapper, this.valueColumns);
  7134. var pivotColumnIdMapper = function (cs) { return cs.colId + '-' + cs.pivotIndex; };
  7135. raiseEventWithAllColumns(Events.EVENT_COLUMN_PIVOT_CHANGED, pivotColumnIdMapper, this.pivotColumns);
  7136. var rowGroupColumnIdMapper = function (cs) { return cs.colId + '-' + cs.rowGroupIndex; };
  7137. raiseEventWithAllColumns(Events.EVENT_COLUMN_ROW_GROUP_CHANGED, rowGroupColumnIdMapper, this.rowGroupColumns);
  7138. // specific ColumnEvents which return what's changed
  7139. var pinnedChangePredicate = function (cs, c) { return cs.pinned !== c.getPinned(); };
  7140. this.raiseColumnPinnedEvent(getChangedColumns(pinnedChangePredicate), source);
  7141. var visibilityChangePredicate = function (cs, c) { return cs.hide === c.isVisible(); };
  7142. var cols = getChangedColumns(visibilityChangePredicate);
  7143. this.raiseColumnVisibleEvent(cols, source);
  7144. var resizeChangePredicate = function (cs, c) { return cs.width !== c.getActualWidth(); };
  7145. this.raiseColumnResizeEvent(getChangedColumns(resizeChangePredicate), source);
  7146. // special handling for moved column events
  7147. this.raiseColumnMovedEvent(columnStateBefore, source);
  7148. };
  7149. ColumnController.prototype.raiseColumnPinnedEvent = function (changedColumns, source) {
  7150. if (!changedColumns.length) {
  7151. return;
  7152. }
  7153. var event = {
  7154. type: Events.EVENT_COLUMN_PINNED,
  7155. pinned: null,
  7156. columns: changedColumns,
  7157. column: null,
  7158. api: this.gridApi,
  7159. columnApi: this.columnApi,
  7160. source: source
  7161. };
  7162. this.eventService.dispatchEvent(event);
  7163. };
  7164. ColumnController.prototype.raiseColumnVisibleEvent = function (changedColumns, source) {
  7165. if (!changedColumns.length) {
  7166. return;
  7167. }
  7168. var event = {
  7169. type: Events.EVENT_COLUMN_VISIBLE,
  7170. visible: undefined,
  7171. columns: changedColumns,
  7172. column: null,
  7173. api: this.gridApi,
  7174. columnApi: this.columnApi,
  7175. source: source
  7176. };
  7177. this.eventService.dispatchEvent(event);
  7178. };
  7179. ColumnController.prototype.raiseColumnResizeEvent = function (changedColumns, source) {
  7180. if (!changedColumns.length) {
  7181. return;
  7182. }
  7183. var event = {
  7184. type: Events.EVENT_COLUMN_RESIZED,
  7185. columns: changedColumns,
  7186. column: null,
  7187. finished: true,
  7188. api: this.gridApi,
  7189. columnApi: this.columnApi,
  7190. source: source
  7191. };
  7192. this.eventService.dispatchEvent(event);
  7193. };
  7194. ColumnController.prototype.raiseColumnMovedEvent = function (columnStateBefore, source) {
  7195. var movedColumns = [];
  7196. var columnStateAfter = this.getColumnState();
  7197. var _loop_3 = function (i) {
  7198. var before = columnStateBefore[i];
  7199. var after = columnStateAfter[i];
  7200. // don't consider column if reintroduced or hidden
  7201. if (!before || after.hide) {
  7202. return "continue";
  7203. }
  7204. if (before.colId !== after.colId) {
  7205. var predicate = function (column) { return column.getColId() === after.colId; };
  7206. var movedColumn = _.find(this_1.allDisplayedColumns, predicate);
  7207. movedColumns.push(movedColumn);
  7208. }
  7209. };
  7210. var this_1 = this;
  7211. for (var i = 0; i < columnStateAfter.length; i++) {
  7212. _loop_3(i);
  7213. }
  7214. if (!movedColumns.length) {
  7215. return;
  7216. }
  7217. var event = {
  7218. type: Events.EVENT_COLUMN_MOVED,
  7219. columns: movedColumns,
  7220. column: null,
  7221. toIndex: undefined,
  7222. api: this.gridApi,
  7223. columnApi: this.columnApi,
  7224. source: source
  7225. };
  7226. this.eventService.dispatchEvent(event);
  7227. };
  7228. ColumnController.prototype.sortColumnListUsingIndexes = function (indexes, colA, colB) {
  7229. var indexA = indexes[colA.getId()];
  7230. var indexB = indexes[colB.getId()];
  7231. return indexA - indexB;
  7232. };
  7233. ColumnController.prototype.syncColumnWithNoState = function (column, source) {
  7234. column.setVisible(false, source);
  7235. column.setAggFunc(null);
  7236. column.setPinned(null);
  7237. column.setRowGroupActive(false, source);
  7238. column.setPivotActive(false, source);
  7239. column.setValueActive(false, source);
  7240. };
  7241. ColumnController.prototype.syncColumnWithStateItem = function (column, stateItem, rowGroupIndexes, pivotIndexes, source) {
  7242. if (!column) {
  7243. return;
  7244. }
  7245. // following ensures we are left with boolean true or false, eg converts (null, undefined, 0) all to true
  7246. column.setVisible(!stateItem.hide, source);
  7247. // sets pinned to 'left' or 'right'
  7248. column.setPinned(stateItem.pinned);
  7249. // if width provided and valid, use it, otherwise stick with the old width
  7250. var minColWidth = this.gridOptionsWrapper.getMinColWidth();
  7251. if (stateItem.flex != null) {
  7252. column.setFlex(stateItem.flex);
  7253. if (!this.flexActive && stateItem.flex) {
  7254. this.flexActive = true;
  7255. }
  7256. }
  7257. if (stateItem.width && minColWidth &&
  7258. (stateItem.width >= minColWidth)) {
  7259. column.setActualWidth(stateItem.width, source);
  7260. }
  7261. if (typeof stateItem.aggFunc === 'string') {
  7262. column.setAggFunc(stateItem.aggFunc);
  7263. column.setValueActive(true, source);
  7264. this.valueColumns.push(column);
  7265. }
  7266. else {
  7267. if (_.exists(stateItem.aggFunc)) {
  7268. console.warn('ag-Grid: stateItem.aggFunc must be a string. if using your own aggregation ' +
  7269. 'functions, register the functions first before using them in get/set state. This is because it is ' +
  7270. 'intended for the column state to be stored and retrieved as simple JSON.');
  7271. }
  7272. column.setAggFunc(null);
  7273. column.setValueActive(false, source);
  7274. }
  7275. if (typeof stateItem.rowGroupIndex === 'number') {
  7276. this.rowGroupColumns.push(column);
  7277. column.setRowGroupActive(true, source);
  7278. rowGroupIndexes[column.getId()] = stateItem.rowGroupIndex;
  7279. }
  7280. else {
  7281. column.setRowGroupActive(false, source);
  7282. }
  7283. if (typeof stateItem.pivotIndex === 'number') {
  7284. this.pivotColumns.push(column);
  7285. column.setPivotActive(true, source);
  7286. pivotIndexes[column.getId()] = stateItem.pivotIndex;
  7287. }
  7288. else {
  7289. column.setPivotActive(false, source);
  7290. }
  7291. };
  7292. ColumnController.prototype.getGridColumns = function (keys) {
  7293. return this.getColumns(keys, this.getGridColumn.bind(this));
  7294. };
  7295. ColumnController.prototype.getColumns = function (keys, columnLookupCallback) {
  7296. var foundColumns = [];
  7297. if (keys) {
  7298. keys.forEach(function (key) {
  7299. var column = columnLookupCallback(key);
  7300. if (column) {
  7301. foundColumns.push(column);
  7302. }
  7303. });
  7304. }
  7305. return foundColumns;
  7306. };
  7307. // used by growGroupPanel
  7308. ColumnController.prototype.getColumnWithValidation = function (key) {
  7309. if (key == null) {
  7310. return null;
  7311. }
  7312. var column = this.getGridColumn(key);
  7313. if (!column) {
  7314. console.warn('ag-Grid: could not find column ' + key);
  7315. }
  7316. return column;
  7317. };
  7318. ColumnController.prototype.getPrimaryColumn = function (key) {
  7319. return this.getColumn(key, this.primaryColumns);
  7320. };
  7321. ColumnController.prototype.getGridColumn = function (key) {
  7322. return this.getColumn(key, this.gridColumns);
  7323. };
  7324. ColumnController.prototype.getColumn = function (key, columnList) {
  7325. if (!key) {
  7326. return null;
  7327. }
  7328. for (var i = 0; i < columnList.length; i++) {
  7329. if (this.columnsMatch(columnList[i], key)) {
  7330. return columnList[i];
  7331. }
  7332. }
  7333. return this.getAutoColumn(key);
  7334. };
  7335. ColumnController.prototype.getAutoColumn = function (key) {
  7336. var _this = this;
  7337. if (!this.groupAutoColumns ||
  7338. !_.exists(this.groupAutoColumns) ||
  7339. _.missing(this.groupAutoColumns)) {
  7340. return null;
  7341. }
  7342. return _.find(this.groupAutoColumns, function (groupCol) { return _this.columnsMatch(groupCol, key); });
  7343. };
  7344. ColumnController.prototype.columnsMatch = function (column, key) {
  7345. var columnMatches = column === key;
  7346. var colDefMatches = column.getColDef() === key;
  7347. var idMatches = column.getColId() == key;
  7348. return columnMatches || colDefMatches || idMatches;
  7349. };
  7350. ColumnController.prototype.getDisplayNameForColumn = function (column, location, includeAggFunc) {
  7351. if (includeAggFunc === void 0) { includeAggFunc = false; }
  7352. if (!column) {
  7353. return null;
  7354. }
  7355. var headerName = this.getHeaderName(column.getColDef(), column, null, null, location);
  7356. if (includeAggFunc) {
  7357. return this.wrapHeaderNameWithAggFunc(column, headerName);
  7358. }
  7359. return headerName;
  7360. };
  7361. ColumnController.prototype.getDisplayNameForOriginalColumnGroup = function (columnGroup, originalColumnGroup, location) {
  7362. var colGroupDef = originalColumnGroup ? originalColumnGroup.getColGroupDef() : null;
  7363. if (colGroupDef) {
  7364. return this.getHeaderName(colGroupDef, null, columnGroup, originalColumnGroup, location);
  7365. }
  7366. return null;
  7367. };
  7368. ColumnController.prototype.getDisplayNameForColumnGroup = function (columnGroup, location) {
  7369. return this.getDisplayNameForOriginalColumnGroup(columnGroup, columnGroup.getOriginalColumnGroup(), location);
  7370. };
  7371. // location is where the column is going to appear, ie who is calling us
  7372. ColumnController.prototype.getHeaderName = function (colDef, column, columnGroup, originalColumnGroup, location) {
  7373. var headerValueGetter = colDef.headerValueGetter;
  7374. if (headerValueGetter) {
  7375. var params = {
  7376. colDef: colDef,
  7377. column: column,
  7378. columnGroup: columnGroup,
  7379. originalColumnGroup: originalColumnGroup,
  7380. location: location,
  7381. api: this.gridOptionsWrapper.getApi(),
  7382. context: this.gridOptionsWrapper.getContext()
  7383. };
  7384. if (typeof headerValueGetter === 'function') {
  7385. // valueGetter is a function, so just call it
  7386. return headerValueGetter(params);
  7387. }
  7388. else if (typeof headerValueGetter === 'string') {
  7389. // valueGetter is an expression, so execute the expression
  7390. return this.expressionService.evaluate(headerValueGetter, params);
  7391. }
  7392. console.warn('ag-grid: headerValueGetter must be a function or a string');
  7393. return '';
  7394. }
  7395. else if (colDef.headerName != null) {
  7396. return colDef.headerName;
  7397. }
  7398. else if (colDef.field) {
  7399. return _.camelCaseToHumanText(colDef.field);
  7400. }
  7401. return '';
  7402. };
  7403. /*
  7404. private getHeaderGroupName(columnGroup: ColumnGroup): string {
  7405. let colGroupDef = columnGroup.getOriginalColumnGroup().getColGroupDef();
  7406. let headerValueGetter = colGroupDef.headerValueGetter;
  7407. if (headerValueGetter) {
  7408. let params = {
  7409. columnGroup: columnGroup,
  7410. colDef: colGroupDef,
  7411. api: this.gridOptionsWrapper.getApi(),
  7412. context: this.gridOptionsWrapper.getContext()
  7413. };
  7414. if (typeof headerValueGetter === 'function') {
  7415. // valueGetter is a function, so just call it
  7416. return headerValueGetter(params);
  7417. } else if (typeof headerValueGetter === 'string') {
  7418. // valueGetter is an expression, so execute the expression
  7419. return this.expressionService.evaluate(headerValueGetter, params);
  7420. } else {
  7421. console.warn('ag-grid: headerValueGetter must be a function or a string');
  7422. return '';
  7423. }
  7424. } else {
  7425. return colGroupDef.headerName;
  7426. }
  7427. }
  7428. */
  7429. ColumnController.prototype.wrapHeaderNameWithAggFunc = function (column, headerName) {
  7430. if (this.gridOptionsWrapper.isSuppressAggFuncInHeader()) {
  7431. return headerName;
  7432. }
  7433. // only columns with aggregation active can have aggregations
  7434. var pivotValueColumn = column.getColDef().pivotValueColumn;
  7435. var pivotActiveOnThisColumn = _.exists(pivotValueColumn);
  7436. var aggFunc = null;
  7437. var aggFuncFound;
  7438. // otherwise we have a measure that is active, and we are doing aggregation on it
  7439. if (pivotActiveOnThisColumn) {
  7440. aggFunc = pivotValueColumn ? pivotValueColumn.getAggFunc() : null;
  7441. aggFuncFound = true;
  7442. }
  7443. else {
  7444. var measureActive = column.isValueActive();
  7445. var aggregationPresent = this.pivotMode || !this.isRowGroupEmpty();
  7446. if (measureActive && aggregationPresent) {
  7447. aggFunc = column.getAggFunc();
  7448. aggFuncFound = true;
  7449. }
  7450. else {
  7451. aggFuncFound = false;
  7452. }
  7453. }
  7454. if (aggFuncFound) {
  7455. var aggFuncString = (typeof aggFunc === 'string') ? aggFunc : 'func';
  7456. var localeTextFunc = this.gridOptionsWrapper.getLocaleTextFunc();
  7457. var aggFuncStringTranslated = localeTextFunc(aggFuncString, aggFuncString);
  7458. return aggFuncStringTranslated + "(" + headerName + ")";
  7459. }
  7460. return headerName;
  7461. };
  7462. // returns the group with matching colId and instanceId. If instanceId is missing,
  7463. // matches only on the colId.
  7464. ColumnController.prototype.getColumnGroup = function (colId, instanceId) {
  7465. if (!colId) {
  7466. return null;
  7467. }
  7468. if (colId instanceof ColumnGroup) {
  7469. return colId;
  7470. }
  7471. var allColumnGroups = this.getAllDisplayedColumnGroups();
  7472. var checkInstanceId = typeof instanceId === 'number';
  7473. var result = null;
  7474. this.columnUtils.depthFirstAllColumnTreeSearch(allColumnGroups, function (child) {
  7475. if (child instanceof ColumnGroup) {
  7476. var columnGroup = child;
  7477. var matched = void 0;
  7478. if (checkInstanceId) {
  7479. matched = colId === columnGroup.getGroupId() && instanceId === columnGroup.getInstanceId();
  7480. }
  7481. else {
  7482. matched = colId === columnGroup.getGroupId();
  7483. }
  7484. if (matched) {
  7485. result = columnGroup;
  7486. }
  7487. }
  7488. });
  7489. return result;
  7490. };
  7491. ColumnController.prototype.isReady = function () {
  7492. return this.ready;
  7493. };
  7494. ColumnController.prototype.createValueColumns = function (source, oldPrimaryColumns) {
  7495. this.valueColumns = this.extractColumns(oldPrimaryColumns, this.valueColumns, function (col, flag) { return col.setValueActive(flag, source); },
  7496. // aggFunc doesn't have index variant, cos order of value cols doesn't matter, so always return null
  7497. function () { return null; },
  7498. // aggFunc is a string, so return it's existence
  7499. function (colDef) { return !!colDef.aggFunc; });
  7500. // all new columns added will have aggFunc missing, so set it to what is in the colDef
  7501. this.valueColumns.forEach(function (col) {
  7502. if (!col.getAggFunc()) {
  7503. col.setAggFunc(col.getColDef().aggFunc);
  7504. }
  7505. });
  7506. };
  7507. ColumnController.prototype.extractRowGroupColumns = function (source, oldPrimaryColumns) {
  7508. this.rowGroupColumns = this.extractColumns(oldPrimaryColumns, this.rowGroupColumns, function (col, flag) { return col.setRowGroupActive(flag, source); }, function (colDef) { return colDef.rowGroupIndex; }, function (colDef) { return colDef.rowGroup; });
  7509. };
  7510. ColumnController.prototype.extractColumns = function (oldPrimaryColumns, previousCols, setFlagFunc, getIndexFunc, getValueFunc) {
  7511. var _this = this;
  7512. if (!previousCols) {
  7513. previousCols = [];
  7514. }
  7515. // remove cols that no longer exist
  7516. var colPresentInPrimaryFunc = function (col) { return _this.primaryColumns.indexOf(col) >= 0; };
  7517. var colMissingFromPrimaryFunc = function (col) { return _this.primaryColumns.indexOf(col) < 0; };
  7518. var colNewFunc = function (col) { return !oldPrimaryColumns || oldPrimaryColumns.indexOf(col) < 0; };
  7519. var removedCols = previousCols.filter(colMissingFromPrimaryFunc);
  7520. var existingCols = previousCols.filter(colPresentInPrimaryFunc);
  7521. var newPrimaryCols = this.primaryColumns.filter(colNewFunc);
  7522. removedCols.forEach(function (col) { return setFlagFunc(col, false); });
  7523. var newCols = [];
  7524. // we only want to work on new columns, as old columns already got processed first time around
  7525. // pull out items with xxxIndex
  7526. newPrimaryCols.forEach(function (col) {
  7527. var index = getIndexFunc(col.getColDef());
  7528. if (typeof index === 'number') {
  7529. newCols.push(col);
  7530. }
  7531. });
  7532. // then sort them
  7533. newCols.sort(function (colA, colB) {
  7534. var indexA = getIndexFunc(colA.getColDef());
  7535. var indexB = getIndexFunc(colB.getColDef());
  7536. if (indexA === indexB) {
  7537. return 0;
  7538. }
  7539. else if (indexA < indexB) {
  7540. return -1;
  7541. }
  7542. return 1;
  7543. });
  7544. // now just pull out items xxx (boolean value), they will be added at the end
  7545. // after the indexed ones, but in the order the columns appear
  7546. newPrimaryCols.forEach(function (col) {
  7547. var booleanValue = getValueFunc(col.getColDef());
  7548. if (booleanValue) {
  7549. // if user already specified xxxIndex then we skip it as this col already included
  7550. if (newCols.indexOf(col) >= 0) {
  7551. return;
  7552. }
  7553. newCols.push(col);
  7554. }
  7555. });
  7556. newCols.forEach(function (col) { return setFlagFunc(col, true); });
  7557. var res = existingCols.concat(newCols);
  7558. return res;
  7559. };
  7560. ColumnController.prototype.extractPivotColumns = function (source, oldPrimaryColumns) {
  7561. this.pivotColumns = this.extractColumns(oldPrimaryColumns, this.pivotColumns, function (col, flag) { return col.setPivotActive(flag, source); }, function (colDef) { return colDef.pivotIndex; }, function (colDef) { return colDef.pivot; });
  7562. };
  7563. ColumnController.prototype.resetColumnGroupState = function (source) {
  7564. if (source === void 0) { source = "api"; }
  7565. var stateItems = [];
  7566. this.columnUtils.depthFirstOriginalTreeSearch(null, this.primaryColumnTree, function (child) {
  7567. if (child instanceof OriginalColumnGroup) {
  7568. var groupState = {
  7569. groupId: child.getGroupId(),
  7570. open: child.getColGroupDef().openByDefault
  7571. };
  7572. stateItems.push(groupState);
  7573. }
  7574. });
  7575. this.setColumnGroupState(stateItems, source);
  7576. };
  7577. ColumnController.prototype.getColumnGroupState = function () {
  7578. var columnGroupState = [];
  7579. this.columnUtils.depthFirstOriginalTreeSearch(null, this.gridBalancedTree, function (node) {
  7580. if (node instanceof OriginalColumnGroup) {
  7581. var originalColumnGroup = node;
  7582. columnGroupState.push({
  7583. groupId: originalColumnGroup.getGroupId(),
  7584. open: originalColumnGroup.isExpanded()
  7585. });
  7586. }
  7587. });
  7588. return columnGroupState;
  7589. };
  7590. ColumnController.prototype.setColumnGroupState = function (stateItems, source) {
  7591. var _this = this;
  7592. if (source === void 0) { source = "api"; }
  7593. this.columnAnimationService.start();
  7594. var impactedGroups = [];
  7595. stateItems.forEach(function (stateItem) {
  7596. var groupKey = stateItem.groupId;
  7597. var newValue = stateItem.open;
  7598. var originalColumnGroup = _this.getOriginalColumnGroup(groupKey);
  7599. if (!originalColumnGroup) {
  7600. return;
  7601. }
  7602. if (originalColumnGroup.isExpanded() === newValue) {
  7603. return;
  7604. }
  7605. _this.logger.log('columnGroupOpened(' + originalColumnGroup.getGroupId() + ',' + newValue + ')');
  7606. originalColumnGroup.setExpanded(newValue);
  7607. impactedGroups.push(originalColumnGroup);
  7608. });
  7609. this.updateGroupsAndDisplayedColumns(source);
  7610. this.setFirstRightAndLastLeftPinned(source);
  7611. impactedGroups.forEach(function (originalColumnGroup) {
  7612. var event = {
  7613. type: Events.EVENT_COLUMN_GROUP_OPENED,
  7614. columnGroup: originalColumnGroup,
  7615. api: _this.gridApi,
  7616. columnApi: _this.columnApi
  7617. };
  7618. _this.eventService.dispatchEvent(event);
  7619. });
  7620. this.columnAnimationService.finish();
  7621. };
  7622. // called by headerRenderer - when a header is opened or closed
  7623. ColumnController.prototype.setColumnGroupOpened = function (key, newValue, source) {
  7624. if (source === void 0) { source = "api"; }
  7625. var keyAsString;
  7626. if (key instanceof OriginalColumnGroup) {
  7627. keyAsString = key.getId();
  7628. }
  7629. else {
  7630. keyAsString = key;
  7631. }
  7632. this.setColumnGroupState([{ groupId: keyAsString, open: newValue }], source);
  7633. };
  7634. ColumnController.prototype.getOriginalColumnGroup = function (key) {
  7635. if (key instanceof OriginalColumnGroup) {
  7636. return key;
  7637. }
  7638. if (typeof key !== 'string') {
  7639. console.error('ag-Grid: group key must be a string');
  7640. }
  7641. // otherwise, search for the column group by id
  7642. var res = null;
  7643. this.columnUtils.depthFirstOriginalTreeSearch(null, this.gridBalancedTree, function (node) {
  7644. if (node instanceof OriginalColumnGroup) {
  7645. var originalColumnGroup = node;
  7646. if (originalColumnGroup.getId() === key) {
  7647. res = originalColumnGroup;
  7648. }
  7649. }
  7650. });
  7651. return res;
  7652. };
  7653. ColumnController.prototype.calculateColumnsForDisplay = function () {
  7654. var _this = this;
  7655. var columnsForDisplay;
  7656. if (this.pivotMode && !this.secondaryColumnsPresent) {
  7657. // pivot mode is on, but we are not pivoting, so we only
  7658. // show columns we are aggregating on
  7659. columnsForDisplay = this.gridColumns.filter(function (column) {
  7660. var isAutoGroupCol = _this.groupAutoColumns && _.includes(_this.groupAutoColumns, column);
  7661. var isValueCol = _this.valueColumns && _.includes(_this.valueColumns, column);
  7662. return isAutoGroupCol || isValueCol;
  7663. });
  7664. }
  7665. else {
  7666. // otherwise continue as normal. this can be working on the primary
  7667. // or secondary columns, whatever the gridColumns are set to
  7668. columnsForDisplay = this.gridColumns.filter(function (column) {
  7669. // keep col if a) it's auto-group or b) it's visible
  7670. var isAutoGroupCol = _this.groupAutoColumns && _.includes(_this.groupAutoColumns, column);
  7671. return isAutoGroupCol || column.isVisible();
  7672. });
  7673. }
  7674. return columnsForDisplay;
  7675. };
  7676. ColumnController.prototype.checkColSpanActiveInCols = function (columns) {
  7677. var result = false;
  7678. columns.forEach(function (col) {
  7679. if (_.exists(col.getColDef().colSpan)) {
  7680. result = true;
  7681. }
  7682. });
  7683. return result;
  7684. };
  7685. ColumnController.prototype.calculateColumnsForGroupDisplay = function () {
  7686. var _this = this;
  7687. this.groupDisplayColumns = [];
  7688. var checkFunc = function (col) {
  7689. var colDef = col.getColDef();
  7690. if (colDef && _.exists(colDef.showRowGroup)) {
  7691. _this.groupDisplayColumns.push(col);
  7692. }
  7693. };
  7694. this.gridColumns.forEach(checkFunc);
  7695. if (this.groupAutoColumns) {
  7696. this.groupAutoColumns.forEach(checkFunc);
  7697. }
  7698. };
  7699. ColumnController.prototype.getGroupDisplayColumns = function () {
  7700. return this.groupDisplayColumns;
  7701. };
  7702. ColumnController.prototype.updateDisplayedColumns = function (source) {
  7703. var columnsForDisplay = this.calculateColumnsForDisplay();
  7704. this.buildDisplayedTrees(columnsForDisplay);
  7705. this.calculateColumnsForGroupDisplay();
  7706. // also called when group opened/closed
  7707. this.updateGroupsAndDisplayedColumns(source);
  7708. // also called when group opened/closed
  7709. this.setFirstRightAndLastLeftPinned(source);
  7710. };
  7711. ColumnController.prototype.isSecondaryColumnsPresent = function () {
  7712. return this.secondaryColumnsPresent;
  7713. };
  7714. ColumnController.prototype.setSecondaryColumns = function (colDefs, source) {
  7715. if (source === void 0) { source = "api"; }
  7716. var newColsPresent = colDefs && colDefs.length > 0;
  7717. // if not cols passed, and we had to cols anyway, then do nothing
  7718. if (!newColsPresent && !this.secondaryColumnsPresent) {
  7719. return;
  7720. }
  7721. if (newColsPresent) {
  7722. this.processSecondaryColumnDefinitions(colDefs);
  7723. var balancedTreeResult = this.columnFactory.createColumnTree(colDefs, false);
  7724. this.secondaryBalancedTree = balancedTreeResult.columnTree;
  7725. this.secondaryHeaderRowCount = balancedTreeResult.treeDept + 1;
  7726. this.secondaryColumns = this.getColumnsFromTree(this.secondaryBalancedTree);
  7727. this.secondaryColumnsPresent = true;
  7728. }
  7729. else {
  7730. this.secondaryBalancedTree = null;
  7731. this.secondaryHeaderRowCount = -1;
  7732. this.secondaryColumns = null;
  7733. this.secondaryColumnsPresent = false;
  7734. }
  7735. this.updateGridColumns();
  7736. this.updateDisplayedColumns(source);
  7737. };
  7738. ColumnController.prototype.processSecondaryColumnDefinitions = function (colDefs) {
  7739. var columnCallback = this.gridOptionsWrapper.getProcessSecondaryColDefFunc();
  7740. var groupCallback = this.gridOptionsWrapper.getProcessSecondaryColGroupDefFunc();
  7741. if (!columnCallback && !groupCallback) {
  7742. return undefined;
  7743. }
  7744. var searchForColDefs = function (colDefs2) {
  7745. colDefs2.forEach(function (abstractColDef) {
  7746. var isGroup = _.exists(abstractColDef.children);
  7747. if (isGroup) {
  7748. var colGroupDef = abstractColDef;
  7749. if (groupCallback) {
  7750. groupCallback(colGroupDef);
  7751. }
  7752. searchForColDefs(colGroupDef.children);
  7753. }
  7754. else {
  7755. var colDef = abstractColDef;
  7756. if (columnCallback) {
  7757. columnCallback(colDef);
  7758. }
  7759. }
  7760. });
  7761. };
  7762. if (colDefs) {
  7763. searchForColDefs(colDefs);
  7764. }
  7765. };
  7766. // called from: setColumnState, setColumnDefs, setSecondaryColumns
  7767. ColumnController.prototype.updateGridColumns = function () {
  7768. if (this.gridColsArePrimary) {
  7769. this.lastPrimaryOrder = this.gridColumns;
  7770. }
  7771. if (this.secondaryColumns && this.secondaryBalancedTree) {
  7772. this.gridBalancedTree = this.secondaryBalancedTree.slice();
  7773. this.gridHeaderRowCount = this.secondaryHeaderRowCount;
  7774. this.gridColumns = this.secondaryColumns.slice();
  7775. this.gridColsArePrimary = false;
  7776. }
  7777. else {
  7778. this.gridBalancedTree = this.primaryColumnTree.slice();
  7779. this.gridHeaderRowCount = this.primaryHeaderRowCount;
  7780. this.gridColumns = this.primaryColumns.slice();
  7781. this.gridColsArePrimary = true;
  7782. // updateGridColumns gets called after user adds a row group. we want to maintain the order of the columns
  7783. // when this happens (eg if user moved a column) rather than revert back to the original column order.
  7784. // likewise if changing in/out of pivot mode, we want to maintain the order of the primary cols
  7785. this.orderGridColsLikeLastPrimary();
  7786. }
  7787. this.addAutoGroupToGridColumns();
  7788. this.autoRowHeightColumns = this.gridColumns.filter(function (col) { return col.getColDef().autoHeight; });
  7789. this.putFixedColumnsFirst();
  7790. this.setupQuickFilterColumns();
  7791. this.clearDisplayedColumns();
  7792. this.colSpanActive = this.checkColSpanActiveInCols(this.gridColumns);
  7793. var event = {
  7794. type: Events.EVENT_GRID_COLUMNS_CHANGED,
  7795. api: this.gridApi,
  7796. columnApi: this.columnApi
  7797. };
  7798. this.eventService.dispatchEvent(event);
  7799. };
  7800. ColumnController.prototype.orderGridColsLikeLastPrimary = function () {
  7801. var _this = this;
  7802. if (_.missing(this.lastPrimaryOrder)) {
  7803. return;
  7804. }
  7805. // only do the sort if at least one column is accounted for. columns will be not accounted for
  7806. // if changing from secondary to primary columns
  7807. var noColsFound = true;
  7808. this.gridColumns.forEach(function (col) {
  7809. if (_this.lastPrimaryOrder.indexOf(col) >= 0) {
  7810. noColsFound = false;
  7811. }
  7812. });
  7813. if (noColsFound) {
  7814. return;
  7815. }
  7816. // order cols in the same order as before. we need to make sure that all
  7817. // cols still exists, so filter out any that no longer exist.
  7818. var oldColsOrdered = this.lastPrimaryOrder.filter(function (col) { return _this.gridColumns.indexOf(col) >= 0; });
  7819. var newColsOrdered = this.gridColumns.filter(function (col) { return oldColsOrdered.indexOf(col) < 0; });
  7820. // add in the new columns, at the end (if no group), or at the end of the group (if a group)
  7821. var newGridColumns = oldColsOrdered.slice();
  7822. newColsOrdered.forEach(function (newCol) {
  7823. var parent = newCol.getOriginalParent();
  7824. // if no parent, means we are not grouping, so just add the column to the end
  7825. if (!parent) {
  7826. newGridColumns.push(newCol);
  7827. return;
  7828. }
  7829. // find the group the column belongs to. if no siblings at the current level (eg col in group on it's
  7830. // own) then go up one level and look for siblings there.
  7831. var siblings = [];
  7832. while (!siblings.length && parent) {
  7833. var leafCols = parent.getLeafColumns();
  7834. leafCols.forEach(function (leafCol) {
  7835. var presentInNewGriColumns = newGridColumns.indexOf(leafCol) >= 0;
  7836. var noYetInSiblings = siblings.indexOf(leafCol) < 0;
  7837. if (presentInNewGriColumns && noYetInSiblings) {
  7838. siblings.push(leafCol);
  7839. }
  7840. });
  7841. parent = parent.getOriginalParent();
  7842. }
  7843. // if no siblings exist at any level, this means the col is in a group (or parent groups) on it's own
  7844. if (!siblings.length) {
  7845. newGridColumns.push(newCol);
  7846. return;
  7847. }
  7848. // find index of last column in the group
  7849. var indexes = siblings.map(function (col) { return newGridColumns.indexOf(col); });
  7850. var lastIndex = Math.max.apply(Math, indexes);
  7851. _.insertIntoArray(newGridColumns, newCol, lastIndex + 1);
  7852. });
  7853. this.gridColumns = newGridColumns;
  7854. };
  7855. ColumnController.prototype.isPrimaryColumnGroupsPresent = function () {
  7856. return this.primaryHeaderRowCount > 1;
  7857. };
  7858. // if we are using autoGroupCols, then they should be included for quick filter. this covers the
  7859. // following scenarios:
  7860. // a) user provides 'field' into autoGroupCol of normal grid, so now because a valid col to filter leafs on
  7861. // b) using tree data and user depends on autoGroupCol for first col, and we also want to filter on this
  7862. // (tree data is a bit different, as parent rows can be filtered on, unlike row grouping)
  7863. ColumnController.prototype.setupQuickFilterColumns = function () {
  7864. if (this.groupAutoColumns) {
  7865. this.columnsForQuickFilter = this.primaryColumns.concat(this.groupAutoColumns);
  7866. }
  7867. else {
  7868. this.columnsForQuickFilter = this.primaryColumns;
  7869. }
  7870. };
  7871. ColumnController.prototype.putFixedColumnsFirst = function () {
  7872. var locked = this.gridColumns.filter(function (c) { return c.getColDef().lockPosition; });
  7873. var unlocked = this.gridColumns.filter(function (c) { return !c.getColDef().lockPosition; });
  7874. this.gridColumns = locked.concat(unlocked);
  7875. };
  7876. ColumnController.prototype.addAutoGroupToGridColumns = function () {
  7877. // add in auto-group here
  7878. this.createGroupAutoColumnsIfNeeded();
  7879. if (_.missing(this.groupAutoColumns)) {
  7880. return;
  7881. }
  7882. this.gridColumns = this.groupAutoColumns ? this.groupAutoColumns.concat(this.gridColumns) : this.gridColumns;
  7883. var autoColBalancedTree = this.columnFactory.createForAutoGroups(this.groupAutoColumns, this.gridBalancedTree);
  7884. this.gridBalancedTree = autoColBalancedTree.concat(this.gridBalancedTree);
  7885. };
  7886. // gets called after we copy down grid columns, to make sure any part of the gui
  7887. // that tries to draw, eg the header, it will get empty lists of columns rather
  7888. // than stale columns. for example, the header will received gridColumnsChanged
  7889. // event, so will try and draw, but it will draw successfully when it acts on the
  7890. // virtualColumnsChanged event
  7891. ColumnController.prototype.clearDisplayedColumns = function () {
  7892. this.displayedLeftColumnTree = [];
  7893. this.displayedRightColumnTree = [];
  7894. this.displayedCentreColumnTree = [];
  7895. this.displayedLeftHeaderRows = {};
  7896. this.displayedRightHeaderRows = {};
  7897. this.displayedCentreHeaderRows = {};
  7898. this.displayedLeftColumns = [];
  7899. this.displayedRightColumns = [];
  7900. this.displayedCenterColumns = [];
  7901. this.allDisplayedColumns = [];
  7902. this.allDisplayedVirtualColumns = [];
  7903. };
  7904. ColumnController.prototype.updateGroupsAndDisplayedColumns = function (source) {
  7905. this.updateOpenClosedVisibilityInColumnGroups();
  7906. this.updateDisplayedColumnsFromTrees(source);
  7907. this.updateVirtualSets();
  7908. this.refreshFlexedColumns(undefined, undefined, true);
  7909. this.updateBodyWidths();
  7910. // this event is picked up by the gui, headerRenderer and rowRenderer, to recalculate what columns to display
  7911. var event = {
  7912. type: Events.EVENT_DISPLAYED_COLUMNS_CHANGED,
  7913. api: this.gridApi,
  7914. columnApi: this.columnApi
  7915. };
  7916. this.eventService.dispatchEvent(event);
  7917. };
  7918. ColumnController.prototype.updateDisplayedColumnsFromTrees = function (source) {
  7919. this.addToDisplayedColumns(this.displayedLeftColumnTree, this.displayedLeftColumns);
  7920. this.addToDisplayedColumns(this.displayedCentreColumnTree, this.displayedCenterColumns);
  7921. this.addToDisplayedColumns(this.displayedRightColumnTree, this.displayedRightColumns);
  7922. this.setupAllDisplayedColumns();
  7923. this.setLeftValues(source);
  7924. };
  7925. ColumnController.prototype.setupAllDisplayedColumns = function () {
  7926. if (this.gridOptionsWrapper.isEnableRtl()) {
  7927. this.allDisplayedColumns = this.displayedRightColumns
  7928. .concat(this.displayedCenterColumns)
  7929. .concat(this.displayedLeftColumns);
  7930. }
  7931. else {
  7932. this.allDisplayedColumns = this.displayedLeftColumns
  7933. .concat(this.displayedCenterColumns)
  7934. .concat(this.displayedRightColumns);
  7935. }
  7936. };
  7937. // sets the left pixel position of each column
  7938. ColumnController.prototype.setLeftValues = function (source) {
  7939. this.setLeftValuesOfColumns(source);
  7940. this.setLeftValuesOfGroups();
  7941. };
  7942. ColumnController.prototype.setLeftValuesOfColumns = function (source) {
  7943. var _this = this;
  7944. // go through each list of displayed columns
  7945. var allColumns = this.primaryColumns.slice(0);
  7946. // let totalColumnWidth = this.getWidthOfColsInList()
  7947. var doingRtl = this.gridOptionsWrapper.isEnableRtl();
  7948. [
  7949. this.displayedLeftColumns,
  7950. this.displayedRightColumns,
  7951. this.displayedCenterColumns
  7952. ].forEach(function (columns) {
  7953. if (doingRtl) {
  7954. // when doing RTL, we start at the top most pixel (ie RHS) and work backwards
  7955. var left_1 = _this.getWidthOfColsInList(columns);
  7956. columns.forEach(function (column) {
  7957. left_1 -= column.getActualWidth();
  7958. column.setLeft(left_1, source);
  7959. });
  7960. }
  7961. else {
  7962. // otherwise normal LTR, we start at zero
  7963. var left_2 = 0;
  7964. columns.forEach(function (column) {
  7965. column.setLeft(left_2, source);
  7966. left_2 += column.getActualWidth();
  7967. });
  7968. }
  7969. _.removeAllFromArray(allColumns, columns);
  7970. });
  7971. // items left in allColumns are columns not displayed, so remove the left position. this is
  7972. // important for the rows, as if a col is made visible, then taken out, then made visible again,
  7973. // we don't want the animation of the cell floating in from the old position, whatever that was.
  7974. allColumns.forEach(function (column) {
  7975. column.setLeft(null, source);
  7976. });
  7977. };
  7978. ColumnController.prototype.setLeftValuesOfGroups = function () {
  7979. // a groups left value is the lest left value of it's children
  7980. [
  7981. this.displayedLeftColumnTree,
  7982. this.displayedRightColumnTree,
  7983. this.displayedCentreColumnTree
  7984. ].forEach(function (columns) {
  7985. columns.forEach(function (column) {
  7986. if (column instanceof ColumnGroup) {
  7987. var columnGroup = column;
  7988. columnGroup.checkLeft();
  7989. }
  7990. });
  7991. });
  7992. };
  7993. ColumnController.prototype.addToDisplayedColumns = function (displayedColumnTree, displayedColumns) {
  7994. displayedColumns.length = 0;
  7995. this.columnUtils.depthFirstDisplayedColumnTreeSearch(displayedColumnTree, function (child) {
  7996. if (child instanceof Column) {
  7997. displayedColumns.push(child);
  7998. }
  7999. });
  8000. };
  8001. ColumnController.prototype.updateDisplayedCenterVirtualColumns = function () {
  8002. if (this.suppressColumnVirtualisation) {
  8003. // no virtualisation, so don't filter
  8004. this.allDisplayedCenterVirtualColumns = this.displayedCenterColumns;
  8005. }
  8006. else {
  8007. // filter out what should be visible
  8008. this.allDisplayedCenterVirtualColumns = this.filterOutColumnsWithinViewport();
  8009. }
  8010. this.allDisplayedVirtualColumns = this.allDisplayedCenterVirtualColumns
  8011. .concat(this.displayedLeftColumns)
  8012. .concat(this.displayedRightColumns);
  8013. // return map of virtual col id's, for easy lookup when building the groups.
  8014. // the map will be colId=>true, ie col id's mapping to 'true'.
  8015. var result = {};
  8016. this.allDisplayedVirtualColumns.forEach(function (col) {
  8017. result[col.getId()] = true;
  8018. });
  8019. return result;
  8020. };
  8021. ColumnController.prototype.getVirtualHeaderGroupRow = function (type, dept) {
  8022. var result;
  8023. switch (type) {
  8024. case Constants.PINNED_LEFT:
  8025. result = this.displayedLeftHeaderRows[dept];
  8026. break;
  8027. case Constants.PINNED_RIGHT:
  8028. result = this.displayedRightHeaderRows[dept];
  8029. break;
  8030. default:
  8031. result = this.displayedCentreHeaderRows[dept];
  8032. break;
  8033. }
  8034. if (_.missing(result)) {
  8035. result = [];
  8036. }
  8037. return result;
  8038. };
  8039. ColumnController.prototype.updateDisplayedVirtualGroups = function (virtualColIds) {
  8040. // go through each group, see if any of it's cols are displayed, and if yes,
  8041. // then this group is included
  8042. this.displayedLeftHeaderRows = {};
  8043. this.displayedRightHeaderRows = {};
  8044. this.displayedCentreHeaderRows = {};
  8045. var testGroup = function (children, result, dept) {
  8046. var returnValue = false;
  8047. for (var i = 0; i < children.length; i++) {
  8048. // see if this item is within viewport
  8049. var child = children[i];
  8050. var addThisItem = void 0;
  8051. if (child instanceof Column) {
  8052. // for column, test if column is included
  8053. addThisItem = virtualColIds[child.getId()] === true;
  8054. }
  8055. else {
  8056. // if group, base decision on children
  8057. var columnGroup = child;
  8058. addThisItem = testGroup(columnGroup.getDisplayedChildren(), result, dept + 1);
  8059. }
  8060. if (addThisItem) {
  8061. returnValue = true;
  8062. if (!result[dept]) {
  8063. result[dept] = [];
  8064. }
  8065. result[dept].push(child);
  8066. }
  8067. }
  8068. return returnValue;
  8069. };
  8070. testGroup(this.displayedLeftColumnTree, this.displayedLeftHeaderRows, 0);
  8071. testGroup(this.displayedRightColumnTree, this.displayedRightHeaderRows, 0);
  8072. testGroup(this.displayedCentreColumnTree, this.displayedCentreHeaderRows, 0);
  8073. };
  8074. ColumnController.prototype.updateVirtualSets = function () {
  8075. var virtualColIds = this.updateDisplayedCenterVirtualColumns();
  8076. this.updateDisplayedVirtualGroups(virtualColIds);
  8077. };
  8078. ColumnController.prototype.filterOutColumnsWithinViewport = function () {
  8079. return this.displayedCenterColumns.filter(this.isColumnInViewport.bind(this));
  8080. };
  8081. ColumnController.prototype.refreshFlexedColumns = function (updatedFlexViewportWidth, source, silent) {
  8082. if (source === void 0) { source = 'flex'; }
  8083. if (!this.flexActive) {
  8084. return;
  8085. }
  8086. this.flexViewportWidth = updatedFlexViewportWidth || this.flexViewportWidth;
  8087. if (!this.flexViewportWidth) {
  8088. return;
  8089. }
  8090. // If the grid has left-over space, divide it between flexing columns in proportion to their flex value.
  8091. // A "flexing column" is one that has a 'flex' value set and is not currently being constrained by its
  8092. // minWidth or maxWidth rules.
  8093. var knownWidthColumns = this.displayedCenterColumns.filter(function (col) { return !col.getFlex(); });
  8094. var flexingColumns = this.displayedCenterColumns.filter(function (col) { return col.getFlex(); });
  8095. if (!flexingColumns.length) {
  8096. this.flexActive = false;
  8097. return;
  8098. }
  8099. var flexingColumnSizes = [];
  8100. var spaceForFlexingColumns;
  8101. outer: while (true) {
  8102. var totalFlex = flexingColumns.reduce(function (count, col) { return count + col.getFlex(); }, 0);
  8103. spaceForFlexingColumns = this.flexViewportWidth - this.getWidthOfColsInList(knownWidthColumns);
  8104. for (var i = 0; i < flexingColumns.length; i++) {
  8105. var col = flexingColumns[i];
  8106. var widthByFlexRule = spaceForFlexingColumns * col.getFlex() / totalFlex;
  8107. var constrainedWidth = void 0;
  8108. if (widthByFlexRule < col.getMinWidth()) {
  8109. constrainedWidth = col.getMinWidth();
  8110. }
  8111. else if (col.getMaxWidth() != null && widthByFlexRule > col.getMaxWidth()) {
  8112. constrainedWidth = col.getMaxWidth();
  8113. }
  8114. if (constrainedWidth) {
  8115. // This column is not in fact flexing as it is being constrained to a specific size
  8116. // so remove it from the list of flexing columns and start again
  8117. col.setActualWidth(constrainedWidth, source);
  8118. _.removeFromArray(flexingColumns, col);
  8119. knownWidthColumns.push(col);
  8120. continue outer;
  8121. }
  8122. flexingColumnSizes[i] = Math.round(widthByFlexRule);
  8123. }
  8124. break;
  8125. }
  8126. var remainingSpace = spaceForFlexingColumns;
  8127. flexingColumns.forEach(function (col, i) {
  8128. col.setActualWidth(Math.min(flexingColumnSizes[i], remainingSpace), source);
  8129. remainingSpace -= flexingColumnSizes[i];
  8130. });
  8131. this.setLeftValues(source);
  8132. if (!silent) {
  8133. this.updateBodyWidths();
  8134. this.fireResizedEventForColumns(flexingColumns, source);
  8135. }
  8136. };
  8137. // called from api
  8138. ColumnController.prototype.sizeColumnsToFit = function (gridWidth, source, silent) {
  8139. if (source === void 0) { source = "sizeColumnsToFit"; }
  8140. // avoid divide by zero
  8141. var allDisplayedColumns = this.getAllDisplayedColumns();
  8142. if (gridWidth <= 0 || !allDisplayedColumns.length) {
  8143. return;
  8144. }
  8145. var colsToSpread = [];
  8146. var colsToNotSpread = [];
  8147. allDisplayedColumns.forEach(function (column) {
  8148. if (column.getColDef().suppressSizeToFit === true) {
  8149. colsToNotSpread.push(column);
  8150. }
  8151. else {
  8152. colsToSpread.push(column);
  8153. }
  8154. });
  8155. // make a copy of the cols that are going to be resized
  8156. var colsToFireEventFor = colsToSpread.slice(0);
  8157. var finishedResizing = false;
  8158. var moveToNotSpread = function (column) {
  8159. _.removeFromArray(colsToSpread, column);
  8160. colsToNotSpread.push(column);
  8161. };
  8162. // resetting cols to their original width makes the sizeColumnsToFit more deterministic,
  8163. // rather than depending on the current size of the columns. most users call sizeColumnsToFit
  8164. // immediately after grid is created, so will make no difference. however if application is calling
  8165. // sizeColumnsToFit repeatedly (eg after column group is opened / closed repeatedly) we don't want
  8166. // the columns to start shrinking / growing over time.
  8167. colsToSpread.forEach(function (column) { return column.resetActualWidth(); });
  8168. while (!finishedResizing) {
  8169. finishedResizing = true;
  8170. var availablePixels = gridWidth - this.getWidthOfColsInList(colsToNotSpread);
  8171. if (availablePixels <= 0) {
  8172. // no width, set everything to minimum
  8173. colsToSpread.forEach(function (column) {
  8174. column.setMinimum(source);
  8175. });
  8176. }
  8177. else {
  8178. var scale = availablePixels / this.getWidthOfColsInList(colsToSpread);
  8179. // we set the pixels for the last col based on what's left, as otherwise
  8180. // we could be a pixel or two short or extra because of rounding errors.
  8181. var pixelsForLastCol = availablePixels;
  8182. // backwards through loop, as we are removing items as we go
  8183. for (var i = colsToSpread.length - 1; i >= 0; i--) {
  8184. var column = colsToSpread[i];
  8185. var newWidth = Math.round(column.getActualWidth() * scale);
  8186. if (newWidth < column.getMinWidth()) {
  8187. column.setMinimum(source);
  8188. moveToNotSpread(column);
  8189. finishedResizing = false;
  8190. }
  8191. else if (column.isGreaterThanMax(newWidth)) {
  8192. column.setActualWidth(column.getMaxWidth(), source);
  8193. moveToNotSpread(column);
  8194. finishedResizing = false;
  8195. }
  8196. else {
  8197. var onLastCol = i === 0;
  8198. if (onLastCol) {
  8199. column.setActualWidth(pixelsForLastCol, source);
  8200. }
  8201. else {
  8202. column.setActualWidth(newWidth, source);
  8203. }
  8204. }
  8205. pixelsForLastCol -= newWidth;
  8206. }
  8207. }
  8208. }
  8209. this.setLeftValues(source);
  8210. this.updateBodyWidths();
  8211. if (silent) {
  8212. return;
  8213. }
  8214. this.fireResizedEventForColumns(colsToFireEventFor, source);
  8215. };
  8216. ColumnController.prototype.fireResizedEventForColumns = function (columns, source) {
  8217. var _this = this;
  8218. columns.forEach(function (column) {
  8219. var event = {
  8220. type: Events.EVENT_COLUMN_RESIZED,
  8221. column: column,
  8222. columns: [column],
  8223. finished: true,
  8224. api: _this.gridApi,
  8225. columnApi: _this.columnApi,
  8226. source: source
  8227. };
  8228. _this.eventService.dispatchEvent(event);
  8229. });
  8230. };
  8231. ColumnController.prototype.buildDisplayedTrees = function (visibleColumns) {
  8232. var leftVisibleColumns = [];
  8233. var rightVisibleColumns = [];
  8234. var centerVisibleColumns = [];
  8235. visibleColumns.forEach(function (column) {
  8236. switch (column.getPinned()) {
  8237. case "left":
  8238. leftVisibleColumns.push(column);
  8239. break;
  8240. case "right":
  8241. rightVisibleColumns.push(column);
  8242. break;
  8243. default:
  8244. centerVisibleColumns.push(column);
  8245. break;
  8246. }
  8247. });
  8248. var groupInstanceIdCreator = new GroupInstanceIdCreator();
  8249. this.displayedLeftColumnTree = this.displayedGroupCreator.createDisplayedGroups(leftVisibleColumns, this.gridBalancedTree, groupInstanceIdCreator, Constants.PINNED_LEFT, this.displayedLeftColumnTree);
  8250. this.displayedRightColumnTree = this.displayedGroupCreator.createDisplayedGroups(rightVisibleColumns, this.gridBalancedTree, groupInstanceIdCreator, Constants.PINNED_RIGHT, this.displayedRightColumnTree);
  8251. this.displayedCentreColumnTree = this.displayedGroupCreator.createDisplayedGroups(centerVisibleColumns, this.gridBalancedTree, groupInstanceIdCreator, null, this.displayedCentreColumnTree);
  8252. };
  8253. ColumnController.prototype.updateOpenClosedVisibilityInColumnGroups = function () {
  8254. var allColumnGroups = this.getAllDisplayedColumnGroups();
  8255. this.columnUtils.depthFirstAllColumnTreeSearch(allColumnGroups, function (child) {
  8256. if (child instanceof ColumnGroup) {
  8257. var columnGroup = child;
  8258. columnGroup.calculateDisplayedColumns();
  8259. }
  8260. });
  8261. };
  8262. ColumnController.prototype.getGroupAutoColumns = function () {
  8263. return this.groupAutoColumns;
  8264. };
  8265. ColumnController.prototype.createGroupAutoColumnsIfNeeded = function () {
  8266. if (!this.autoGroupsNeedBuilding) {
  8267. return;
  8268. }
  8269. this.autoGroupsNeedBuilding = false;
  8270. var groupFullWidthRow = this.gridOptionsWrapper.isGroupUseEntireRow(this.pivotMode);
  8271. // we need to allow suppressing auto-column separately for group and pivot as the normal situation
  8272. // is CSRM and user provides group column themselves for normal view, but when they go into pivot the
  8273. // columns are generated by the grid so no opportunity for user to provide group column. so need a way
  8274. // to suppress auto-col for grouping only, and not pivot.
  8275. // however if using Viewport RM or SSRM and user is providing the columns, the user may wish full control
  8276. // of the group column in this instance.
  8277. var suppressAutoColumn = this.pivotMode ?
  8278. this.gridOptionsWrapper.isPivotSuppressAutoColumn() : this.gridOptionsWrapper.isGroupSuppressAutoColumn();
  8279. // const groupSuppressAutoColumn = this.gridOptionsWrapper.isGroupSuppressAutoColumn() && !this.pivotMode;
  8280. var groupSuppressRow = this.gridOptionsWrapper.isGroupSuppressRow();
  8281. var groupingActive = this.rowGroupColumns.length > 0 || this.usingTreeData;
  8282. var needAutoColumns = groupingActive && !suppressAutoColumn && !groupFullWidthRow && !groupSuppressRow;
  8283. if (needAutoColumns) {
  8284. var newAutoGroupCols = this.autoGroupColService.createAutoGroupColumns(this.rowGroupColumns);
  8285. var autoColsDifferent = !this.autoColsEqual(newAutoGroupCols, this.groupAutoColumns);
  8286. // we force recreate when suppressSetColumnStateEvents changes, so new group cols pick up the new
  8287. // definitions. otherwise we could ignore the new cols becasue they appear to be the same.
  8288. if (autoColsDifferent || this.forceRecreateAutoGroups) {
  8289. this.groupAutoColumns = newAutoGroupCols;
  8290. }
  8291. }
  8292. else {
  8293. this.groupAutoColumns = null;
  8294. }
  8295. };
  8296. ColumnController.prototype.autoColsEqual = function (colsA, colsB) {
  8297. return areEqual(colsA, colsB, function (a, b) { return a.getColId() === b.getColId(); });
  8298. };
  8299. ColumnController.prototype.getWidthOfColsInList = function (columnList) {
  8300. return columnList.reduce(function (width, col) { return width + col.getActualWidth(); }, 0);
  8301. };
  8302. ColumnController.prototype.getGridBalancedTree = function () {
  8303. return this.gridBalancedTree;
  8304. };
  8305. ColumnController.prototype.hasFloatingFilters = function () {
  8306. var defaultColDef = this.gridOptionsWrapper.getDefaultColDef();
  8307. return (defaultColDef != null && defaultColDef.floatingFilter === true) ||
  8308. (this.columnDefs != null && this.columnDefs.some(function (c) { return c.floatingFilter === true; }));
  8309. };
  8310. ColumnController.prototype.getFirstDisplayedColumn = function () {
  8311. var isRtl = this.gridOptionsWrapper.isEnableRtl();
  8312. var queryOrder = [
  8313. 'getDisplayedLeftColumns',
  8314. 'getDisplayedCenterColumns',
  8315. 'getDisplayedRightColumns'
  8316. ];
  8317. if (isRtl) {
  8318. queryOrder.reverse();
  8319. }
  8320. for (var i = 0; i < queryOrder.length; i++) {
  8321. var container = this[queryOrder[i]]();
  8322. if (container.length) {
  8323. return isRtl ? _.last(container) : container[0];
  8324. }
  8325. }
  8326. return null;
  8327. };
  8328. __decorate$5([
  8329. Autowired('gridOptionsWrapper')
  8330. ], ColumnController.prototype, "gridOptionsWrapper", void 0);
  8331. __decorate$5([
  8332. Autowired('expressionService')
  8333. ], ColumnController.prototype, "expressionService", void 0);
  8334. __decorate$5([
  8335. Autowired('columnFactory')
  8336. ], ColumnController.prototype, "columnFactory", void 0);
  8337. __decorate$5([
  8338. Autowired('displayedGroupCreator')
  8339. ], ColumnController.prototype, "displayedGroupCreator", void 0);
  8340. __decorate$5([
  8341. Autowired('autoWidthCalculator')
  8342. ], ColumnController.prototype, "autoWidthCalculator", void 0);
  8343. __decorate$5([
  8344. Autowired('columnUtils')
  8345. ], ColumnController.prototype, "columnUtils", void 0);
  8346. __decorate$5([
  8347. Autowired('columnAnimationService')
  8348. ], ColumnController.prototype, "columnAnimationService", void 0);
  8349. __decorate$5([
  8350. Autowired('autoGroupColService')
  8351. ], ColumnController.prototype, "autoGroupColService", void 0);
  8352. __decorate$5([
  8353. Optional('aggFuncService')
  8354. ], ColumnController.prototype, "aggFuncService", void 0);
  8355. __decorate$5([
  8356. Optional('valueCache')
  8357. ], ColumnController.prototype, "valueCache", void 0);
  8358. __decorate$5([
  8359. Optional('animationFrameService')
  8360. ], ColumnController.prototype, "animationFrameService", void 0);
  8361. __decorate$5([
  8362. Autowired('columnApi')
  8363. ], ColumnController.prototype, "columnApi", void 0);
  8364. __decorate$5([
  8365. Autowired('gridApi')
  8366. ], ColumnController.prototype, "gridApi", void 0);
  8367. __decorate$5([
  8368. PostConstruct
  8369. ], ColumnController.prototype, "init", null);
  8370. __decorate$5([
  8371. __param$2(0, Qualifier('loggerFactory'))
  8372. ], ColumnController.prototype, "setBeans", null);
  8373. ColumnController = __decorate$5([
  8374. Bean('columnController')
  8375. ], ColumnController);
  8376. return ColumnController;
  8377. }(BeanStub));
  8378. /**
  8379. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  8380. * @version v23.2.1
  8381. * @link http://www.ag-grid.com/
  8382. * @license MIT
  8383. */
  8384. var __extends$2 = (undefined && undefined.__extends) || (function () {
  8385. var extendStatics = function (d, b) {
  8386. extendStatics = Object.setPrototypeOf ||
  8387. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  8388. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  8389. return extendStatics(d, b);
  8390. };
  8391. return function (d, b) {
  8392. extendStatics(d, b);
  8393. function __() { this.constructor = d; }
  8394. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  8395. };
  8396. })();
  8397. var __decorate$6 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  8398. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  8399. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  8400. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  8401. return c > 3 && r && Object.defineProperty(target, key, r), r;
  8402. };
  8403. // takes in a list of columns, as specified by the column definitions, and returns column groups
  8404. var ColumnUtils = /** @class */ (function (_super) {
  8405. __extends$2(ColumnUtils, _super);
  8406. function ColumnUtils() {
  8407. return _super !== null && _super.apply(this, arguments) || this;
  8408. }
  8409. ColumnUtils.prototype.calculateColInitialWidth = function (colDef) {
  8410. var optionsWrapper = this.gridOptionsWrapper;
  8411. var minColWidth = colDef.minWidth != null ? colDef.minWidth : optionsWrapper.getMinColWidth();
  8412. var maxColWidth = colDef.maxWidth != null ? colDef.maxWidth : (optionsWrapper.getMaxColWidth() || _.getMaxSafeInteger());
  8413. var width = colDef.width != null ? colDef.width : optionsWrapper.getColWidth();
  8414. return Math.max(Math.min(width, maxColWidth), minColWidth);
  8415. };
  8416. ColumnUtils.prototype.getOriginalPathForColumn = function (column, originalBalancedTree) {
  8417. var result = [];
  8418. var found = false;
  8419. var recursePath = function (balancedColumnTree, dept) {
  8420. for (var i = 0; i < balancedColumnTree.length; i++) {
  8421. if (found) {
  8422. return;
  8423. }
  8424. // quit the search, so 'result' is kept with the found result
  8425. var node = balancedColumnTree[i];
  8426. if (node instanceof OriginalColumnGroup) {
  8427. var nextNode = node;
  8428. recursePath(nextNode.getChildren(), dept + 1);
  8429. result[dept] = node;
  8430. }
  8431. else if (node === column) {
  8432. found = true;
  8433. }
  8434. }
  8435. };
  8436. recursePath(originalBalancedTree, 0);
  8437. // we should always find the path, but in case there is a bug somewhere, returning null
  8438. // will make it fail rather than provide a 'hard to track down' bug
  8439. return found ? result : null;
  8440. };
  8441. /* public getPathForColumn(column: Column, allDisplayedColumnGroups: ColumnGroupChild[]): ColumnGroup[] {
  8442. let result: ColumnGroup[] = [];
  8443. let found = false;
  8444. recursePath(allDisplayedColumnGroups, 0);
  8445. // we should always find the path, but in case there is a bug somewhere, returning null
  8446. // will make it fail rather than provide a 'hard to track down' bug
  8447. if (found) {
  8448. return result;
  8449. } else {
  8450. return null;
  8451. }
  8452. function recursePath(balancedColumnTree: ColumnGroupChild[], dept: number): void {
  8453. for (let i = 0; i<balancedColumnTree.length; i++) {
  8454. if (found) {
  8455. // quit the search, so 'result' is kept with the found result
  8456. return;
  8457. }
  8458. let node = balancedColumnTree[i];
  8459. if (node instanceof ColumnGroup) {
  8460. let nextNode = <ColumnGroup> node;
  8461. recursePath(nextNode.getChildren(), dept+1);
  8462. result[dept] = node;
  8463. } else {
  8464. if (node === column) {
  8465. found = true;
  8466. }
  8467. }
  8468. }
  8469. }
  8470. }*/
  8471. ColumnUtils.prototype.depthFirstOriginalTreeSearch = function (parent, tree, callback) {
  8472. var _this = this;
  8473. if (!tree) {
  8474. return;
  8475. }
  8476. tree.forEach(function (child) {
  8477. if (child instanceof OriginalColumnGroup) {
  8478. _this.depthFirstOriginalTreeSearch(child, child.getChildren(), callback);
  8479. }
  8480. callback(child, parent);
  8481. });
  8482. };
  8483. ColumnUtils.prototype.depthFirstAllColumnTreeSearch = function (tree, callback) {
  8484. var _this = this;
  8485. if (!tree) {
  8486. return;
  8487. }
  8488. tree.forEach(function (child) {
  8489. if (child instanceof ColumnGroup) {
  8490. _this.depthFirstAllColumnTreeSearch(child.getChildren(), callback);
  8491. }
  8492. callback(child);
  8493. });
  8494. };
  8495. ColumnUtils.prototype.depthFirstDisplayedColumnTreeSearch = function (tree, callback) {
  8496. var _this = this;
  8497. if (!tree) {
  8498. return;
  8499. }
  8500. tree.forEach(function (child) {
  8501. if (child instanceof ColumnGroup) {
  8502. _this.depthFirstDisplayedColumnTreeSearch(child.getDisplayedChildren(), callback);
  8503. }
  8504. callback(child);
  8505. });
  8506. };
  8507. __decorate$6([
  8508. Autowired('gridOptionsWrapper')
  8509. ], ColumnUtils.prototype, "gridOptionsWrapper", void 0);
  8510. ColumnUtils = __decorate$6([
  8511. Bean('columnUtils')
  8512. ], ColumnUtils);
  8513. return ColumnUtils;
  8514. }(BeanStub));
  8515. /**
  8516. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  8517. * @version v23.2.1
  8518. * @link http://www.ag-grid.com/
  8519. * @license MIT
  8520. */
  8521. var __extends$3 = (undefined && undefined.__extends) || (function () {
  8522. var extendStatics = function (d, b) {
  8523. extendStatics = Object.setPrototypeOf ||
  8524. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  8525. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  8526. return extendStatics(d, b);
  8527. };
  8528. return function (d, b) {
  8529. extendStatics(d, b);
  8530. function __() { this.constructor = d; }
  8531. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  8532. };
  8533. })();
  8534. var __decorate$7 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  8535. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  8536. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  8537. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  8538. return c > 3 && r && Object.defineProperty(target, key, r), r;
  8539. };
  8540. // takes in a list of columns, as specified by the column definitions, and returns column groups
  8541. var DisplayedGroupCreator = /** @class */ (function (_super) {
  8542. __extends$3(DisplayedGroupCreator, _super);
  8543. function DisplayedGroupCreator() {
  8544. return _super !== null && _super.apply(this, arguments) || this;
  8545. }
  8546. DisplayedGroupCreator.prototype.createDisplayedGroups = function (
  8547. // all displayed columns sorted - this is the columns the grid should show
  8548. sortedVisibleColumns,
  8549. // the tree of columns, as provided by the users, used to know what groups columns roll up into
  8550. balancedColumnTree,
  8551. // creates unique id's for the group
  8552. groupInstanceIdCreator,
  8553. // whether it's left, right or center col
  8554. pinned,
  8555. // we try to reuse old groups if we can, to allow gui to do animation
  8556. oldDisplayedGroups) {
  8557. var _this = this;
  8558. var result = [];
  8559. var previousRealPath;
  8560. var previousOriginalPath;
  8561. var oldColumnsMapped = this.mapOldGroupsById(oldDisplayedGroups);
  8562. // go through each column, then do a bottom up comparison to the previous column, and start
  8563. // to share groups if they converge at any point.
  8564. sortedVisibleColumns.forEach(function (currentColumn) {
  8565. var currentOriginalPath = _this.getOriginalPathForColumn(balancedColumnTree, currentColumn);
  8566. var currentRealPath = [];
  8567. var firstColumn = !previousOriginalPath;
  8568. for (var i = 0; i < currentOriginalPath.length; i++) {
  8569. if (firstColumn || currentOriginalPath[i] !== previousOriginalPath[i]) {
  8570. // new group needed
  8571. var newGroup = _this.createColumnGroup(currentOriginalPath[i], groupInstanceIdCreator, oldColumnsMapped, pinned);
  8572. currentRealPath[i] = newGroup;
  8573. // if top level, add to result, otherwise add to parent
  8574. if (i == 0) {
  8575. result.push(newGroup);
  8576. }
  8577. else {
  8578. currentRealPath[i - 1].addChild(newGroup);
  8579. }
  8580. }
  8581. else {
  8582. // reuse old group
  8583. currentRealPath[i] = previousRealPath[i];
  8584. }
  8585. }
  8586. var noColumnGroups = currentRealPath.length === 0;
  8587. if (noColumnGroups) {
  8588. // if we are not grouping, then the result of the above is an empty
  8589. // path (no groups), and we just add the column to the root list.
  8590. result.push(currentColumn);
  8591. }
  8592. else {
  8593. var leafGroup = _.last(currentRealPath);
  8594. leafGroup.addChild(currentColumn);
  8595. }
  8596. previousRealPath = currentRealPath;
  8597. previousOriginalPath = currentOriginalPath;
  8598. });
  8599. this.setupParentsIntoColumns(result, null);
  8600. return result;
  8601. };
  8602. DisplayedGroupCreator.prototype.createColumnGroup = function (originalGroup, groupInstanceIdCreator, oldColumnsMapped, pinned) {
  8603. var groupId = originalGroup.getGroupId();
  8604. var instanceId = groupInstanceIdCreator.getInstanceIdForKey(groupId);
  8605. var uniqueId = ColumnGroup.createUniqueId(groupId, instanceId);
  8606. var columnGroup = oldColumnsMapped[uniqueId];
  8607. // if the user is setting new colDefs, it is possible that the id's overlap, and we
  8608. // would have a false match from above. so we double check we are talking about the
  8609. // same original column group.
  8610. if (columnGroup && columnGroup.getOriginalColumnGroup() !== originalGroup) {
  8611. columnGroup = null;
  8612. }
  8613. if (_.exists(columnGroup)) {
  8614. // clean out the old column group here, as we will be adding children into it again
  8615. columnGroup.reset();
  8616. }
  8617. else {
  8618. columnGroup = new ColumnGroup(originalGroup, groupId, instanceId, pinned);
  8619. this.context.createBean(columnGroup);
  8620. }
  8621. return columnGroup;
  8622. };
  8623. // returns back a 2d map of ColumnGroup as follows: groupId -> instanceId -> ColumnGroup
  8624. DisplayedGroupCreator.prototype.mapOldGroupsById = function (displayedGroups) {
  8625. var result = {};
  8626. var recursive = function (columnsOrGroups) {
  8627. columnsOrGroups.forEach(function (columnOrGroup) {
  8628. if (columnOrGroup instanceof ColumnGroup) {
  8629. var columnGroup = columnOrGroup;
  8630. result[columnOrGroup.getUniqueId()] = columnGroup;
  8631. recursive(columnGroup.getChildren());
  8632. }
  8633. });
  8634. };
  8635. if (displayedGroups) {
  8636. recursive(displayedGroups);
  8637. }
  8638. return result;
  8639. };
  8640. DisplayedGroupCreator.prototype.setupParentsIntoColumns = function (columnsOrGroups, parent) {
  8641. var _this = this;
  8642. columnsOrGroups.forEach(function (columnsOrGroup) {
  8643. columnsOrGroup.setParent(parent);
  8644. if (columnsOrGroup instanceof ColumnGroup) {
  8645. var columnGroup = columnsOrGroup;
  8646. _this.setupParentsIntoColumns(columnGroup.getChildren(), columnGroup);
  8647. }
  8648. });
  8649. };
  8650. DisplayedGroupCreator.prototype.getOriginalPathForColumn = function (balancedColumnTree, column) {
  8651. var result = [];
  8652. var found = false;
  8653. var recursePath = function (balancedColumnTree, dept) {
  8654. for (var i = 0; i < balancedColumnTree.length; i++) {
  8655. // quit the search, so 'result' is kept with the found result
  8656. if (found) {
  8657. return;
  8658. }
  8659. var node = balancedColumnTree[i];
  8660. if (node instanceof OriginalColumnGroup) {
  8661. var nextNode = node;
  8662. recursePath(nextNode.getChildren(), dept + 1);
  8663. result[dept] = node;
  8664. }
  8665. else if (node === column) {
  8666. found = true;
  8667. }
  8668. }
  8669. };
  8670. recursePath(balancedColumnTree, 0);
  8671. // it's possible we didn't find a path. this happens if the column is generated
  8672. // by the grid (auto-group), in that the definition didn't come from the client. in this case,
  8673. // we create a fake original path.
  8674. if (found) {
  8675. return result;
  8676. }
  8677. console.warn('could not get path');
  8678. return null;
  8679. };
  8680. __decorate$7([
  8681. Autowired('columnUtils')
  8682. ], DisplayedGroupCreator.prototype, "columnUtils", void 0);
  8683. DisplayedGroupCreator = __decorate$7([
  8684. Bean('displayedGroupCreator')
  8685. ], DisplayedGroupCreator);
  8686. return DisplayedGroupCreator;
  8687. }(BeanStub));
  8688. /**
  8689. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  8690. * @version v23.2.1
  8691. * @link http://www.ag-grid.com/
  8692. * @license MIT
  8693. */
  8694. var __spreadArrays = (undefined && undefined.__spreadArrays) || function () {
  8695. for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
  8696. for (var r = Array(s), k = 0, i = 0; i < il; i++)
  8697. for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
  8698. r[k] = a[j];
  8699. return r;
  8700. };
  8701. /**
  8702. * These keys are used for validating properties supplied on a gridOptions object, and for code generation.
  8703. * If you change the properties on the gridOptions interface, you *must* update this file as well to be consistent.
  8704. */
  8705. var PropertyKeys = /** @class */ (function () {
  8706. function PropertyKeys() {
  8707. }
  8708. PropertyKeys.STRING_PROPERTIES = [
  8709. 'sortingOrder', 'rowClass', 'rowSelection', 'overlayLoadingTemplate',
  8710. 'overlayNoRowsTemplate', 'quickFilterText', 'rowModelType',
  8711. 'editType', 'domLayout', 'clipboardDeliminator', 'rowGroupPanelShow',
  8712. 'multiSortKey', 'pivotColumnGroupTotals', 'pivotRowTotals', 'pivotPanelShow'
  8713. ];
  8714. PropertyKeys.OBJECT_PROPERTIES = [
  8715. 'components', 'frameworkComponents', 'rowStyle', 'context', 'autoGroupColumnDef', 'groupColumnDef', 'localeText',
  8716. 'icons', 'datasource', 'serverSideDatasource', 'viewportDatasource', 'groupRowRendererParams', 'aggFuncs',
  8717. 'fullWidthCellRendererParams', 'defaultColGroupDef', 'defaultColDef', 'defaultExportParams', 'columnTypes',
  8718. 'rowClassRules', 'detailGridOptions', 'detailCellRendererParams', 'loadingCellRendererParams', 'loadingOverlayComponentParams',
  8719. 'noRowsOverlayComponentParams', 'popupParent', 'colResizeDefault', 'reduxStore', 'statusBar', 'sideBar'
  8720. ];
  8721. PropertyKeys.ARRAY_PROPERTIES = [
  8722. 'slaveGrids', 'alignedGrids', 'rowData', 'columnDefs', 'excelStyles', 'pinnedTopRowData', 'pinnedBottomRowData'
  8723. ];
  8724. PropertyKeys.NUMBER_PROPERTIES = [
  8725. 'rowHeight', 'detailRowHeight', 'rowBuffer', 'colWidth', 'headerHeight', 'groupHeaderHeight', 'floatingFiltersHeight',
  8726. 'pivotHeaderHeight', 'pivotGroupHeaderHeight', 'groupDefaultExpanded', 'minColWidth', 'maxColWidth', 'viewportRowModelPageSize',
  8727. 'viewportRowModelBufferSize', 'autoSizePadding', 'maxBlocksInCache', 'maxConcurrentDatasourceRequests', 'tooltipShowDelay',
  8728. 'cacheOverflowSize', 'paginationPageSize', 'cacheBlockSize', 'infiniteInitialRowCount', 'scrollbarWidth', 'paginationStartPage',
  8729. 'infiniteBlockSize', 'batchUpdateWaitMillis', 'asyncTransactionWaitMillis', 'blockLoadDebounceMillis', 'keepDetailRowsCount',
  8730. 'undoRedoCellEditingLimit', 'cellFlashDelay', 'cellFadeDelay'
  8731. ];
  8732. PropertyKeys.BOOLEAN_PROPERTIES = [
  8733. 'toolPanelSuppressRowGroups', 'toolPanelSuppressValues', 'toolPanelSuppressPivots', 'toolPanelSuppressPivotMode',
  8734. 'toolPanelSuppressSideButtons', 'toolPanelSuppressColumnFilter', 'toolPanelSuppressColumnSelectAll',
  8735. 'toolPanelSuppressColumnExpandAll', 'suppressMakeColumnVisibleAfterUnGroup', 'suppressRowClickSelection',
  8736. 'suppressCellSelection', 'suppressHorizontalScroll', 'alwaysShowVerticalScroll', 'debug', 'enableBrowserTooltips',
  8737. 'enableColResize', 'enableCellExpressions', 'enableSorting', 'enableServerSideSorting', 'enableFilter', 'enableServerSideFilter',
  8738. 'angularCompileRows', 'angularCompileFilters', 'angularCompileHeaders', 'groupSuppressAutoColumn', 'groupSelectsChildren',
  8739. 'groupIncludeFooter', 'groupIncludeTotalFooter', 'groupUseEntireRow', 'groupSuppressRow', 'groupSuppressBlankHeader',
  8740. 'forPrint', 'suppressMenuHide', 'rowDeselection', 'unSortIcon', 'suppressMultiSort', 'singleClickEdit', 'suppressLoadingOverlay',
  8741. 'suppressNoRowsOverlay', 'suppressAutoSize', 'skipHeaderOnAutoSize', 'suppressParentsInRowNodes', 'showToolPanel',
  8742. 'suppressColumnMoveAnimation', 'suppressMovableColumns', 'suppressFieldDotNotation', 'enableRangeSelection', 'enableRangeHandle',
  8743. 'enableFillHandle', 'suppressClearOnFillReduction', 'deltaSort', 'suppressTouch', 'suppressAsyncEvents', 'allowContextMenuWithControlKey',
  8744. 'suppressContextMenu', 'suppressMenuFilterPanel', 'suppressMenuMainPanel', 'suppressMenuColumnPanel', 'rememberGroupStateWhenNewData',
  8745. 'enableCellChangeFlash', 'suppressDragLeaveHidesColumns', 'suppressMiddleClickScrolls', 'suppressPreventDefaultOnMouseWheel',
  8746. 'suppressUseColIdForGroups', 'suppressCopyRowsToClipboard', 'copyHeadersToClipboard', 'pivotMode', 'suppressAggFuncInHeader',
  8747. 'suppressColumnVirtualisation', 'suppressAggAtRootLevel', 'suppressFocusAfterRefresh', 'functionsPassive', 'functionsReadOnly',
  8748. 'animateRows', 'groupSelectsFiltered', 'groupRemoveSingleChildren', 'groupRemoveLowestSingleChildren', 'enableRtl', 'suppressClickEdit',
  8749. 'rowDragManaged', 'suppressRowDrag', 'suppressMoveWhenRowDragging', 'enableMultiRowDragging', 'enableGroupEdit', 'embedFullWidthRows',
  8750. 'deprecatedEmbedFullWidthRows', 'suppressTabbing', 'suppressPaginationPanel', 'floatingFilter', 'groupHideOpenParents', 'groupMultiAutoColumn',
  8751. 'pagination', 'stopEditingWhenGridLosesFocus', 'paginationAutoPageSize', 'suppressScrollOnNewData', 'purgeClosedRowNodes', 'cacheQuickFilter',
  8752. 'deltaRowDataMode', 'ensureDomOrder', 'accentedSort', 'pivotTotals', 'suppressChangeDetection', 'valueCache', 'valueCacheNeverExpires',
  8753. 'aggregateOnlyChangedColumns', 'suppressAnimationFrame', 'suppressExcelExport', 'suppressCsvExport', 'treeData', 'masterDetail',
  8754. 'suppressMultiRangeSelection', 'enterMovesDownAfterEdit', 'enterMovesDown', 'suppressPropertyNamesCheck', 'rowMultiSelectWithClick',
  8755. 'contractColumnSelection', 'suppressEnterpriseResetOnNewColumns', 'enableOldSetFilterModel', 'suppressRowHoverHighlight', 'gridAutoHeight',
  8756. 'suppressRowTransform', 'suppressClipboardPaste', 'suppressLastEmptyLineOnPaste', 'serverSideSortingAlwaysResets', 'reactNext',
  8757. 'suppressSetColumnStateEvents', 'enableCharts', 'deltaColumnMode', 'suppressMaintainUnsortedOrder', 'enableCellTextSelection',
  8758. 'suppressBrowserResizeObserver', 'suppressMaxRenderedRowRestriction', 'excludeChildrenWhenTreeDataFiltering', 'tooltipMouseTrack',
  8759. 'keepDetailRows', 'paginateChildRows', 'preventDefaultOnContextMenu', 'undoRedoCellEditing', 'allowDragFromColumnsToolPanel',
  8760. 'immutableData', 'immutableColumns', 'pivotSuppressAutoColumn'
  8761. ];
  8762. /** You do not need to include event callbacks in this list, as they are generated automatically. */
  8763. PropertyKeys.FUNCTION_PROPERTIES = [
  8764. 'localeTextFunc', 'groupRowInnerRenderer', 'groupRowInnerRendererFramework', 'dateComponent', 'dateComponentFramework', 'groupRowRenderer',
  8765. 'groupRowRendererFramework', 'isExternalFilterPresent', 'getRowHeight', 'doesExternalFilterPass', 'getRowClass', 'getRowStyle',
  8766. 'getRowClassRules', 'traverseNode', 'getContextMenuItems', 'getMainMenuItems', 'processRowPostCreate', 'processCellForClipboard',
  8767. 'getNodeChildDetails', 'groupRowAggNodes', 'getRowNodeId', 'isFullWidthCell', 'fullWidthCellRenderer', 'fullWidthCellRendererFramework',
  8768. 'doesDataFlower', 'processSecondaryColDef', 'processSecondaryColGroupDef', 'getBusinessKeyForNode', 'sendToClipboard', 'navigateToNextCell',
  8769. 'tabToNextCell', 'getDetailRowData', 'processCellFromClipboard', 'getDocument', 'postProcessPopup', 'getChildCount', 'getDataPath',
  8770. 'loadingCellRenderer', 'loadingCellRendererFramework', 'loadingOverlayComponent', 'loadingOverlayComponentFramework', 'noRowsOverlayComponent',
  8771. 'noRowsOverlayComponentFramework', 'detailCellRenderer', 'detailCellRendererFramework', 'defaultGroupSortComparator', 'isRowMaster',
  8772. 'isRowSelectable', 'postSort', 'processHeaderForClipboard', 'paginationNumberFormatter', 'processDataFromClipboard', 'getServerSideGroupKey',
  8773. 'isServerSideGroup', 'suppressKeyboardEvent', 'createChartContainer', 'processChartOptions', 'getChartToolbarItems', 'fillOperation'
  8774. ];
  8775. PropertyKeys.ALL_PROPERTIES = __spreadArrays(PropertyKeys.ARRAY_PROPERTIES, PropertyKeys.OBJECT_PROPERTIES, PropertyKeys.STRING_PROPERTIES, PropertyKeys.NUMBER_PROPERTIES, PropertyKeys.FUNCTION_PROPERTIES, PropertyKeys.BOOLEAN_PROPERTIES);
  8776. /**
  8777. * Used when performing property checks. This avoids noise caused when using frameworks, which can add their own
  8778. * framework-specific properties to colDefs, gridOptions etc.
  8779. */
  8780. PropertyKeys.FRAMEWORK_PROPERTIES = [
  8781. '__ob__', '__metadata__', 'mappedColumnProperties', 'hasChildColumns', 'toColDef', 'createColDefFromGridColumn'
  8782. ];
  8783. return PropertyKeys;
  8784. }());
  8785. /**
  8786. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  8787. * @version v23.2.1
  8788. * @link http://www.ag-grid.com/
  8789. * @license MIT
  8790. */
  8791. var __spreadArrays$1 = (undefined && undefined.__spreadArrays) || function () {
  8792. for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
  8793. for (var r = Array(s), k = 0, i = 0; i < il; i++)
  8794. for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
  8795. r[k] = a[j];
  8796. return r;
  8797. };
  8798. var ColDefUtil = /** @class */ (function () {
  8799. function ColDefUtil() {
  8800. }
  8801. ColDefUtil.STRING_PROPERTIES = [
  8802. 'headerName',
  8803. 'columnGroupShow',
  8804. 'headerClass',
  8805. 'toolPanelClass',
  8806. 'headerValueGetter',
  8807. 'pivotKeys',
  8808. 'groupId',
  8809. 'colId',
  8810. 'sort',
  8811. 'field',
  8812. 'type',
  8813. 'tooltipComponent',
  8814. 'tooltipField',
  8815. 'headerTooltip',
  8816. 'cellClass',
  8817. 'showRowGroup',
  8818. 'template',
  8819. 'templateUrl',
  8820. 'filter',
  8821. 'aggFunc',
  8822. 'cellRenderer',
  8823. 'cellEditor',
  8824. 'pinned',
  8825. 'chartDataType'
  8826. ];
  8827. ColDefUtil.OBJECT_PROPERTIES = [
  8828. 'headerGroupComponent',
  8829. 'headerGroupComponentFramework',
  8830. 'headerGroupComponentParams',
  8831. 'cellStyle',
  8832. 'cellRendererParams',
  8833. 'cellEditorFramework',
  8834. 'cellEditorParams',
  8835. 'pinnedRowCellRendererFramework',
  8836. 'pinnedRowCellRendererParams',
  8837. 'filterFramework',
  8838. 'filterParams',
  8839. 'pivotValueColumn',
  8840. 'headerComponent',
  8841. 'headerComponentFramework',
  8842. 'headerComponentParams',
  8843. 'floatingFilterComponent',
  8844. 'floatingFilterComponentParams',
  8845. 'floatingFilterComponentFramework',
  8846. 'tooltipComponent',
  8847. 'tooltipComponentParams',
  8848. 'tooltipComponentFramework',
  8849. 'refData'
  8850. ];
  8851. ColDefUtil.ARRAY_PROPERTIES = [
  8852. 'children',
  8853. 'sortingOrder',
  8854. 'allowedAggFuncs',
  8855. 'menuTabs',
  8856. 'pivotTotalColumnIds',
  8857. 'cellClassRules',
  8858. 'icons'
  8859. ];
  8860. ColDefUtil.NUMBER_PROPERTIES = [
  8861. 'sortedAt',
  8862. 'flex',
  8863. 'width',
  8864. 'minWidth',
  8865. 'maxWidth',
  8866. 'rowGroupIndex',
  8867. 'pivotIndex'
  8868. ];
  8869. ColDefUtil.BOOLEAN_PROPERTIES = [
  8870. 'suppressCellFlash',
  8871. 'suppressColumnsToolPanel',
  8872. 'suppressFiltersToolPanel',
  8873. 'openByDefault',
  8874. 'marryChildren',
  8875. 'hide',
  8876. 'rowGroup',
  8877. 'pivot',
  8878. 'checkboxSelection',
  8879. 'headerCheckboxSelection',
  8880. 'headerCheckboxSelectionFilteredOnly',
  8881. 'suppressMenu',
  8882. 'suppressSorting',
  8883. 'suppressMovable',
  8884. 'suppressFilter',
  8885. 'lockPosition',
  8886. 'lockVisible',
  8887. 'lockPinned',
  8888. 'unSortIcon',
  8889. 'suppressSizeToFit',
  8890. 'suppressResize',
  8891. 'suppressAutoSize',
  8892. 'enableRowGroup',
  8893. 'enablePivot',
  8894. 'enableValue',
  8895. 'editable',
  8896. 'suppressPaste',
  8897. 'suppressNavigable',
  8898. 'enableCellChangeFlash',
  8899. 'rowDrag',
  8900. 'dndSource',
  8901. 'autoHeight',
  8902. 'sortable',
  8903. 'resizable',
  8904. 'singleClickEdit',
  8905. 'floatingFilter',
  8906. ];
  8907. ColDefUtil.FUNCTION_PROPERTIES = [
  8908. 'dndSourceOnRowDrag',
  8909. 'valueGetter',
  8910. 'valueSetter',
  8911. 'filterValueGetter',
  8912. 'keyCreator',
  8913. 'cellRenderer',
  8914. 'cellRendererFramework',
  8915. 'pinnedRowCellRenderer',
  8916. 'valueFormatter',
  8917. 'pinnedRowValueFormatter',
  8918. 'valueParser',
  8919. 'comparator',
  8920. 'equals',
  8921. 'pivotComparator',
  8922. 'suppressKeyboardEvent',
  8923. 'colSpan',
  8924. 'rowSpan',
  8925. 'getQuickFilterText',
  8926. 'newValueHandler',
  8927. 'onCellValueChanged',
  8928. 'onCellClicked',
  8929. 'onCellDoubleClicked',
  8930. 'onCellContextMenu',
  8931. 'rowDragText',
  8932. 'tooltip',
  8933. 'tooltipValueGetter',
  8934. 'tooltipComponent',
  8935. 'tooltipComponentFramework',
  8936. 'cellRendererSelector',
  8937. 'cellEditorSelector'
  8938. ];
  8939. ColDefUtil.ALL_PROPERTIES = __spreadArrays$1(ColDefUtil.ARRAY_PROPERTIES, ColDefUtil.OBJECT_PROPERTIES, ColDefUtil.STRING_PROPERTIES, ColDefUtil.NUMBER_PROPERTIES, ColDefUtil.FUNCTION_PROPERTIES, ColDefUtil.BOOLEAN_PROPERTIES);
  8940. // used when doing property checks - this causes noise when using frameworks which can add their own fw specific
  8941. // properties to colDefs, gridOptions etc
  8942. ColDefUtil.FRAMEWORK_PROPERTIES = ['__ob__', '__metadata__', 'mappedColumnProperties', 'hasChildColumns',
  8943. 'toColDef', 'createColDefFromGridColumn'];
  8944. return ColDefUtil;
  8945. }());
  8946. /**
  8947. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  8948. * @version v23.2.1
  8949. * @link http://www.ag-grid.com/
  8950. * @license MIT
  8951. */
  8952. var SideBarDefParser = /** @class */ (function () {
  8953. function SideBarDefParser() {
  8954. }
  8955. SideBarDefParser.parse = function (toParse) {
  8956. if (!toParse) {
  8957. return null;
  8958. }
  8959. if (toParse === true) {
  8960. return {
  8961. toolPanels: [
  8962. SideBarDefParser.DEFAULT_COLUMN_COMP,
  8963. SideBarDefParser.DEFAULT_FILTER_COMP,
  8964. ],
  8965. defaultToolPanel: 'columns'
  8966. };
  8967. }
  8968. if (typeof toParse === 'string') {
  8969. return SideBarDefParser.parse([toParse]);
  8970. }
  8971. if (Array.isArray(toParse)) {
  8972. var comps_1 = [];
  8973. toParse.forEach(function (key) {
  8974. var lookupResult = SideBarDefParser.DEFAULT_BY_KEY[key];
  8975. if (!lookupResult) {
  8976. console.warn("ag-grid: the key " + key + " is not a valid key for specifying a tool panel, valid keys are: " + Object.keys(SideBarDefParser.DEFAULT_BY_KEY).join(','));
  8977. return;
  8978. }
  8979. comps_1.push(lookupResult);
  8980. });
  8981. if (comps_1.length === 0) {
  8982. return null;
  8983. }
  8984. return {
  8985. toolPanels: comps_1,
  8986. defaultToolPanel: comps_1[0].id
  8987. };
  8988. }
  8989. var result = {
  8990. toolPanels: SideBarDefParser.parseComponents(toParse.toolPanels),
  8991. defaultToolPanel: toParse.defaultToolPanel,
  8992. hiddenByDefault: toParse.hiddenByDefault,
  8993. position: toParse.position
  8994. };
  8995. return result;
  8996. };
  8997. SideBarDefParser.parseComponents = function (from) {
  8998. var result = [];
  8999. from.forEach(function (it) {
  9000. var toAdd = null;
  9001. if (typeof it === 'string') {
  9002. var lookupResult = SideBarDefParser.DEFAULT_BY_KEY[it];
  9003. if (!lookupResult) {
  9004. console.warn("ag-grid: the key " + it + " is not a valid key for specifying a tool panel, valid keys are: " + Object.keys(SideBarDefParser.DEFAULT_BY_KEY).join(','));
  9005. return;
  9006. }
  9007. toAdd = lookupResult;
  9008. }
  9009. else {
  9010. toAdd = it;
  9011. }
  9012. result.push(toAdd);
  9013. });
  9014. return result;
  9015. };
  9016. SideBarDefParser.DEFAULT_COLUMN_COMP = {
  9017. id: 'columns',
  9018. labelDefault: 'Columns',
  9019. labelKey: 'columns',
  9020. iconKey: 'columns',
  9021. toolPanel: 'agColumnsToolPanel',
  9022. };
  9023. SideBarDefParser.DEFAULT_FILTER_COMP = {
  9024. id: 'filters',
  9025. labelDefault: 'Filters',
  9026. labelKey: 'filters',
  9027. iconKey: 'filter',
  9028. toolPanel: 'agFiltersToolPanel',
  9029. };
  9030. SideBarDefParser.DEFAULT_BY_KEY = {
  9031. columns: SideBarDefParser.DEFAULT_COLUMN_COMP,
  9032. filters: SideBarDefParser.DEFAULT_FILTER_COMP
  9033. };
  9034. return SideBarDefParser;
  9035. }());
  9036. /**
  9037. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  9038. * @version v23.2.1
  9039. * @link http://www.ag-grid.com/
  9040. * @license MIT
  9041. */
  9042. var __decorate$8 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  9043. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  9044. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  9045. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  9046. return c > 3 && r && Object.defineProperty(target, key, r), r;
  9047. };
  9048. var __param$3 = (undefined && undefined.__param) || function (paramIndex, decorator) {
  9049. return function (target, key) { decorator(target, key, paramIndex); }
  9050. };
  9051. var __spreadArrays$2 = (undefined && undefined.__spreadArrays) || function () {
  9052. for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
  9053. for (var r = Array(s), k = 0, i = 0; i < il; i++)
  9054. for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
  9055. r[k] = a[j];
  9056. return r;
  9057. };
  9058. var DEFAULT_ROW_HEIGHT = 25;
  9059. var DEFAULT_DETAIL_ROW_HEIGHT = 300;
  9060. var DEFAULT_VIEWPORT_ROW_MODEL_PAGE_SIZE = 5;
  9061. var DEFAULT_VIEWPORT_ROW_MODEL_BUFFER_SIZE = 5;
  9062. var DEFAULT_KEEP_DETAIL_ROW_COUNT = 10;
  9063. function isTrue(value) {
  9064. return value === true || value === 'true';
  9065. }
  9066. function zeroOrGreater(value, defaultValue) {
  9067. if (value >= 0) {
  9068. return value;
  9069. }
  9070. // zero gets returned if number is missing or the wrong type
  9071. return defaultValue;
  9072. }
  9073. function oneOrGreater(value, defaultValue) {
  9074. if (value > 0) {
  9075. return value;
  9076. }
  9077. // zero gets returned if number is missing or the wrong type
  9078. return defaultValue;
  9079. }
  9080. var GridOptionsWrapper = /** @class */ (function () {
  9081. function GridOptionsWrapper() {
  9082. this.propertyEventService = new EventService();
  9083. this.domDataKey = '__AG_' + Math.random().toString();
  9084. this.layoutElements = [];
  9085. }
  9086. GridOptionsWrapper_1 = GridOptionsWrapper;
  9087. GridOptionsWrapper.prototype.agWire = function (gridApi, columnApi) {
  9088. this.gridOptions.api = gridApi;
  9089. this.gridOptions.columnApi = columnApi;
  9090. this.checkForDeprecated();
  9091. this.checkForViolations();
  9092. };
  9093. GridOptionsWrapper.prototype.destroy = function () {
  9094. // need to remove these, as we don't own the lifecycle of the gridOptions, we need to
  9095. // remove the references in case the user keeps the grid options, we want the rest
  9096. // of the grid to be picked up by the garbage collector
  9097. this.gridOptions.api = null;
  9098. this.gridOptions.columnApi = null;
  9099. this.removeEventListener(GridOptionsWrapper_1.PROP_DOM_LAYOUT, this.updateLayoutClassesListener);
  9100. };
  9101. GridOptionsWrapper.prototype.init = function () {
  9102. var _this = this;
  9103. if (!(this.gridOptions.suppressPropertyNamesCheck === true)) {
  9104. this.checkGridOptionsProperties();
  9105. this.checkColumnDefProperties();
  9106. }
  9107. var async = this.useAsyncEvents();
  9108. this.eventService.addGlobalListener(this.globalEventHandler.bind(this), async);
  9109. if (this.isGroupSelectsChildren() && this.isSuppressParentsInRowNodes()) {
  9110. console.warn("ag-Grid: 'groupSelectsChildren' does not work with 'suppressParentsInRowNodes', this selection method needs the part in rowNode to work");
  9111. }
  9112. if (this.isGroupSelectsChildren()) {
  9113. if (!this.isRowSelectionMulti()) {
  9114. console.warn("ag-Grid: rowSelection must be 'multiple' for groupSelectsChildren to make sense");
  9115. }
  9116. if (this.isRowModelServerSide()) {
  9117. console.warn('ag-Grid: group selects children is NOT support for Server Side Row Model. ' +
  9118. 'This is because the rows are lazy loaded, so selecting a group is not possible as' +
  9119. 'the grid has no way of knowing what the children are.');
  9120. }
  9121. }
  9122. if (this.isGroupRemoveSingleChildren() && this.isGroupHideOpenParents()) {
  9123. console.warn("ag-Grid: groupRemoveSingleChildren and groupHideOpenParents do not work with each other, you need to pick one. And don't ask us how to us these together on our support forum either you will get the same answer!");
  9124. }
  9125. if (this.isRowModelServerSide()) {
  9126. var msg = function (prop) { return "ag-Grid: '" + prop + "' is not supported on the Server-Side Row Model"; };
  9127. if (_.exists(this.gridOptions.groupDefaultExpanded)) {
  9128. console.warn(msg('groupDefaultExpanded'));
  9129. }
  9130. if (_.exists(this.gridOptions.groupDefaultExpanded)) {
  9131. console.warn(msg('groupIncludeFooter'));
  9132. }
  9133. if (_.exists(this.gridOptions.groupDefaultExpanded)) {
  9134. console.warn(msg('groupIncludeTotalFooter'));
  9135. }
  9136. }
  9137. if (this.isEnableRangeSelection()) {
  9138. ModuleRegistry.assertRegistered(exports.ModuleNames.RangeSelectionModule, 'enableRangeSelection');
  9139. }
  9140. if (!this.isEnableRangeSelection() && (this.isEnableRangeHandle() || this.isEnableFillHandle())) {
  9141. console.warn("ag-Grid: 'enableRangeHandle' and 'enableFillHandle' will not work unless 'enableRangeSelection' is set to true");
  9142. }
  9143. var warnOfDeprecaredIcon = function (name) {
  9144. if (_this.gridOptions.icons && _this.gridOptions.icons[name]) {
  9145. console.warn("gridOptions.icons." + name + " is no longer supported. For information on how to style checkboxes and radio buttons, see https://www.ag-grid.com/javascript-grid-icons/");
  9146. }
  9147. };
  9148. warnOfDeprecaredIcon('radioButtonOff');
  9149. warnOfDeprecaredIcon('radioButtonOn');
  9150. warnOfDeprecaredIcon('checkboxChecked');
  9151. warnOfDeprecaredIcon('checkboxUnchecked');
  9152. warnOfDeprecaredIcon('checkboxIndeterminate');
  9153. this.updateLayoutClassesListener = this.updateLayoutClasses.bind(this);
  9154. this.addEventListener(GridOptionsWrapper_1.PROP_DOM_LAYOUT, this.updateLayoutClassesListener);
  9155. };
  9156. GridOptionsWrapper.prototype.checkColumnDefProperties = function () {
  9157. var _this = this;
  9158. if (this.gridOptions.columnDefs == null) {
  9159. return;
  9160. }
  9161. this.gridOptions.columnDefs.forEach(function (colDef) {
  9162. var userProperties = Object.getOwnPropertyNames(colDef);
  9163. var validProperties = __spreadArrays$2(ColDefUtil.ALL_PROPERTIES, ColDefUtil.FRAMEWORK_PROPERTIES);
  9164. _this.checkProperties(userProperties, validProperties, validProperties, 'colDef', 'https://www.ag-grid.com/javascript-grid-column-properties/');
  9165. });
  9166. };
  9167. GridOptionsWrapper.prototype.checkGridOptionsProperties = function () {
  9168. var userProperties = Object.getOwnPropertyNames(this.gridOptions);
  9169. var validProperties = __spreadArrays$2(PropertyKeys.ALL_PROPERTIES, PropertyKeys.FRAMEWORK_PROPERTIES, _.values(Events).map(function (event) { return ComponentUtil.getCallbackForEvent(event); }));
  9170. var validPropertiesAndExceptions = __spreadArrays$2(validProperties, ['api', 'columnApi']);
  9171. this.checkProperties(userProperties, validPropertiesAndExceptions, validProperties, 'gridOptions', 'https://www.ag-grid.com/javascript-grid-properties/');
  9172. };
  9173. GridOptionsWrapper.prototype.checkProperties = function (userProperties, validPropertiesAndExceptions, validProperties, containerName, docsUrl) {
  9174. var invalidProperties = _.fuzzyCheckStrings(userProperties, validPropertiesAndExceptions, validProperties);
  9175. _.iterateObject(invalidProperties, function (key, value) {
  9176. console.warn("ag-grid: invalid " + containerName + " property '" + key + "' did you mean any of these: " + value.slice(0, 8).join(", "));
  9177. });
  9178. if (Object.keys(invalidProperties).length > 0) {
  9179. console.warn("ag-grid: to see all the valid " + containerName + " properties please check: " + docsUrl);
  9180. }
  9181. };
  9182. // returns the dom data, or undefined if not found
  9183. GridOptionsWrapper.prototype.getDomData = function (element, key) {
  9184. var domData = element[this.domDataKey];
  9185. return domData ? domData[key] : undefined;
  9186. };
  9187. GridOptionsWrapper.prototype.setDomData = function (element, key, value) {
  9188. var domData = element[this.domDataKey];
  9189. if (_.missing(domData)) {
  9190. domData = {};
  9191. element[this.domDataKey] = domData;
  9192. }
  9193. domData[key] = value;
  9194. };
  9195. GridOptionsWrapper.prototype.isRowSelection = function () {
  9196. return this.gridOptions.rowSelection === 'single' || this.gridOptions.rowSelection === 'multiple';
  9197. };
  9198. GridOptionsWrapper.prototype.isRowDeselection = function () {
  9199. return isTrue(this.gridOptions.rowDeselection);
  9200. };
  9201. GridOptionsWrapper.prototype.isRowSelectionMulti = function () {
  9202. return this.gridOptions.rowSelection === 'multiple';
  9203. };
  9204. GridOptionsWrapper.prototype.isRowMultiSelectWithClick = function () {
  9205. return isTrue(this.gridOptions.rowMultiSelectWithClick);
  9206. };
  9207. GridOptionsWrapper.prototype.getContext = function () {
  9208. return this.gridOptions.context;
  9209. };
  9210. GridOptionsWrapper.prototype.isPivotMode = function () {
  9211. return isTrue(this.gridOptions.pivotMode);
  9212. };
  9213. GridOptionsWrapper.prototype.isPivotTotals = function () {
  9214. return isTrue(this.gridOptions.pivotTotals);
  9215. };
  9216. GridOptionsWrapper.prototype.getPivotColumnGroupTotals = function () {
  9217. return this.gridOptions.pivotColumnGroupTotals;
  9218. };
  9219. GridOptionsWrapper.prototype.getPivotRowTotals = function () {
  9220. return this.gridOptions.pivotRowTotals;
  9221. };
  9222. GridOptionsWrapper.prototype.isRowModelInfinite = function () {
  9223. return this.gridOptions.rowModelType === Constants.ROW_MODEL_TYPE_INFINITE;
  9224. };
  9225. GridOptionsWrapper.prototype.isRowModelViewport = function () {
  9226. return this.gridOptions.rowModelType === Constants.ROW_MODEL_TYPE_VIEWPORT;
  9227. };
  9228. GridOptionsWrapper.prototype.isRowModelServerSide = function () {
  9229. return this.gridOptions.rowModelType === Constants.ROW_MODEL_TYPE_SERVER_SIDE;
  9230. };
  9231. GridOptionsWrapper.prototype.isRowModelDefault = function () {
  9232. return (_.missing(this.gridOptions.rowModelType) ||
  9233. this.gridOptions.rowModelType === Constants.ROW_MODEL_TYPE_CLIENT_SIDE ||
  9234. this.gridOptions.rowModelType === Constants.DEPRECATED_ROW_MODEL_TYPE_NORMAL);
  9235. };
  9236. GridOptionsWrapper.prototype.isFullRowEdit = function () {
  9237. return this.gridOptions.editType === 'fullRow';
  9238. };
  9239. GridOptionsWrapper.prototype.isSuppressFocusAfterRefresh = function () {
  9240. return isTrue(this.gridOptions.suppressFocusAfterRefresh);
  9241. };
  9242. GridOptionsWrapper.prototype.isSuppressBrowserResizeObserver = function () {
  9243. return isTrue(this.gridOptions.suppressBrowserResizeObserver);
  9244. };
  9245. GridOptionsWrapper.prototype.isSuppressMaintainUnsortedOrder = function () {
  9246. return isTrue(this.gridOptions.suppressMaintainUnsortedOrder);
  9247. };
  9248. GridOptionsWrapper.prototype.isSuppressClearOnFillReduction = function () {
  9249. return isTrue(this.gridOptions.suppressClearOnFillReduction);
  9250. };
  9251. GridOptionsWrapper.prototype.isShowToolPanel = function () {
  9252. return isTrue(this.gridOptions.sideBar && Array.isArray(this.getSideBar().toolPanels));
  9253. };
  9254. GridOptionsWrapper.prototype.getSideBar = function () {
  9255. return this.gridOptions.sideBar;
  9256. };
  9257. GridOptionsWrapper.prototype.isSuppressTouch = function () {
  9258. return isTrue(this.gridOptions.suppressTouch);
  9259. };
  9260. GridOptionsWrapper.prototype.isSuppressRowTransform = function () {
  9261. return isTrue(this.gridOptions.suppressRowTransform);
  9262. };
  9263. GridOptionsWrapper.prototype.isSuppressSetColumnStateEvents = function () {
  9264. return isTrue(this.gridOptions.suppressSetColumnStateEvents);
  9265. };
  9266. GridOptionsWrapper.prototype.isAllowDragFromColumnsToolPanel = function () {
  9267. return isTrue(this.gridOptions.allowDragFromColumnsToolPanel);
  9268. };
  9269. GridOptionsWrapper.prototype.useAsyncEvents = function () {
  9270. return !isTrue(this.gridOptions.suppressAsyncEvents);
  9271. };
  9272. GridOptionsWrapper.prototype.isEnableCellChangeFlash = function () {
  9273. return isTrue(this.gridOptions.enableCellChangeFlash);
  9274. };
  9275. GridOptionsWrapper.prototype.getCellFlashDelay = function () {
  9276. return this.gridOptions.cellFlashDelay || 500;
  9277. };
  9278. GridOptionsWrapper.prototype.getCellFadeDelay = function () {
  9279. return this.gridOptions.cellFadeDelay || 1000;
  9280. };
  9281. GridOptionsWrapper.prototype.isGroupSelectsChildren = function () {
  9282. var result = isTrue(this.gridOptions.groupSelectsChildren);
  9283. if (result && this.isTreeData()) {
  9284. console.warn('ag-Grid: groupSelectsChildren does not work with tree data');
  9285. return false;
  9286. }
  9287. return result;
  9288. };
  9289. GridOptionsWrapper.prototype.isSuppressRowHoverHighlight = function () {
  9290. return isTrue(this.gridOptions.suppressRowHoverHighlight);
  9291. };
  9292. GridOptionsWrapper.prototype.isGroupSelectsFiltered = function () {
  9293. return isTrue(this.gridOptions.groupSelectsFiltered);
  9294. };
  9295. GridOptionsWrapper.prototype.isGroupHideOpenParents = function () {
  9296. return isTrue(this.gridOptions.groupHideOpenParents);
  9297. };
  9298. // if we are doing hideOpenParents, then we always have groupMultiAutoColumn, otherwise hideOpenParents would not work
  9299. GridOptionsWrapper.prototype.isGroupMultiAutoColumn = function () {
  9300. return isTrue(this.gridOptions.groupMultiAutoColumn) || isTrue(this.gridOptions.groupHideOpenParents);
  9301. };
  9302. GridOptionsWrapper.prototype.isGroupRemoveSingleChildren = function () {
  9303. return isTrue(this.gridOptions.groupRemoveSingleChildren);
  9304. };
  9305. GridOptionsWrapper.prototype.isGroupRemoveLowestSingleChildren = function () {
  9306. return isTrue(this.gridOptions.groupRemoveLowestSingleChildren);
  9307. };
  9308. GridOptionsWrapper.prototype.isGroupIncludeFooter = function () {
  9309. return isTrue(this.gridOptions.groupIncludeFooter);
  9310. };
  9311. GridOptionsWrapper.prototype.isGroupIncludeTotalFooter = function () {
  9312. return isTrue(this.gridOptions.groupIncludeTotalFooter);
  9313. };
  9314. GridOptionsWrapper.prototype.isGroupSuppressBlankHeader = function () {
  9315. return isTrue(this.gridOptions.groupSuppressBlankHeader);
  9316. };
  9317. GridOptionsWrapper.prototype.isSuppressRowClickSelection = function () {
  9318. return isTrue(this.gridOptions.suppressRowClickSelection);
  9319. };
  9320. GridOptionsWrapper.prototype.isSuppressCellSelection = function () {
  9321. return isTrue(this.gridOptions.suppressCellSelection);
  9322. };
  9323. GridOptionsWrapper.prototype.isSuppressMultiSort = function () {
  9324. return isTrue(this.gridOptions.suppressMultiSort);
  9325. };
  9326. GridOptionsWrapper.prototype.isMultiSortKeyCtrl = function () {
  9327. return this.gridOptions.multiSortKey === 'ctrl';
  9328. };
  9329. GridOptionsWrapper.prototype.isGroupSuppressAutoColumn = function () {
  9330. return isTrue(this.gridOptions.groupSuppressAutoColumn);
  9331. };
  9332. GridOptionsWrapper.prototype.isPivotSuppressAutoColumn = function () {
  9333. return isTrue(this.gridOptions.pivotSuppressAutoColumn);
  9334. };
  9335. GridOptionsWrapper.prototype.isSuppressDragLeaveHidesColumns = function () {
  9336. return isTrue(this.gridOptions.suppressDragLeaveHidesColumns);
  9337. };
  9338. GridOptionsWrapper.prototype.isSuppressScrollOnNewData = function () {
  9339. return isTrue(this.gridOptions.suppressScrollOnNewData);
  9340. };
  9341. GridOptionsWrapper.prototype.isRowDragManaged = function () {
  9342. return isTrue(this.gridOptions.rowDragManaged);
  9343. };
  9344. GridOptionsWrapper.prototype.isSuppressRowDrag = function () {
  9345. return isTrue(this.gridOptions.suppressRowDrag);
  9346. };
  9347. GridOptionsWrapper.prototype.isSuppressMoveWhenRowDragging = function () {
  9348. return isTrue(this.gridOptions.suppressMoveWhenRowDragging);
  9349. };
  9350. GridOptionsWrapper.prototype.isEnableMultiRowDragging = function () {
  9351. return isTrue(this.gridOptions.enableMultiRowDragging);
  9352. };
  9353. // returns either 'print', 'autoHeight' or 'normal' (normal is the default)
  9354. GridOptionsWrapper.prototype.getDomLayout = function () {
  9355. var domLayout = this.gridOptions.domLayout || Constants.DOM_LAYOUT_NORMAL;
  9356. var validLayouts = [
  9357. Constants.DOM_LAYOUT_PRINT,
  9358. Constants.DOM_LAYOUT_AUTO_HEIGHT,
  9359. Constants.DOM_LAYOUT_NORMAL
  9360. ];
  9361. if (validLayouts.indexOf(domLayout) === -1) {
  9362. _.doOnce(function () {
  9363. return console.warn("ag-Grid: " + domLayout + " is not valid for DOM Layout, valid values are " + Constants.DOM_LAYOUT_NORMAL + ", " + Constants.DOM_LAYOUT_AUTO_HEIGHT + " and " + Constants.DOM_LAYOUT_PRINT);
  9364. }, 'warn about dom layout values');
  9365. return Constants.DOM_LAYOUT_NORMAL;
  9366. }
  9367. return domLayout;
  9368. };
  9369. GridOptionsWrapper.prototype.isSuppressHorizontalScroll = function () {
  9370. return isTrue(this.gridOptions.suppressHorizontalScroll);
  9371. };
  9372. GridOptionsWrapper.prototype.isSuppressMaxRenderedRowRestriction = function () {
  9373. return isTrue(this.gridOptions.suppressMaxRenderedRowRestriction);
  9374. };
  9375. GridOptionsWrapper.prototype.isExcludeChildrenWhenTreeDataFiltering = function () {
  9376. return isTrue(this.gridOptions.excludeChildrenWhenTreeDataFiltering);
  9377. };
  9378. GridOptionsWrapper.prototype.isAlwaysShowVerticalScroll = function () {
  9379. return isTrue(this.gridOptions.alwaysShowVerticalScroll);
  9380. };
  9381. GridOptionsWrapper.prototype.isSuppressLoadingOverlay = function () {
  9382. return isTrue(this.gridOptions.suppressLoadingOverlay);
  9383. };
  9384. GridOptionsWrapper.prototype.isSuppressNoRowsOverlay = function () {
  9385. return isTrue(this.gridOptions.suppressNoRowsOverlay);
  9386. };
  9387. GridOptionsWrapper.prototype.isSuppressFieldDotNotation = function () {
  9388. return isTrue(this.gridOptions.suppressFieldDotNotation);
  9389. };
  9390. GridOptionsWrapper.prototype.getPinnedTopRowData = function () {
  9391. return this.gridOptions.pinnedTopRowData;
  9392. };
  9393. GridOptionsWrapper.prototype.getPinnedBottomRowData = function () {
  9394. return this.gridOptions.pinnedBottomRowData;
  9395. };
  9396. GridOptionsWrapper.prototype.isFunctionsPassive = function () {
  9397. return isTrue(this.gridOptions.functionsPassive);
  9398. };
  9399. GridOptionsWrapper.prototype.isSuppressTabbing = function () {
  9400. return isTrue(this.gridOptions.suppressTabbing);
  9401. };
  9402. GridOptionsWrapper.prototype.isSuppressChangeDetection = function () {
  9403. return isTrue(this.gridOptions.suppressChangeDetection);
  9404. };
  9405. GridOptionsWrapper.prototype.isSuppressAnimationFrame = function () {
  9406. return isTrue(this.gridOptions.suppressAnimationFrame);
  9407. };
  9408. GridOptionsWrapper.prototype.getQuickFilterText = function () {
  9409. return this.gridOptions.quickFilterText;
  9410. };
  9411. GridOptionsWrapper.prototype.isCacheQuickFilter = function () {
  9412. return isTrue(this.gridOptions.cacheQuickFilter);
  9413. };
  9414. GridOptionsWrapper.prototype.isUnSortIcon = function () {
  9415. return isTrue(this.gridOptions.unSortIcon);
  9416. };
  9417. GridOptionsWrapper.prototype.isSuppressMenuHide = function () {
  9418. return isTrue(this.gridOptions.suppressMenuHide);
  9419. };
  9420. GridOptionsWrapper.prototype.isEnterMovesDownAfterEdit = function () {
  9421. return isTrue(this.gridOptions.enterMovesDownAfterEdit);
  9422. };
  9423. GridOptionsWrapper.prototype.isEnterMovesDown = function () {
  9424. return isTrue(this.gridOptions.enterMovesDown);
  9425. };
  9426. GridOptionsWrapper.prototype.isUndoRedoCellEditing = function () {
  9427. return isTrue(this.gridOptions.undoRedoCellEditing);
  9428. };
  9429. GridOptionsWrapper.prototype.getUndoRedoCellEditingLimit = function () {
  9430. return this.gridOptions.undoRedoCellEditingLimit;
  9431. };
  9432. GridOptionsWrapper.prototype.getRowStyle = function () {
  9433. return this.gridOptions.rowStyle;
  9434. };
  9435. GridOptionsWrapper.prototype.getRowClass = function () {
  9436. return this.gridOptions.rowClass;
  9437. };
  9438. GridOptionsWrapper.prototype.getRowStyleFunc = function () {
  9439. return this.gridOptions.getRowStyle;
  9440. };
  9441. GridOptionsWrapper.prototype.getRowClassFunc = function () {
  9442. return this.gridOptions.getRowClass;
  9443. };
  9444. GridOptionsWrapper.prototype.rowClassRules = function () {
  9445. return this.gridOptions.rowClassRules;
  9446. };
  9447. GridOptionsWrapper.prototype.getCreateChartContainerFunc = function () {
  9448. return this.gridOptions.createChartContainer;
  9449. };
  9450. GridOptionsWrapper.prototype.getPopupParent = function () {
  9451. return this.gridOptions.popupParent;
  9452. };
  9453. GridOptionsWrapper.prototype.getBlockLoadDebounceMillis = function () {
  9454. return this.gridOptions.blockLoadDebounceMillis;
  9455. };
  9456. GridOptionsWrapper.prototype.getPostProcessPopupFunc = function () {
  9457. return this.gridOptions.postProcessPopup;
  9458. };
  9459. GridOptionsWrapper.prototype.getDoesDataFlowerFunc = function () {
  9460. return this.gridOptions.doesDataFlower;
  9461. };
  9462. GridOptionsWrapper.prototype.getPaginationNumberFormatterFunc = function () {
  9463. return this.gridOptions.paginationNumberFormatter;
  9464. };
  9465. GridOptionsWrapper.prototype.getChildCountFunc = function () {
  9466. return this.gridOptions.getChildCount;
  9467. };
  9468. GridOptionsWrapper.prototype.getDefaultGroupSortComparator = function () {
  9469. return this.gridOptions.defaultGroupSortComparator;
  9470. };
  9471. GridOptionsWrapper.prototype.getIsFullWidthCellFunc = function () {
  9472. return this.gridOptions.isFullWidthCell;
  9473. };
  9474. GridOptionsWrapper.prototype.getFullWidthCellRendererParams = function () {
  9475. return this.gridOptions.fullWidthCellRendererParams;
  9476. };
  9477. GridOptionsWrapper.prototype.isEmbedFullWidthRows = function () {
  9478. return isTrue(this.gridOptions.embedFullWidthRows) || isTrue(this.gridOptions.deprecatedEmbedFullWidthRows);
  9479. };
  9480. GridOptionsWrapper.prototype.getSuppressKeyboardEventFunc = function () {
  9481. return this.gridOptions.suppressKeyboardEvent;
  9482. };
  9483. GridOptionsWrapper.prototype.getBusinessKeyForNodeFunc = function () {
  9484. return this.gridOptions.getBusinessKeyForNode;
  9485. };
  9486. GridOptionsWrapper.prototype.getApi = function () {
  9487. return this.gridOptions.api;
  9488. };
  9489. GridOptionsWrapper.prototype.getColumnApi = function () {
  9490. return this.gridOptions.columnApi;
  9491. };
  9492. GridOptionsWrapper.prototype.isImmutableData = function () {
  9493. return isTrue(this.gridOptions.immutableData);
  9494. };
  9495. GridOptionsWrapper.prototype.isImmutableColumns = function () {
  9496. return isTrue(this.gridOptions.immutableColumns);
  9497. };
  9498. GridOptionsWrapper.prototype.isEnsureDomOrder = function () {
  9499. return isTrue(this.gridOptions.ensureDomOrder);
  9500. };
  9501. GridOptionsWrapper.prototype.isEnableCharts = function () {
  9502. if (isTrue(this.gridOptions.enableCharts)) {
  9503. return ModuleRegistry.assertRegistered(exports.ModuleNames.GridChartsModule, 'enableCharts');
  9504. }
  9505. return false;
  9506. };
  9507. GridOptionsWrapper.prototype.getColResizeDefault = function () {
  9508. return this.gridOptions.colResizeDefault;
  9509. };
  9510. GridOptionsWrapper.prototype.isSingleClickEdit = function () {
  9511. return isTrue(this.gridOptions.singleClickEdit);
  9512. };
  9513. GridOptionsWrapper.prototype.isSuppressClickEdit = function () {
  9514. return isTrue(this.gridOptions.suppressClickEdit);
  9515. };
  9516. GridOptionsWrapper.prototype.isStopEditingWhenGridLosesFocus = function () {
  9517. return isTrue(this.gridOptions.stopEditingWhenGridLosesFocus);
  9518. };
  9519. GridOptionsWrapper.prototype.getGroupDefaultExpanded = function () {
  9520. return this.gridOptions.groupDefaultExpanded;
  9521. };
  9522. GridOptionsWrapper.prototype.getMaxConcurrentDatasourceRequests = function () {
  9523. return this.gridOptions.maxConcurrentDatasourceRequests;
  9524. };
  9525. GridOptionsWrapper.prototype.getMaxBlocksInCache = function () {
  9526. return this.gridOptions.maxBlocksInCache;
  9527. };
  9528. GridOptionsWrapper.prototype.getCacheOverflowSize = function () {
  9529. return this.gridOptions.cacheOverflowSize;
  9530. };
  9531. GridOptionsWrapper.prototype.getPaginationPageSize = function () {
  9532. return this.gridOptions.paginationPageSize;
  9533. };
  9534. GridOptionsWrapper.prototype.isPaginateChildRows = function () {
  9535. // if using groupSuppressRow, means we are not showing parent rows,
  9536. // so we always paginate on the child rows here as there are no parent rows
  9537. var shouldPaginate = this.isGroupSuppressRow() || this.isGroupRemoveSingleChildren() || this.isGroupRemoveLowestSingleChildren();
  9538. if (shouldPaginate) {
  9539. return true;
  9540. }
  9541. return isTrue(this.gridOptions.paginateChildRows);
  9542. };
  9543. GridOptionsWrapper.prototype.getCacheBlockSize = function () {
  9544. return this.gridOptions.cacheBlockSize;
  9545. };
  9546. GridOptionsWrapper.prototype.getInfiniteInitialRowCount = function () {
  9547. return this.gridOptions.infiniteInitialRowCount;
  9548. };
  9549. GridOptionsWrapper.prototype.isPurgeClosedRowNodes = function () {
  9550. return isTrue(this.gridOptions.purgeClosedRowNodes);
  9551. };
  9552. GridOptionsWrapper.prototype.isSuppressPaginationPanel = function () {
  9553. return isTrue(this.gridOptions.suppressPaginationPanel);
  9554. };
  9555. GridOptionsWrapper.prototype.getRowData = function () {
  9556. return this.gridOptions.rowData;
  9557. };
  9558. // this property is different - we never allow groupUseEntireRow if in pivot mode,
  9559. // as otherwise we don't see the pivot values.
  9560. GridOptionsWrapper.prototype.isGroupUseEntireRow = function (pivotMode) {
  9561. return pivotMode ? false : isTrue(this.gridOptions.groupUseEntireRow);
  9562. };
  9563. GridOptionsWrapper.prototype.isEnableRtl = function () {
  9564. return isTrue(this.gridOptions.enableRtl);
  9565. };
  9566. GridOptionsWrapper.prototype.getAutoGroupColumnDef = function () {
  9567. return this.gridOptions.autoGroupColumnDef;
  9568. };
  9569. GridOptionsWrapper.prototype.isGroupSuppressRow = function () {
  9570. return isTrue(this.gridOptions.groupSuppressRow);
  9571. };
  9572. GridOptionsWrapper.prototype.getRowGroupPanelShow = function () {
  9573. return this.gridOptions.rowGroupPanelShow;
  9574. };
  9575. GridOptionsWrapper.prototype.getPivotPanelShow = function () {
  9576. return this.gridOptions.pivotPanelShow;
  9577. };
  9578. GridOptionsWrapper.prototype.isAngularCompileRows = function () {
  9579. return isTrue(this.gridOptions.angularCompileRows);
  9580. };
  9581. GridOptionsWrapper.prototype.isAngularCompileFilters = function () {
  9582. return isTrue(this.gridOptions.angularCompileFilters);
  9583. };
  9584. GridOptionsWrapper.prototype.isAngularCompileHeaders = function () {
  9585. return isTrue(this.gridOptions.angularCompileHeaders);
  9586. };
  9587. GridOptionsWrapper.prototype.isDebug = function () {
  9588. return isTrue(this.gridOptions.debug);
  9589. };
  9590. GridOptionsWrapper.prototype.getColumnDefs = function () {
  9591. return this.gridOptions.columnDefs;
  9592. };
  9593. GridOptionsWrapper.prototype.getColumnTypes = function () {
  9594. return this.gridOptions.columnTypes;
  9595. };
  9596. GridOptionsWrapper.prototype.getDatasource = function () {
  9597. return this.gridOptions.datasource;
  9598. };
  9599. GridOptionsWrapper.prototype.getViewportDatasource = function () {
  9600. return this.gridOptions.viewportDatasource;
  9601. };
  9602. GridOptionsWrapper.prototype.getServerSideDatasource = function () {
  9603. return this.gridOptions.serverSideDatasource;
  9604. };
  9605. GridOptionsWrapper.prototype.isAccentedSort = function () {
  9606. return isTrue(this.gridOptions.accentedSort);
  9607. };
  9608. GridOptionsWrapper.prototype.isEnableBrowserTooltips = function () {
  9609. return isTrue(this.gridOptions.enableBrowserTooltips);
  9610. };
  9611. GridOptionsWrapper.prototype.isEnableCellExpressions = function () {
  9612. return isTrue(this.gridOptions.enableCellExpressions);
  9613. };
  9614. GridOptionsWrapper.prototype.isEnableGroupEdit = function () {
  9615. return isTrue(this.gridOptions.enableGroupEdit);
  9616. };
  9617. GridOptionsWrapper.prototype.isSuppressMiddleClickScrolls = function () {
  9618. return isTrue(this.gridOptions.suppressMiddleClickScrolls);
  9619. };
  9620. GridOptionsWrapper.prototype.isPreventDefaultOnContextMenu = function () {
  9621. return isTrue(this.gridOptions.preventDefaultOnContextMenu);
  9622. };
  9623. GridOptionsWrapper.prototype.isSuppressPreventDefaultOnMouseWheel = function () {
  9624. return isTrue(this.gridOptions.suppressPreventDefaultOnMouseWheel);
  9625. };
  9626. GridOptionsWrapper.prototype.isSuppressColumnVirtualisation = function () {
  9627. return isTrue(this.gridOptions.suppressColumnVirtualisation);
  9628. };
  9629. GridOptionsWrapper.prototype.isSuppressContextMenu = function () {
  9630. return isTrue(this.gridOptions.suppressContextMenu);
  9631. };
  9632. GridOptionsWrapper.prototype.isAllowContextMenuWithControlKey = function () {
  9633. return isTrue(this.gridOptions.allowContextMenuWithControlKey);
  9634. };
  9635. GridOptionsWrapper.prototype.isSuppressCopyRowsToClipboard = function () {
  9636. return isTrue(this.gridOptions.suppressCopyRowsToClipboard);
  9637. };
  9638. GridOptionsWrapper.prototype.isCopyHeadersToClipboard = function () {
  9639. return isTrue(this.gridOptions.copyHeadersToClipboard);
  9640. };
  9641. GridOptionsWrapper.prototype.isSuppressClipboardPaste = function () {
  9642. return isTrue(this.gridOptions.suppressClipboardPaste);
  9643. };
  9644. GridOptionsWrapper.prototype.isSuppressLastEmptyLineOnPaste = function () {
  9645. return isTrue(this.gridOptions.suppressLastEmptyLineOnPaste);
  9646. };
  9647. GridOptionsWrapper.prototype.isPagination = function () {
  9648. return isTrue(this.gridOptions.pagination);
  9649. };
  9650. GridOptionsWrapper.prototype.isSuppressEnterpriseResetOnNewColumns = function () {
  9651. return isTrue(this.gridOptions.suppressEnterpriseResetOnNewColumns);
  9652. };
  9653. GridOptionsWrapper.prototype.getProcessDataFromClipboardFunc = function () {
  9654. return this.gridOptions.processDataFromClipboard;
  9655. };
  9656. GridOptionsWrapper.prototype.getAsyncTransactionWaitMillis = function () {
  9657. return _.exists(this.gridOptions.asyncTransactionWaitMillis) ? this.gridOptions.asyncTransactionWaitMillis : Constants.BATCH_WAIT_MILLIS;
  9658. };
  9659. GridOptionsWrapper.prototype.isSuppressMovableColumns = function () {
  9660. return isTrue(this.gridOptions.suppressMovableColumns);
  9661. };
  9662. GridOptionsWrapper.prototype.isAnimateRows = function () {
  9663. // never allow animating if enforcing the row order
  9664. if (this.isEnsureDomOrder()) {
  9665. return false;
  9666. }
  9667. return isTrue(this.gridOptions.animateRows);
  9668. };
  9669. GridOptionsWrapper.prototype.isSuppressColumnMoveAnimation = function () {
  9670. return isTrue(this.gridOptions.suppressColumnMoveAnimation);
  9671. };
  9672. GridOptionsWrapper.prototype.isSuppressAggFuncInHeader = function () {
  9673. return isTrue(this.gridOptions.suppressAggFuncInHeader);
  9674. };
  9675. GridOptionsWrapper.prototype.isSuppressAggAtRootLevel = function () {
  9676. return isTrue(this.gridOptions.suppressAggAtRootLevel);
  9677. };
  9678. GridOptionsWrapper.prototype.isEnableRangeSelection = function () {
  9679. return ModuleRegistry.isRegistered(exports.ModuleNames.RangeSelectionModule) && isTrue(this.gridOptions.enableRangeSelection);
  9680. };
  9681. GridOptionsWrapper.prototype.isEnableRangeHandle = function () {
  9682. return isTrue(this.gridOptions.enableRangeHandle);
  9683. };
  9684. GridOptionsWrapper.prototype.isEnableFillHandle = function () {
  9685. return isTrue(this.gridOptions.enableFillHandle);
  9686. };
  9687. GridOptionsWrapper.prototype.getFillOperation = function () {
  9688. return this.gridOptions.fillOperation;
  9689. };
  9690. GridOptionsWrapper.prototype.isSuppressMultiRangeSelection = function () {
  9691. return isTrue(this.gridOptions.suppressMultiRangeSelection);
  9692. };
  9693. GridOptionsWrapper.prototype.isPaginationAutoPageSize = function () {
  9694. return isTrue(this.gridOptions.paginationAutoPageSize);
  9695. };
  9696. GridOptionsWrapper.prototype.isRememberGroupStateWhenNewData = function () {
  9697. return isTrue(this.gridOptions.rememberGroupStateWhenNewData);
  9698. };
  9699. GridOptionsWrapper.prototype.getIcons = function () {
  9700. return this.gridOptions.icons;
  9701. };
  9702. GridOptionsWrapper.prototype.getAggFuncs = function () {
  9703. return this.gridOptions.aggFuncs;
  9704. };
  9705. GridOptionsWrapper.prototype.getSortingOrder = function () {
  9706. return this.gridOptions.sortingOrder;
  9707. };
  9708. GridOptionsWrapper.prototype.getAlignedGrids = function () {
  9709. return this.gridOptions.alignedGrids;
  9710. };
  9711. GridOptionsWrapper.prototype.isMasterDetail = function () {
  9712. var masterDetail = isTrue(this.gridOptions.masterDetail);
  9713. if (masterDetail) {
  9714. return ModuleRegistry.assertRegistered(exports.ModuleNames.MasterDetailModule, 'masterDetail');
  9715. }
  9716. else {
  9717. return false;
  9718. }
  9719. };
  9720. GridOptionsWrapper.prototype.isKeepDetailRows = function () {
  9721. return isTrue(this.gridOptions.keepDetailRows);
  9722. };
  9723. GridOptionsWrapper.prototype.getKeepDetailRowsCount = function () {
  9724. if (this.gridOptions.keepDetailRowsCount > 0) {
  9725. return this.gridOptions.keepDetailRowsCount;
  9726. }
  9727. return DEFAULT_KEEP_DETAIL_ROW_COUNT;
  9728. };
  9729. GridOptionsWrapper.prototype.getIsRowMasterFunc = function () {
  9730. return this.gridOptions.isRowMaster;
  9731. };
  9732. GridOptionsWrapper.prototype.getIsRowSelectableFunc = function () {
  9733. return this.gridOptions.isRowSelectable;
  9734. };
  9735. GridOptionsWrapper.prototype.getGroupRowRendererParams = function () {
  9736. return this.gridOptions.groupRowRendererParams;
  9737. };
  9738. GridOptionsWrapper.prototype.getOverlayLoadingTemplate = function () {
  9739. return this.gridOptions.overlayLoadingTemplate;
  9740. };
  9741. GridOptionsWrapper.prototype.getOverlayNoRowsTemplate = function () {
  9742. return this.gridOptions.overlayNoRowsTemplate;
  9743. };
  9744. GridOptionsWrapper.prototype.isSuppressAutoSize = function () {
  9745. return isTrue(this.gridOptions.suppressAutoSize);
  9746. };
  9747. GridOptionsWrapper.prototype.isEnableCellTextSelection = function () {
  9748. return isTrue(this.gridOptions.enableCellTextSelection);
  9749. };
  9750. GridOptionsWrapper.prototype.isSuppressParentsInRowNodes = function () {
  9751. return isTrue(this.gridOptions.suppressParentsInRowNodes);
  9752. };
  9753. GridOptionsWrapper.prototype.isFunctionsReadOnly = function () {
  9754. return isTrue(this.gridOptions.functionsReadOnly);
  9755. };
  9756. GridOptionsWrapper.prototype.isFloatingFilter = function () {
  9757. return this.gridOptions.floatingFilter;
  9758. };
  9759. GridOptionsWrapper.prototype.isEnableCellTextSelect = function () {
  9760. return isTrue(this.gridOptions.enableCellTextSelection);
  9761. };
  9762. GridOptionsWrapper.prototype.isEnableOldSetFilterModel = function () {
  9763. return isTrue(this.gridOptions.enableOldSetFilterModel);
  9764. };
  9765. GridOptionsWrapper.prototype.getDefaultColDef = function () {
  9766. return this.gridOptions.defaultColDef;
  9767. };
  9768. GridOptionsWrapper.prototype.getDefaultColGroupDef = function () {
  9769. return this.gridOptions.defaultColGroupDef;
  9770. };
  9771. GridOptionsWrapper.prototype.getDefaultExportParams = function () {
  9772. return this.gridOptions.defaultExportParams;
  9773. };
  9774. GridOptionsWrapper.prototype.isSuppressCsvExport = function () {
  9775. return isTrue(this.gridOptions.suppressCsvExport);
  9776. };
  9777. GridOptionsWrapper.prototype.isAllowShowChangeAfterFilter = function () {
  9778. return isTrue(this.gridOptions.allowShowChangeAfterFilter);
  9779. };
  9780. GridOptionsWrapper.prototype.isSuppressExcelExport = function () {
  9781. return isTrue(this.gridOptions.suppressExcelExport);
  9782. };
  9783. GridOptionsWrapper.prototype.isSuppressMakeColumnVisibleAfterUnGroup = function () {
  9784. return isTrue(this.gridOptions.suppressMakeColumnVisibleAfterUnGroup);
  9785. };
  9786. GridOptionsWrapper.prototype.getNodeChildDetailsFunc = function () {
  9787. return this.gridOptions.getNodeChildDetails;
  9788. };
  9789. GridOptionsWrapper.prototype.getDataPathFunc = function () {
  9790. return this.gridOptions.getDataPath;
  9791. };
  9792. GridOptionsWrapper.prototype.getIsServerSideGroupFunc = function () {
  9793. return this.gridOptions.isServerSideGroup;
  9794. };
  9795. GridOptionsWrapper.prototype.getServerSideGroupKeyFunc = function () {
  9796. return this.gridOptions.getServerSideGroupKey;
  9797. };
  9798. GridOptionsWrapper.prototype.getGroupRowAggNodesFunc = function () {
  9799. return this.gridOptions.groupRowAggNodes;
  9800. };
  9801. GridOptionsWrapper.prototype.getContextMenuItemsFunc = function () {
  9802. return this.gridOptions.getContextMenuItems;
  9803. };
  9804. GridOptionsWrapper.prototype.getMainMenuItemsFunc = function () {
  9805. return this.gridOptions.getMainMenuItems;
  9806. };
  9807. GridOptionsWrapper.prototype.getChartToolbarItemsFunc = function () {
  9808. return this.gridOptions.getChartToolbarItems;
  9809. };
  9810. GridOptionsWrapper.prototype.getRowNodeIdFunc = function () {
  9811. return this.gridOptions.getRowNodeId;
  9812. };
  9813. GridOptionsWrapper.prototype.getNavigateToNextCellFunc = function () {
  9814. return this.gridOptions.navigateToNextCell;
  9815. };
  9816. GridOptionsWrapper.prototype.getTabToNextCellFunc = function () {
  9817. return this.gridOptions.tabToNextCell;
  9818. };
  9819. GridOptionsWrapper.prototype.isTreeData = function () {
  9820. var usingTreeData = isTrue(this.gridOptions.treeData);
  9821. if (usingTreeData) {
  9822. return ModuleRegistry.assertRegistered(exports.ModuleNames.RowGroupingModule, 'Tree Data');
  9823. }
  9824. else {
  9825. return false;
  9826. }
  9827. };
  9828. GridOptionsWrapper.prototype.isValueCache = function () {
  9829. return isTrue(this.gridOptions.valueCache);
  9830. };
  9831. GridOptionsWrapper.prototype.isValueCacheNeverExpires = function () {
  9832. return isTrue(this.gridOptions.valueCacheNeverExpires);
  9833. };
  9834. GridOptionsWrapper.prototype.isDeltaSort = function () {
  9835. return isTrue(this.gridOptions.deltaSort);
  9836. };
  9837. GridOptionsWrapper.prototype.isAggregateOnlyChangedColumns = function () {
  9838. return isTrue(this.gridOptions.aggregateOnlyChangedColumns);
  9839. };
  9840. GridOptionsWrapper.prototype.getProcessSecondaryColDefFunc = function () {
  9841. return this.gridOptions.processSecondaryColDef;
  9842. };
  9843. GridOptionsWrapper.prototype.getProcessSecondaryColGroupDefFunc = function () {
  9844. return this.gridOptions.processSecondaryColGroupDef;
  9845. };
  9846. GridOptionsWrapper.prototype.getSendToClipboardFunc = function () {
  9847. return this.gridOptions.sendToClipboard;
  9848. };
  9849. GridOptionsWrapper.prototype.getProcessRowPostCreateFunc = function () {
  9850. return this.gridOptions.processRowPostCreate;
  9851. };
  9852. GridOptionsWrapper.prototype.getProcessCellForClipboardFunc = function () {
  9853. return this.gridOptions.processCellForClipboard;
  9854. };
  9855. GridOptionsWrapper.prototype.getProcessHeaderForClipboardFunc = function () {
  9856. return this.gridOptions.processHeaderForClipboard;
  9857. };
  9858. GridOptionsWrapper.prototype.getProcessCellFromClipboardFunc = function () {
  9859. return this.gridOptions.processCellFromClipboard;
  9860. };
  9861. GridOptionsWrapper.prototype.getViewportRowModelPageSize = function () {
  9862. return oneOrGreater(this.gridOptions.viewportRowModelPageSize, DEFAULT_VIEWPORT_ROW_MODEL_PAGE_SIZE);
  9863. };
  9864. GridOptionsWrapper.prototype.getViewportRowModelBufferSize = function () {
  9865. return zeroOrGreater(this.gridOptions.viewportRowModelBufferSize, DEFAULT_VIEWPORT_ROW_MODEL_BUFFER_SIZE);
  9866. };
  9867. GridOptionsWrapper.prototype.isServerSideSortingAlwaysResets = function () {
  9868. return isTrue(this.gridOptions.serverSideSortingAlwaysResets);
  9869. };
  9870. GridOptionsWrapper.prototype.getPostSortFunc = function () {
  9871. return this.gridOptions.postSort;
  9872. };
  9873. GridOptionsWrapper.prototype.getProcessChartOptionsFunc = function () {
  9874. return this.gridOptions.processChartOptions;
  9875. };
  9876. GridOptionsWrapper.prototype.getClipboardDeliminator = function () {
  9877. return _.exists(this.gridOptions.clipboardDeliminator) ? this.gridOptions.clipboardDeliminator : '\t';
  9878. };
  9879. GridOptionsWrapper.prototype.setProperty = function (key, value, force) {
  9880. if (force === void 0) { force = false; }
  9881. var gridOptionsNoType = this.gridOptions;
  9882. var previousValue = gridOptionsNoType[key];
  9883. if (force || previousValue !== value) {
  9884. gridOptionsNoType[key] = value;
  9885. var event_1 = {
  9886. type: key,
  9887. currentValue: value,
  9888. previousValue: previousValue
  9889. };
  9890. this.propertyEventService.dispatchEvent(event_1);
  9891. }
  9892. };
  9893. // this logic is repeated in lots of places. any element that had different CSS
  9894. // dependent on the layout needs to have the layout class added ot it.
  9895. GridOptionsWrapper.prototype.addLayoutElement = function (element) {
  9896. this.layoutElements.push(element);
  9897. this.updateLayoutClasses();
  9898. };
  9899. GridOptionsWrapper.prototype.updateLayoutClasses = function () {
  9900. var domLayout = this.getDomLayout();
  9901. var domLayoutAutoHeight = domLayout === Constants.DOM_LAYOUT_AUTO_HEIGHT;
  9902. var domLayoutPrint = domLayout === Constants.DOM_LAYOUT_PRINT;
  9903. var domLayoutNormal = domLayout === Constants.DOM_LAYOUT_NORMAL;
  9904. this.layoutElements.forEach(function (e) {
  9905. _.addOrRemoveCssClass(e, 'ag-layout-auto-height', domLayoutAutoHeight);
  9906. _.addOrRemoveCssClass(e, 'ag-layout-normal', domLayoutNormal);
  9907. _.addOrRemoveCssClass(e, 'ag-layout-print', domLayoutPrint);
  9908. });
  9909. };
  9910. GridOptionsWrapper.prototype.addEventListener = function (key, listener) {
  9911. GridOptionsWrapper_1.checkEventDeprecation(key);
  9912. this.propertyEventService.addEventListener(key, listener);
  9913. };
  9914. GridOptionsWrapper.checkEventDeprecation = function (eventName) {
  9915. if (eventName === 'floatingRowDataChanged') {
  9916. console.warn('ag-Grid: floatingRowDataChanged is now called pinnedRowDataChanged');
  9917. }
  9918. };
  9919. GridOptionsWrapper.prototype.removeEventListener = function (key, listener) {
  9920. this.propertyEventService.removeEventListener(key, listener);
  9921. };
  9922. GridOptionsWrapper.prototype.isSkipHeaderOnAutoSize = function () {
  9923. return !!this.gridOptions.skipHeaderOnAutoSize;
  9924. };
  9925. GridOptionsWrapper.prototype.getAutoSizePadding = function () {
  9926. return this.gridOptions.autoSizePadding && this.gridOptions.autoSizePadding > 0 ? this.gridOptions.autoSizePadding : 20;
  9927. };
  9928. // properties
  9929. GridOptionsWrapper.prototype.getHeaderHeight = function () {
  9930. if (typeof this.gridOptions.headerHeight === 'number') {
  9931. return this.gridOptions.headerHeight;
  9932. }
  9933. return this.getFromTheme(25, 'headerHeight');
  9934. };
  9935. GridOptionsWrapper.prototype.getFloatingFiltersHeight = function () {
  9936. if (typeof this.gridOptions.floatingFiltersHeight === 'number') {
  9937. return this.gridOptions.floatingFiltersHeight;
  9938. }
  9939. return this.getFromTheme(25, 'headerHeight');
  9940. };
  9941. GridOptionsWrapper.prototype.getGroupHeaderHeight = function () {
  9942. if (typeof this.gridOptions.groupHeaderHeight === 'number') {
  9943. return this.gridOptions.groupHeaderHeight;
  9944. }
  9945. return this.getHeaderHeight();
  9946. };
  9947. GridOptionsWrapper.prototype.getPivotHeaderHeight = function () {
  9948. if (typeof this.gridOptions.pivotHeaderHeight === 'number') {
  9949. return this.gridOptions.pivotHeaderHeight;
  9950. }
  9951. return this.getHeaderHeight();
  9952. };
  9953. GridOptionsWrapper.prototype.getPivotGroupHeaderHeight = function () {
  9954. if (typeof this.gridOptions.pivotGroupHeaderHeight === 'number') {
  9955. return this.gridOptions.pivotGroupHeaderHeight;
  9956. }
  9957. return this.getGroupHeaderHeight();
  9958. };
  9959. GridOptionsWrapper.prototype.isExternalFilterPresent = function () {
  9960. if (typeof this.gridOptions.isExternalFilterPresent === 'function') {
  9961. return this.gridOptions.isExternalFilterPresent();
  9962. }
  9963. return false;
  9964. };
  9965. GridOptionsWrapper.prototype.doesExternalFilterPass = function (node) {
  9966. if (typeof this.gridOptions.doesExternalFilterPass === 'function') {
  9967. return this.gridOptions.doesExternalFilterPass(node);
  9968. }
  9969. return false;
  9970. };
  9971. GridOptionsWrapper.prototype.getTooltipShowDelay = function () {
  9972. var tooltipShowDelay = this.gridOptions.tooltipShowDelay;
  9973. if (_.exists(tooltipShowDelay)) {
  9974. if (tooltipShowDelay < 0) {
  9975. console.warn('ag-grid: tooltipShowDelay should not be lower than 0');
  9976. }
  9977. return Math.max(200, tooltipShowDelay);
  9978. }
  9979. return null;
  9980. };
  9981. GridOptionsWrapper.prototype.isTooltipMouseTrack = function () {
  9982. return isTrue(this.gridOptions.tooltipMouseTrack);
  9983. };
  9984. GridOptionsWrapper.prototype.getDocument = function () {
  9985. // if user is providing document, we use the users one,
  9986. // otherwise we use the document on the global namespace.
  9987. var result = null;
  9988. if (this.gridOptions.getDocument && _.exists(this.gridOptions.getDocument)) {
  9989. result = this.gridOptions.getDocument();
  9990. }
  9991. if (result && _.exists(result)) {
  9992. return result;
  9993. }
  9994. return document;
  9995. };
  9996. GridOptionsWrapper.prototype.getMinColWidth = function () {
  9997. if (this.gridOptions.minColWidth > GridOptionsWrapper_1.MIN_COL_WIDTH) {
  9998. return this.gridOptions.minColWidth;
  9999. }
  10000. var measuredMin = this.getFromTheme(null, 'headerCellMinWidth');
  10001. return Math.max(measuredMin, GridOptionsWrapper_1.MIN_COL_WIDTH);
  10002. };
  10003. GridOptionsWrapper.prototype.getMaxColWidth = function () {
  10004. if (this.gridOptions.maxColWidth && this.gridOptions.maxColWidth > GridOptionsWrapper_1.MIN_COL_WIDTH) {
  10005. return this.gridOptions.maxColWidth;
  10006. }
  10007. return null;
  10008. };
  10009. GridOptionsWrapper.prototype.getColWidth = function () {
  10010. if (typeof this.gridOptions.colWidth !== 'number' || this.gridOptions.colWidth < GridOptionsWrapper_1.MIN_COL_WIDTH) {
  10011. return 200;
  10012. }
  10013. return this.gridOptions.colWidth;
  10014. };
  10015. GridOptionsWrapper.prototype.getRowBuffer = function () {
  10016. var rowBuffer = this.gridOptions.rowBuffer;
  10017. if (typeof rowBuffer === 'number') {
  10018. if (rowBuffer < 0) {
  10019. _.doOnce(function () { return console.warn("ag-Grid: rowBuffer should not be negative"); }, 'warn rowBuffer negative');
  10020. this.gridOptions.rowBuffer = rowBuffer = 0;
  10021. }
  10022. }
  10023. else {
  10024. rowBuffer = Constants.ROW_BUFFER_SIZE;
  10025. }
  10026. return rowBuffer;
  10027. };
  10028. GridOptionsWrapper.prototype.getRowBufferInPixels = function () {
  10029. var rowsToBuffer = this.getRowBuffer();
  10030. var defaultRowHeight = this.getRowHeightAsNumber();
  10031. return rowsToBuffer * defaultRowHeight;
  10032. };
  10033. // the user might be using some non-standard scrollbar, eg a scrollbar that has zero
  10034. // width and overlays (like the Safari scrollbar, but presented in Chrome). so we
  10035. // allow the user to provide the scroll width before we work it out.
  10036. GridOptionsWrapper.prototype.getScrollbarWidth = function () {
  10037. if (this.scrollWidth == null) {
  10038. var useGridOptions = typeof this.gridOptions.scrollbarWidth === 'number' && this.gridOptions.scrollbarWidth >= 0;
  10039. this.scrollWidth = useGridOptions ? this.gridOptions.scrollbarWidth : _.getScrollbarWidth();
  10040. }
  10041. return this.scrollWidth;
  10042. };
  10043. GridOptionsWrapper.prototype.checkForDeprecated = function () {
  10044. var _this = this;
  10045. // casting to generic object, so typescript compiles even though
  10046. // we are looking for attributes that don't exist
  10047. var options = this.gridOptions;
  10048. if (options.suppressUnSort) {
  10049. console.warn('ag-grid: as of v1.12.4 suppressUnSort is not used. Please use sortingOrder instead.');
  10050. }
  10051. if (options.suppressDescSort) {
  10052. console.warn('ag-grid: as of v1.12.4 suppressDescSort is not used. Please use sortingOrder instead.');
  10053. }
  10054. if (options.groupAggFields) {
  10055. console.warn('ag-grid: as of v3 groupAggFields is not used. Please add appropriate agg fields to your columns.');
  10056. }
  10057. if (options.groupHidePivotColumns) {
  10058. console.warn('ag-grid: as of v3 groupHidePivotColumns is not used as pivot columns are now called rowGroup columns. Please refer to the documentation');
  10059. }
  10060. if (options.groupKeys) {
  10061. console.warn('ag-grid: as of v3 groupKeys is not used. You need to set rowGroupIndex on the columns to group. Please refer to the documentation');
  10062. }
  10063. if (typeof options.groupDefaultExpanded === 'boolean') {
  10064. console.warn('ag-grid: groupDefaultExpanded can no longer be boolean. for groupDefaultExpanded=true, use groupDefaultExpanded=9999 instead, to expand all the groups');
  10065. }
  10066. if (options.onRowDeselected || options.rowDeselected) {
  10067. console.warn('ag-grid: since version 3.4 event rowDeselected no longer exists, please check the docs');
  10068. }
  10069. if (options.rowsAlreadyGrouped) {
  10070. console.warn('ag-grid: since version 3.4 rowsAlreadyGrouped no longer exists, please use getNodeChildDetails() instead');
  10071. }
  10072. if (options.groupAggFunction) {
  10073. console.warn('ag-grid: since version 4.3.x groupAggFunction is now called groupRowAggNodes');
  10074. }
  10075. if (options.checkboxSelection) {
  10076. console.warn('ag-grid: since version 8.0.x checkboxSelection is not supported as a grid option. ' + 'If you want this on all columns, use defaultColDef instead and set it there');
  10077. }
  10078. if (options.paginationInitialRowCount) {
  10079. console.warn('ag-grid: since version 9.0.x paginationInitialRowCount is now called infiniteInitialRowCount');
  10080. }
  10081. if (options.infinitePageSize) {
  10082. console.warn('ag-grid: since version 9.0.x infinitePageSize is now called cacheBlockSize');
  10083. }
  10084. if (options.infiniteBlockSize) {
  10085. console.warn('ag-grid: since version 10.0.x infiniteBlockSize is now called cacheBlockSize');
  10086. }
  10087. if (options.maxPagesInCache) {
  10088. console.warn('ag-grid: since version 10.0.x maxPagesInCache is now called maxBlocksInCache');
  10089. }
  10090. if (options.paginationOverflowSize) {
  10091. console.warn('ag-grid: since version 10.0.x paginationOverflowSize is now called cacheOverflowSize');
  10092. }
  10093. // if (options.forPrint) {
  10094. // console.warn('ag-grid: since version 10.1.x, use property domLayout="forPrint" instead of forPrint=true');
  10095. // }
  10096. if (options.suppressMenuFilterPanel) {
  10097. console.warn("ag-grid: since version 11.0.x, use property colDef.menuTabs=['generalMenuTab','columnsMenuTab'] instead of suppressMenuFilterPanel=true");
  10098. }
  10099. if (options.suppressMenuMainPanel) {
  10100. console.warn("ag-grid: since version 11.0.x, use property colDef.menuTabs=['filterMenuTab','columnsMenuTab'] instead of suppressMenuMainPanel=true");
  10101. }
  10102. if (options.suppressMenuColumnPanel) {
  10103. console.warn("ag-grid: since version 11.0.x, use property colDef.menuTabs=['generalMenuTab','filterMenuTab'] instead of suppressMenuColumnPanel=true");
  10104. }
  10105. if (options.suppressUseColIdForGroups) {
  10106. console.warn("ag-grid: since version 11.0.x, this is not in use anymore. You should be able to remove it from your definition");
  10107. }
  10108. if (options.groupSuppressRow) {
  10109. console.warn("ag-grid: since version 18.2.x, 'groupSuppressRow' should not be used anymore. Instead remove row groups and perform custom sorting.");
  10110. }
  10111. if (options.groupColumnDef) {
  10112. console.warn("ag-grid: since version 11.0.x, groupColumnDef has been renamed, this property is now called autoGroupColumnDef. Please change your configuration accordingly");
  10113. }
  10114. if (options.slaveGrids) {
  10115. console.warn("ag-grid: since version 12.x, slaveGrids has been renamed, this property is now called alignedGrids. Please change your configuration accordingly");
  10116. }
  10117. if (options.floatingTopRowData) {
  10118. console.warn("ag-grid: since version 12.x, floatingTopRowData is now called pinnedTopRowData");
  10119. }
  10120. if (options.floatingBottomRowData) {
  10121. console.warn("ag-grid: since version 12.x, floatingBottomRowData is now called pinnedBottomRowData");
  10122. }
  10123. if (options.paginationStartPage) {
  10124. console.warn("ag-grid: since version 12.x, paginationStartPage is gone, please call api.paginationGoToPage(" + options.paginationStartPage + ") instead.");
  10125. }
  10126. if (options.getHeaderCellTemplate) {
  10127. console.warn("ag-grid: since version 15.x, getHeaderCellTemplate is gone, please check the header documentation on how to set header templates.");
  10128. }
  10129. if (options.headerCellTemplate) {
  10130. console.warn("ag-grid: since version 15.x, headerCellTemplate is gone, please check the header documentation on how to set header templates.");
  10131. }
  10132. if (options.headerCellRenderer) {
  10133. console.warn("ag-grid: since version 15.x, headerCellRenderer is gone, please check the header documentation on how to set header templates.");
  10134. }
  10135. if (options.angularCompileHeaders) {
  10136. console.warn("ag-grid: since version 15.x, angularCompileHeaders is gone, please see the getting started for Angular 1 docs to see how to do headers in Angular 1.x.");
  10137. }
  10138. if (options.pivotTotals) {
  10139. console.warn("ag-grid: since version 18.x, pivotTotals has been removed, instead if using pivotTotals, set pivotColumnGroupTotals='before'|'after'.");
  10140. options.pivotColumnGroupTotals = 'before';
  10141. }
  10142. if (options.rowModelType === 'inMemory') {
  10143. console.warn("ag-grid: since version 18.x, The In Memory Row Model has been renamed to the Client Side Row Model, set rowModelType='clientSide' instead.");
  10144. options.rowModelType = 'clientSide';
  10145. }
  10146. if (options.rowModelType === 'enterprise') {
  10147. console.warn("ag-grid: since version 18.x, The Enterprise Row Model has been renamed to the Server Side Row Model, set rowModelType='serverSide' instead.");
  10148. options.rowModelType = 'serverSide';
  10149. }
  10150. if (options.layoutInterval) {
  10151. console.warn("ag-grid: since version 18.x, layoutInterval is no longer a property. This is because the grid now uses CSS Flex for layout.");
  10152. }
  10153. if (options.gridAutoHeight) {
  10154. console.warn("ag-grid: since version 19.x, gridAutoHeight is gone, please use domLayout=autoHeight instead");
  10155. options.domLayout = 'autoHeight';
  10156. }
  10157. if (options.showToolPanel === true) {
  10158. console.warn("ag-grid: since version 19.x, showToolPanel is gone, please specify toolPanel components. See https://www.ag-grid.com/javascript-grid-tool-panel/");
  10159. options.showToolPanel = undefined;
  10160. options.sideBar = options.sideBar || true;
  10161. }
  10162. if (options.showToolPanel === false) {
  10163. console.warn("ag-grid: since version 19.x, showToolPanel is gone, please specify toolPanel components. See https://www.ag-grid.com/javascript-grid-tool-panel/");
  10164. options.showToolPanel = undefined;
  10165. options.sideBar = options.sideBar || false;
  10166. }
  10167. var oldToolPanelProperties = {
  10168. toolPanelSuppressRowGroups: 'suppressRowGroups',
  10169. toolPanelSuppressValues: 'suppressValues',
  10170. toolPanelSuppressPivots: 'suppressPivots',
  10171. toolPanelSuppressPivotMode: 'suppressPivotMode',
  10172. toolPanelSuppressColumnFilter: 'suppressColumnFilter',
  10173. toolPanelSuppressColumnSelectAll: 'suppressColumnSelectAll',
  10174. toolPanelSuppressSideButtons: 'suppressSideButtons',
  10175. toolPanelSuppressColumnExpandAll: 'suppressColumnExpandAll',
  10176. contractColumnSelection: 'contractColumnSelection'
  10177. };
  10178. var toolPanelColumnsCompProps = {};
  10179. Object.keys(oldToolPanelProperties).forEach(function (key) {
  10180. var translation = oldToolPanelProperties[key];
  10181. var value = _this.gridOptions[key];
  10182. if (value !== undefined) {
  10183. if (key === 'toolPanelSuppressSideButtons') {
  10184. console.warn('ag-grid: since v19.0 toolPanelSuppressSideButtons has been completely removed. See https://www.ag-grid.com/javascript-grid-tool-panel/');
  10185. return;
  10186. }
  10187. console.warn("ag-grid: since v19.0 gridOptions." + key + " is deprecated, please use gridOptions.sideBar.toolPanel[columnsIndex].componentParams." + translation);
  10188. toolPanelColumnsCompProps[translation] = value;
  10189. }
  10190. });
  10191. if (Object.keys(toolPanelColumnsCompProps).length > 0 && !_.exists(options.sideBar)) {
  10192. console.warn("ag-grid: since version 19.x, sideBar is mandatory if using toolPanel related properties. See https://www.ag-grid.com/javascript-grid-tool-panel/");
  10193. options.sideBar = true;
  10194. }
  10195. if (options.sideBar != null) {
  10196. options.sideBar = SideBarDefParser.parse(options.sideBar);
  10197. }
  10198. var sideBarDef = this.gridOptions.sideBar;
  10199. if (Object.keys(toolPanelColumnsCompProps).length > 0 && sideBarDef && sideBarDef.toolPanels) {
  10200. var columnsDef = sideBarDef.toolPanels.filter(function (it) { return it.id === 'columns'; });
  10201. if (columnsDef.length === 1) {
  10202. _.mergeDeep(columnsDef[0], {
  10203. componentParams: toolPanelColumnsCompProps
  10204. });
  10205. }
  10206. }
  10207. if (options.enableStatusBar) {
  10208. console.warn("ag-grid: since version 19.x, enableStatusBar is gone, please specify statusBar components");
  10209. options.statusBar = options.statusBar || {
  10210. components: [{ component: 'agAggregationComponent' }]
  10211. };
  10212. }
  10213. if (options.alwaysShowStatusBar) {
  10214. console.warn("ag-grid: since version 19.x, alwaysShowStatusBar is gone. Please specify a min-height on the ag-status-bar css class, eg .ag-status-bar {min-height: 35px; }");
  10215. }
  10216. if (options.enableServerSideSorting || options.enableSorting) {
  10217. console.warn("ag-Grid: since v20, grid options enableSorting and enableServerSideSorting are gone. Instead set sortable=true on the column definition for the columns sorting are allowed on. To migrate from gridOption.enableSorting=true, set gridOptions.defaultColDef.sortable=true");
  10218. if (!options.defaultColDef) {
  10219. options.defaultColDef = {};
  10220. }
  10221. if (!options.defaultColDef.sortable) {
  10222. options.defaultColDef.sortable = true;
  10223. }
  10224. }
  10225. if (options.enableFilter || options.enableServerSideFilter) {
  10226. console.warn("ag-Grid: since v20, grid options enableFilter and enableServerSideFilter are gone. Instead set filter=true (if not already specifying a specific filter) on the column definition for the columns filtering is allowed on. To migrate from gridOptions.enableFilter=true, set gridOptions.defaultColDef.filter=true. If you are explicitly setting specific filters for each column (ie colDef.filter is already set) the you don't need to do anything.");
  10227. if (!options.defaultColDef) {
  10228. options.defaultColDef = {};
  10229. }
  10230. if (!options.defaultColDef.filter) {
  10231. options.defaultColDef.filter = true;
  10232. }
  10233. }
  10234. if (options.enableColResize) {
  10235. console.warn("ag-Grid: since v20, grid options enableColResize is gone. Instead set resizable=true on the column definition for the columns resizing are allowed on. To migrate from gridOption.enableColResize=true, set gridOptions.defaultColDef.resizable=true");
  10236. if (!options.defaultColDef) {
  10237. options.defaultColDef = {};
  10238. }
  10239. if (!options.defaultColDef.resizable) {
  10240. options.defaultColDef.resizable = true;
  10241. }
  10242. }
  10243. if (options.deprecatedEmbedFullWidthRows) {
  10244. console.warn("ag-Grid: since v21.2, deprecatedEmbedFullWidthRows has been replaced with embedFullWidthRows.");
  10245. }
  10246. if (options.suppressTabbing) {
  10247. console.warn("ag-Grid: since v20.1, suppressTabbing is replaced with the more powerful grid callback suppressKeyboardEvent(params) which can suppress any keyboard event including tabbing.");
  10248. }
  10249. if (options.doesDataFlower) {
  10250. console.warn('ag-Grid: since v21.1, doesDataFlower is deprecated. Master/Detail is the new way for showing child data for a row and was introduced over a year ago. Please migrate your code to use master/detail instead.');
  10251. }
  10252. if (options.enableOldSetFilterModel) {
  10253. console.warn('ag-Grid: since v22.x, enableOldSetFilterModel is deprecated. Please move to the new Set Filter Model as the old one may not be supported in v23 onwards.');
  10254. }
  10255. if (options.floatingFilter) {
  10256. console.warn('ag-Grid: since v23.1, floatingFilter on the gridOptions is deprecated. Please use floatingFilter on the colDef instead.');
  10257. if (!options.defaultColDef) {
  10258. options.defaultColDef = {};
  10259. }
  10260. if (options.defaultColDef.floatingFilter == null) {
  10261. options.defaultColDef.floatingFilter = true;
  10262. }
  10263. }
  10264. var checkRenamedProperty = function (oldProp, newProp, version) {
  10265. if (options[oldProp] != null) {
  10266. console.warn("ag-grid: since version " + version + ", '" + oldProp + "' is deprecated / renamed, please use the new property name '" + newProp + "' instead.");
  10267. if (options[newProp] == null) {
  10268. options[newProp] = options[oldProp];
  10269. }
  10270. }
  10271. };
  10272. checkRenamedProperty('batchUpdateWaitMillis', 'asyncTransactionWaitMillis', '23.1.x');
  10273. checkRenamedProperty('deltaRowDataMode', 'immutableData', '23.1.x');
  10274. checkRenamedProperty('deltaColumnMode', 'immutableColumns', '23.1.x');
  10275. };
  10276. GridOptionsWrapper.prototype.checkForViolations = function () {
  10277. if (this.isTreeData()) {
  10278. this.treeDataViolations();
  10279. }
  10280. };
  10281. GridOptionsWrapper.prototype.treeDataViolations = function () {
  10282. if (this.isRowModelDefault()) {
  10283. if (_.missing(this.getDataPathFunc())) {
  10284. console.warn('ag-Grid: property usingTreeData=true with rowModel=clientSide, but you did not ' +
  10285. 'provide getDataPath function, please provide getDataPath function if using tree data.');
  10286. }
  10287. }
  10288. if (this.isRowModelServerSide()) {
  10289. if (_.missing(this.getIsServerSideGroupFunc())) {
  10290. console.warn('ag-Grid: property usingTreeData=true with rowModel=serverSide, but you did not ' +
  10291. 'provide isServerSideGroup function, please provide isServerSideGroup function if using tree data.');
  10292. }
  10293. if (_.missing(this.getServerSideGroupKeyFunc())) {
  10294. console.warn('ag-Grid: property usingTreeData=true with rowModel=serverSide, but you did not ' +
  10295. 'provide getServerSideGroupKey function, please provide getServerSideGroupKey function if using tree data.');
  10296. }
  10297. }
  10298. };
  10299. GridOptionsWrapper.prototype.getLocaleTextFunc = function () {
  10300. if (this.gridOptions.localeTextFunc) {
  10301. return this.gridOptions.localeTextFunc;
  10302. }
  10303. var localeText = this.gridOptions.localeText;
  10304. return function (key, defaultValue) {
  10305. return localeText && localeText[key] ? localeText[key] : defaultValue;
  10306. };
  10307. };
  10308. // responsible for calling the onXXX functions on gridOptions
  10309. GridOptionsWrapper.prototype.globalEventHandler = function (eventName, event) {
  10310. var callbackMethodName = ComponentUtil.getCallbackForEvent(eventName);
  10311. if (typeof this.gridOptions[callbackMethodName] === 'function') {
  10312. this.gridOptions[callbackMethodName](event);
  10313. }
  10314. };
  10315. // we don't allow dynamic row height for virtual paging
  10316. GridOptionsWrapper.prototype.getRowHeightAsNumber = function () {
  10317. if (!this.gridOptions.rowHeight || _.missing(this.gridOptions.rowHeight)) {
  10318. return this.getDefaultRowHeight();
  10319. }
  10320. else if (this.gridOptions.rowHeight && this.isNumeric(this.gridOptions.rowHeight)) {
  10321. return this.gridOptions.rowHeight;
  10322. }
  10323. console.warn('ag-Grid row height must be a number if not using standard row model');
  10324. return this.getDefaultRowHeight();
  10325. };
  10326. GridOptionsWrapper.prototype.getRowHeightForNode = function (rowNode, allowEstimate) {
  10327. // check the function first, in case use set both function and
  10328. // number, when using virtual pagination then function can be
  10329. // used for pinned rows and the number for the body rows.
  10330. if (allowEstimate === void 0) { allowEstimate = false; }
  10331. if (typeof this.gridOptions.getRowHeight === 'function') {
  10332. if (allowEstimate) {
  10333. return { height: this.getDefaultRowHeight(), estimated: true };
  10334. }
  10335. var params = {
  10336. node: rowNode,
  10337. data: rowNode.data,
  10338. api: this.gridOptions.api,
  10339. context: this.gridOptions.context
  10340. };
  10341. var height = this.gridOptions.getRowHeight(params);
  10342. if (height != null) {
  10343. return { height: height, estimated: false };
  10344. }
  10345. }
  10346. if (rowNode.detail && this.isMasterDetail()) {
  10347. if (this.isNumeric(this.gridOptions.detailRowHeight)) {
  10348. return { height: this.gridOptions.detailRowHeight, estimated: false };
  10349. }
  10350. return { height: DEFAULT_DETAIL_ROW_HEIGHT, estimated: false };
  10351. }
  10352. var defaultRowHeight = this.getDefaultRowHeight();
  10353. var rowHeight = this.gridOptions.rowHeight && this.isNumeric(this.gridOptions.rowHeight) ? this.gridOptions.rowHeight : defaultRowHeight;
  10354. var minRowHeight = Math.min(defaultRowHeight, rowHeight);
  10355. if (this.columnController.isAutoRowHeightActive()) {
  10356. if (allowEstimate) {
  10357. return { height: rowHeight, estimated: true };
  10358. }
  10359. var autoHeight = this.autoHeightCalculator.getPreferredHeightForRow(rowNode);
  10360. // never return less than the default row height - covers when auto height
  10361. // cells are blank.
  10362. return { height: Math.max(autoHeight, minRowHeight), estimated: false };
  10363. }
  10364. return { height: rowHeight, estimated: false };
  10365. };
  10366. GridOptionsWrapper.prototype.isDynamicRowHeight = function () {
  10367. return typeof this.gridOptions.getRowHeight === 'function';
  10368. };
  10369. GridOptionsWrapper.prototype.getListItemHeight = function () {
  10370. return this.getFromTheme(20, 'listItemHeight');
  10371. };
  10372. GridOptionsWrapper.prototype.chartMenuPanelWidth = function () {
  10373. return this.environment.chartMenuPanelWidth();
  10374. };
  10375. GridOptionsWrapper.prototype.isNumeric = function (value) {
  10376. return !isNaN(value) && typeof value === 'number';
  10377. };
  10378. // Material data table has strict guidelines about whitespace, and these values are different than the ones
  10379. // ag-grid uses by default. We override the default ones for the sake of making it better out of the box
  10380. GridOptionsWrapper.prototype.getFromTheme = function (defaultValue, sassVariableName) {
  10381. var theme = this.environment.getTheme().theme;
  10382. if (theme && theme.indexOf('ag-theme') === 0) {
  10383. return this.environment.getSassVariable(theme, sassVariableName);
  10384. }
  10385. return defaultValue;
  10386. };
  10387. GridOptionsWrapper.prototype.getDefaultRowHeight = function () {
  10388. return this.getFromTheme(DEFAULT_ROW_HEIGHT, 'rowHeight');
  10389. };
  10390. var GridOptionsWrapper_1;
  10391. GridOptionsWrapper.MIN_COL_WIDTH = 10;
  10392. GridOptionsWrapper.PROP_HEADER_HEIGHT = 'headerHeight';
  10393. GridOptionsWrapper.PROP_GROUP_REMOVE_SINGLE_CHILDREN = 'groupRemoveSingleChildren';
  10394. GridOptionsWrapper.PROP_GROUP_REMOVE_LOWEST_SINGLE_CHILDREN = 'groupRemoveLowestSingleChildren';
  10395. GridOptionsWrapper.PROP_PIVOT_HEADER_HEIGHT = 'pivotHeaderHeight';
  10396. GridOptionsWrapper.PROP_SUPPRESS_CLIPBOARD_PASTE = 'suppressClipboardPaste';
  10397. GridOptionsWrapper.PROP_GROUP_HEADER_HEIGHT = 'groupHeaderHeight';
  10398. GridOptionsWrapper.PROP_PIVOT_GROUP_HEADER_HEIGHT = 'pivotGroupHeaderHeight';
  10399. GridOptionsWrapper.PROP_FLOATING_FILTERS_HEIGHT = 'floatingFiltersHeight';
  10400. GridOptionsWrapper.PROP_SUPPRESS_ROW_CLICK_SELECTION = 'suppressRowClickSelection';
  10401. GridOptionsWrapper.PROP_SUPPRESS_ROW_DRAG = 'suppressRowDrag';
  10402. GridOptionsWrapper.PROP_SUPPRESS_MOVE_WHEN_ROW_DRAG = 'suppressMoveWhenRowDragging';
  10403. GridOptionsWrapper.PROP_POPUP_PARENT = 'popupParent';
  10404. GridOptionsWrapper.PROP_DOM_LAYOUT = 'domLayout';
  10405. __decorate$8([
  10406. Autowired('gridOptions')
  10407. ], GridOptionsWrapper.prototype, "gridOptions", void 0);
  10408. __decorate$8([
  10409. Autowired('columnController')
  10410. ], GridOptionsWrapper.prototype, "columnController", void 0);
  10411. __decorate$8([
  10412. Autowired('eventService')
  10413. ], GridOptionsWrapper.prototype, "eventService", void 0);
  10414. __decorate$8([
  10415. Autowired('environment')
  10416. ], GridOptionsWrapper.prototype, "environment", void 0);
  10417. __decorate$8([
  10418. Autowired('autoHeightCalculator')
  10419. ], GridOptionsWrapper.prototype, "autoHeightCalculator", void 0);
  10420. __decorate$8([
  10421. __param$3(0, Qualifier('gridApi')), __param$3(1, Qualifier('columnApi'))
  10422. ], GridOptionsWrapper.prototype, "agWire", null);
  10423. __decorate$8([
  10424. PreDestroy
  10425. ], GridOptionsWrapper.prototype, "destroy", null);
  10426. __decorate$8([
  10427. PostConstruct
  10428. ], GridOptionsWrapper.prototype, "init", null);
  10429. GridOptionsWrapper = GridOptionsWrapper_1 = __decorate$8([
  10430. Bean('gridOptionsWrapper')
  10431. ], GridOptionsWrapper);
  10432. return GridOptionsWrapper;
  10433. }());
  10434. /**
  10435. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  10436. * @version v23.2.1
  10437. * @link http://www.ag-grid.com/
  10438. * @license MIT
  10439. */
  10440. var __spreadArrays$3 = (undefined && undefined.__spreadArrays) || function () {
  10441. for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
  10442. for (var r = Array(s), k = 0, i = 0; i < il; i++)
  10443. for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
  10444. r[k] = a[j];
  10445. return r;
  10446. };
  10447. var ComponentUtil = /** @class */ (function () {
  10448. function ComponentUtil() {
  10449. }
  10450. ComponentUtil.getEventCallbacks = function () {
  10451. if (!ComponentUtil.EVENT_CALLBACKS) {
  10452. ComponentUtil.EVENT_CALLBACKS = ComponentUtil.EVENTS.map(function (event) { return ComponentUtil.getCallbackForEvent(event); });
  10453. }
  10454. return ComponentUtil.EVENT_CALLBACKS;
  10455. };
  10456. ComponentUtil.copyAttributesToGridOptions = function (gridOptions, component, skipEventDeprecationCheck) {
  10457. if (skipEventDeprecationCheck === void 0) { skipEventDeprecationCheck = false; }
  10458. checkForDeprecated(component);
  10459. // create empty grid options if none were passed
  10460. if (typeof gridOptions !== 'object') {
  10461. gridOptions = {};
  10462. }
  10463. // to allow array style lookup in TypeScript, take type away from 'this' and 'gridOptions'
  10464. var pGridOptions = gridOptions;
  10465. var keyExists = function (key) { return typeof component[key] !== 'undefined'; };
  10466. // add in all the simple properties
  10467. __spreadArrays$3(ComponentUtil.ARRAY_PROPERTIES, ComponentUtil.STRING_PROPERTIES, ComponentUtil.OBJECT_PROPERTIES, ComponentUtil.FUNCTION_PROPERTIES, ComponentUtil.getEventCallbacks()).filter(keyExists)
  10468. .forEach(function (key) { return pGridOptions[key] = component[key]; });
  10469. ComponentUtil.BOOLEAN_PROPERTIES
  10470. .filter(keyExists)
  10471. .forEach(function (key) { return pGridOptions[key] = ComponentUtil.toBoolean(component[key]); });
  10472. ComponentUtil.NUMBER_PROPERTIES
  10473. .filter(keyExists)
  10474. .forEach(function (key) { return pGridOptions[key] = ComponentUtil.toNumber(component[key]); });
  10475. // purely for event deprecation checks (for frameworks - wouldn't apply for non-fw versions)
  10476. if (!skipEventDeprecationCheck) {
  10477. ComponentUtil.EVENTS
  10478. // React uses onXXX, not sure why this is different to the other frameworks
  10479. .filter(function (event) { return keyExists(event) || keyExists(ComponentUtil.getCallbackForEvent(event)); })
  10480. .forEach(function (event) { return GridOptionsWrapper.checkEventDeprecation(event); });
  10481. }
  10482. return gridOptions;
  10483. };
  10484. ComponentUtil.getCallbackForEvent = function (eventName) {
  10485. if (!eventName || eventName.length < 2) {
  10486. return eventName;
  10487. }
  10488. else {
  10489. return 'on' + eventName[0].toUpperCase() + eventName.substr(1);
  10490. }
  10491. };
  10492. ComponentUtil.processOnChange = function (changes, gridOptions, api, columnApi) {
  10493. if (!changes) {
  10494. return;
  10495. }
  10496. checkForDeprecated(changes);
  10497. // to allow array style lookup in TypeScript, take type away from 'this' and 'gridOptions'
  10498. var pGridOptions = gridOptions;
  10499. var keyExists = function (key) { return changes[key]; };
  10500. // check if any change for the simple types, and if so, then just copy in the new value
  10501. __spreadArrays$3(ComponentUtil.ARRAY_PROPERTIES, ComponentUtil.OBJECT_PROPERTIES, ComponentUtil.STRING_PROPERTIES, ComponentUtil.getEventCallbacks()).filter(keyExists)
  10502. .forEach(function (key) { return pGridOptions[key] = changes[key].currentValue; });
  10503. ComponentUtil.BOOLEAN_PROPERTIES
  10504. .filter(keyExists)
  10505. .forEach(function (key) { return pGridOptions[key] = ComponentUtil.toBoolean(changes[key].currentValue); });
  10506. ComponentUtil.NUMBER_PROPERTIES
  10507. .filter(keyExists)
  10508. .forEach(function (key) { return pGridOptions[key] = ComponentUtil.toNumber(changes[key].currentValue); });
  10509. if (changes.enableCellTextSelection) {
  10510. api.setEnableCellTextSelection(ComponentUtil.toBoolean(changes.enableCellTextSelection.currentValue));
  10511. }
  10512. if (changes.showToolPanel) {
  10513. api.showToolPanel(ComponentUtil.toBoolean(changes.showToolPanel.currentValue));
  10514. }
  10515. if (changes.quickFilterText) {
  10516. api.setQuickFilter(changes.quickFilterText.currentValue);
  10517. }
  10518. if (changes.rowData) {
  10519. api.setRowData(changes.rowData.currentValue);
  10520. }
  10521. if (changes.pinnedTopRowData) {
  10522. api.setPinnedTopRowData(changes.pinnedTopRowData.currentValue);
  10523. }
  10524. if (changes.pinnedBottomRowData) {
  10525. api.setPinnedBottomRowData(changes.pinnedBottomRowData.currentValue);
  10526. }
  10527. if (changes.autoGroupColumnDef) {
  10528. api.setAutoGroupColumnDef(changes.autoGroupColumnDef.currentValue, "gridOptionsChanged");
  10529. }
  10530. if (changes.columnDefs) {
  10531. api.setColumnDefs(changes.columnDefs.currentValue, "gridOptionsChanged");
  10532. }
  10533. if (changes.datasource) {
  10534. api.setDatasource(changes.datasource.currentValue);
  10535. }
  10536. if (changes.headerHeight) {
  10537. api.setHeaderHeight(ComponentUtil.toNumber(changes.headerHeight.currentValue));
  10538. }
  10539. if (changes.paginationPageSize) {
  10540. api.paginationSetPageSize(ComponentUtil.toNumber(changes.paginationPageSize.currentValue));
  10541. }
  10542. if (changes.pivotMode) {
  10543. columnApi.setPivotMode(ComponentUtil.toBoolean(changes.pivotMode.currentValue));
  10544. }
  10545. if (changes.groupRemoveSingleChildren) {
  10546. api.setGroupRemoveSingleChildren(ComponentUtil.toBoolean(changes.groupRemoveSingleChildren.currentValue));
  10547. }
  10548. if (changes.suppressRowDrag) {
  10549. api.setSuppressRowDrag(ComponentUtil.toBoolean(changes.suppressRowDrag.currentValue));
  10550. }
  10551. if (changes.suppressMoveWhenRowDragging) {
  10552. api.setSuppressMoveWhenRowDragging(ComponentUtil.toBoolean(changes.suppressMoveWhenRowDragging.currentValue));
  10553. }
  10554. if (changes.suppressRowClickSelection) {
  10555. api.setSuppressRowClickSelection(ComponentUtil.toBoolean(changes.suppressRowClickSelection.currentValue));
  10556. }
  10557. if (changes.gridAutoHeight) {
  10558. api.setGridAutoHeight(ComponentUtil.toBoolean(changes.gridAutoHeight.currentValue));
  10559. }
  10560. if (changes.suppressClipboardPaste) {
  10561. api.setSuppressClipboardPaste(ComponentUtil.toBoolean(changes.suppressClipboardPaste.currentValue));
  10562. }
  10563. if (changes.sideBar) {
  10564. api.setSideBar(changes.sideBar.currentValue);
  10565. }
  10566. // copy changes into an event for dispatch
  10567. var event = {
  10568. type: Events.EVENT_COMPONENT_STATE_CHANGED,
  10569. api: gridOptions.api,
  10570. columnApi: gridOptions.columnApi
  10571. };
  10572. _.iterateObject(changes, function (key, value) {
  10573. event[key] = value;
  10574. });
  10575. api.dispatchEvent(event);
  10576. };
  10577. ComponentUtil.toBoolean = function (value) {
  10578. if (typeof value === 'boolean') {
  10579. return value;
  10580. }
  10581. else if (typeof value === 'string') {
  10582. // for boolean, compare to empty String to allow attributes appearing with
  10583. // no value to be treated as 'true'
  10584. return value.toUpperCase() === 'TRUE' || value == '';
  10585. }
  10586. else {
  10587. return false;
  10588. }
  10589. };
  10590. ComponentUtil.toNumber = function (value) {
  10591. if (typeof value === 'number') {
  10592. return value;
  10593. }
  10594. else if (typeof value === 'string') {
  10595. return Number(value);
  10596. }
  10597. else {
  10598. return undefined;
  10599. }
  10600. };
  10601. // all the events are populated in here AFTER this class (at the bottom of the file).
  10602. ComponentUtil.EVENTS = [];
  10603. ComponentUtil.STRING_PROPERTIES = PropertyKeys.STRING_PROPERTIES;
  10604. ComponentUtil.OBJECT_PROPERTIES = PropertyKeys.OBJECT_PROPERTIES;
  10605. ComponentUtil.ARRAY_PROPERTIES = PropertyKeys.ARRAY_PROPERTIES;
  10606. ComponentUtil.NUMBER_PROPERTIES = PropertyKeys.NUMBER_PROPERTIES;
  10607. ComponentUtil.BOOLEAN_PROPERTIES = PropertyKeys.BOOLEAN_PROPERTIES;
  10608. ComponentUtil.FUNCTION_PROPERTIES = PropertyKeys.FUNCTION_PROPERTIES;
  10609. ComponentUtil.ALL_PROPERTIES = PropertyKeys.ALL_PROPERTIES;
  10610. return ComponentUtil;
  10611. }());
  10612. ComponentUtil.EVENTS = _.values(Events);
  10613. function checkForDeprecated(changes) {
  10614. if (changes.rowDeselected || changes.onRowDeselected) {
  10615. console.warn('ag-grid: as of v3.4 rowDeselected no longer exists. Please check the docs.');
  10616. }
  10617. }
  10618. /**
  10619. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  10620. * @version v23.2.1
  10621. * @link http://www.ag-grid.com/
  10622. * @license MIT
  10623. */
  10624. var __extends$4 = (undefined && undefined.__extends) || (function () {
  10625. var extendStatics = function (d, b) {
  10626. extendStatics = Object.setPrototypeOf ||
  10627. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  10628. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  10629. return extendStatics(d, b);
  10630. };
  10631. return function (d, b) {
  10632. extendStatics(d, b);
  10633. function __() { this.constructor = d; }
  10634. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  10635. };
  10636. })();
  10637. var __decorate$9 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  10638. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  10639. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  10640. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  10641. return c > 3 && r && Object.defineProperty(target, key, r), r;
  10642. };
  10643. var compIdSequence = new NumberSequence();
  10644. var Component = /** @class */ (function (_super) {
  10645. __extends$4(Component, _super);
  10646. function Component(template) {
  10647. var _this = _super.call(this) || this;
  10648. _this.annotatedGuiListeners = [];
  10649. // if false, then CSS class "ag-hidden" is applied, which sets "display: none"
  10650. _this.displayed = true;
  10651. // if false, then CSS class "ag-invisible" is applied, which sets "visibility: hidden"
  10652. _this.visible = true;
  10653. // unique id for this row component. this is used for getting a reference to the HTML dom.
  10654. // we cannot use the RowNode id as this is not unique (due to animation, old rows can be lying
  10655. // around as we create a new rowComp instance for the same row node).
  10656. _this.compId = compIdSequence.next();
  10657. if (template) {
  10658. _this.setTemplate(template);
  10659. }
  10660. return _this;
  10661. }
  10662. Component.prototype.getCompId = function () {
  10663. return this.compId;
  10664. };
  10665. // for registered components only, eg creates AgCheckbox instance from ag-checkbox HTML tag
  10666. Component.prototype.createChildComponentsFromTags = function (parentNode, paramsMap) {
  10667. var _this = this;
  10668. // we MUST take a copy of the list first, as the 'swapComponentForNode' adds comments into the DOM
  10669. // which messes up the traversal order of the children.
  10670. var childNodeList = _.copyNodeList(parentNode.childNodes);
  10671. _.forEach(childNodeList, function (childNode) {
  10672. if (!(childNode instanceof HTMLElement)) {
  10673. return;
  10674. }
  10675. var childComp = _this.createComponentFromElement(childNode, function (childComp) {
  10676. // copy over all attributes, including css classes, so any attributes user put on the tag
  10677. // wll be carried across
  10678. _this.copyAttributesFromNode(childNode, childComp.getGui());
  10679. }, paramsMap);
  10680. if (childComp) {
  10681. if (childComp.addItems && childNode.children.length) {
  10682. _this.createChildComponentsFromTags(childNode);
  10683. // converting from HTMLCollection to Array
  10684. var items = Array.prototype.slice.call(childNode.children);
  10685. childComp.addItems(items);
  10686. }
  10687. // replace the tag (eg ag-checkbox) with the proper HTMLElement (eg 'div') in the dom
  10688. _this.swapComponentForNode(childComp, parentNode, childNode);
  10689. }
  10690. else if (childNode.childNodes) {
  10691. _this.createChildComponentsFromTags(childNode);
  10692. }
  10693. });
  10694. };
  10695. Component.prototype.createComponentFromElement = function (element, afterPreCreateCallback, paramsMap) {
  10696. var key = element.nodeName;
  10697. var componentParams = paramsMap ? paramsMap[element.getAttribute('ref')] : undefined;
  10698. var ComponentClass = this.agStackComponentsRegistry.getComponentClass(key);
  10699. if (ComponentClass) {
  10700. var newComponent = new ComponentClass(componentParams);
  10701. this.createBean(newComponent, null, afterPreCreateCallback);
  10702. return newComponent;
  10703. }
  10704. return null;
  10705. };
  10706. Component.prototype.copyAttributesFromNode = function (source, dest) {
  10707. _.iterateNamedNodeMap(source.attributes, function (name, value) { return dest.setAttribute(name, value); });
  10708. };
  10709. Component.prototype.swapComponentForNode = function (newComponent, parentNode, childNode) {
  10710. var eComponent = newComponent.getGui();
  10711. parentNode.replaceChild(eComponent, childNode);
  10712. parentNode.insertBefore(document.createComment(childNode.nodeName), eComponent);
  10713. this.addDestroyFunc(this.destroyBean.bind(this, newComponent));
  10714. this.swapInComponentForQuerySelectors(newComponent, childNode);
  10715. };
  10716. Component.prototype.swapInComponentForQuerySelectors = function (newComponent, childNode) {
  10717. var thisNoType = this;
  10718. this.iterateOverQuerySelectors(function (querySelector) {
  10719. if (thisNoType[querySelector.attributeName] === childNode) {
  10720. thisNoType[querySelector.attributeName] = newComponent;
  10721. }
  10722. });
  10723. };
  10724. Component.prototype.iterateOverQuerySelectors = function (action) {
  10725. var thisPrototype = Object.getPrototypeOf(this);
  10726. while (thisPrototype != null) {
  10727. var metaData = thisPrototype.__agComponentMetaData;
  10728. var currentProtoName = (thisPrototype.constructor).name;
  10729. if (metaData && metaData[currentProtoName] && metaData[currentProtoName].querySelectors) {
  10730. _.forEach(metaData[currentProtoName].querySelectors, function (querySelector) { return action(querySelector); });
  10731. }
  10732. thisPrototype = Object.getPrototypeOf(thisPrototype);
  10733. }
  10734. };
  10735. Component.prototype.setTemplate = function (template, paramsMap) {
  10736. var eGui = _.loadTemplate(template);
  10737. this.setTemplateFromElement(eGui, paramsMap);
  10738. };
  10739. Component.prototype.setTemplateFromElement = function (element, paramsMap) {
  10740. this.eGui = element;
  10741. this.eGui.__agComponent = this;
  10742. this.addAnnotatedGuiEventListeners();
  10743. this.wireQuerySelectors();
  10744. // context will not be available when user sets template in constructor
  10745. if (!!this.getContext()) {
  10746. this.createChildComponentsFromTags(this.getGui(), paramsMap);
  10747. }
  10748. };
  10749. Component.prototype.createChildComponentsPreConstruct = function () {
  10750. // ui exists if user sets template in constructor. when this happens, we have to wait for the context
  10751. // to be autoWired first before we can create child components.
  10752. if (!!this.getGui()) {
  10753. this.createChildComponentsFromTags(this.getGui());
  10754. }
  10755. };
  10756. Component.prototype.wireQuerySelectors = function () {
  10757. var _this = this;
  10758. if (!this.eGui) {
  10759. return;
  10760. }
  10761. var thisNoType = this;
  10762. this.iterateOverQuerySelectors(function (querySelector) {
  10763. var resultOfQuery = _this.eGui.querySelector(querySelector.querySelector);
  10764. if (resultOfQuery) {
  10765. thisNoType[querySelector.attributeName] = resultOfQuery.__agComponent || resultOfQuery;
  10766. }
  10767. });
  10768. };
  10769. Component.prototype.addAnnotatedGuiEventListeners = function () {
  10770. var _this = this;
  10771. this.removeAnnotatedGuiEventListeners();
  10772. if (!this.eGui) {
  10773. return;
  10774. }
  10775. var listenerMethods = this.getAgComponentMetaData('guiListenerMethods');
  10776. if (!listenerMethods) {
  10777. return;
  10778. }
  10779. if (!this.annotatedGuiListeners) {
  10780. this.annotatedGuiListeners = [];
  10781. }
  10782. listenerMethods.forEach(function (meta) {
  10783. var element = _this.getRefElement(meta.ref);
  10784. if (!element) {
  10785. return;
  10786. }
  10787. var listener = _this[meta.methodName].bind(_this);
  10788. element.addEventListener(meta.eventName, listener);
  10789. _this.annotatedGuiListeners.push({ eventName: meta.eventName, listener: listener, element: element });
  10790. });
  10791. };
  10792. Component.prototype.addAnnotatedGridEventListeners = function () {
  10793. var _this = this;
  10794. var listenerMetas = this.getAgComponentMetaData('gridListenerMethods');
  10795. if (!listenerMetas) {
  10796. return;
  10797. }
  10798. listenerMetas.forEach(function (meta) {
  10799. var listener = _this[meta.methodName].bind(_this);
  10800. _this.addManagedListener(_this.eventService, meta.eventName, listener);
  10801. });
  10802. };
  10803. Component.prototype.getAgComponentMetaData = function (key) {
  10804. var res = [];
  10805. var thisProto = Object.getPrototypeOf(this);
  10806. while (thisProto != null) {
  10807. var metaData = thisProto.__agComponentMetaData;
  10808. var currentProtoName = (thisProto.constructor).name;
  10809. // IE does not support Function.prototype.name, so we need to extract
  10810. // the name using a RegEx
  10811. // from: https://matt.scharley.me/2012/03/monkey-patch-name-ie.html
  10812. if (currentProtoName === undefined) {
  10813. var funcNameRegex = /function\s([^(]{1,})\(/;
  10814. var results = funcNameRegex.exec(thisProto.constructor.toString());
  10815. if (results && results.length > 1) {
  10816. currentProtoName = results[1].trim();
  10817. }
  10818. }
  10819. if (metaData && metaData[currentProtoName] && metaData[currentProtoName][key]) {
  10820. res = res.concat(metaData[currentProtoName][key]);
  10821. }
  10822. thisProto = Object.getPrototypeOf(thisProto);
  10823. }
  10824. return res;
  10825. };
  10826. Component.prototype.removeAnnotatedGuiEventListeners = function () {
  10827. if (!this.annotatedGuiListeners) {
  10828. return;
  10829. }
  10830. _.forEach(this.annotatedGuiListeners, function (e) {
  10831. e.element.removeEventListener(e.eventName, e.listener);
  10832. });
  10833. this.annotatedGuiListeners = [];
  10834. };
  10835. Component.prototype.getGui = function () {
  10836. return this.eGui;
  10837. };
  10838. Component.prototype.getFocusableElement = function () {
  10839. return this.eGui;
  10840. };
  10841. Component.prototype.setParentComponent = function (component) {
  10842. this.parentComponent = component;
  10843. };
  10844. Component.prototype.getParentComponent = function () {
  10845. return this.parentComponent;
  10846. };
  10847. // this method is for older code, that wants to provide the gui element,
  10848. // it is not intended for this to be in ag-Stack
  10849. Component.prototype.setGui = function (eGui) {
  10850. this.eGui = eGui;
  10851. };
  10852. Component.prototype.queryForHtmlElement = function (cssSelector) {
  10853. return this.eGui.querySelector(cssSelector);
  10854. };
  10855. Component.prototype.queryForHtmlInputElement = function (cssSelector) {
  10856. return this.eGui.querySelector(cssSelector);
  10857. };
  10858. Component.prototype.appendChild = function (newChild, container) {
  10859. if (!container) {
  10860. container = this.eGui;
  10861. }
  10862. if (_.isNodeOrElement(newChild)) {
  10863. container.appendChild(newChild);
  10864. }
  10865. else {
  10866. var childComponent = newChild;
  10867. container.appendChild(childComponent.getGui());
  10868. this.addDestroyFunc(this.destroyBean.bind(this, childComponent));
  10869. }
  10870. };
  10871. Component.prototype.isDisplayed = function () {
  10872. return this.displayed;
  10873. };
  10874. Component.prototype.setVisible = function (visible) {
  10875. if (visible !== this.visible) {
  10876. this.visible = visible;
  10877. _.setVisible(this.eGui, visible);
  10878. }
  10879. };
  10880. Component.prototype.setDisplayed = function (displayed) {
  10881. if (displayed !== this.displayed) {
  10882. this.displayed = displayed;
  10883. _.setDisplayed(this.eGui, displayed);
  10884. var event_1 = {
  10885. type: Component.EVENT_DISPLAYED_CHANGED,
  10886. visible: this.displayed
  10887. };
  10888. this.dispatchEvent(event_1);
  10889. }
  10890. };
  10891. Component.prototype.destroy = function () {
  10892. this.removeAnnotatedGuiEventListeners();
  10893. _super.prototype.destroy.call(this);
  10894. };
  10895. Component.prototype.addGuiEventListener = function (event, listener) {
  10896. var _this = this;
  10897. this.eGui.addEventListener(event, listener);
  10898. this.addDestroyFunc(function () { return _this.eGui.removeEventListener(event, listener); });
  10899. };
  10900. Component.prototype.addCssClass = function (className) {
  10901. _.addCssClass(this.eGui, className);
  10902. };
  10903. Component.prototype.removeCssClass = function (className) {
  10904. _.removeCssClass(this.eGui, className);
  10905. };
  10906. Component.prototype.addOrRemoveCssClass = function (className, addOrRemove) {
  10907. _.addOrRemoveCssClass(this.eGui, className, addOrRemove);
  10908. };
  10909. Component.prototype.getAttribute = function (key) {
  10910. var eGui = this.eGui;
  10911. return eGui ? eGui.getAttribute(key) : null;
  10912. };
  10913. Component.prototype.getRefElement = function (refName) {
  10914. return this.queryForHtmlElement("[ref=\"" + refName + "\"]");
  10915. };
  10916. Component.EVENT_DISPLAYED_CHANGED = 'displayedChanged';
  10917. __decorate$9([
  10918. Autowired('agStackComponentsRegistry')
  10919. ], Component.prototype, "agStackComponentsRegistry", void 0);
  10920. __decorate$9([
  10921. PreConstruct
  10922. ], Component.prototype, "createChildComponentsPreConstruct", null);
  10923. __decorate$9([
  10924. PostConstruct
  10925. ], Component.prototype, "addAnnotatedGridEventListeners", null);
  10926. return Component;
  10927. }(BeanStub));
  10928. /**
  10929. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  10930. * @version v23.2.1
  10931. * @link http://www.ag-grid.com/
  10932. * @license MIT
  10933. */
  10934. var __extends$5 = (undefined && undefined.__extends) || (function () {
  10935. var extendStatics = function (d, b) {
  10936. extendStatics = Object.setPrototypeOf ||
  10937. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  10938. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  10939. return extendStatics(d, b);
  10940. };
  10941. return function (d, b) {
  10942. extendStatics(d, b);
  10943. function __() { this.constructor = d; }
  10944. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  10945. };
  10946. })();
  10947. var PopupComponent = /** @class */ (function (_super) {
  10948. __extends$5(PopupComponent, _super);
  10949. function PopupComponent() {
  10950. return _super !== null && _super.apply(this, arguments) || this;
  10951. }
  10952. PopupComponent.prototype.isPopup = function () {
  10953. return true;
  10954. };
  10955. PopupComponent.prototype.setParentComponent = function (container) {
  10956. _.addCssClass(container.getGui(), 'ag-has-popup');
  10957. _super.prototype.setParentComponent.call(this, container);
  10958. };
  10959. PopupComponent.prototype.destroy = function () {
  10960. var parentComp = this.parentComponent;
  10961. var hasParent = parentComp && parentComp.isAlive();
  10962. if (hasParent) {
  10963. _.removeCssClass(parentComp.getGui(), 'ag-has-popup');
  10964. }
  10965. _super.prototype.destroy.call(this);
  10966. };
  10967. return PopupComponent;
  10968. }(Component));
  10969. /**
  10970. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  10971. * @version v23.2.1
  10972. * @link http://www.ag-grid.com/
  10973. * @license MIT
  10974. */
  10975. function QuerySelector(selector) {
  10976. return querySelectorFunc.bind(this, selector);
  10977. }
  10978. function RefSelector(ref) {
  10979. return querySelectorFunc.bind(this, "[ref=" + ref + "]");
  10980. }
  10981. function querySelectorFunc(selector, classPrototype, methodOrAttributeName, index) {
  10982. if (selector === null) {
  10983. console.error("ag-Grid: QuerySelector selector should not be null");
  10984. return;
  10985. }
  10986. if (typeof index === "number") {
  10987. console.error("ag-Grid: QuerySelector should be on an attribute");
  10988. return;
  10989. }
  10990. addToObjectProps(classPrototype, 'querySelectors', {
  10991. attributeName: methodOrAttributeName,
  10992. querySelector: selector
  10993. });
  10994. }
  10995. // think we should take this out, put property bindings on the
  10996. function GridListener(eventName) {
  10997. return gridListenerFunc.bind(this, eventName);
  10998. }
  10999. function gridListenerFunc(eventName, target, methodName) {
  11000. if (eventName == null) {
  11001. console.error("ag-Grid: GridListener eventName is missing");
  11002. return;
  11003. }
  11004. addToObjectProps(target, 'gridListenerMethods', {
  11005. methodName: methodName,
  11006. eventName: eventName
  11007. });
  11008. }
  11009. // think we should take this out, put property bindings on the
  11010. function GuiListener(ref, eventName) {
  11011. return guiListenerFunc.bind(this, ref, eventName);
  11012. }
  11013. function guiListenerFunc(ref, eventName, target, methodName) {
  11014. if (eventName == null) {
  11015. console.error("ag-Grid: GuiListener eventName is missing");
  11016. return;
  11017. }
  11018. addToObjectProps(target, 'guiListenerMethods', {
  11019. methodName: methodName,
  11020. eventName: eventName,
  11021. ref: ref
  11022. });
  11023. }
  11024. // // think we should take this out, put property bindings on the
  11025. // export function Method(eventName?: string): Function {
  11026. // return methodFunc.bind(this, eventName);
  11027. // }
  11028. //
  11029. // function methodFunc(alias: string, target: Object, methodName: string) {
  11030. // if (alias === null) {
  11031. // console.error("ag-Grid: EventListener eventName should not be null");
  11032. // return;
  11033. // }
  11034. //
  11035. // addToObjectProps(target, 'methods', {
  11036. // methodName: methodName,
  11037. // alias: alias
  11038. // });
  11039. // }
  11040. function addToObjectProps(target, key, value) {
  11041. // it's an attribute on the class
  11042. var props = getOrCreateProps$1(target, target.constructor.name);
  11043. if (!props[key]) {
  11044. props[key] = [];
  11045. }
  11046. props[key].push(value);
  11047. }
  11048. function getOrCreateProps$1(target, instanceName) {
  11049. if (!target.__agComponentMetaData) {
  11050. target.__agComponentMetaData = {};
  11051. }
  11052. if (!target.__agComponentMetaData[instanceName]) {
  11053. target.__agComponentMetaData[instanceName] = {};
  11054. }
  11055. return target.__agComponentMetaData[instanceName];
  11056. }
  11057. /**
  11058. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  11059. * @version v23.2.1
  11060. * @link http://www.ag-grid.com/
  11061. * @license MIT
  11062. */
  11063. var __extends$6 = (undefined && undefined.__extends) || (function () {
  11064. var extendStatics = function (d, b) {
  11065. extendStatics = Object.setPrototypeOf ||
  11066. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  11067. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  11068. return extendStatics(d, b);
  11069. };
  11070. return function (d, b) {
  11071. extendStatics(d, b);
  11072. function __() { this.constructor = d; }
  11073. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  11074. };
  11075. })();
  11076. var __decorate$a = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  11077. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  11078. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  11079. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  11080. return c > 3 && r && Object.defineProperty(target, key, r), r;
  11081. };
  11082. var TextCellEditor = /** @class */ (function (_super) {
  11083. __extends$6(TextCellEditor, _super);
  11084. function TextCellEditor() {
  11085. return _super.call(this, TextCellEditor.TEMPLATE) || this;
  11086. }
  11087. TextCellEditor.prototype.init = function (params) {
  11088. this.params = params;
  11089. var eInput = this.eInput;
  11090. var startValue;
  11091. // cellStartedEdit is only false if we are doing fullRow editing
  11092. if (params.cellStartedEdit) {
  11093. this.focusAfterAttached = true;
  11094. var keyPressBackspaceOrDelete = params.keyPress === Constants.KEY_BACKSPACE
  11095. || params.keyPress === Constants.KEY_DELETE;
  11096. if (keyPressBackspaceOrDelete) {
  11097. startValue = '';
  11098. }
  11099. else if (params.charPress) {
  11100. startValue = params.charPress;
  11101. }
  11102. else {
  11103. startValue = this.getStartValue(params);
  11104. if (params.keyPress !== Constants.KEY_F2) {
  11105. this.highlightAllOnFocus = true;
  11106. }
  11107. }
  11108. }
  11109. else {
  11110. this.focusAfterAttached = false;
  11111. startValue = this.getStartValue(params);
  11112. }
  11113. if (_.exists(startValue)) {
  11114. eInput.setValue(startValue, true);
  11115. }
  11116. this.addManagedListener(eInput.getGui(), 'keydown', function (event) {
  11117. var pageUp = event.keyCode === Constants.KEY_PAGE_UP;
  11118. var pageDown = event.keyCode === Constants.KEY_PAGE_DOWN;
  11119. if (pageUp || pageDown) {
  11120. event.preventDefault();
  11121. }
  11122. });
  11123. };
  11124. TextCellEditor.prototype.afterGuiAttached = function () {
  11125. if (!this.focusAfterAttached) {
  11126. return;
  11127. }
  11128. var eInput = this.eInput;
  11129. // Added for AG-3238. We can't remove this explicit focus() because Chrome requires an input
  11130. // to be focused before setSelectionRange will work. But it triggers a bug in Safari where
  11131. // explicitly focusing then blurring an empty field will cause the parent container to scroll.
  11132. if (!_.isBrowserSafari()) {
  11133. eInput.getFocusableElement().focus();
  11134. }
  11135. var inputEl = eInput.getInputElement();
  11136. if (this.highlightAllOnFocus) {
  11137. inputEl.select();
  11138. }
  11139. else {
  11140. // when we started editing, we want the caret at the end, not the start.
  11141. // this comes into play in two scenarios: a) when user hits F2 and b)
  11142. // when user hits a printable character, then on IE (and only IE) the caret
  11143. // was placed after the first character, thus 'apply' would end up as 'pplea'
  11144. var value = eInput.getValue();
  11145. var len = (_.exists(value) && value.length) || 0;
  11146. if (len) {
  11147. inputEl.setSelectionRange(len, len);
  11148. }
  11149. }
  11150. };
  11151. // gets called when tabbing trough cells and in full row edit mode
  11152. TextCellEditor.prototype.focusIn = function () {
  11153. var eInput = this.eInput;
  11154. var focusEl = eInput.getFocusableElement();
  11155. var inputEl = eInput.getInputElement();
  11156. focusEl.focus();
  11157. inputEl.select();
  11158. };
  11159. TextCellEditor.prototype.focusOut = function () {
  11160. var inputEl = this.eInput.getInputElement();
  11161. if (_.isBrowserIE()) {
  11162. inputEl.setSelectionRange(0, 0);
  11163. }
  11164. };
  11165. TextCellEditor.prototype.getValue = function () {
  11166. var eInput = this.eInput;
  11167. return this.params.parseValue(eInput.getValue());
  11168. };
  11169. TextCellEditor.prototype.getStartValue = function (params) {
  11170. var formatValue = params.useFormatter || params.column.getColDef().refData;
  11171. return formatValue ? params.formatValue(params.value) : params.value;
  11172. };
  11173. TextCellEditor.prototype.isPopup = function () {
  11174. return false;
  11175. };
  11176. TextCellEditor.TEMPLATE = '<div class="ag-cell-edit-wrapper"><ag-input-text-field class="ag-cell-editor" ref="eInput"></ag-input-text-field></div>';
  11177. __decorate$a([
  11178. RefSelector('eInput')
  11179. ], TextCellEditor.prototype, "eInput", void 0);
  11180. return TextCellEditor;
  11181. }(PopupComponent));
  11182. /**
  11183. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  11184. * @version v23.2.1
  11185. * @link http://www.ag-grid.com/
  11186. * @license MIT
  11187. */
  11188. /** Provides sync access to async component. Date component can be lazy created - this class encapsulates
  11189. * this by keeping value locally until DateComp has loaded, then passing DateComp the value. */
  11190. var DateCompWrapper = /** @class */ (function () {
  11191. function DateCompWrapper(context, userComponentFactory, dateComponentParams, eParent) {
  11192. var _this = this;
  11193. this.alive = true;
  11194. this.context = context;
  11195. userComponentFactory.newDateComponent(dateComponentParams).then(function (dateComp) {
  11196. // because async, check the filter still exists after component comes back
  11197. if (!_this.alive) {
  11198. context.destroyBean(dateComp);
  11199. return;
  11200. }
  11201. _this.dateComp = dateComp;
  11202. eParent.appendChild(dateComp.getGui());
  11203. if (dateComp.afterGuiAttached) {
  11204. dateComp.afterGuiAttached();
  11205. }
  11206. if (_this.tempValue) {
  11207. dateComp.setDate(_this.tempValue);
  11208. }
  11209. });
  11210. }
  11211. DateCompWrapper.prototype.destroy = function () {
  11212. this.alive = false;
  11213. this.dateComp = this.context.destroyBean(this.dateComp);
  11214. };
  11215. DateCompWrapper.prototype.getDate = function () {
  11216. return this.dateComp ? this.dateComp.getDate() : this.tempValue;
  11217. };
  11218. DateCompWrapper.prototype.setDate = function (value) {
  11219. if (this.dateComp) {
  11220. this.dateComp.setDate(value);
  11221. }
  11222. else {
  11223. this.tempValue = value;
  11224. }
  11225. };
  11226. DateCompWrapper.prototype.setInputPlaceholder = function (placeholder) {
  11227. if (this.dateComp && this.dateComp.setInputPlaceholder) {
  11228. this.dateComp.setInputPlaceholder(placeholder);
  11229. }
  11230. };
  11231. return DateCompWrapper;
  11232. }());
  11233. /**
  11234. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  11235. * @version v23.2.1
  11236. * @link http://www.ag-grid.com/
  11237. * @license MIT
  11238. */
  11239. /* Common logic for options, used by both filters and floating filters. */
  11240. var OptionsFactory = /** @class */ (function () {
  11241. function OptionsFactory() {
  11242. this.customFilterOptions = {};
  11243. }
  11244. OptionsFactory.prototype.init = function (params, defaultOptions) {
  11245. this.filterOptions = params.filterOptions || defaultOptions;
  11246. this.mapCustomOptions();
  11247. this.selectDefaultItem(params);
  11248. };
  11249. OptionsFactory.prototype.getFilterOptions = function () {
  11250. return this.filterOptions;
  11251. };
  11252. OptionsFactory.prototype.mapCustomOptions = function () {
  11253. var _this = this;
  11254. if (!this.filterOptions) {
  11255. return;
  11256. }
  11257. this.filterOptions.forEach(function (filterOption) {
  11258. if (typeof filterOption === 'string') {
  11259. return;
  11260. }
  11261. var requiredProperties = ['displayKey', 'displayName', 'test'];
  11262. if (every(requiredProperties, function (key) {
  11263. if (!filterOption[key]) {
  11264. console.warn("ag-Grid: ignoring FilterOptionDef as it doesn't contain a '" + key + "'");
  11265. return false;
  11266. }
  11267. return true;
  11268. })) {
  11269. _this.customFilterOptions[filterOption.displayKey] = filterOption;
  11270. }
  11271. });
  11272. };
  11273. OptionsFactory.prototype.selectDefaultItem = function (params) {
  11274. if (params.defaultOption) {
  11275. this.defaultOption = params.defaultOption;
  11276. }
  11277. else if (this.filterOptions.length >= 1) {
  11278. var firstFilterOption = this.filterOptions[0];
  11279. if (typeof firstFilterOption === 'string') {
  11280. this.defaultOption = firstFilterOption;
  11281. }
  11282. else if (firstFilterOption.displayKey) {
  11283. this.defaultOption = firstFilterOption.displayKey;
  11284. }
  11285. else {
  11286. console.warn("ag-Grid: invalid FilterOptionDef supplied as it doesn't contain a 'displayKey'");
  11287. }
  11288. }
  11289. else {
  11290. console.warn('ag-Grid: no filter options for filter');
  11291. }
  11292. };
  11293. OptionsFactory.prototype.getDefaultOption = function () {
  11294. return this.defaultOption;
  11295. };
  11296. OptionsFactory.prototype.getCustomOption = function (name) {
  11297. return this.customFilterOptions[name];
  11298. };
  11299. return OptionsFactory;
  11300. }());
  11301. /**
  11302. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  11303. * @version v23.2.1
  11304. * @link http://www.ag-grid.com/
  11305. * @license MIT
  11306. */
  11307. var __extends$7 = (undefined && undefined.__extends) || (function () {
  11308. var extendStatics = function (d, b) {
  11309. extendStatics = Object.setPrototypeOf ||
  11310. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  11311. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  11312. return extendStatics(d, b);
  11313. };
  11314. return function (d, b) {
  11315. extendStatics(d, b);
  11316. function __() { this.constructor = d; }
  11317. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  11318. };
  11319. })();
  11320. var __decorate$b = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  11321. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  11322. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  11323. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  11324. return c > 3 && r && Object.defineProperty(target, key, r), r;
  11325. };
  11326. /**
  11327. * Contains common logic to all provided filters (apply button, clear button, etc).
  11328. * All the filters that come with ag-Grid extend this class. User filters do not
  11329. * extend this class.
  11330. */
  11331. var ProvidedFilter = /** @class */ (function (_super) {
  11332. __extends$7(ProvidedFilter, _super);
  11333. function ProvidedFilter() {
  11334. var _this = _super !== null && _super.apply(this, arguments) || this;
  11335. _this.applyActive = false;
  11336. _this.hidePopup = null;
  11337. // after the user hits 'apply' the model gets copied to here. this is then the model that we use for
  11338. // all filtering. so if user changes UI but doesn't hit apply, then the UI will be out of sync with this model.
  11339. // this is what we want, as the UI should only become the 'active' filter once it's applied. when apply is
  11340. // inactive, this model will be in sync (following the debounce ms). if the UI is not a valid filter
  11341. // (eg the value is missing so nothing to filter on, or for set filter all checkboxes are checked so filter
  11342. // not active) then this appliedModel will be null/undefined.
  11343. _this.appliedModel = null;
  11344. return _this;
  11345. }
  11346. /** @deprecated */
  11347. ProvidedFilter.prototype.onFilterChanged = function () {
  11348. console.warn("ag-Grid: you should not call onFilterChanged() directly on the filter, please call\n gridApi.onFilterChanged() instead. onFilterChanged is not part of the exposed filter interface (it was\n a method that existed on an old version of the filters that was not intended for public use.");
  11349. this.providedFilterParams.filterChangedCallback();
  11350. };
  11351. ProvidedFilter.prototype.isFilterActive = function () {
  11352. // filter is active if we have a valid applied model
  11353. return !!this.appliedModel;
  11354. };
  11355. ProvidedFilter.prototype.postConstruct = function () {
  11356. var templateString = /* html */ "\n <div>\n <div class=\"ag-filter-body-wrapper ag-" + this.getCssIdentifier() + "-body-wrapper\">\n " + this.createBodyTemplate() + "\n </div>\n </div>";
  11357. this.setTemplate(templateString);
  11358. };
  11359. ProvidedFilter.prototype.init = function (params) {
  11360. var _this = this;
  11361. this.setParams(params);
  11362. this.resetUiToDefaults(true).then(function () {
  11363. _this.updateUiVisibility();
  11364. _this.setupOnBtApplyDebounce();
  11365. });
  11366. };
  11367. ProvidedFilter.prototype.setParams = function (params) {
  11368. ProvidedFilter.checkForDeprecatedParams(params);
  11369. this.providedFilterParams = params;
  11370. if (params.newRowsAction === 'keep') {
  11371. this.newRowsActionKeep = true;
  11372. }
  11373. else if (params.newRowsAction === 'clear') {
  11374. this.newRowsActionKeep = false;
  11375. }
  11376. else {
  11377. // the default for SSRM and IRM is 'keep', for CSRM and VRM the default is 'clear'
  11378. var modelsForKeep = [Constants.ROW_MODEL_TYPE_SERVER_SIDE, Constants.ROW_MODEL_TYPE_INFINITE];
  11379. this.newRowsActionKeep = modelsForKeep.indexOf(this.rowModel.getType()) >= 0;
  11380. }
  11381. this.applyActive = ProvidedFilter.isUseApplyButton(params);
  11382. this.createButtonPanel();
  11383. };
  11384. ProvidedFilter.prototype.createButtonPanel = function () {
  11385. var _this = this;
  11386. var buttons = this.providedFilterParams.buttons;
  11387. if (!buttons || buttons.length < 1) {
  11388. return;
  11389. }
  11390. var translate = this.gridOptionsWrapper.getLocaleTextFunc();
  11391. var eButtonsPanel = document.createElement('div');
  11392. addCssClass(eButtonsPanel, 'ag-filter-apply-panel');
  11393. var addButton = function (type) {
  11394. var text;
  11395. var clickListener;
  11396. switch (type) {
  11397. case 'apply':
  11398. text = translate('applyFilter', 'Apply Filter');
  11399. clickListener = function (e) { return _this.onBtApply(false, false, e); };
  11400. break;
  11401. case 'clear':
  11402. text = translate('clearFilter', 'Clear Filter');
  11403. clickListener = function () { return _this.onBtClear(); };
  11404. break;
  11405. case 'reset':
  11406. text = translate('resetFilter', 'Reset Filter');
  11407. clickListener = function () { return _this.onBtReset(); };
  11408. break;
  11409. case 'cancel':
  11410. text = translate('cancelFilter', 'Cancel Filter');
  11411. clickListener = function (e) { _this.onBtCancel(e); };
  11412. break;
  11413. default:
  11414. console.warn('Unknown button type specified');
  11415. return;
  11416. }
  11417. var button = loadTemplate(/* html */ "<button\n type=\"button\"\n ref=\"" + type + "FilterButton\"\n class=\"ag-standard-button ag-filter-apply-panel-button\">" + text + "</button>");
  11418. eButtonsPanel.appendChild(button);
  11419. _this.addManagedListener(button, 'click', clickListener);
  11420. };
  11421. new Set(buttons).forEach(function (type) { return addButton(type); });
  11422. this.getGui().appendChild(eButtonsPanel);
  11423. };
  11424. ProvidedFilter.checkForDeprecatedParams = function (params) {
  11425. var buttons = params.buttons || [];
  11426. if (buttons.length > 0) {
  11427. return;
  11428. }
  11429. var applyButton = params.applyButton, resetButton = params.resetButton, clearButton = params.clearButton;
  11430. if (clearButton) {
  11431. console.warn('ag-Grid: as of ag-Grid v23.2, filterParams.clearButton is deprecated. Please use filterParams.buttons instead');
  11432. buttons.push('clear');
  11433. }
  11434. if (resetButton) {
  11435. console.warn('ag-Grid: as of ag-Grid v23.2, filterParams.resetButton is deprecated. Please use filterParams.buttons instead');
  11436. buttons.push('reset');
  11437. }
  11438. if (applyButton) {
  11439. console.warn('ag-Grid: as of ag-Grid v23.2, filterParams.applyButton is deprecated. Please use filterParams.buttons instead');
  11440. buttons.push('apply');
  11441. }
  11442. if (params.apply) {
  11443. console.warn('ag-Grid: as of ag-Grid v21, filterParams.apply is deprecated. Please use filterParams.buttons instead');
  11444. buttons.push('apply');
  11445. }
  11446. params.buttons = buttons;
  11447. };
  11448. // subclasses can override this to provide alternative debounce defaults
  11449. ProvidedFilter.prototype.getDefaultDebounceMs = function () {
  11450. return 0;
  11451. };
  11452. ProvidedFilter.prototype.setupOnBtApplyDebounce = function () {
  11453. var debounceMs = ProvidedFilter.getDebounceMs(this.providedFilterParams, this.getDefaultDebounceMs());
  11454. this.onBtApplyDebounce = debounce(this.onBtApply.bind(this), debounceMs);
  11455. };
  11456. ProvidedFilter.prototype.getModel = function () {
  11457. return this.appliedModel;
  11458. };
  11459. ProvidedFilter.prototype.setModel = function (model) {
  11460. var _this = this;
  11461. var promise = model ? this.setModelIntoUi(model) : this.resetUiToDefaults();
  11462. return promise.then(function () {
  11463. _this.updateUiVisibility();
  11464. // we set the model from the gui, rather than the provided model,
  11465. // so the model is consistent. eg handling of null/undefined will be the same,
  11466. // of if model is case insensitive, then casing is removed.
  11467. _this.applyModel();
  11468. });
  11469. };
  11470. ProvidedFilter.prototype.onBtCancel = function (e) {
  11471. var _this = this;
  11472. this.setModelIntoUi(this.getModel()).then(function () {
  11473. _this.onUiChanged(false, 'prevent');
  11474. if (_this.providedFilterParams.closeOnApply) {
  11475. _this.close(e);
  11476. }
  11477. });
  11478. };
  11479. ProvidedFilter.prototype.onBtClear = function () {
  11480. var _this = this;
  11481. this.resetUiToDefaults().then(function () { return _this.onUiChanged(); });
  11482. };
  11483. ProvidedFilter.prototype.onBtReset = function () {
  11484. this.onBtClear();
  11485. this.onBtApply();
  11486. };
  11487. /**
  11488. * Applies changes made in the UI to the filter, and returns true if the model has changed.
  11489. */
  11490. ProvidedFilter.prototype.applyModel = function () {
  11491. var newModel = this.getModelFromUi();
  11492. if (!this.isModelValid(newModel)) {
  11493. return false;
  11494. }
  11495. var previousModel = this.appliedModel;
  11496. this.appliedModel = newModel;
  11497. // models can be same if user pasted same content into text field, or maybe just changed the case
  11498. // and it's a case insensitive filter
  11499. return !this.areModelsEqual(previousModel, newModel);
  11500. };
  11501. ProvidedFilter.prototype.isModelValid = function (model) {
  11502. return true;
  11503. };
  11504. ProvidedFilter.prototype.onBtApply = function (afterFloatingFilter, afterDataChange, e) {
  11505. if (afterFloatingFilter === void 0) { afterFloatingFilter = false; }
  11506. if (afterDataChange === void 0) { afterDataChange = false; }
  11507. if (this.applyModel()) {
  11508. // the floating filter uses 'afterFloatingFilter' info, so it doesn't refresh after filter changed if change
  11509. // came from floating filter
  11510. this.providedFilterParams.filterChangedCallback({ afterFloatingFilter: afterFloatingFilter, afterDataChange: afterDataChange });
  11511. }
  11512. var closeOnApply = this.providedFilterParams.closeOnApply;
  11513. // only close if an apply button is visible, otherwise we'd be closing every time a change was made!
  11514. if (closeOnApply && !afterFloatingFilter && this.applyActive) {
  11515. this.close(e);
  11516. }
  11517. };
  11518. ProvidedFilter.prototype.onNewRowsLoaded = function () {
  11519. var _this = this;
  11520. if (!this.newRowsActionKeep) {
  11521. this.resetUiToDefaults().then(function () { return _this.appliedModel = null; });
  11522. }
  11523. };
  11524. ProvidedFilter.prototype.close = function (e) {
  11525. if (!this.hidePopup) {
  11526. return;
  11527. }
  11528. var keyboardEvent = e;
  11529. var key = keyboardEvent && keyboardEvent.key;
  11530. var params;
  11531. if (key === 'Enter' || key === 'Space') {
  11532. params = { keyboardEvent: keyboardEvent };
  11533. }
  11534. this.hidePopup(params);
  11535. this.hidePopup = null;
  11536. };
  11537. // called by set filter
  11538. ProvidedFilter.prototype.isNewRowsActionKeep = function () {
  11539. return this.newRowsActionKeep;
  11540. };
  11541. /**
  11542. * By default, if the change came from a floating filter it will be applied immediately, otherwise if there is no
  11543. * apply button it will be applied after a debounce, otherwise it will not be applied at all. This behaviour can
  11544. * be adjusted by using the apply parameter.
  11545. */
  11546. ProvidedFilter.prototype.onUiChanged = function (fromFloatingFilter, apply) {
  11547. if (fromFloatingFilter === void 0) { fromFloatingFilter = false; }
  11548. this.updateUiVisibility();
  11549. this.providedFilterParams.filterModifiedCallback();
  11550. if (this.applyActive) {
  11551. var isValid = this.isModelValid(this.getModelFromUi());
  11552. setDisabled(this.getRefElement('applyFilterButton'), !isValid);
  11553. }
  11554. if ((fromFloatingFilter && !apply) || apply === 'immediately') {
  11555. this.onBtApply(fromFloatingFilter);
  11556. }
  11557. else if ((!this.applyActive && !apply) || apply === 'debounce') {
  11558. this.onBtApplyDebounce();
  11559. }
  11560. };
  11561. ProvidedFilter.prototype.afterGuiAttached = function (params) {
  11562. this.hidePopup = params.hidePopup;
  11563. };
  11564. // static, as used by floating filter also
  11565. ProvidedFilter.getDebounceMs = function (params, debounceDefault) {
  11566. if (ProvidedFilter.isUseApplyButton(params)) {
  11567. if (params.debounceMs != null) {
  11568. console.warn('ag-Grid: debounceMs is ignored when apply button is present');
  11569. }
  11570. return 0;
  11571. }
  11572. return params.debounceMs != null ? params.debounceMs : debounceDefault;
  11573. };
  11574. // static, as used by floating filter also
  11575. ProvidedFilter.isUseApplyButton = function (params) {
  11576. ProvidedFilter.checkForDeprecatedParams(params);
  11577. return params.buttons && params.buttons.indexOf('apply') >= 0;
  11578. };
  11579. ProvidedFilter.prototype.destroy = function () {
  11580. this.hidePopup = null;
  11581. _super.prototype.destroy.call(this);
  11582. };
  11583. __decorate$b([
  11584. Autowired('gridOptionsWrapper')
  11585. ], ProvidedFilter.prototype, "gridOptionsWrapper", void 0);
  11586. __decorate$b([
  11587. Autowired('rowModel')
  11588. ], ProvidedFilter.prototype, "rowModel", void 0);
  11589. __decorate$b([
  11590. PostConstruct
  11591. ], ProvidedFilter.prototype, "postConstruct", null);
  11592. return ProvidedFilter;
  11593. }(Component));
  11594. /**
  11595. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  11596. * @version v23.2.1
  11597. * @link http://www.ag-grid.com/
  11598. * @license MIT
  11599. */
  11600. var __extends$8 = (undefined && undefined.__extends) || (function () {
  11601. var extendStatics = function (d, b) {
  11602. extendStatics = Object.setPrototypeOf ||
  11603. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  11604. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  11605. return extendStatics(d, b);
  11606. };
  11607. return function (d, b) {
  11608. extendStatics(d, b);
  11609. function __() { this.constructor = d; }
  11610. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  11611. };
  11612. })();
  11613. var __decorate$c = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  11614. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  11615. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  11616. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  11617. return c > 3 && r && Object.defineProperty(target, key, r), r;
  11618. };
  11619. var ConditionPosition;
  11620. (function (ConditionPosition) {
  11621. ConditionPosition[ConditionPosition["One"] = 0] = "One";
  11622. ConditionPosition[ConditionPosition["Two"] = 1] = "Two";
  11623. })(ConditionPosition || (ConditionPosition = {}));
  11624. var DEFAULT_TRANSLATIONS = {
  11625. filterOoo: 'Filter...',
  11626. empty: 'Choose One',
  11627. equals: 'Equals',
  11628. notEqual: 'Not equal',
  11629. lessThan: 'Less than',
  11630. greaterThan: 'Greater than',
  11631. inRange: 'In range',
  11632. inRangeStart: 'From',
  11633. inRangeEnd: 'To',
  11634. lessThanOrEqual: 'Less than or equals',
  11635. greaterThanOrEqual: 'Greater than or equals',
  11636. contains: 'Contains',
  11637. notContains: 'Not contains',
  11638. startsWith: 'Starts with',
  11639. endsWith: 'Ends with',
  11640. andCondition: 'AND',
  11641. orCondition: 'OR',
  11642. };
  11643. /**
  11644. * Every filter with a dropdown where the user can specify a comparing type against the filter values
  11645. */
  11646. var SimpleFilter = /** @class */ (function (_super) {
  11647. __extends$8(SimpleFilter, _super);
  11648. function SimpleFilter() {
  11649. return _super !== null && _super.apply(this, arguments) || this;
  11650. }
  11651. // returns true if this type requires a 'from' field, eg any filter that requires at least one text value
  11652. SimpleFilter.prototype.showValueFrom = function (type) {
  11653. return !this.doesFilterHaveHiddenInput(type) && type !== SimpleFilter.EMPTY;
  11654. };
  11655. // returns true if this type requires a 'to' field, currently only 'range' returns true
  11656. SimpleFilter.prototype.showValueTo = function (type) {
  11657. return type === SimpleFilter.IN_RANGE;
  11658. };
  11659. // floating filter calls this when user applies filter from floating filter
  11660. SimpleFilter.prototype.onFloatingFilterChanged = function (type, value) {
  11661. this.setTypeFromFloatingFilter(type);
  11662. this.setValueFromFloatingFilter(value);
  11663. this.onUiChanged(true);
  11664. };
  11665. SimpleFilter.prototype.setTypeFromFloatingFilter = function (type) {
  11666. this.eType1.setValue(type);
  11667. this.eType2.setValue(this.optionsFactory.getDefaultOption());
  11668. this.eJoinOperatorAnd.setValue(true);
  11669. };
  11670. SimpleFilter.prototype.getModelFromUi = function () {
  11671. if (!this.isConditionUiComplete(ConditionPosition.One)) {
  11672. return null;
  11673. }
  11674. if (this.isAllowTwoConditions() && this.isConditionUiComplete(ConditionPosition.Two)) {
  11675. return {
  11676. filterType: this.getFilterType(),
  11677. operator: this.getJoinOperator(),
  11678. condition1: this.createCondition(ConditionPosition.One),
  11679. condition2: this.createCondition(ConditionPosition.Two)
  11680. };
  11681. }
  11682. return this.createCondition(ConditionPosition.One);
  11683. };
  11684. SimpleFilter.prototype.getCondition1Type = function () {
  11685. return this.eType1.getValue();
  11686. };
  11687. SimpleFilter.prototype.getCondition2Type = function () {
  11688. return this.eType2.getValue();
  11689. };
  11690. SimpleFilter.prototype.getJoinOperator = function () {
  11691. return this.eJoinOperatorOr.getValue() === true ? 'OR' : 'AND';
  11692. };
  11693. SimpleFilter.prototype.areModelsEqual = function (a, b) {
  11694. // both are missing
  11695. if (!a && !b) {
  11696. return true;
  11697. }
  11698. // one is missing, other present
  11699. if ((!a && b) || (a && !b)) {
  11700. return false;
  11701. }
  11702. // one is combined, the other is not
  11703. var aIsSimple = !a.operator;
  11704. var bIsSimple = !b.operator;
  11705. var oneSimpleOneCombined = (!aIsSimple && bIsSimple) || (aIsSimple && !bIsSimple);
  11706. if (oneSimpleOneCombined) {
  11707. return false;
  11708. }
  11709. var res;
  11710. // otherwise both present, so compare
  11711. if (aIsSimple) {
  11712. var aSimple = a;
  11713. var bSimple = b;
  11714. res = this.areSimpleModelsEqual(aSimple, bSimple);
  11715. }
  11716. else {
  11717. var aCombined = a;
  11718. var bCombined = b;
  11719. res = aCombined.operator === bCombined.operator
  11720. && this.areSimpleModelsEqual(aCombined.condition1, bCombined.condition1)
  11721. && this.areSimpleModelsEqual(aCombined.condition2, bCombined.condition2);
  11722. }
  11723. return res;
  11724. };
  11725. SimpleFilter.prototype.setModelIntoUi = function (model) {
  11726. var isCombined = model.operator;
  11727. if (isCombined) {
  11728. var combinedModel = model;
  11729. var orChecked = combinedModel.operator === 'OR';
  11730. this.eJoinOperatorAnd.setValue(!orChecked);
  11731. this.eJoinOperatorOr.setValue(orChecked);
  11732. this.eType1.setValue(combinedModel.condition1.type);
  11733. this.eType2.setValue(combinedModel.condition2.type);
  11734. this.setConditionIntoUi(combinedModel.condition1, ConditionPosition.One);
  11735. this.setConditionIntoUi(combinedModel.condition2, ConditionPosition.Two);
  11736. }
  11737. else {
  11738. var simpleModel = model;
  11739. this.eJoinOperatorAnd.setValue(true);
  11740. this.eJoinOperatorOr.setValue(false);
  11741. this.eType1.setValue(simpleModel.type);
  11742. this.eType2.setValue(this.optionsFactory.getDefaultOption());
  11743. this.setConditionIntoUi(simpleModel, ConditionPosition.One);
  11744. this.setConditionIntoUi(null, ConditionPosition.Two);
  11745. }
  11746. return Promise.resolve();
  11747. };
  11748. SimpleFilter.prototype.doesFilterPass = function (params) {
  11749. var model = this.getModel();
  11750. var isCombined = model.operator;
  11751. if (isCombined) {
  11752. var combinedModel = model;
  11753. var firstResult = this.individualConditionPasses(params, combinedModel.condition1);
  11754. var secondResult = this.individualConditionPasses(params, combinedModel.condition2);
  11755. if (combinedModel.operator === 'AND') {
  11756. return firstResult && secondResult;
  11757. }
  11758. return firstResult || secondResult;
  11759. }
  11760. var simpleModel = model;
  11761. var result = this.individualConditionPasses(params, simpleModel);
  11762. return result;
  11763. };
  11764. SimpleFilter.prototype.setParams = function (params) {
  11765. _super.prototype.setParams.call(this, params);
  11766. this.optionsFactory = new OptionsFactory();
  11767. this.optionsFactory.init(params, this.getDefaultFilterOptions());
  11768. this.allowTwoConditions = !params.suppressAndOrCondition;
  11769. this.putOptionsIntoDropdown();
  11770. this.addChangedListeners();
  11771. };
  11772. SimpleFilter.prototype.putOptionsIntoDropdown = function () {
  11773. var _this = this;
  11774. var filterOptions = this.optionsFactory.getFilterOptions();
  11775. forEach(filterOptions, function (option) {
  11776. var value;
  11777. var text;
  11778. if (typeof option === 'string') {
  11779. value = option;
  11780. text = _this.translate(value);
  11781. }
  11782. else {
  11783. value = option.displayKey;
  11784. var customOption = _this.optionsFactory.getCustomOption(value);
  11785. text = customOption ? customOption.displayName : _this.translate(value);
  11786. }
  11787. var createOption = function () { return ({ value: value, text: text }); };
  11788. _this.eType1.addOption(createOption());
  11789. _this.eType2.addOption(createOption());
  11790. });
  11791. var readOnly = filterOptions.length <= 1;
  11792. this.eType1.setDisabled(readOnly);
  11793. this.eType2.setDisabled(readOnly);
  11794. };
  11795. SimpleFilter.prototype.isAllowTwoConditions = function () {
  11796. return this.allowTwoConditions;
  11797. };
  11798. SimpleFilter.prototype.createBodyTemplate = function () {
  11799. return /* html */ "\n <ag-select class=\"ag-filter-select\" ref=\"eOptions1\"></ag-select>\n " + this.createValueTemplate(ConditionPosition.One) + "\n <div class=\"ag-filter-condition\" ref=\"eJoinOperatorPanel\">\n <ag-radio-button ref=\"eJoinOperatorAnd\" class=\"ag-filter-condition-operator ag-filter-condition-operator-and\"></ag-radio-button>\n <ag-radio-button ref=\"eJoinOperatorOr\" class=\"ag-filter-condition-operator ag-filter-condition-operator-or\"></ag-radio-button>\n </div>\n <ag-select class=\"ag-filter-select\" ref=\"eOptions2\"></ag-select>\n " + this.createValueTemplate(ConditionPosition.Two);
  11800. };
  11801. SimpleFilter.prototype.getCssIdentifier = function () {
  11802. return 'simple-filter';
  11803. };
  11804. SimpleFilter.prototype.updateUiVisibility = function () {
  11805. var firstConditionComplete = this.isConditionUiComplete(ConditionPosition.One);
  11806. var showSecondFilter = this.allowTwoConditions && firstConditionComplete;
  11807. setDisplayed(this.eCondition2Body, showSecondFilter);
  11808. setDisplayed(this.eType2.getGui(), showSecondFilter);
  11809. setDisplayed(this.eJoinOperatorPanel, showSecondFilter);
  11810. };
  11811. SimpleFilter.prototype.resetUiToDefaults = function (silent) {
  11812. var uniqueGroupId = 'ag-simple-filter-and-or-' + this.getCompId();
  11813. var defaultOption = this.optionsFactory.getDefaultOption();
  11814. this.eType1.setValue(defaultOption, silent);
  11815. this.eType2.setValue(defaultOption, silent);
  11816. this.eJoinOperatorAnd
  11817. .setValue(true, silent)
  11818. .setName(uniqueGroupId)
  11819. .setLabel(this.translate('andCondition'));
  11820. this.eJoinOperatorOr
  11821. .setValue(false, silent)
  11822. .setName(uniqueGroupId)
  11823. .setLabel(this.translate('orCondition'));
  11824. return Promise.resolve();
  11825. };
  11826. SimpleFilter.prototype.translate = function (toTranslate) {
  11827. var translate = this.gridOptionsWrapper.getLocaleTextFunc();
  11828. return translate(toTranslate, DEFAULT_TRANSLATIONS[toTranslate]);
  11829. };
  11830. SimpleFilter.prototype.addChangedListeners = function () {
  11831. var _this = this;
  11832. var listener = function () { return _this.onUiChanged(); };
  11833. this.eType1.onValueChange(listener);
  11834. this.eType2.onValueChange(listener);
  11835. this.eJoinOperatorOr.onValueChange(listener);
  11836. this.eJoinOperatorAnd.onValueChange(listener);
  11837. };
  11838. SimpleFilter.prototype.doesFilterHaveHiddenInput = function (filterType) {
  11839. var customFilterOption = this.optionsFactory.getCustomOption(filterType);
  11840. return customFilterOption && customFilterOption.hideFilterInput;
  11841. };
  11842. SimpleFilter.EMPTY = 'empty';
  11843. SimpleFilter.EQUALS = 'equals';
  11844. SimpleFilter.NOT_EQUAL = 'notEqual';
  11845. SimpleFilter.LESS_THAN = 'lessThan';
  11846. SimpleFilter.LESS_THAN_OR_EQUAL = 'lessThanOrEqual';
  11847. SimpleFilter.GREATER_THAN = 'greaterThan';
  11848. SimpleFilter.GREATER_THAN_OR_EQUAL = 'greaterThanOrEqual';
  11849. SimpleFilter.IN_RANGE = 'inRange';
  11850. SimpleFilter.CONTAINS = 'contains';
  11851. SimpleFilter.NOT_CONTAINS = 'notContains';
  11852. SimpleFilter.STARTS_WITH = 'startsWith';
  11853. SimpleFilter.ENDS_WITH = 'endsWith';
  11854. __decorate$c([
  11855. RefSelector('eOptions1')
  11856. ], SimpleFilter.prototype, "eType1", void 0);
  11857. __decorate$c([
  11858. RefSelector('eOptions2')
  11859. ], SimpleFilter.prototype, "eType2", void 0);
  11860. __decorate$c([
  11861. RefSelector('eJoinOperatorAnd')
  11862. ], SimpleFilter.prototype, "eJoinOperatorAnd", void 0);
  11863. __decorate$c([
  11864. RefSelector('eJoinOperatorOr')
  11865. ], SimpleFilter.prototype, "eJoinOperatorOr", void 0);
  11866. __decorate$c([
  11867. RefSelector('eCondition2Body')
  11868. ], SimpleFilter.prototype, "eCondition2Body", void 0);
  11869. __decorate$c([
  11870. RefSelector('eJoinOperatorPanel')
  11871. ], SimpleFilter.prototype, "eJoinOperatorPanel", void 0);
  11872. return SimpleFilter;
  11873. }(ProvidedFilter));
  11874. /**
  11875. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  11876. * @version v23.2.1
  11877. * @link http://www.ag-grid.com/
  11878. * @license MIT
  11879. */
  11880. var __extends$9 = (undefined && undefined.__extends) || (function () {
  11881. var extendStatics = function (d, b) {
  11882. extendStatics = Object.setPrototypeOf ||
  11883. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  11884. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  11885. return extendStatics(d, b);
  11886. };
  11887. return function (d, b) {
  11888. extendStatics(d, b);
  11889. function __() { this.constructor = d; }
  11890. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  11891. };
  11892. })();
  11893. var ScalarFilter = /** @class */ (function (_super) {
  11894. __extends$9(ScalarFilter, _super);
  11895. function ScalarFilter() {
  11896. return _super !== null && _super.apply(this, arguments) || this;
  11897. }
  11898. ScalarFilter.prototype.setParams = function (params) {
  11899. _super.prototype.setParams.call(this, params);
  11900. this.scalarFilterParams = params;
  11901. this.checkDeprecatedParams();
  11902. };
  11903. ScalarFilter.prototype.checkDeprecatedParams = function () {
  11904. if (this.scalarFilterParams.nullComparator) {
  11905. console.warn('ag-Grid: Since v21.0, the property filterParams.nullComparator is deprecated. ' +
  11906. 'Please use filterParams.includeBlanksInEquals, filterParams.includeBlanksInLessThan and ' +
  11907. 'filterParams.includeBlanksInGreaterThan instead.');
  11908. this.scalarFilterParams.includeBlanksInEquals = this.scalarFilterParams.nullComparator.equals;
  11909. this.scalarFilterParams.includeBlanksInLessThan = this.scalarFilterParams.nullComparator.lessThan;
  11910. this.scalarFilterParams.includeBlanksInGreaterThan = this.scalarFilterParams.nullComparator.greaterThan;
  11911. }
  11912. };
  11913. ScalarFilter.prototype.nullComparator = function (selectedOption, filterValue, gridValue) {
  11914. if (gridValue == null) {
  11915. switch (selectedOption) {
  11916. case ScalarFilter.EMPTY:
  11917. return 0;
  11918. case ScalarFilter.EQUALS:
  11919. return this.scalarFilterParams.includeBlanksInEquals ? 0 : 1;
  11920. case ScalarFilter.NOT_EQUAL:
  11921. return this.scalarFilterParams.includeBlanksInEquals ? 1 : 0;
  11922. case ScalarFilter.GREATER_THAN:
  11923. case ScalarFilter.GREATER_THAN_OR_EQUAL:
  11924. return this.scalarFilterParams.includeBlanksInGreaterThan ? 1 : -1;
  11925. case ScalarFilter.LESS_THAN:
  11926. case ScalarFilter.LESS_THAN_OR_EQUAL:
  11927. return this.scalarFilterParams.includeBlanksInLessThan ? -1 : 1;
  11928. }
  11929. }
  11930. return this.comparator()(filterValue, gridValue);
  11931. };
  11932. ScalarFilter.prototype.individualConditionPasses = function (params, filterModel) {
  11933. var cellValue = this.scalarFilterParams.valueGetter(params.node);
  11934. var range = this.mapRangeFromModel(filterModel);
  11935. var filterValue = range.from;
  11936. var filterValueTo = range.to;
  11937. var filterType = filterModel.type;
  11938. var customFilterOption = this.optionsFactory.getCustomOption(filterType);
  11939. if (customFilterOption) {
  11940. // only execute the custom filter if a value exists or a value isn't required, i.e. input is hidden
  11941. if (filterValue != null || customFilterOption.hideFilterInput) {
  11942. return customFilterOption.test(filterValue, cellValue);
  11943. }
  11944. }
  11945. var compareResult = this.nullComparator(filterType, filterValue, cellValue);
  11946. switch (filterType) {
  11947. case ScalarFilter.EQUALS:
  11948. return compareResult === 0;
  11949. case ScalarFilter.NOT_EQUAL:
  11950. return compareResult !== 0;
  11951. case ScalarFilter.GREATER_THAN:
  11952. return compareResult > 0;
  11953. case ScalarFilter.GREATER_THAN_OR_EQUAL:
  11954. return compareResult >= 0;
  11955. case ScalarFilter.LESS_THAN:
  11956. return compareResult < 0;
  11957. case ScalarFilter.LESS_THAN_OR_EQUAL:
  11958. return compareResult <= 0;
  11959. case ScalarFilter.IN_RANGE: {
  11960. var compareToResult = this.nullComparator(filterType, filterValueTo, cellValue);
  11961. return this.scalarFilterParams.inRangeInclusive ?
  11962. compareResult >= 0 && compareToResult <= 0 :
  11963. compareResult > 0 && compareToResult < 0;
  11964. }
  11965. default:
  11966. throw new Error('Unexpected type of filter: ' + filterType);
  11967. }
  11968. };
  11969. return ScalarFilter;
  11970. }(SimpleFilter));
  11971. /**
  11972. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  11973. * @version v23.2.1
  11974. * @link http://www.ag-grid.com/
  11975. * @license MIT
  11976. */
  11977. var __extends$a = (undefined && undefined.__extends) || (function () {
  11978. var extendStatics = function (d, b) {
  11979. extendStatics = Object.setPrototypeOf ||
  11980. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  11981. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  11982. return extendStatics(d, b);
  11983. };
  11984. return function (d, b) {
  11985. extendStatics(d, b);
  11986. function __() { this.constructor = d; }
  11987. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  11988. };
  11989. })();
  11990. var __decorate$d = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  11991. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  11992. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  11993. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  11994. return c > 3 && r && Object.defineProperty(target, key, r), r;
  11995. };
  11996. var DateFilter = /** @class */ (function (_super) {
  11997. __extends$a(DateFilter, _super);
  11998. function DateFilter() {
  11999. return _super !== null && _super.apply(this, arguments) || this;
  12000. }
  12001. DateFilter.prototype.mapRangeFromModel = function (filterModel) {
  12002. // unlike the other filters, we do two things here:
  12003. // 1) allow for different attribute names (same as done for other filters) (eg the 'from' and 'to'
  12004. // are in different locations in Date and Number filter models)
  12005. // 2) convert the type (because Date filter uses Dates, however model is 'string')
  12006. //
  12007. // NOTE: The conversion of string to date also removes the timezone - i.e. when user picks
  12008. // a date from the UI, it will have timezone info in it. This is lost when creating
  12009. // the model. When we recreate the date again here, it's without a timezone.
  12010. return {
  12011. from: parseDateTimeFromString(filterModel.dateFrom),
  12012. to: parseDateTimeFromString(filterModel.dateTo)
  12013. };
  12014. };
  12015. DateFilter.prototype.setValueFromFloatingFilter = function (value) {
  12016. if (value != null) {
  12017. var dateFrom = parseDateTimeFromString(value);
  12018. this.dateCondition1FromComp.setDate(dateFrom);
  12019. }
  12020. else {
  12021. this.dateCondition1FromComp.setDate(null);
  12022. }
  12023. this.dateCondition1ToComp.setDate(null);
  12024. this.dateCondition2FromComp.setDate(null);
  12025. this.dateCondition2ToComp.setDate(null);
  12026. };
  12027. DateFilter.prototype.setConditionIntoUi = function (model, position) {
  12028. var _a = model ?
  12029. [parseDateTimeFromString(model.dateFrom), parseDateTimeFromString(model.dateTo)] :
  12030. [null, null], dateFrom = _a[0], dateTo = _a[1];
  12031. var _b = this.getFromToComponents(position), compFrom = _b[0], compTo = _b[1];
  12032. compFrom.setDate(dateFrom);
  12033. compTo.setDate(dateTo);
  12034. };
  12035. DateFilter.prototype.resetUiToDefaults = function (silent) {
  12036. var _this = this;
  12037. return _super.prototype.resetUiToDefaults.call(this, silent).then(function () {
  12038. _this.dateCondition1FromComp.setDate(null);
  12039. _this.dateCondition1ToComp.setDate(null);
  12040. _this.dateCondition2FromComp.setDate(null);
  12041. _this.dateCondition2ToComp.setDate(null);
  12042. });
  12043. };
  12044. DateFilter.prototype.comparator = function () {
  12045. return this.dateFilterParams.comparator ? this.dateFilterParams.comparator : this.defaultComparator.bind(this);
  12046. };
  12047. DateFilter.prototype.defaultComparator = function (filterDate, cellValue) {
  12048. // The default comparator assumes that the cellValue is a date
  12049. var cellAsDate = cellValue;
  12050. if (cellValue == null || cellAsDate < filterDate) {
  12051. return -1;
  12052. }
  12053. if (cellAsDate > filterDate) {
  12054. return 1;
  12055. }
  12056. return 0;
  12057. };
  12058. DateFilter.prototype.setParams = function (params) {
  12059. _super.prototype.setParams.call(this, params);
  12060. this.dateFilterParams = params;
  12061. this.createDateComponents();
  12062. };
  12063. DateFilter.prototype.createDateComponents = function () {
  12064. var _this = this;
  12065. // params to pass to all four date comps
  12066. var dateComponentParams = {
  12067. onDateChanged: function () { return _this.onUiChanged(); },
  12068. filterParams: this.dateFilterParams
  12069. };
  12070. this.dateCondition1FromComp = new DateCompWrapper(this.getContext(), this.userComponentFactory, dateComponentParams, this.eCondition1PanelFrom);
  12071. this.dateCondition1ToComp = new DateCompWrapper(this.getContext(), this.userComponentFactory, dateComponentParams, this.eCondition1PanelTo);
  12072. this.dateCondition2FromComp = new DateCompWrapper(this.getContext(), this.userComponentFactory, dateComponentParams, this.eCondition2PanelFrom);
  12073. this.dateCondition2ToComp = new DateCompWrapper(this.getContext(), this.userComponentFactory, dateComponentParams, this.eCondition2PanelTo);
  12074. this.addDestroyFunc(function () {
  12075. _this.dateCondition1FromComp.destroy();
  12076. _this.dateCondition1ToComp.destroy();
  12077. _this.dateCondition2FromComp.destroy();
  12078. _this.dateCondition2ToComp.destroy();
  12079. });
  12080. };
  12081. DateFilter.prototype.getDefaultFilterOptions = function () {
  12082. return DateFilter.DEFAULT_FILTER_OPTIONS;
  12083. };
  12084. DateFilter.prototype.createValueTemplate = function (position) {
  12085. var pos = position === ConditionPosition.One ? '1' : '2';
  12086. return /* html */ "\n <div class=\"ag-filter-body\" ref=\"eCondition" + pos + "Body\">\n <div class=\"ag-filter-from ag-filter-date-from\" ref=\"eCondition" + pos + "PanelFrom\">\n </div>\n <div class=\"ag-filter-to ag-filter-date-to\" ref=\"eCondition" + pos + "PanelTo\">\n </div>\n </div>";
  12087. };
  12088. DateFilter.prototype.isConditionUiComplete = function (position) {
  12089. var positionOne = position === ConditionPosition.One;
  12090. var option = positionOne ? this.getCondition1Type() : this.getCondition2Type();
  12091. if (option === SimpleFilter.EMPTY) {
  12092. return false;
  12093. }
  12094. if (this.doesFilterHaveHiddenInput(option)) {
  12095. return true;
  12096. }
  12097. var _a = this.getFromToComponents(position), compFrom = _a[0], compTo = _a[1];
  12098. return compFrom.getDate() != null && (option !== SimpleFilter.IN_RANGE || compTo.getDate() != null);
  12099. };
  12100. DateFilter.prototype.areSimpleModelsEqual = function (aSimple, bSimple) {
  12101. return aSimple.dateFrom === bSimple.dateFrom
  12102. && aSimple.dateTo === bSimple.dateTo
  12103. && aSimple.type === bSimple.type;
  12104. };
  12105. // needed for creating filter model
  12106. DateFilter.prototype.getFilterType = function () {
  12107. return DateFilter.FILTER_TYPE;
  12108. };
  12109. DateFilter.prototype.createCondition = function (position) {
  12110. var positionOne = position === ConditionPosition.One;
  12111. var type = positionOne ? this.getCondition1Type() : this.getCondition2Type();
  12112. var _a = this.getFromToComponents(position), compFrom = _a[0], compTo = _a[1];
  12113. return {
  12114. dateFrom: serialiseDate(compFrom.getDate()),
  12115. dateTo: serialiseDate(compTo.getDate()),
  12116. type: type,
  12117. filterType: DateFilter.FILTER_TYPE
  12118. };
  12119. };
  12120. DateFilter.prototype.resetPlaceholder = function () {
  12121. var translate = this.gridOptionsWrapper.getLocaleTextFunc();
  12122. var placeholder = translate('dateFormatOoo', 'yyyy-mm-dd');
  12123. this.dateCondition1FromComp.setInputPlaceholder(placeholder);
  12124. this.dateCondition1ToComp.setInputPlaceholder(placeholder);
  12125. this.dateCondition2FromComp.setInputPlaceholder(placeholder);
  12126. this.dateCondition2ToComp.setInputPlaceholder(placeholder);
  12127. };
  12128. DateFilter.prototype.updateUiVisibility = function () {
  12129. _super.prototype.updateUiVisibility.call(this);
  12130. this.resetPlaceholder();
  12131. var condition1Type = this.getCondition1Type();
  12132. setDisplayed(this.eCondition1PanelFrom, this.showValueFrom(condition1Type));
  12133. setDisplayed(this.eCondition1PanelTo, this.showValueTo(condition1Type));
  12134. var condition2Type = this.getCondition2Type();
  12135. setDisplayed(this.eCondition2PanelFrom, this.showValueFrom(condition2Type));
  12136. setDisplayed(this.eCondition2PanelTo, this.showValueTo(condition2Type));
  12137. };
  12138. DateFilter.prototype.getFromToComponents = function (position) {
  12139. return position === ConditionPosition.One ?
  12140. [this.dateCondition1FromComp, this.dateCondition1ToComp] :
  12141. [this.dateCondition2FromComp, this.dateCondition2ToComp];
  12142. };
  12143. DateFilter.FILTER_TYPE = 'date';
  12144. DateFilter.DEFAULT_FILTER_OPTIONS = [
  12145. ScalarFilter.EQUALS,
  12146. ScalarFilter.GREATER_THAN,
  12147. ScalarFilter.LESS_THAN,
  12148. ScalarFilter.NOT_EQUAL,
  12149. ScalarFilter.IN_RANGE
  12150. ];
  12151. __decorate$d([
  12152. RefSelector('eCondition1PanelFrom')
  12153. ], DateFilter.prototype, "eCondition1PanelFrom", void 0);
  12154. __decorate$d([
  12155. RefSelector('eCondition1PanelTo')
  12156. ], DateFilter.prototype, "eCondition1PanelTo", void 0);
  12157. __decorate$d([
  12158. RefSelector('eCondition2PanelFrom')
  12159. ], DateFilter.prototype, "eCondition2PanelFrom", void 0);
  12160. __decorate$d([
  12161. RefSelector('eCondition2PanelTo')
  12162. ], DateFilter.prototype, "eCondition2PanelTo", void 0);
  12163. __decorate$d([
  12164. Autowired('userComponentFactory')
  12165. ], DateFilter.prototype, "userComponentFactory", void 0);
  12166. return DateFilter;
  12167. }(ScalarFilter));
  12168. /**
  12169. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  12170. * @version v23.2.1
  12171. * @link http://www.ag-grid.com/
  12172. * @license MIT
  12173. */
  12174. var TouchListener = /** @class */ (function () {
  12175. function TouchListener(eElement, preventMouseClick) {
  12176. var _this = this;
  12177. if (preventMouseClick === void 0) { preventMouseClick = false; }
  12178. this.destroyFuncs = [];
  12179. this.touching = false;
  12180. this.eventService = new EventService();
  12181. this.eElement = eElement;
  12182. this.preventMouseClick = preventMouseClick;
  12183. var startListener = this.onTouchStart.bind(this);
  12184. var moveListener = this.onTouchMove.bind(this);
  12185. var endListener = this.onTouchEnd.bind(this);
  12186. this.eElement.addEventListener("touchstart", startListener, { passive: true });
  12187. this.eElement.addEventListener("touchmove", moveListener, { passive: true });
  12188. // we set passive=false, as we want to prevent default on this event
  12189. this.eElement.addEventListener("touchend", endListener, { passive: false });
  12190. this.destroyFuncs.push(function () {
  12191. _this.eElement.removeEventListener("touchstart", startListener, { passive: true });
  12192. _this.eElement.removeEventListener("touchmove", moveListener, { passive: true });
  12193. _this.eElement.removeEventListener("touchend", endListener, { passive: false });
  12194. });
  12195. }
  12196. TouchListener.prototype.getActiveTouch = function (touchList) {
  12197. for (var i = 0; i < touchList.length; i++) {
  12198. var matches = touchList[i].identifier === this.touchStart.identifier;
  12199. if (matches) {
  12200. return touchList[i];
  12201. }
  12202. }
  12203. return null;
  12204. };
  12205. TouchListener.prototype.addEventListener = function (eventType, listener) {
  12206. this.eventService.addEventListener(eventType, listener);
  12207. };
  12208. TouchListener.prototype.removeEventListener = function (eventType, listener) {
  12209. this.eventService.removeEventListener(eventType, listener);
  12210. };
  12211. TouchListener.prototype.onTouchStart = function (touchEvent) {
  12212. var _this = this;
  12213. // only looking at one touch point at any time
  12214. if (this.touching) {
  12215. return;
  12216. }
  12217. this.touchStart = touchEvent.touches[0];
  12218. this.touching = true;
  12219. this.moved = false;
  12220. var touchStartCopy = this.touchStart;
  12221. window.setTimeout(function () {
  12222. var touchesMatch = _this.touchStart === touchStartCopy;
  12223. if (_this.touching && touchesMatch && !_this.moved) {
  12224. _this.moved = true;
  12225. var event_1 = {
  12226. type: TouchListener.EVENT_LONG_TAP,
  12227. touchStart: _this.touchStart,
  12228. touchEvent: touchEvent
  12229. };
  12230. _this.eventService.dispatchEvent(event_1);
  12231. }
  12232. }, 500);
  12233. };
  12234. TouchListener.prototype.onTouchMove = function (touchEvent) {
  12235. if (!this.touching) {
  12236. return;
  12237. }
  12238. var touch = this.getActiveTouch(touchEvent.touches);
  12239. if (!touch) {
  12240. return;
  12241. }
  12242. var eventIsFarAway = !_.areEventsNear(touch, this.touchStart, 4);
  12243. if (eventIsFarAway) {
  12244. this.moved = true;
  12245. }
  12246. };
  12247. TouchListener.prototype.onTouchEnd = function (touchEvent) {
  12248. if (!this.touching) {
  12249. return;
  12250. }
  12251. if (!this.moved) {
  12252. var event_2 = {
  12253. type: TouchListener.EVENT_TAP,
  12254. touchStart: this.touchStart
  12255. };
  12256. this.eventService.dispatchEvent(event_2);
  12257. this.checkForDoubleTap();
  12258. }
  12259. // stops the tap from also been processed as a mouse click
  12260. if (this.preventMouseClick) {
  12261. touchEvent.preventDefault();
  12262. }
  12263. this.touching = false;
  12264. };
  12265. TouchListener.prototype.checkForDoubleTap = function () {
  12266. var now = new Date().getTime();
  12267. if (this.lastTapTime && this.lastTapTime > 0) {
  12268. // if previous tap, see if duration is short enough to be considered double tap
  12269. var interval = now - this.lastTapTime;
  12270. if (interval > TouchListener.DOUBLE_TAP_MILLIS) {
  12271. // dispatch double tap event
  12272. var event_3 = {
  12273. type: TouchListener.EVENT_DOUBLE_TAP,
  12274. touchStart: this.touchStart
  12275. };
  12276. this.eventService.dispatchEvent(event_3);
  12277. // this stops a tripple tap ending up as two double taps
  12278. this.lastTapTime = null;
  12279. }
  12280. else {
  12281. this.lastTapTime = now;
  12282. }
  12283. }
  12284. else {
  12285. this.lastTapTime = now;
  12286. }
  12287. };
  12288. TouchListener.prototype.destroy = function () {
  12289. this.destroyFuncs.forEach(function (func) { return func(); });
  12290. };
  12291. TouchListener.EVENT_TAP = "tap";
  12292. TouchListener.EVENT_DOUBLE_TAP = "doubleTap";
  12293. TouchListener.EVENT_LONG_TAP = "longTap";
  12294. TouchListener.DOUBLE_TAP_MILLIS = 500;
  12295. return TouchListener;
  12296. }());
  12297. /**
  12298. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  12299. * @version v23.2.1
  12300. * @link http://www.ag-grid.com/
  12301. * @license MIT
  12302. */
  12303. var __extends$b = (undefined && undefined.__extends) || (function () {
  12304. var extendStatics = function (d, b) {
  12305. extendStatics = Object.setPrototypeOf ||
  12306. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  12307. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  12308. return extendStatics(d, b);
  12309. };
  12310. return function (d, b) {
  12311. extendStatics(d, b);
  12312. function __() { this.constructor = d; }
  12313. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  12314. };
  12315. })();
  12316. var __decorate$e = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  12317. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  12318. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  12319. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  12320. return c > 3 && r && Object.defineProperty(target, key, r), r;
  12321. };
  12322. var HeaderComp = /** @class */ (function (_super) {
  12323. __extends$b(HeaderComp, _super);
  12324. function HeaderComp() {
  12325. var _this = _super !== null && _super.apply(this, arguments) || this;
  12326. _this.lastMovingChanged = 0;
  12327. return _this;
  12328. }
  12329. // this is a user component, and IComponent has "public destroy()" as part of the interface.
  12330. // so we need to override destroy() just to make the method public.
  12331. HeaderComp.prototype.destroy = function () {
  12332. _super.prototype.destroy.call(this);
  12333. };
  12334. HeaderComp.prototype.init = function (params) {
  12335. var template = _.firstExistingValue(params.template, HeaderComp.TEMPLATE);
  12336. // take account of any newlines & whitespace before/after the actual template
  12337. template = template && template.trim ? template.trim() : template;
  12338. this.setTemplate(template);
  12339. this.params = params;
  12340. this.setupTap();
  12341. this.setupIcons(params.column);
  12342. this.setupMenu();
  12343. this.setupSort();
  12344. this.setupFilterIcon();
  12345. this.setupText(params.displayName);
  12346. };
  12347. HeaderComp.prototype.setupText = function (displayName) {
  12348. var displayNameSanitised = _.escape(displayName);
  12349. if (this.eText) {
  12350. this.eText.innerHTML = displayNameSanitised;
  12351. }
  12352. };
  12353. HeaderComp.prototype.setupIcons = function (column) {
  12354. this.addInIcon('sortAscending', this.eSortAsc, column);
  12355. this.addInIcon('sortDescending', this.eSortDesc, column);
  12356. this.addInIcon('sortUnSort', this.eSortNone, column);
  12357. this.addInIcon('menu', this.eMenu, column);
  12358. this.addInIcon('filter', this.eFilter, column);
  12359. };
  12360. HeaderComp.prototype.addInIcon = function (iconName, eParent, column) {
  12361. if (eParent == null) {
  12362. return;
  12363. }
  12364. var eIcon = _.createIconNoSpan(iconName, this.gridOptionsWrapper, column);
  12365. eParent.appendChild(eIcon);
  12366. };
  12367. HeaderComp.prototype.setupTap = function () {
  12368. var _this = this;
  12369. var options = this.gridOptionsWrapper;
  12370. if (options.isSuppressTouch()) {
  12371. return;
  12372. }
  12373. var touchListener = new TouchListener(this.getGui(), true);
  12374. var suppressMenuHide = options.isSuppressMenuHide();
  12375. var tapMenuButton = suppressMenuHide && _.exists(this.eMenu);
  12376. var menuTouchListener = tapMenuButton ? new TouchListener(this.eMenu, true) : touchListener;
  12377. if (this.params.enableMenu) {
  12378. var eventType = tapMenuButton ? 'EVENT_TAP' : 'EVENT_LONG_TAP';
  12379. var showMenuFn = function (event) {
  12380. options.getApi().showColumnMenuAfterMouseClick(_this.params.column, event.touchStart);
  12381. };
  12382. this.addManagedListener(menuTouchListener, TouchListener[eventType], showMenuFn);
  12383. }
  12384. if (this.params.enableSorting) {
  12385. var tapListener = function (event) {
  12386. var target = event.touchStart.target;
  12387. // When suppressMenuHide is true, a tap on the menu icon will bubble up
  12388. // to the header container, in that case we should not sort
  12389. if (suppressMenuHide && _this.eMenu.contains(target)) {
  12390. return;
  12391. }
  12392. _this.sortController.progressSort(_this.params.column, false, "uiColumnSorted");
  12393. };
  12394. this.addManagedListener(touchListener, TouchListener.EVENT_TAP, tapListener);
  12395. }
  12396. // if tapMenuButton is true `touchListener` and `menuTouchListener` are different
  12397. // so we need to make sure to destroy both listeners here
  12398. this.addDestroyFunc(function () { return touchListener.destroy(); });
  12399. if (tapMenuButton) {
  12400. this.addDestroyFunc(function () { return menuTouchListener.destroy(); });
  12401. }
  12402. };
  12403. HeaderComp.prototype.setupMenu = function () {
  12404. var _this = this;
  12405. // if no menu provided in template, do nothing
  12406. if (!this.eMenu) {
  12407. return;
  12408. }
  12409. // we don't show the menu if on an iPad/iPhone, as the user cannot have a pointer device
  12410. // Note: If suppressMenuHide is set to true the menu will be displayed, and if suppressMenuHide
  12411. // is false (default) user will need to use longpress to display the menu.
  12412. var suppressMenuHide = this.gridOptionsWrapper.isSuppressMenuHide();
  12413. var hideShowMenu = !this.params.enableMenu || (_.isIOSUserAgent() && !suppressMenuHide);
  12414. if (hideShowMenu) {
  12415. _.removeFromParent(this.eMenu);
  12416. return;
  12417. }
  12418. this.addManagedListener(this.eMenu, 'click', function () { return _this.showMenu(_this.eMenu); });
  12419. if (!suppressMenuHide) {
  12420. this.eMenu.style.opacity = '0';
  12421. }
  12422. var style = this.eMenu.style;
  12423. style.transition = 'opacity 0.2s, border 0.2s';
  12424. style['-webkit-transition'] = 'opacity 0.2s, border 0.2s';
  12425. };
  12426. HeaderComp.prototype.setActiveParent = function (activeParent) {
  12427. if (!this.gridOptionsWrapper.isSuppressMenuHide()) {
  12428. this.eMenu.style.opacity = activeParent ? '1' : '0';
  12429. }
  12430. };
  12431. HeaderComp.prototype.showMenu = function (eventSource) {
  12432. if (!eventSource) {
  12433. eventSource = this.eMenu;
  12434. }
  12435. this.menuFactory.showMenuAfterButtonClick(this.params.column, eventSource);
  12436. };
  12437. HeaderComp.prototype.removeSortIcons = function () {
  12438. _.removeFromParent(this.eSortAsc);
  12439. _.removeFromParent(this.eSortDesc);
  12440. _.removeFromParent(this.eSortNone);
  12441. _.removeFromParent(this.eSortOrder);
  12442. };
  12443. HeaderComp.prototype.setupSort = function () {
  12444. var _this = this;
  12445. var enableSorting = this.params.enableSorting;
  12446. if (!enableSorting) {
  12447. this.removeSortIcons();
  12448. return;
  12449. }
  12450. var sortUsingCtrl = this.gridOptionsWrapper.isMultiSortKeyCtrl();
  12451. // keep track of last time the moving changed flag was set
  12452. this.addManagedListener(this.params.column, Column.EVENT_MOVING_CHANGED, function () {
  12453. _this.lastMovingChanged = new Date().getTime();
  12454. });
  12455. // add the event on the header, so when clicked, we do sorting
  12456. if (this.eLabel) {
  12457. this.addManagedListener(this.eLabel, 'click', function (event) {
  12458. // sometimes when moving a column via dragging, this was also firing a clicked event.
  12459. // here is issue raised by user: https://ag-grid.zendesk.com/agent/tickets/1076
  12460. // this check stops sort if a) column is moving or b) column moved less than 200ms ago (so caters for race condition)
  12461. var moving = _this.params.column.isMoving();
  12462. var nowTime = new Date().getTime();
  12463. // typically there is <2ms if moving flag was set recently, as it would be done in same VM turn
  12464. var movedRecently = (nowTime - _this.lastMovingChanged) < 50;
  12465. var columnMoving = moving || movedRecently;
  12466. if (!columnMoving) {
  12467. var multiSort = sortUsingCtrl ? (event.ctrlKey || event.metaKey) : event.shiftKey;
  12468. _this.params.progressSort(multiSort);
  12469. }
  12470. });
  12471. }
  12472. this.addManagedListener(this.params.column, Column.EVENT_SORT_CHANGED, this.onSortChanged.bind(this));
  12473. this.onSortChanged();
  12474. this.addManagedListener(this.eventService, Events.EVENT_SORT_CHANGED, this.setMultiSortOrder.bind(this));
  12475. this.setMultiSortOrder();
  12476. };
  12477. HeaderComp.prototype.onSortChanged = function () {
  12478. _.addOrRemoveCssClass(this.getGui(), 'ag-header-cell-sorted-asc', this.params.column.isSortAscending());
  12479. _.addOrRemoveCssClass(this.getGui(), 'ag-header-cell-sorted-desc', this.params.column.isSortDescending());
  12480. _.addOrRemoveCssClass(this.getGui(), 'ag-header-cell-sorted-none', this.params.column.isSortNone());
  12481. if (this.eSortAsc) {
  12482. _.addOrRemoveCssClass(this.eSortAsc, 'ag-hidden', !this.params.column.isSortAscending());
  12483. }
  12484. if (this.eSortDesc) {
  12485. _.addOrRemoveCssClass(this.eSortDesc, 'ag-hidden', !this.params.column.isSortDescending());
  12486. }
  12487. if (this.eSortNone) {
  12488. var alwaysHideNoSort = !this.params.column.getColDef().unSortIcon && !this.gridOptionsWrapper.isUnSortIcon();
  12489. _.addOrRemoveCssClass(this.eSortNone, 'ag-hidden', alwaysHideNoSort || !this.params.column.isSortNone());
  12490. }
  12491. };
  12492. // we listen here for global sort events, NOT column sort events, as we want to do this
  12493. // when sorting has been set on all column (if we listened just for our col (where we
  12494. // set the asc / desc icons) then it's possible other cols are yet to get their sorting state.
  12495. HeaderComp.prototype.setMultiSortOrder = function () {
  12496. if (!this.eSortOrder) {
  12497. return;
  12498. }
  12499. var col = this.params.column;
  12500. var allColumnsWithSorting = this.sortController.getColumnsWithSortingOrdered();
  12501. var indexThisCol = allColumnsWithSorting.indexOf(col);
  12502. var moreThanOneColSorting = allColumnsWithSorting.length > 1;
  12503. var showIndex = col.isSorting() && moreThanOneColSorting;
  12504. _.setDisplayed(this.eSortOrder, showIndex);
  12505. if (indexThisCol >= 0) {
  12506. this.eSortOrder.innerHTML = (indexThisCol + 1).toString();
  12507. }
  12508. else {
  12509. _.clearElement(this.eSortOrder);
  12510. }
  12511. };
  12512. HeaderComp.prototype.setupFilterIcon = function () {
  12513. if (!this.eFilter) {
  12514. return;
  12515. }
  12516. this.addManagedListener(this.params.column, Column.EVENT_FILTER_CHANGED, this.onFilterChanged.bind(this));
  12517. this.onFilterChanged();
  12518. };
  12519. HeaderComp.prototype.onFilterChanged = function () {
  12520. var filterPresent = this.params.column.isFilterActive();
  12521. _.addOrRemoveCssClass(this.eFilter, 'ag-hidden', !filterPresent);
  12522. };
  12523. HeaderComp.TEMPLATE = "<div class=\"ag-cell-label-container\">\n <span ref=\"eMenu\" class=\"ag-header-icon ag-header-cell-menu-button\" aria-hidden=\"true\"></span>\n <div ref=\"eLabel\" class=\"ag-header-cell-label\" role=\"presentation\" unselectable=\"on\">\n <span ref=\"eText\" class=\"ag-header-cell-text\" role=\"columnheader\" unselectable=\"on\"></span>\n <span ref=\"eFilter\" class=\"ag-header-icon ag-header-label-icon ag-filter-icon\" aria-hidden=\"true\"></span>\n <span ref=\"eSortOrder\" class=\"ag-header-icon ag-header-label-icon ag-sort-order\" aria-hidden=\"true\"></span>\n <span ref=\"eSortAsc\" class=\"ag-header-icon ag-header-label-icon ag-sort-ascending-icon\" aria-hidden=\"true\"></span>\n <span ref=\"eSortDesc\" class=\"ag-header-icon ag-header-label-icon ag-sort-descending-icon\" aria-hidden=\"true\"></span>\n <span ref=\"eSortNone\" class=\"ag-header-icon ag-header-label-icon ag-sort-none-icon\" aria-hidden=\"true\"></span>\n </div>\n </div>";
  12524. __decorate$e([
  12525. Autowired('gridOptionsWrapper')
  12526. ], HeaderComp.prototype, "gridOptionsWrapper", void 0);
  12527. __decorate$e([
  12528. Autowired('sortController')
  12529. ], HeaderComp.prototype, "sortController", void 0);
  12530. __decorate$e([
  12531. Autowired('menuFactory')
  12532. ], HeaderComp.prototype, "menuFactory", void 0);
  12533. __decorate$e([
  12534. RefSelector('eFilter')
  12535. ], HeaderComp.prototype, "eFilter", void 0);
  12536. __decorate$e([
  12537. RefSelector('eSortAsc')
  12538. ], HeaderComp.prototype, "eSortAsc", void 0);
  12539. __decorate$e([
  12540. RefSelector('eSortDesc')
  12541. ], HeaderComp.prototype, "eSortDesc", void 0);
  12542. __decorate$e([
  12543. RefSelector('eSortNone')
  12544. ], HeaderComp.prototype, "eSortNone", void 0);
  12545. __decorate$e([
  12546. RefSelector('eSortOrder')
  12547. ], HeaderComp.prototype, "eSortOrder", void 0);
  12548. __decorate$e([
  12549. RefSelector('eMenu')
  12550. ], HeaderComp.prototype, "eMenu", void 0);
  12551. __decorate$e([
  12552. RefSelector('eLabel')
  12553. ], HeaderComp.prototype, "eLabel", void 0);
  12554. __decorate$e([
  12555. RefSelector('eText')
  12556. ], HeaderComp.prototype, "eText", void 0);
  12557. return HeaderComp;
  12558. }(Component));
  12559. /**
  12560. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  12561. * @version v23.2.1
  12562. * @link http://www.ag-grid.com/
  12563. * @license MIT
  12564. */
  12565. var __extends$c = (undefined && undefined.__extends) || (function () {
  12566. var extendStatics = function (d, b) {
  12567. extendStatics = Object.setPrototypeOf ||
  12568. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  12569. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  12570. return extendStatics(d, b);
  12571. };
  12572. return function (d, b) {
  12573. extendStatics(d, b);
  12574. function __() { this.constructor = d; }
  12575. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  12576. };
  12577. })();
  12578. var __decorate$f = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  12579. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  12580. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  12581. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  12582. return c > 3 && r && Object.defineProperty(target, key, r), r;
  12583. };
  12584. var HeaderGroupComp = /** @class */ (function (_super) {
  12585. __extends$c(HeaderGroupComp, _super);
  12586. function HeaderGroupComp() {
  12587. return _super.call(this, HeaderGroupComp.TEMPLATE) || this;
  12588. }
  12589. // this is a user component, and IComponent has "public destroy()" as part of the interface.
  12590. // so we need to override destroy() just to make the method public.
  12591. HeaderGroupComp.prototype.destroy = function () {
  12592. _super.prototype.destroy.call(this);
  12593. };
  12594. HeaderGroupComp.prototype.init = function (params) {
  12595. this.params = params;
  12596. this.setupLabel();
  12597. this.addGroupExpandIcon();
  12598. this.setupExpandIcons();
  12599. };
  12600. HeaderGroupComp.prototype.setupExpandIcons = function () {
  12601. var _this = this;
  12602. this.addInIcon("columnGroupOpened", "agOpened");
  12603. this.addInIcon("columnGroupClosed", "agClosed");
  12604. var expandAction = function (event) {
  12605. if (_.isStopPropagationForAgGrid(event)) {
  12606. return;
  12607. }
  12608. var newExpandedValue = !_this.params.columnGroup.isExpanded();
  12609. _this.columnController.setColumnGroupOpened(_this.params.columnGroup.getOriginalColumnGroup(), newExpandedValue, "uiColumnExpanded");
  12610. };
  12611. this.addTouchAndClickListeners(this.eCloseIcon, expandAction);
  12612. this.addTouchAndClickListeners(this.eOpenIcon, expandAction);
  12613. var stopPropagationAction = function (event) {
  12614. _.stopPropagationForAgGrid(event);
  12615. };
  12616. // adding stopPropagation to the double click for the icons prevents double click action happening
  12617. // when the icons are clicked. if the icons are double clicked, then the groups should open and
  12618. // then close again straight away. if we also listened to double click, then the group would open,
  12619. // close, then open, which is not what we want. double click should only action if the user double
  12620. // clicks outside of the icons.
  12621. this.addManagedListener(this.eCloseIcon, "dblclick", stopPropagationAction);
  12622. this.addManagedListener(this.eOpenIcon, "dblclick", stopPropagationAction);
  12623. this.addManagedListener(this.getGui(), "dblclick", expandAction);
  12624. this.updateIconVisibility();
  12625. var originalColumnGroup = this.params.columnGroup.getOriginalColumnGroup();
  12626. this.addManagedListener(originalColumnGroup, OriginalColumnGroup.EVENT_EXPANDED_CHANGED, this.updateIconVisibility.bind(this));
  12627. this.addManagedListener(originalColumnGroup, OriginalColumnGroup.EVENT_EXPANDABLE_CHANGED, this.updateIconVisibility.bind(this));
  12628. };
  12629. HeaderGroupComp.prototype.addTouchAndClickListeners = function (eElement, action) {
  12630. var touchListener = new TouchListener(eElement);
  12631. this.addManagedListener(touchListener, TouchListener.EVENT_TAP, action);
  12632. this.addDestroyFunc(function () { return touchListener.destroy(); });
  12633. this.addManagedListener(eElement, "click", action);
  12634. };
  12635. HeaderGroupComp.prototype.updateIconVisibility = function () {
  12636. var columnGroup = this.params.columnGroup;
  12637. if (columnGroup.isExpandable()) {
  12638. var expanded = this.params.columnGroup.isExpanded();
  12639. _.setDisplayed(this.eOpenIcon, expanded);
  12640. _.setDisplayed(this.eCloseIcon, !expanded);
  12641. }
  12642. else {
  12643. _.setDisplayed(this.eOpenIcon, false);
  12644. _.setDisplayed(this.eCloseIcon, false);
  12645. }
  12646. };
  12647. HeaderGroupComp.prototype.addInIcon = function (iconName, refName) {
  12648. var eIcon = _.createIconNoSpan(iconName, this.gridOptionsWrapper, null);
  12649. this.getRefElement(refName).appendChild(eIcon);
  12650. };
  12651. HeaderGroupComp.prototype.addGroupExpandIcon = function () {
  12652. if (!this.params.columnGroup.isExpandable()) {
  12653. _.setDisplayed(this.eOpenIcon, false);
  12654. _.setDisplayed(this.eCloseIcon, false);
  12655. return;
  12656. }
  12657. };
  12658. HeaderGroupComp.prototype.setupLabel = function () {
  12659. // no renderer, default text render
  12660. var displayName = this.params.displayName;
  12661. if (_.exists(displayName)) {
  12662. var displayNameSanitised = _.escape(displayName);
  12663. this.getRefElement("agLabel").innerHTML = displayNameSanitised;
  12664. }
  12665. };
  12666. HeaderGroupComp.TEMPLATE = "<div class=\"ag-header-group-cell-label\" ref=\"agContainer\" role=\"presentation\">\n <span ref=\"agLabel\" class=\"ag-header-group-text\" role=\"columnheader\"></span>\n <span ref=\"agOpened\" class=\"ag-header-icon ag-header-expand-icon ag-header-expand-icon-expanded\"></span>\n <span ref=\"agClosed\" class=\"ag-header-icon ag-header-expand-icon ag-header-expand-icon-collapsed\"></span>\n </div>";
  12667. __decorate$f([
  12668. Autowired("columnController")
  12669. ], HeaderGroupComp.prototype, "columnController", void 0);
  12670. __decorate$f([
  12671. Autowired("gridOptionsWrapper")
  12672. ], HeaderGroupComp.prototype, "gridOptionsWrapper", void 0);
  12673. __decorate$f([
  12674. RefSelector("agOpened")
  12675. ], HeaderGroupComp.prototype, "eOpenIcon", void 0);
  12676. __decorate$f([
  12677. RefSelector("agClosed")
  12678. ], HeaderGroupComp.prototype, "eCloseIcon", void 0);
  12679. return HeaderGroupComp;
  12680. }(Component));
  12681. /**
  12682. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  12683. * @version v23.2.1
  12684. * @link http://www.ag-grid.com/
  12685. * @license MIT
  12686. */
  12687. var __decorate$g = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  12688. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  12689. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  12690. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  12691. return c > 3 && r && Object.defineProperty(target, key, r), r;
  12692. };
  12693. var RowNode = /** @class */ (function () {
  12694. function RowNode() {
  12695. /** Children mapped by the pivot columns */
  12696. this.childrenMapped = {};
  12697. /** True by default - can be overridden via gridOptions.isRowSelectable(rowNode) */
  12698. this.selectable = true;
  12699. /** Used by sorting service - to give deterministic sort to groups. Previously we
  12700. * just id for this, however id is a string and had slower sorting compared to numbers. */
  12701. this.__objectId = RowNode.OBJECT_ID_SEQUENCE++;
  12702. /** True when nodes with the same id are being removed and added as part of the same batch transaction */
  12703. this.alreadyRendered = false;
  12704. this.highlighted = null;
  12705. this.selected = false;
  12706. }
  12707. RowNode.prototype.setData = function (data) {
  12708. var oldData = this.data;
  12709. this.data = data;
  12710. this.valueCache.onDataChanged();
  12711. this.updateDataOnDetailNode();
  12712. this.checkRowSelectable();
  12713. var event = this.createDataChangedEvent(data, oldData, false);
  12714. this.dispatchLocalEvent(event);
  12715. };
  12716. // when we are doing master / detail, the detail node is lazy created, but then kept around.
  12717. // so if we show / hide the detail, the same detail rowNode is used. so we need to keep the data
  12718. // in sync, otherwise expand/collapse of the detail would still show the old values.
  12719. RowNode.prototype.updateDataOnDetailNode = function () {
  12720. if (this.detailNode) {
  12721. this.detailNode.data = this.data;
  12722. }
  12723. };
  12724. RowNode.prototype.createDataChangedEvent = function (newData, oldData, update) {
  12725. return {
  12726. type: RowNode.EVENT_DATA_CHANGED,
  12727. node: this,
  12728. oldData: oldData,
  12729. newData: newData,
  12730. update: update
  12731. };
  12732. };
  12733. RowNode.prototype.createLocalRowEvent = function (type) {
  12734. return {
  12735. type: type,
  12736. node: this
  12737. };
  12738. };
  12739. // similar to setRowData, however it is expected that the data is the same data item. this
  12740. // is intended to be used with Redux type stores, where the whole data can be changed. we are
  12741. // guaranteed that the data is the same entity (so grid doesn't need to worry about the id of the
  12742. // underlying data changing, hence doesn't need to worry about selection). the grid, upon receiving
  12743. // dataChanged event, will refresh the cells rather than rip them all out (so user can show transitions).
  12744. RowNode.prototype.updateData = function (data) {
  12745. var oldData = this.data;
  12746. this.data = data;
  12747. this.updateDataOnDetailNode();
  12748. this.checkRowSelectable();
  12749. this.updateDataOnDetailNode();
  12750. var event = this.createDataChangedEvent(data, oldData, true);
  12751. this.dispatchLocalEvent(event);
  12752. };
  12753. RowNode.prototype.getRowIndexString = function () {
  12754. if (this.rowPinned === Constants.PINNED_TOP) {
  12755. return 't-' + this.rowIndex;
  12756. }
  12757. else if (this.rowPinned === Constants.PINNED_BOTTOM) {
  12758. return 'b-' + this.rowIndex;
  12759. }
  12760. return this.rowIndex.toString();
  12761. };
  12762. RowNode.prototype.createDaemonNode = function () {
  12763. var oldNode = new RowNode();
  12764. this.context.createBean(oldNode);
  12765. // just copy the id and data, this is enough for the node to be used
  12766. // in the selection controller (the selection controller is the only
  12767. // place where daemon nodes can live).
  12768. oldNode.id = this.id;
  12769. oldNode.data = this.data;
  12770. oldNode.daemon = true;
  12771. oldNode.selected = this.selected;
  12772. oldNode.level = this.level;
  12773. return oldNode;
  12774. };
  12775. RowNode.prototype.setDataAndId = function (data, id) {
  12776. var oldNode = _.exists(this.id) ? this.createDaemonNode() : null;
  12777. var oldData = this.data;
  12778. this.data = data;
  12779. this.updateDataOnDetailNode();
  12780. this.setId(id);
  12781. this.selectionController.syncInRowNode(this, oldNode);
  12782. this.checkRowSelectable();
  12783. var event = this.createDataChangedEvent(data, oldData, false);
  12784. this.dispatchLocalEvent(event);
  12785. };
  12786. RowNode.prototype.checkRowSelectable = function () {
  12787. var isRowSelectableFunc = this.gridOptionsWrapper.getIsRowSelectableFunc();
  12788. var shouldInvokeIsRowSelectable = isRowSelectableFunc && _.exists(this);
  12789. this.setRowSelectable(shouldInvokeIsRowSelectable ? isRowSelectableFunc(this) : true);
  12790. };
  12791. RowNode.prototype.setRowSelectable = function (newVal) {
  12792. if (this.selectable !== newVal) {
  12793. this.selectable = newVal;
  12794. if (this.eventService) {
  12795. this.eventService.dispatchEvent(this.createLocalRowEvent(RowNode.EVENT_SELECTABLE_CHANGED));
  12796. }
  12797. }
  12798. };
  12799. RowNode.prototype.setId = function (id) {
  12800. // see if user is providing the id's
  12801. var getRowNodeId = this.gridOptionsWrapper.getRowNodeIdFunc();
  12802. if (getRowNodeId) {
  12803. // if user is providing the id's, then we set the id only after the data has been set.
  12804. // this is important for virtual pagination and viewport, where empty rows exist.
  12805. if (this.data) {
  12806. this.id = getRowNodeId(this.data);
  12807. // make sure id provided doesn't start with 'row-group-' as this is reserved. also check that
  12808. // it has 'startsWith' in case the user provided a number.
  12809. if (this.id && this.id.startsWith && this.id.startsWith(RowNode.ID_PREFIX_ROW_GROUP)) {
  12810. console.error("ag-Grid: Row ID's cannot start with " + RowNode.ID_PREFIX_ROW_GROUP + ", this is a reserved prefix for ag-Grid's row grouping feature.");
  12811. }
  12812. }
  12813. else {
  12814. // this can happen if user has set blank into the rowNode after the row previously
  12815. // having data. this happens in virtual page row model, when data is delete and
  12816. // the page is refreshed.
  12817. this.id = undefined;
  12818. }
  12819. }
  12820. else {
  12821. this.id = id;
  12822. }
  12823. };
  12824. RowNode.prototype.isPixelInRange = function (pixel) {
  12825. return pixel >= this.rowTop && pixel < (this.rowTop + this.rowHeight);
  12826. };
  12827. RowNode.prototype.clearRowTop = function () {
  12828. this.oldRowTop = this.rowTop;
  12829. this.setRowTop(null);
  12830. };
  12831. RowNode.prototype.setFirstChild = function (firstChild) {
  12832. if (this.firstChild === firstChild) {
  12833. return;
  12834. }
  12835. this.firstChild = firstChild;
  12836. if (this.eventService) {
  12837. this.eventService.dispatchEvent(this.createLocalRowEvent(RowNode.EVENT_FIRST_CHILD_CHANGED));
  12838. }
  12839. };
  12840. RowNode.prototype.setLastChild = function (lastChild) {
  12841. if (this.lastChild === lastChild) {
  12842. return;
  12843. }
  12844. this.lastChild = lastChild;
  12845. if (this.eventService) {
  12846. this.eventService.dispatchEvent(this.createLocalRowEvent(RowNode.EVENT_LAST_CHILD_CHANGED));
  12847. }
  12848. };
  12849. RowNode.prototype.setChildIndex = function (childIndex) {
  12850. if (this.childIndex === childIndex) {
  12851. return;
  12852. }
  12853. this.childIndex = childIndex;
  12854. if (this.eventService) {
  12855. this.eventService.dispatchEvent(this.createLocalRowEvent(RowNode.EVENT_CHILD_INDEX_CHANGED));
  12856. }
  12857. };
  12858. RowNode.prototype.setRowTop = function (rowTop) {
  12859. if (this.rowTop === rowTop) {
  12860. return;
  12861. }
  12862. this.rowTop = rowTop;
  12863. if (this.eventService) {
  12864. this.eventService.dispatchEvent(this.createLocalRowEvent(RowNode.EVENT_TOP_CHANGED));
  12865. }
  12866. };
  12867. RowNode.prototype.setDragging = function (dragging) {
  12868. if (this.dragging === dragging) {
  12869. return;
  12870. }
  12871. this.dragging = dragging;
  12872. if (this.eventService) {
  12873. this.eventService.dispatchEvent(this.createLocalRowEvent(RowNode.EVENT_DRAGGING_CHANGED));
  12874. }
  12875. };
  12876. RowNode.prototype.setHighlighted = function (highlighted) {
  12877. if (highlighted === this.highlighted) {
  12878. return;
  12879. }
  12880. this.highlighted = highlighted;
  12881. if (this.eventService) {
  12882. this.eventService.dispatchEvent(this.createLocalRowEvent(RowNode.EVENT_HIGHLIGHT_CHANGED));
  12883. }
  12884. };
  12885. RowNode.prototype.setAllChildrenCount = function (allChildrenCount) {
  12886. if (this.allChildrenCount === allChildrenCount) {
  12887. return;
  12888. }
  12889. this.allChildrenCount = allChildrenCount;
  12890. if (this.eventService) {
  12891. this.eventService.dispatchEvent(this.createLocalRowEvent(RowNode.EVENT_ALL_CHILDREN_COUNT_CHANGED));
  12892. }
  12893. };
  12894. RowNode.prototype.setMaster = function (master) {
  12895. if (this.master === master) {
  12896. return;
  12897. }
  12898. // if changing AWAY from master, then unexpand, otherwise
  12899. // next time it's shown it is expanded again
  12900. if (this.master && !master) {
  12901. this.expanded = false;
  12902. }
  12903. this.master = master;
  12904. if (this.eventService) {
  12905. this.eventService.dispatchEvent(this.createLocalRowEvent(RowNode.EVENT_MASTER_CHANGED));
  12906. }
  12907. };
  12908. RowNode.prototype.setRowHeight = function (rowHeight, estimated) {
  12909. if (estimated === void 0) { estimated = false; }
  12910. this.rowHeight = rowHeight;
  12911. this.rowHeightEstimated = estimated;
  12912. if (this.eventService) {
  12913. this.eventService.dispatchEvent(this.createLocalRowEvent(RowNode.EVENT_HEIGHT_CHANGED));
  12914. }
  12915. };
  12916. RowNode.prototype.setRowIndex = function (rowIndex) {
  12917. this.rowIndex = rowIndex;
  12918. if (this.eventService) {
  12919. this.eventService.dispatchEvent(this.createLocalRowEvent(RowNode.EVENT_ROW_INDEX_CHANGED));
  12920. }
  12921. };
  12922. RowNode.prototype.setUiLevel = function (uiLevel) {
  12923. if (this.uiLevel === uiLevel) {
  12924. return;
  12925. }
  12926. this.uiLevel = uiLevel;
  12927. if (this.eventService) {
  12928. this.eventService.dispatchEvent(this.createLocalRowEvent(RowNode.EVENT_UI_LEVEL_CHANGED));
  12929. }
  12930. };
  12931. RowNode.prototype.setExpanded = function (expanded) {
  12932. if (this.expanded === expanded) {
  12933. return;
  12934. }
  12935. this.expanded = expanded;
  12936. if (this.eventService) {
  12937. this.eventService.dispatchEvent(this.createLocalRowEvent(RowNode.EVENT_EXPANDED_CHANGED));
  12938. }
  12939. var event = _.assign({}, this.createGlobalRowEvent(Events.EVENT_ROW_GROUP_OPENED), {
  12940. expanded: expanded
  12941. });
  12942. this.mainEventService.dispatchEvent(event);
  12943. if (this.gridOptionsWrapper.isGroupIncludeFooter()) {
  12944. this.gridApi.redrawRows({ rowNodes: [this] });
  12945. }
  12946. };
  12947. RowNode.prototype.createGlobalRowEvent = function (type) {
  12948. return {
  12949. type: type,
  12950. node: this,
  12951. data: this.data,
  12952. rowIndex: this.rowIndex,
  12953. rowPinned: this.rowPinned,
  12954. context: this.gridOptionsWrapper.getContext(),
  12955. api: this.gridOptionsWrapper.getApi(),
  12956. columnApi: this.gridOptionsWrapper.getColumnApi()
  12957. };
  12958. };
  12959. RowNode.prototype.dispatchLocalEvent = function (event) {
  12960. if (this.eventService) {
  12961. this.eventService.dispatchEvent(event);
  12962. }
  12963. };
  12964. // we also allow editing the value via the editors. when it is done via
  12965. // the editors, no 'cell changed' event gets fired, as it's assumed that
  12966. // the cell knows about the change given it's in charge of the editing.
  12967. // this method is for the client to call, so the cell listens for the change
  12968. // event, and also flashes the cell when the change occurs.
  12969. RowNode.prototype.setDataValue = function (colKey, newValue) {
  12970. var column = this.columnController.getPrimaryColumn(colKey);
  12971. var oldValue = this.valueService.getValue(column, this);
  12972. this.valueService.setValue(this, column, newValue);
  12973. this.dispatchCellChangedEvent(column, newValue, oldValue);
  12974. };
  12975. RowNode.prototype.setGroupValue = function (colKey, newValue) {
  12976. var column = this.columnController.getGridColumn(colKey);
  12977. if (_.missing(this.groupData)) {
  12978. this.groupData = {};
  12979. }
  12980. var columnId = column.getColId();
  12981. var oldValue = this.groupData[columnId];
  12982. if (oldValue === newValue) {
  12983. return;
  12984. }
  12985. this.groupData[columnId] = newValue;
  12986. this.dispatchCellChangedEvent(column, newValue, oldValue);
  12987. };
  12988. // sets the data for an aggregation
  12989. RowNode.prototype.setAggData = function (newAggData) {
  12990. var _this = this;
  12991. // find out all keys that could potentially change
  12992. var colIds = _.getAllKeysInObjects([this.aggData, newAggData]);
  12993. var oldAggData = this.aggData;
  12994. this.aggData = newAggData;
  12995. // if no event service, nobody has registered for events, so no need fire event
  12996. if (this.eventService) {
  12997. colIds.forEach(function (colId) {
  12998. var column = _this.columnController.getGridColumn(colId);
  12999. var value = _this.aggData ? _this.aggData[colId] : undefined;
  13000. var oldValue = oldAggData ? oldAggData[colId] : undefined;
  13001. _this.dispatchCellChangedEvent(column, value, oldValue);
  13002. });
  13003. }
  13004. };
  13005. RowNode.prototype.hasChildren = function () {
  13006. // we need to return true when this.group=true, as this is used by server side row model
  13007. // (as children are lazy loaded and stored in a cache anyway). otherwise we return true
  13008. // if children exist.
  13009. return this.group || (this.childrenAfterGroup && this.childrenAfterGroup.length > 0);
  13010. };
  13011. RowNode.prototype.isEmptyRowGroupNode = function () {
  13012. return this.group && _.missingOrEmpty(this.childrenAfterGroup);
  13013. };
  13014. RowNode.prototype.dispatchCellChangedEvent = function (column, newValue, oldValue) {
  13015. var cellChangedEvent = {
  13016. type: RowNode.EVENT_CELL_CHANGED,
  13017. node: this,
  13018. column: column,
  13019. newValue: newValue,
  13020. oldValue: oldValue
  13021. };
  13022. this.dispatchLocalEvent(cellChangedEvent);
  13023. };
  13024. RowNode.prototype.resetQuickFilterAggregateText = function () {
  13025. this.quickFilterAggregateText = null;
  13026. };
  13027. RowNode.prototype.isExpandable = function () {
  13028. return this.hasChildren() || this.master;
  13029. };
  13030. RowNode.prototype.isSelected = function () {
  13031. // for footers, we just return what our sibling selected state is, as cannot select a footer
  13032. if (this.footer) {
  13033. return this.sibling.isSelected();
  13034. }
  13035. return this.selected;
  13036. };
  13037. RowNode.prototype.depthFirstSearch = function (callback) {
  13038. if (this.childrenAfterGroup) {
  13039. this.childrenAfterGroup.forEach(function (child) { return child.depthFirstSearch(callback); });
  13040. }
  13041. callback(this);
  13042. };
  13043. // + rowController.updateGroupsInSelection()
  13044. // + selectionController.calculatedSelectedForAllGroupNodes()
  13045. RowNode.prototype.calculateSelectedFromChildren = function () {
  13046. var atLeastOneSelected = false;
  13047. var atLeastOneDeSelected = false;
  13048. var atLeastOneMixed = false;
  13049. var newSelectedValue;
  13050. if (this.childrenAfterGroup) {
  13051. for (var i = 0; i < this.childrenAfterGroup.length; i++) {
  13052. var child = this.childrenAfterGroup[i];
  13053. // skip non-selectable nodes to prevent inconsistent selection values
  13054. if (!child.selectable) {
  13055. continue;
  13056. }
  13057. var childState = child.isSelected();
  13058. switch (childState) {
  13059. case true:
  13060. atLeastOneSelected = true;
  13061. break;
  13062. case false:
  13063. atLeastOneDeSelected = true;
  13064. break;
  13065. default:
  13066. atLeastOneMixed = true;
  13067. break;
  13068. }
  13069. }
  13070. }
  13071. if (atLeastOneMixed) {
  13072. newSelectedValue = undefined;
  13073. }
  13074. else if (atLeastOneSelected && !atLeastOneDeSelected) {
  13075. newSelectedValue = true;
  13076. }
  13077. else if (!atLeastOneSelected && atLeastOneDeSelected) {
  13078. newSelectedValue = false;
  13079. }
  13080. else {
  13081. newSelectedValue = undefined;
  13082. }
  13083. this.selectThisNode(newSelectedValue);
  13084. };
  13085. RowNode.prototype.setSelectedInitialValue = function (selected) {
  13086. this.selected = selected;
  13087. };
  13088. RowNode.prototype.setSelected = function (newValue, clearSelection, suppressFinishActions) {
  13089. if (clearSelection === void 0) { clearSelection = false; }
  13090. if (suppressFinishActions === void 0) { suppressFinishActions = false; }
  13091. this.setSelectedParams({
  13092. newValue: newValue,
  13093. clearSelection: clearSelection,
  13094. suppressFinishActions: suppressFinishActions,
  13095. rangeSelect: false
  13096. });
  13097. };
  13098. RowNode.prototype.isRowPinned = function () {
  13099. return this.rowPinned === Constants.PINNED_TOP || this.rowPinned === Constants.PINNED_BOTTOM;
  13100. };
  13101. // to make calling code more readable, this is the same method as setSelected except it takes names parameters
  13102. RowNode.prototype.setSelectedParams = function (params) {
  13103. var groupSelectsChildren = this.gridOptionsWrapper.isGroupSelectsChildren();
  13104. var newValue = params.newValue === true;
  13105. var clearSelection = params.clearSelection === true;
  13106. var suppressFinishActions = params.suppressFinishActions === true;
  13107. var rangeSelect = params.rangeSelect === true;
  13108. // groupSelectsFiltered only makes sense when group selects children
  13109. var groupSelectsFiltered = groupSelectsChildren && (params.groupSelectsFiltered === true);
  13110. if (this.id === undefined) {
  13111. console.warn('ag-Grid: cannot select node until id for node is known');
  13112. return 0;
  13113. }
  13114. if (this.rowPinned) {
  13115. console.warn('ag-Grid: cannot select pinned rows');
  13116. return 0;
  13117. }
  13118. // if we are a footer, we don't do selection, just pass the info
  13119. // to the sibling (the parent of the group)
  13120. if (this.footer) {
  13121. var count = this.sibling.setSelectedParams(params);
  13122. return count;
  13123. }
  13124. if (rangeSelect) {
  13125. var newRowClicked = this.selectionController.getLastSelectedNode() !== this;
  13126. var allowMultiSelect = this.gridOptionsWrapper.isRowSelectionMulti();
  13127. if (newRowClicked && allowMultiSelect) {
  13128. return this.doRowRangeSelection();
  13129. }
  13130. }
  13131. var updatedCount = 0;
  13132. // when groupSelectsFiltered, then this node may end up intermediate despite
  13133. // trying to set it to true / false. this group will be calculated further on
  13134. // down when we call calculatedSelectedForAllGroupNodes(). we need to skip it
  13135. // here, otherwise the updatedCount would include it.
  13136. var skipThisNode = groupSelectsFiltered && this.group;
  13137. if (!skipThisNode) {
  13138. var thisNodeWasSelected = this.selectThisNode(newValue);
  13139. if (thisNodeWasSelected) {
  13140. updatedCount++;
  13141. }
  13142. }
  13143. if (groupSelectsChildren && this.group) {
  13144. updatedCount += this.selectChildNodes(newValue, groupSelectsFiltered);
  13145. }
  13146. // clear other nodes if not doing multi select
  13147. if (!suppressFinishActions) {
  13148. var clearOtherNodes = newValue && (clearSelection || !this.gridOptionsWrapper.isRowSelectionMulti());
  13149. if (clearOtherNodes) {
  13150. updatedCount += this.selectionController.clearOtherNodes(this);
  13151. }
  13152. // only if we selected something, then update groups and fire events
  13153. if (updatedCount > 0) {
  13154. this.selectionController.updateGroupsFromChildrenSelections();
  13155. // this is the very end of the 'action node', so we are finished all the updates,
  13156. // include any parent / child changes that this method caused
  13157. var event_1 = {
  13158. type: Events.EVENT_SELECTION_CHANGED,
  13159. api: this.gridApi,
  13160. columnApi: this.columnApi
  13161. };
  13162. this.mainEventService.dispatchEvent(event_1);
  13163. }
  13164. // so if user next does shift-select, we know where to start the selection from
  13165. if (newValue) {
  13166. this.selectionController.setLastSelectedNode(this);
  13167. }
  13168. }
  13169. return updatedCount;
  13170. };
  13171. // selects all rows between this node and the last selected node (or the top if this is the first selection).
  13172. // not to be mixed up with 'cell range selection' where you drag the mouse, this is row range selection, by
  13173. // holding down 'shift'.
  13174. RowNode.prototype.doRowRangeSelection = function () {
  13175. var groupsSelectChildren = this.gridOptionsWrapper.isGroupSelectsChildren();
  13176. var lastSelectedNode = this.selectionController.getLastSelectedNode();
  13177. var nodesToSelect = this.rowModel.getNodesInRangeForSelection(this, lastSelectedNode);
  13178. var updatedCount = 0;
  13179. nodesToSelect.forEach(function (rowNode) {
  13180. if (rowNode.group && groupsSelectChildren) {
  13181. return;
  13182. }
  13183. var nodeWasSelected = rowNode.selectThisNode(true);
  13184. if (nodeWasSelected) {
  13185. updatedCount++;
  13186. }
  13187. });
  13188. this.selectionController.updateGroupsFromChildrenSelections();
  13189. var event = {
  13190. type: Events.EVENT_SELECTION_CHANGED,
  13191. api: this.gridApi,
  13192. columnApi: this.columnApi
  13193. };
  13194. this.mainEventService.dispatchEvent(event);
  13195. return updatedCount;
  13196. };
  13197. RowNode.prototype.isParentOfNode = function (potentialParent) {
  13198. var parentNode = this.parent;
  13199. while (parentNode) {
  13200. if (parentNode === potentialParent) {
  13201. return true;
  13202. }
  13203. parentNode = parentNode.parent;
  13204. }
  13205. return false;
  13206. };
  13207. RowNode.prototype.selectThisNode = function (newValue) {
  13208. // we only check selectable when newValue=true (ie selecting) to allow unselecting values,
  13209. // as selectable is dynamic, need a way to unselect rows when selectable becomes false.
  13210. var selectionNotAllowed = !this.selectable && newValue;
  13211. var selectionNotChanged = this.selected === newValue;
  13212. if (selectionNotAllowed || selectionNotChanged) {
  13213. return false;
  13214. }
  13215. this.selected = newValue;
  13216. if (this.eventService) {
  13217. this.dispatchLocalEvent(this.createLocalRowEvent(RowNode.EVENT_ROW_SELECTED));
  13218. }
  13219. var event = this.createGlobalRowEvent(Events.EVENT_ROW_SELECTED);
  13220. this.mainEventService.dispatchEvent(event);
  13221. return true;
  13222. };
  13223. RowNode.prototype.selectChildNodes = function (newValue, groupSelectsFiltered) {
  13224. var children = groupSelectsFiltered ? this.childrenAfterFilter : this.childrenAfterGroup;
  13225. if (_.missing(children)) {
  13226. return;
  13227. }
  13228. var updatedCount = 0;
  13229. for (var i = 0; i < children.length; i++) {
  13230. updatedCount += children[i].setSelectedParams({
  13231. newValue: newValue,
  13232. clearSelection: false,
  13233. suppressFinishActions: true,
  13234. groupSelectsFiltered: groupSelectsFiltered
  13235. });
  13236. }
  13237. return updatedCount;
  13238. };
  13239. RowNode.prototype.addEventListener = function (eventType, listener) {
  13240. if (!this.eventService) {
  13241. this.eventService = new EventService();
  13242. }
  13243. this.eventService.addEventListener(eventType, listener);
  13244. };
  13245. RowNode.prototype.removeEventListener = function (eventType, listener) {
  13246. this.eventService.removeEventListener(eventType, listener);
  13247. };
  13248. RowNode.prototype.onMouseEnter = function () {
  13249. this.dispatchLocalEvent(this.createLocalRowEvent(RowNode.EVENT_MOUSE_ENTER));
  13250. };
  13251. RowNode.prototype.onMouseLeave = function () {
  13252. this.dispatchLocalEvent(this.createLocalRowEvent(RowNode.EVENT_MOUSE_LEAVE));
  13253. };
  13254. RowNode.prototype.getFirstChildOfFirstChild = function (rowGroupColumn) {
  13255. var currentRowNode = this;
  13256. var isCandidate = true;
  13257. var foundFirstChildPath = false;
  13258. var nodeToSwapIn;
  13259. // if we are hiding groups, then if we are the first child, of the first child,
  13260. // all the way up to the column we are interested in, then we show the group cell.
  13261. while (isCandidate && !foundFirstChildPath) {
  13262. var parentRowNode = currentRowNode.parent;
  13263. var firstChild = _.exists(parentRowNode) && currentRowNode.firstChild;
  13264. if (firstChild) {
  13265. if (parentRowNode.rowGroupColumn === rowGroupColumn) {
  13266. foundFirstChildPath = true;
  13267. nodeToSwapIn = parentRowNode;
  13268. }
  13269. }
  13270. else {
  13271. isCandidate = false;
  13272. }
  13273. currentRowNode = parentRowNode;
  13274. }
  13275. return foundFirstChildPath ? nodeToSwapIn : null;
  13276. };
  13277. RowNode.prototype.isFullWidthCell = function () {
  13278. var isFullWidthCellFunc = this.gridOptionsWrapper.getIsFullWidthCellFunc();
  13279. return isFullWidthCellFunc ? isFullWidthCellFunc(this) : false;
  13280. };
  13281. RowNode.ID_PREFIX_ROW_GROUP = 'row-group-';
  13282. RowNode.ID_PREFIX_TOP_PINNED = 't-';
  13283. RowNode.ID_PREFIX_BOTTOM_PINNED = 'b-';
  13284. RowNode.OBJECT_ID_SEQUENCE = 0;
  13285. RowNode.EVENT_ROW_SELECTED = 'rowSelected';
  13286. RowNode.EVENT_DATA_CHANGED = 'dataChanged';
  13287. RowNode.EVENT_CELL_CHANGED = 'cellChanged';
  13288. RowNode.EVENT_ALL_CHILDREN_COUNT_CHANGED = 'allChildrenCountChanged';
  13289. RowNode.EVENT_MASTER_CHANGED = 'masterChanged';
  13290. RowNode.EVENT_MOUSE_ENTER = 'mouseEnter';
  13291. RowNode.EVENT_MOUSE_LEAVE = 'mouseLeave';
  13292. RowNode.EVENT_HEIGHT_CHANGED = 'heightChanged';
  13293. RowNode.EVENT_TOP_CHANGED = 'topChanged';
  13294. RowNode.EVENT_FIRST_CHILD_CHANGED = 'firstChildChanged';
  13295. RowNode.EVENT_LAST_CHILD_CHANGED = 'lastChildChanged';
  13296. RowNode.EVENT_CHILD_INDEX_CHANGED = 'childIndexChanged';
  13297. RowNode.EVENT_ROW_INDEX_CHANGED = 'rowIndexChanged';
  13298. RowNode.EVENT_EXPANDED_CHANGED = 'expandedChanged';
  13299. RowNode.EVENT_SELECTABLE_CHANGED = 'selectableChanged';
  13300. RowNode.EVENT_UI_LEVEL_CHANGED = 'uiLevelChanged';
  13301. RowNode.EVENT_HIGHLIGHT_CHANGED = 'rowHighlightChanged';
  13302. RowNode.EVENT_DRAGGING_CHANGED = 'draggingChanged';
  13303. __decorate$g([
  13304. Autowired('eventService')
  13305. ], RowNode.prototype, "mainEventService", void 0);
  13306. __decorate$g([
  13307. Autowired('gridOptionsWrapper')
  13308. ], RowNode.prototype, "gridOptionsWrapper", void 0);
  13309. __decorate$g([
  13310. Autowired('selectionController')
  13311. ], RowNode.prototype, "selectionController", void 0);
  13312. __decorate$g([
  13313. Autowired('columnController')
  13314. ], RowNode.prototype, "columnController", void 0);
  13315. __decorate$g([
  13316. Autowired('valueService')
  13317. ], RowNode.prototype, "valueService", void 0);
  13318. __decorate$g([
  13319. Autowired('rowModel')
  13320. ], RowNode.prototype, "rowModel", void 0);
  13321. __decorate$g([
  13322. Autowired('context')
  13323. ], RowNode.prototype, "context", void 0);
  13324. __decorate$g([
  13325. Autowired('valueCache')
  13326. ], RowNode.prototype, "valueCache", void 0);
  13327. __decorate$g([
  13328. Autowired('columnApi')
  13329. ], RowNode.prototype, "columnApi", void 0);
  13330. __decorate$g([
  13331. Autowired('gridApi')
  13332. ], RowNode.prototype, "gridApi", void 0);
  13333. return RowNode;
  13334. }());
  13335. /**
  13336. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  13337. * @version v23.2.1
  13338. * @link http://www.ag-grid.com/
  13339. * @license MIT
  13340. */
  13341. var __extends$d = (undefined && undefined.__extends) || (function () {
  13342. var extendStatics = function (d, b) {
  13343. extendStatics = Object.setPrototypeOf ||
  13344. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  13345. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  13346. return extendStatics(d, b);
  13347. };
  13348. return function (d, b) {
  13349. extendStatics(d, b);
  13350. function __() { this.constructor = d; }
  13351. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  13352. };
  13353. })();
  13354. var __decorate$h = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  13355. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  13356. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  13357. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  13358. return c > 3 && r && Object.defineProperty(target, key, r), r;
  13359. };
  13360. var AgAbstractLabel = /** @class */ (function (_super) {
  13361. __extends$d(AgAbstractLabel, _super);
  13362. function AgAbstractLabel() {
  13363. var _this = _super !== null && _super.apply(this, arguments) || this;
  13364. _this.labelSeparator = '';
  13365. _this.labelAlignment = 'left';
  13366. _this.config = {};
  13367. _this.label = '';
  13368. return _this;
  13369. }
  13370. AgAbstractLabel.prototype.postConstruct = function () {
  13371. _.addCssClass(this.getGui(), 'ag-labeled');
  13372. _.addCssClass(this.eLabel, 'ag-label');
  13373. var _a = this.config, labelSeparator = _a.labelSeparator, label = _a.label, labelWidth = _a.labelWidth, labelAlignment = _a.labelAlignment;
  13374. if (labelSeparator != null) {
  13375. this.setLabelSeparator(labelSeparator);
  13376. }
  13377. if (label != null) {
  13378. this.setLabel(label);
  13379. }
  13380. if (labelWidth != null) {
  13381. this.setLabelWidth(labelWidth);
  13382. }
  13383. this.setLabelAlignment(labelAlignment || this.labelAlignment);
  13384. this.refreshLabel();
  13385. };
  13386. AgAbstractLabel.prototype.refreshLabel = function () {
  13387. this.eLabel.innerText = this.label + this.labelSeparator;
  13388. _.addOrRemoveCssClass(this.eLabel, 'ag-hidden', this.label === '');
  13389. };
  13390. AgAbstractLabel.prototype.setLabelSeparator = function (labelSeparator) {
  13391. if (this.labelSeparator === labelSeparator) {
  13392. return this;
  13393. }
  13394. this.labelSeparator = labelSeparator;
  13395. if (this.label != null) {
  13396. this.refreshLabel();
  13397. }
  13398. return this;
  13399. };
  13400. AgAbstractLabel.prototype.setLabel = function (label) {
  13401. if (this.label === label) {
  13402. return this;
  13403. }
  13404. this.label = label;
  13405. this.refreshLabel();
  13406. return this;
  13407. };
  13408. AgAbstractLabel.prototype.setLabelAlignment = function (alignment) {
  13409. var eGui = this.getGui();
  13410. _.addOrRemoveCssClass(eGui, 'ag-label-align-left', alignment === 'left');
  13411. _.addOrRemoveCssClass(eGui, 'ag-label-align-right', alignment === 'right');
  13412. _.addOrRemoveCssClass(eGui, 'ag-label-align-top', alignment === 'top');
  13413. return this;
  13414. };
  13415. AgAbstractLabel.prototype.setLabelWidth = function (width) {
  13416. if (this.label == null) {
  13417. return this;
  13418. }
  13419. _.setElementWidth(this.eLabel, width);
  13420. return this;
  13421. };
  13422. __decorate$h([
  13423. PostConstruct
  13424. ], AgAbstractLabel.prototype, "postConstruct", null);
  13425. return AgAbstractLabel;
  13426. }(Component));
  13427. /**
  13428. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  13429. * @version v23.2.1
  13430. * @link http://www.ag-grid.com/
  13431. * @license MIT
  13432. */
  13433. var __extends$e = (undefined && undefined.__extends) || (function () {
  13434. var extendStatics = function (d, b) {
  13435. extendStatics = Object.setPrototypeOf ||
  13436. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  13437. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  13438. return extendStatics(d, b);
  13439. };
  13440. return function (d, b) {
  13441. extendStatics(d, b);
  13442. function __() { this.constructor = d; }
  13443. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  13444. };
  13445. })();
  13446. var AgAbstractField = /** @class */ (function (_super) {
  13447. __extends$e(AgAbstractField, _super);
  13448. function AgAbstractField() {
  13449. var _this = _super !== null && _super.apply(this, arguments) || this;
  13450. _this.disabled = false;
  13451. return _this;
  13452. }
  13453. AgAbstractField.prototype.postConstruct = function () {
  13454. _super.prototype.postConstruct.call(this);
  13455. addCssClass(this.getGui(), this.className);
  13456. };
  13457. AgAbstractField.prototype.onValueChange = function (callbackFn) {
  13458. var _this = this;
  13459. this.addManagedListener(this, AgAbstractField.EVENT_CHANGED, function () { return callbackFn(_this.getValue()); });
  13460. return this;
  13461. };
  13462. AgAbstractField.prototype.getWidth = function () {
  13463. return this.getGui().clientWidth;
  13464. };
  13465. AgAbstractField.prototype.setWidth = function (width) {
  13466. setFixedWidth(this.getGui(), width);
  13467. return this;
  13468. };
  13469. AgAbstractField.prototype.getValue = function () {
  13470. return this.value;
  13471. };
  13472. AgAbstractField.prototype.setValue = function (value, silent) {
  13473. if (this.value === value) {
  13474. return this;
  13475. }
  13476. this.value = value;
  13477. if (!silent) {
  13478. this.dispatchEvent({ type: AgAbstractField.EVENT_CHANGED });
  13479. }
  13480. return this;
  13481. };
  13482. AgAbstractField.prototype.setDisabled = function (disabled) {
  13483. disabled = !!disabled;
  13484. var element = this.getGui();
  13485. setDisabled(element, disabled);
  13486. addOrRemoveCssClass(element, 'ag-disabled', disabled);
  13487. this.disabled = disabled;
  13488. return this;
  13489. };
  13490. AgAbstractField.prototype.isDisabled = function () {
  13491. return !!this.disabled;
  13492. };
  13493. AgAbstractField.EVENT_CHANGED = 'valueChange';
  13494. return AgAbstractField;
  13495. }(AgAbstractLabel));
  13496. /**
  13497. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  13498. * @version v23.2.1
  13499. * @link http://www.ag-grid.com/
  13500. * @license MIT
  13501. */
  13502. var __extends$f = (undefined && undefined.__extends) || (function () {
  13503. var extendStatics = function (d, b) {
  13504. extendStatics = Object.setPrototypeOf ||
  13505. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  13506. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  13507. return extendStatics(d, b);
  13508. };
  13509. return function (d, b) {
  13510. extendStatics(d, b);
  13511. function __() { this.constructor = d; }
  13512. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  13513. };
  13514. })();
  13515. var __decorate$i = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  13516. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  13517. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  13518. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  13519. return c > 3 && r && Object.defineProperty(target, key, r), r;
  13520. };
  13521. var AgAbstractInputField = /** @class */ (function (_super) {
  13522. __extends$f(AgAbstractInputField, _super);
  13523. function AgAbstractInputField() {
  13524. var _this = _super !== null && _super.apply(this, arguments) || this;
  13525. _this.config = {};
  13526. _this.TEMPLATE = "\n <div role=\"presentation\">\n <label ref=\"eLabel\" class=\"ag-input-field-label\"></label>\n <div ref=\"eWrapper\" class=\"ag-wrapper ag-input-wrapper\" role=\"presentation\">\n <%displayField% ref=\"eInput\" class=\"ag-input-field-input\"></%displayField%>\n </div>\n </div>";
  13527. return _this;
  13528. }
  13529. AgAbstractInputField.prototype.postConstruct = function () {
  13530. _super.prototype.postConstruct.call(this);
  13531. this.setInputType();
  13532. addCssClass(this.eLabel, this.className + "-label");
  13533. addCssClass(this.eWrapper, this.className + "-input-wrapper");
  13534. addCssClass(this.eInput, this.className + "-input");
  13535. addCssClass(this.getGui(), 'ag-input-field');
  13536. var inputId = this.eInput.id ? this.eInput.id : "ag-input-id-" + this.getCompId();
  13537. this.eLabel.htmlFor = inputId;
  13538. this.eInput.id = inputId;
  13539. var _a = this.config, width = _a.width, value = _a.value;
  13540. if (width != null) {
  13541. this.setWidth(width);
  13542. }
  13543. if (value != null) {
  13544. this.setValue(value);
  13545. }
  13546. this.addInputListeners();
  13547. };
  13548. AgAbstractInputField.prototype.addInputListeners = function () {
  13549. var _this = this;
  13550. this.addManagedListener(this.eInput, 'input', function (e) {
  13551. var value = e.target.value;
  13552. _this.setValue(value);
  13553. });
  13554. };
  13555. AgAbstractInputField.prototype.setInputType = function () {
  13556. if (this.inputType) {
  13557. this.eInput.setAttribute('type', this.inputType);
  13558. }
  13559. };
  13560. AgAbstractInputField.prototype.getInputElement = function () {
  13561. return this.eInput;
  13562. };
  13563. AgAbstractInputField.prototype.setInputWidth = function (width) {
  13564. setElementWidth(this.eWrapper, width);
  13565. return this;
  13566. };
  13567. AgAbstractInputField.prototype.setInputName = function (name) {
  13568. this.getInputElement().setAttribute('name', name);
  13569. return this;
  13570. };
  13571. AgAbstractInputField.prototype.getFocusableElement = function () {
  13572. return this.eInput;
  13573. };
  13574. AgAbstractInputField.prototype.setMaxLength = function (length) {
  13575. var eInput = this.eInput;
  13576. eInput.maxLength = length;
  13577. return this;
  13578. };
  13579. AgAbstractInputField.prototype.setInputPlaceholder = function (placeholder) {
  13580. var eInput = this.eInput;
  13581. var attributeName = 'placeholder';
  13582. if (placeholder) {
  13583. eInput.setAttribute(attributeName, placeholder);
  13584. }
  13585. else {
  13586. eInput.removeAttribute(attributeName);
  13587. }
  13588. return this;
  13589. };
  13590. AgAbstractInputField.prototype.setDisabled = function (disabled) {
  13591. setDisabled(this.eInput, disabled);
  13592. return _super.prototype.setDisabled.call(this, disabled);
  13593. };
  13594. AgAbstractInputField.prototype.setInputAriaLabel = function (label) {
  13595. this.eInput.setAttribute('aria-label', label);
  13596. return this;
  13597. };
  13598. __decorate$i([
  13599. RefSelector('eLabel')
  13600. ], AgAbstractInputField.prototype, "eLabel", void 0);
  13601. __decorate$i([
  13602. RefSelector('eWrapper')
  13603. ], AgAbstractInputField.prototype, "eWrapper", void 0);
  13604. __decorate$i([
  13605. RefSelector('eInput')
  13606. ], AgAbstractInputField.prototype, "eInput", void 0);
  13607. return AgAbstractInputField;
  13608. }(AgAbstractField));
  13609. /**
  13610. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  13611. * @version v23.2.1
  13612. * @link http://www.ag-grid.com/
  13613. * @license MIT
  13614. */
  13615. var __extends$g = (undefined && undefined.__extends) || (function () {
  13616. var extendStatics = function (d, b) {
  13617. extendStatics = Object.setPrototypeOf ||
  13618. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  13619. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  13620. return extendStatics(d, b);
  13621. };
  13622. return function (d, b) {
  13623. extendStatics(d, b);
  13624. function __() { this.constructor = d; }
  13625. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  13626. };
  13627. })();
  13628. var __decorate$j = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  13629. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  13630. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  13631. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  13632. return c > 3 && r && Object.defineProperty(target, key, r), r;
  13633. };
  13634. var AgCheckbox = /** @class */ (function (_super) {
  13635. __extends$g(AgCheckbox, _super);
  13636. function AgCheckbox() {
  13637. var _this = _super.call(this) || this;
  13638. _this.className = 'ag-checkbox';
  13639. _this.displayTag = 'input';
  13640. _this.inputType = 'checkbox';
  13641. _this.labelAlignment = 'right';
  13642. _this.selected = false;
  13643. _this.readOnly = false;
  13644. _this.passive = false;
  13645. _this.setTemplate(_this.TEMPLATE.replace(/%displayField%/g, _this.displayTag));
  13646. return _this;
  13647. }
  13648. AgCheckbox.prototype.addInputListeners = function () {
  13649. this.addManagedListener(this.eInput, 'click', this.onCheckboxClick.bind(this));
  13650. };
  13651. AgCheckbox.prototype.getNextValue = function () {
  13652. return this.selected === undefined ? true : !this.selected;
  13653. };
  13654. AgCheckbox.prototype.setPassive = function (passive) {
  13655. this.passive = passive;
  13656. };
  13657. AgCheckbox.prototype.isReadOnly = function () {
  13658. return this.readOnly;
  13659. };
  13660. AgCheckbox.prototype.setReadOnly = function (readOnly) {
  13661. _.addOrRemoveCssClass(this.eWrapper, 'ag-disabled', readOnly);
  13662. this.eInput.disabled = readOnly;
  13663. this.readOnly = readOnly;
  13664. };
  13665. AgCheckbox.prototype.setDisabled = function (disabled) {
  13666. _.addOrRemoveCssClass(this.eWrapper, 'ag-disabled', disabled);
  13667. return _super.prototype.setDisabled.call(this, disabled);
  13668. };
  13669. AgCheckbox.prototype.toggle = function () {
  13670. var nextValue = this.getNextValue();
  13671. if (this.passive) {
  13672. this.dispatchChange(nextValue);
  13673. }
  13674. else {
  13675. this.setValue(nextValue);
  13676. }
  13677. };
  13678. AgCheckbox.prototype.getValue = function () {
  13679. return this.isSelected();
  13680. };
  13681. AgCheckbox.prototype.setValue = function (value, silent) {
  13682. this.refreshSelectedClass(value);
  13683. this.setSelected(value, silent);
  13684. return this;
  13685. };
  13686. AgCheckbox.prototype.setName = function (name) {
  13687. var input = this.getInputElement();
  13688. input.name = name;
  13689. return this;
  13690. };
  13691. AgCheckbox.prototype.isSelected = function () {
  13692. return this.selected;
  13693. };
  13694. AgCheckbox.prototype.setSelected = function (selected, silent) {
  13695. if (this.isSelected() === selected) {
  13696. return;
  13697. }
  13698. this.selected = typeof selected === 'boolean' ? selected : undefined;
  13699. this.eInput.checked = this.selected;
  13700. this.eInput.indeterminate = this.selected === undefined;
  13701. if (!silent) {
  13702. this.dispatchChange(this.selected);
  13703. }
  13704. };
  13705. AgCheckbox.prototype.dispatchChange = function (selected, event) {
  13706. this.dispatchEvent({ type: AgCheckbox.EVENT_CHANGED, selected: selected, event: event });
  13707. var input = this.getInputElement();
  13708. var checkboxChangedEvent = {
  13709. type: Events.EVENT_CHECKBOX_CHANGED,
  13710. id: input.id,
  13711. name: input.name,
  13712. selected: selected
  13713. };
  13714. this.eventService.dispatchEvent(checkboxChangedEvent);
  13715. };
  13716. AgCheckbox.prototype.onCheckboxClick = function (e) {
  13717. this.selected = e.target.checked;
  13718. this.refreshSelectedClass(this.selected);
  13719. this.dispatchChange(this.selected, e);
  13720. };
  13721. AgCheckbox.prototype.refreshSelectedClass = function (value) {
  13722. _.addOrRemoveCssClass(this.eWrapper, 'ag-checked', value === true);
  13723. _.addOrRemoveCssClass(this.eWrapper, 'ag-indeterminate', value == null);
  13724. };
  13725. __decorate$j([
  13726. Autowired('gridOptionsWrapper')
  13727. ], AgCheckbox.prototype, "gridOptionsWrapper", void 0);
  13728. return AgCheckbox;
  13729. }(AgAbstractInputField));
  13730. /**
  13731. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  13732. * @version v23.2.1
  13733. * @link http://www.ag-grid.com/
  13734. * @license MIT
  13735. */
  13736. var __extends$h = (undefined && undefined.__extends) || (function () {
  13737. var extendStatics = function (d, b) {
  13738. extendStatics = Object.setPrototypeOf ||
  13739. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  13740. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  13741. return extendStatics(d, b);
  13742. };
  13743. return function (d, b) {
  13744. extendStatics(d, b);
  13745. function __() { this.constructor = d; }
  13746. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  13747. };
  13748. })();
  13749. var __decorate$k = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  13750. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  13751. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  13752. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  13753. return c > 3 && r && Object.defineProperty(target, key, r), r;
  13754. };
  13755. var CheckboxSelectionComponent = /** @class */ (function (_super) {
  13756. __extends$h(CheckboxSelectionComponent, _super);
  13757. function CheckboxSelectionComponent() {
  13758. return _super.call(this, /* html*/ "\n <div class=\"ag-selection-checkbox\">\n <ag-checkbox role=\"presentation\" ref=\"eCheckbox\"></ag-checkbox>\n </div>") || this;
  13759. }
  13760. CheckboxSelectionComponent.prototype.onDataChanged = function () {
  13761. // when rows are loaded for the second time, this can impact the selection, as a row
  13762. // could be loaded as already selected (if user scrolls down, and then up again).
  13763. this.onSelectionChanged();
  13764. };
  13765. CheckboxSelectionComponent.prototype.onSelectableChanged = function () {
  13766. this.showOrHideSelect();
  13767. };
  13768. CheckboxSelectionComponent.prototype.onSelectionChanged = function () {
  13769. var state = this.rowNode.isSelected();
  13770. this.eCheckbox.setValue(state, true);
  13771. };
  13772. CheckboxSelectionComponent.prototype.onCheckedClicked = function () {
  13773. var groupSelectsFiltered = this.gridOptionsWrapper.isGroupSelectsFiltered();
  13774. var updatedCount = this.rowNode.setSelectedParams({ newValue: false, groupSelectsFiltered: groupSelectsFiltered });
  13775. return updatedCount;
  13776. };
  13777. CheckboxSelectionComponent.prototype.onUncheckedClicked = function (event) {
  13778. var groupSelectsFiltered = this.gridOptionsWrapper.isGroupSelectsFiltered();
  13779. var updatedCount = this.rowNode.setSelectedParams({ newValue: true, rangeSelect: event.shiftKey, groupSelectsFiltered: groupSelectsFiltered });
  13780. return updatedCount;
  13781. };
  13782. CheckboxSelectionComponent.prototype.init = function (params) {
  13783. var _this = this;
  13784. this.rowNode = params.rowNode;
  13785. this.column = params.column;
  13786. this.onSelectionChanged();
  13787. // we don't want the row clicked event to fire when selecting the checkbox, otherwise the row
  13788. // would possibly get selected twice
  13789. this.addGuiEventListener('click', function (event) { return _.stopPropagationForAgGrid(event); });
  13790. // likewise we don't want double click on this icon to open a group
  13791. this.addGuiEventListener('dblclick', function (event) { return _.stopPropagationForAgGrid(event); });
  13792. this.addManagedListener(this.eCheckbox, AgCheckbox.EVENT_CHANGED, function (params) {
  13793. if (params.selected) {
  13794. _this.onUncheckedClicked(params.event || {});
  13795. }
  13796. else {
  13797. _this.onCheckedClicked();
  13798. }
  13799. });
  13800. this.addManagedListener(this.rowNode, RowNode.EVENT_ROW_SELECTED, this.onSelectionChanged.bind(this));
  13801. this.addManagedListener(this.rowNode, RowNode.EVENT_DATA_CHANGED, this.onDataChanged.bind(this));
  13802. this.addManagedListener(this.rowNode, RowNode.EVENT_SELECTABLE_CHANGED, this.onSelectableChanged.bind(this));
  13803. this.isRowSelectableFunc = this.gridOptionsWrapper.getIsRowSelectableFunc();
  13804. var checkboxVisibleIsDynamic = this.isRowSelectableFunc || this.checkboxCallbackExists();
  13805. if (checkboxVisibleIsDynamic) {
  13806. this.addManagedListener(this.eventService, Events.EVENT_DISPLAYED_COLUMNS_CHANGED, this.showOrHideSelect.bind(this));
  13807. this.showOrHideSelect();
  13808. }
  13809. this.eCheckbox.setInputAriaLabel('Toggle Row Selection');
  13810. };
  13811. CheckboxSelectionComponent.prototype.showOrHideSelect = function () {
  13812. // if the isRowSelectable() is not provided the row node is selectable by default
  13813. var selectable = this.rowNode.selectable;
  13814. // checkboxSelection callback is deemed a legacy solution however we will still consider it's result.
  13815. // If selectable, then also check the colDef callback. if not selectable, this it short circuits - no need
  13816. // to call the colDef callback.
  13817. if (selectable && this.checkboxCallbackExists()) {
  13818. selectable = this.column.isCellCheckboxSelection(this.rowNode);
  13819. }
  13820. // show checkbox if both conditions are true
  13821. this.setDisplayed(selectable);
  13822. };
  13823. CheckboxSelectionComponent.prototype.checkboxCallbackExists = function () {
  13824. // column will be missing if groupUseEntireRow=true
  13825. var colDef = this.column ? this.column.getColDef() : null;
  13826. return colDef && typeof colDef.checkboxSelection === 'function';
  13827. };
  13828. __decorate$k([
  13829. Autowired('gridOptionsWrapper')
  13830. ], CheckboxSelectionComponent.prototype, "gridOptionsWrapper", void 0);
  13831. __decorate$k([
  13832. RefSelector('eCheckbox')
  13833. ], CheckboxSelectionComponent.prototype, "eCheckbox", void 0);
  13834. return CheckboxSelectionComponent;
  13835. }(Component));
  13836. /**
  13837. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  13838. * @version v23.2.1
  13839. * @link http://www.ag-grid.com/
  13840. * @license MIT
  13841. */
  13842. var DateComponent = {
  13843. propertyName: 'dateComponent',
  13844. isCellRenderer: function () { return false; }
  13845. };
  13846. var HeaderComponent = {
  13847. propertyName: 'headerComponent',
  13848. isCellRenderer: function () { return false; },
  13849. };
  13850. var HeaderGroupComponent = {
  13851. propertyName: 'headerGroupComponent',
  13852. isCellRenderer: function () { return false; },
  13853. };
  13854. var GroupRowInnerRendererComponent = {
  13855. propertyName: 'groupRowInnerRenderer',
  13856. isCellRenderer: function () { return true; },
  13857. };
  13858. var CellRendererComponent = {
  13859. propertyName: 'cellRenderer',
  13860. isCellRenderer: function () { return true; },
  13861. };
  13862. var PinnedRowCellRendererComponent = {
  13863. propertyName: 'pinnedRowCellRenderer',
  13864. isCellRenderer: function () { return true; },
  13865. };
  13866. var CellEditorComponent = {
  13867. propertyName: 'cellEditor',
  13868. isCellRenderer: function () { return false; },
  13869. };
  13870. var InnerRendererComponent = {
  13871. propertyName: 'innerRenderer',
  13872. isCellRenderer: function () { return true; },
  13873. };
  13874. var LoadingOverlayComponent = {
  13875. propertyName: 'loadingOverlayComponent',
  13876. isCellRenderer: function () { return false; },
  13877. };
  13878. var NoRowsOverlayComponent = {
  13879. propertyName: 'noRowsOverlayComponent',
  13880. isCellRenderer: function () { return false; },
  13881. };
  13882. var TooltipComponent = {
  13883. propertyName: 'tooltipComponent',
  13884. isCellRenderer: function () { return false; },
  13885. };
  13886. var FilterComponent = {
  13887. propertyName: 'filter',
  13888. isCellRenderer: function () { return false; },
  13889. };
  13890. var FloatingFilterComponent = {
  13891. propertyName: 'floatingFilterComponent',
  13892. isCellRenderer: function () { return false; },
  13893. };
  13894. var ToolPanelComponent = {
  13895. propertyName: 'toolPanel',
  13896. isCellRenderer: function () { return false; },
  13897. };
  13898. var StatusPanelComponent = {
  13899. propertyName: 'statusPanel',
  13900. isCellRenderer: function () { return false; },
  13901. };
  13902. /**
  13903. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  13904. * @version v23.2.1
  13905. * @link http://www.ag-grid.com/
  13906. * @license MIT
  13907. */
  13908. var __extends$i = (undefined && undefined.__extends) || (function () {
  13909. var extendStatics = function (d, b) {
  13910. extendStatics = Object.setPrototypeOf ||
  13911. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  13912. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  13913. return extendStatics(d, b);
  13914. };
  13915. return function (d, b) {
  13916. extendStatics(d, b);
  13917. function __() { this.constructor = d; }
  13918. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  13919. };
  13920. })();
  13921. var __decorate$l = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  13922. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  13923. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  13924. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  13925. return c > 3 && r && Object.defineProperty(target, key, r), r;
  13926. };
  13927. var ComponentSource;
  13928. (function (ComponentSource) {
  13929. ComponentSource[ComponentSource["DEFAULT"] = 0] = "DEFAULT";
  13930. ComponentSource[ComponentSource["REGISTERED_BY_NAME"] = 1] = "REGISTERED_BY_NAME";
  13931. ComponentSource[ComponentSource["HARDCODED"] = 2] = "HARDCODED";
  13932. })(ComponentSource || (ComponentSource = {}));
  13933. var UserComponentFactory = /** @class */ (function (_super) {
  13934. __extends$i(UserComponentFactory, _super);
  13935. function UserComponentFactory() {
  13936. return _super !== null && _super.apply(this, arguments) || this;
  13937. }
  13938. UserComponentFactory.prototype.newDateComponent = function (params) {
  13939. return this.createAndInitUserComponent(this.gridOptions, params, DateComponent, 'agDateInput');
  13940. };
  13941. UserComponentFactory.prototype.newHeaderComponent = function (params) {
  13942. return this.createAndInitUserComponent(params.column.getColDef(), params, HeaderComponent, 'agColumnHeader');
  13943. };
  13944. UserComponentFactory.prototype.newHeaderGroupComponent = function (params) {
  13945. return this.createAndInitUserComponent(params.columnGroup.getColGroupDef(), params, HeaderGroupComponent, 'agColumnGroupHeader');
  13946. };
  13947. UserComponentFactory.prototype.newFullWidthGroupRowInnerCellRenderer = function (params) {
  13948. return this.createAndInitUserComponent(this.gridOptions, params, GroupRowInnerRendererComponent, null, true);
  13949. };
  13950. // this one is unusual, as it can be LoadingCellRenderer, DetailCellRenderer, FullWidthCellRenderer or GroupRowRenderer.
  13951. // so we have to pass the type in.
  13952. UserComponentFactory.prototype.newFullWidthCellRenderer = function (params, cellRendererType, cellRendererName) {
  13953. return this.createAndInitUserComponent(null, params, {
  13954. propertyName: cellRendererType,
  13955. isCellRenderer: function () { return true; }
  13956. }, cellRendererName);
  13957. };
  13958. UserComponentFactory.prototype.newCellRenderer = function (target, params, isPinned) {
  13959. if (isPinned === void 0) { isPinned = false; }
  13960. return this.createAndInitUserComponent(target, params, isPinned ? PinnedRowCellRendererComponent : CellRendererComponent, null, true);
  13961. };
  13962. UserComponentFactory.prototype.newCellEditor = function (colDef, params) {
  13963. return this.createAndInitUserComponent(colDef, params, CellEditorComponent, 'agCellEditor');
  13964. };
  13965. UserComponentFactory.prototype.newInnerCellRenderer = function (target, params) {
  13966. return this.createAndInitUserComponent(target, params, InnerRendererComponent, null);
  13967. };
  13968. UserComponentFactory.prototype.newLoadingOverlayComponent = function (params) {
  13969. return this.createAndInitUserComponent(this.gridOptions, params, LoadingOverlayComponent, 'agLoadingOverlay');
  13970. };
  13971. UserComponentFactory.prototype.newNoRowsOverlayComponent = function (params) {
  13972. return this.createAndInitUserComponent(this.gridOptions, params, NoRowsOverlayComponent, 'agNoRowsOverlay');
  13973. };
  13974. UserComponentFactory.prototype.newTooltipComponent = function (params) {
  13975. return this.createAndInitUserComponent(params.colDef, params, TooltipComponent, 'agTooltipComponent');
  13976. };
  13977. UserComponentFactory.prototype.newFilterComponent = function (colDef, params, defaultFilter, modifyParamsCallback) {
  13978. return this.createAndInitUserComponent(colDef, params, FilterComponent, defaultFilter, false, modifyParamsCallback);
  13979. };
  13980. UserComponentFactory.prototype.newSetFilterCellRenderer = function (target, params) {
  13981. return this.createAndInitUserComponent(target, params, CellRendererComponent, null, true);
  13982. };
  13983. UserComponentFactory.prototype.newFloatingFilterComponent = function (colDef, params, defaultFloatingFilter) {
  13984. return this.createAndInitUserComponent(colDef, params, FloatingFilterComponent, defaultFloatingFilter, true);
  13985. };
  13986. UserComponentFactory.prototype.newToolPanelComponent = function (toolPanelDef, params) {
  13987. return this.createAndInitUserComponent(toolPanelDef, params, ToolPanelComponent);
  13988. };
  13989. UserComponentFactory.prototype.newStatusPanelComponent = function (def, params) {
  13990. return this.createAndInitUserComponent(def, params, StatusPanelComponent);
  13991. };
  13992. /**
  13993. * This method creates a component given everything needed to guess what sort of component needs to be instantiated
  13994. * It takes
  13995. * @param definitionObject: This is the context for which this component needs to be created, it can be gridOptions
  13996. * (global) or columnDef mostly.
  13997. * @param paramsFromGrid: Params to be passed to the component and passed by ag-Grid. This will get merged with any params
  13998. * specified by the user in the configuration
  13999. * @param propertyName: The name of the property used in ag-grid as a convention to refer to the component, it can be:
  14000. * 'floatingFilter', 'cellRenderer', is used to find if the user is specifying a custom component
  14001. * @param defaultComponentName: The actual name of the component to instantiate, this is usually the same as propertyName, but in
  14002. * some cases is not, like floatingFilter, if it is the same is not necessary to specify
  14003. * @param optional: Handy method to tell if this should return a component ALWAYS. if that is the case, but there is no
  14004. * component found, it throws an error, by default all components are MANDATORY
  14005. * @param modifyParamsCallback: A chance to customise the params passed to the init method. It receives what the current
  14006. * params are and the component that init is about to get called for
  14007. */
  14008. UserComponentFactory.prototype.createAndInitUserComponent = function (definitionObject, paramsFromGrid, componentType, defaultComponentName,
  14009. // optional items are: FloatingFilter, CellComp (for cellRenderer)
  14010. optional,
  14011. // used by FilterManager only
  14012. modifyParamsCallback) {
  14013. if (optional === void 0) { optional = false; }
  14014. if (!definitionObject) {
  14015. definitionObject = this.gridOptions;
  14016. }
  14017. // Create the component instance
  14018. var componentAndParams = this.createComponentInstance(definitionObject, componentType, paramsFromGrid, defaultComponentName, optional);
  14019. if (!componentAndParams) {
  14020. return null;
  14021. }
  14022. var componentInstance = componentAndParams.componentInstance;
  14023. // Wire the component and call the init method with the correct params
  14024. var params = this.createFinalParams(definitionObject, componentType.propertyName, paramsFromGrid, componentAndParams.paramsFromSelector);
  14025. this.addReactHacks(params);
  14026. // give caller chance to set any params that depend on the componentInstance (need here as the
  14027. // componentInstance was not available when createUserComponent was called)
  14028. var paramsAfterCallback = modifyParamsCallback ? modifyParamsCallback(params, componentInstance) : params;
  14029. var deferredInit = this.initComponent(componentInstance, paramsAfterCallback);
  14030. if (deferredInit == null) {
  14031. return Promise.resolve(componentInstance);
  14032. }
  14033. else {
  14034. return deferredInit.then(function () { return componentInstance; });
  14035. }
  14036. };
  14037. UserComponentFactory.prototype.addReactHacks = function (params) {
  14038. // a temporary fix for AG-1574
  14039. // AG-1715 raised to do a wider ranging refactor to improve this
  14040. var agGridReact = this.context.getBean('agGridReact');
  14041. if (agGridReact) {
  14042. params.agGridReact = cloneObject(agGridReact);
  14043. }
  14044. // AG-1716 - directly related to AG-1574 and AG-1715
  14045. var frameworkComponentWrapper = this.context.getBean('frameworkComponentWrapper');
  14046. if (frameworkComponentWrapper) {
  14047. params.frameworkComponentWrapper = frameworkComponentWrapper;
  14048. }
  14049. };
  14050. /**
  14051. * This method creates a component given everything needed to guess what sort of component needs to be instantiated
  14052. * It takes
  14053. * @param clazz: The class to instantiate,
  14054. * @param agGridParams: Params to be passed to the component and passed by ag-Grid. This will get merged with any params
  14055. * specified by the user in the configuration
  14056. * @param modifyParamsCallback: A chance to customise the params passed to the init method. It receives what the current
  14057. * params are and the component that init is about to get called for
  14058. */
  14059. UserComponentFactory.prototype.createUserComponentFromConcreteClass = function (clazz, agGridParams) {
  14060. var internalComponent = new clazz();
  14061. this.initComponent(internalComponent, agGridParams);
  14062. return internalComponent;
  14063. };
  14064. /**
  14065. * This method returns the underlying representation of the component to be created. ie for Javascript the
  14066. * underlying function where we should be calling new into. In case of the frameworks, the framework class
  14067. * object that represents the component to be created.
  14068. *
  14069. * This method is handy for different reasons, for example if you want to check if a component has a particular
  14070. * method implemented without having to create the component, just by inspecting the source component
  14071. *
  14072. * It takes
  14073. * @param definitionObject: This is the context for which this component needs to be created, it can be gridOptions
  14074. * (global) or columnDef mostly.
  14075. * @param propertyName: The name of the property used in ag-grid as a convention to refer to the component, it can be:
  14076. * 'floatingFilter', 'cellRenderer', is used to find if the user is specifying a custom component
  14077. * @param params: Params to be passed to the dynamic component function in case it needs to be
  14078. * invoked
  14079. * @param defaultComponentName: The name of the component to load if there is no component specified
  14080. */
  14081. UserComponentFactory.prototype.lookupComponentClassDef = function (definitionObject, propertyName, params, defaultComponentName) {
  14082. if (params === void 0) { params = null; }
  14083. /**
  14084. * There are five things that can happen when resolving a component.
  14085. * a) HardcodedFwComponent: That holder[propertyName]Framework has associated a Framework native component
  14086. * b) HardcodedJsComponent: That holder[propertyName] has associate a JS component
  14087. * c) hardcodedJsFunction: That holder[propertyName] has associate a JS function
  14088. * d) hardcodedNameComponent: That holder[propertyName] has associate a string that represents a component to load
  14089. * e) That none of the three previous are specified, then we need to use the DefaultRegisteredComponent
  14090. */
  14091. var hardcodedNameComponent = null;
  14092. var HardcodedJsComponent = null;
  14093. var hardcodedJsFunction = null;
  14094. var HardcodedFwComponent = null;
  14095. var componentSelectorFunc;
  14096. if (definitionObject != null) {
  14097. var componentPropertyValue = definitionObject[propertyName];
  14098. // for filters only, we allow 'true' for the component, which means default filter to be used
  14099. var usingDefaultComponent = componentPropertyValue === true;
  14100. if (componentPropertyValue != null && !usingDefaultComponent) {
  14101. if (typeof componentPropertyValue === 'string') {
  14102. hardcodedNameComponent = componentPropertyValue;
  14103. }
  14104. else if (typeof componentPropertyValue === 'boolean') ;
  14105. else if (this.agComponentUtils.doesImplementIComponent(componentPropertyValue)) {
  14106. HardcodedJsComponent = componentPropertyValue;
  14107. }
  14108. else {
  14109. hardcodedJsFunction = componentPropertyValue;
  14110. }
  14111. }
  14112. HardcodedFwComponent = definitionObject[propertyName + "Framework"];
  14113. componentSelectorFunc = definitionObject[propertyName + "Selector"];
  14114. }
  14115. /**
  14116. * Since we allow many types of flavors for specifying the components, let's make sure this is not an illegal
  14117. * combination
  14118. */
  14119. if ((HardcodedJsComponent && HardcodedFwComponent) ||
  14120. (hardcodedNameComponent && HardcodedFwComponent) ||
  14121. (hardcodedJsFunction && HardcodedFwComponent)) {
  14122. throw Error("ag-grid: you are trying to specify: " + propertyName + " twice as a component.");
  14123. }
  14124. if (HardcodedFwComponent && !this.frameworkComponentWrapper) {
  14125. throw Error("ag-grid: you are specifying a framework component but you are not using a framework version of ag-grid for : " + propertyName);
  14126. }
  14127. if (componentSelectorFunc && (hardcodedNameComponent || HardcodedJsComponent || hardcodedJsFunction || HardcodedFwComponent)) {
  14128. throw Error("ag-grid: you can't specify both, the selector and the component of ag-grid for : " + propertyName);
  14129. }
  14130. /**
  14131. * At this stage we are guaranteed to either have,
  14132. * DEPRECATED
  14133. * - A unique HardcodedFwComponent
  14134. * - A unique HardcodedJsComponent
  14135. * - A unique hardcodedJsFunction
  14136. * BY NAME- FAVOURED APPROACH
  14137. * - A unique hardcodedNameComponent
  14138. * - None of the previous, hence we revert to: RegisteredComponent
  14139. */
  14140. if (HardcodedFwComponent) {
  14141. // console.warn(`ag-grid: Since version 12.1.0 specifying a component directly is deprecated, you should register the component by name`);
  14142. // console.warn(`${HardcodedFwComponent}`);
  14143. return {
  14144. componentFromFramework: true,
  14145. component: HardcodedFwComponent,
  14146. source: ComponentSource.HARDCODED,
  14147. paramsFromSelector: null
  14148. };
  14149. }
  14150. if (HardcodedJsComponent) {
  14151. // console.warn(`ag-grid: Since version 12.1.0 specifying a component directly is deprecated, you should register the component by name`);
  14152. // console.warn(`${HardcodedJsComponent}`);
  14153. return {
  14154. componentFromFramework: false,
  14155. component: HardcodedJsComponent,
  14156. source: ComponentSource.HARDCODED,
  14157. paramsFromSelector: null
  14158. };
  14159. }
  14160. if (hardcodedJsFunction) {
  14161. // console.warn(`ag-grid: Since version 12.1.0 specifying a function directly is deprecated, you should register the component by name`);
  14162. // console.warn(`${hardcodedJsFunction}`);
  14163. return this.agComponentUtils.adaptFunction(propertyName, hardcodedJsFunction, false, ComponentSource.HARDCODED);
  14164. }
  14165. var selectorResult = componentSelectorFunc ? componentSelectorFunc(params) : null;
  14166. var componentNameToUse;
  14167. if (selectorResult && selectorResult.component) {
  14168. componentNameToUse = selectorResult.component;
  14169. }
  14170. else if (hardcodedNameComponent) {
  14171. componentNameToUse = hardcodedNameComponent;
  14172. }
  14173. else {
  14174. componentNameToUse = defaultComponentName;
  14175. }
  14176. if (!componentNameToUse) {
  14177. return null;
  14178. }
  14179. var registeredCompClassDef = this.lookupFromRegisteredComponents(propertyName, componentNameToUse);
  14180. if (!registeredCompClassDef) {
  14181. return null;
  14182. }
  14183. return {
  14184. componentFromFramework: registeredCompClassDef.componentFromFramework,
  14185. component: registeredCompClassDef.component,
  14186. source: registeredCompClassDef.source,
  14187. paramsFromSelector: selectorResult ? selectorResult.params : null
  14188. };
  14189. };
  14190. UserComponentFactory.prototype.lookupFromRegisteredComponents = function (propertyName, componentNameOpt) {
  14191. var componentName = componentNameOpt != null ? componentNameOpt : propertyName;
  14192. var registeredComponent = this.userComponentRegistry.retrieve(componentName);
  14193. if (registeredComponent == null) {
  14194. return null;
  14195. }
  14196. //If it is a FW it has to be registered as a component
  14197. if (registeredComponent.componentFromFramework) {
  14198. return {
  14199. component: registeredComponent.component,
  14200. componentFromFramework: true,
  14201. source: ComponentSource.REGISTERED_BY_NAME,
  14202. paramsFromSelector: null
  14203. };
  14204. }
  14205. //If it is JS it may be a function or a component
  14206. if (this.agComponentUtils.doesImplementIComponent(registeredComponent.component)) {
  14207. return {
  14208. component: registeredComponent.component,
  14209. componentFromFramework: false,
  14210. source: (registeredComponent.source == RegisteredComponentSource.REGISTERED) ? ComponentSource.REGISTERED_BY_NAME : ComponentSource.DEFAULT,
  14211. paramsFromSelector: null
  14212. };
  14213. }
  14214. // This is a function
  14215. return this.agComponentUtils.adaptFunction(propertyName, registeredComponent.component, registeredComponent.componentFromFramework, (registeredComponent.source == RegisteredComponentSource.REGISTERED) ? ComponentSource.REGISTERED_BY_NAME : ComponentSource.DEFAULT);
  14216. };
  14217. /**
  14218. * Useful to check what would be the resultant params for a given object
  14219. * @param definitionObject: This is the context for which this component needs to be created, it can be gridOptions
  14220. * (global) or columnDef mostly.
  14221. * @param propertyName: The name of the property used in ag-grid as a convention to refer to the component, it can be:
  14222. * 'floatingFilter', 'cellRenderer', is used to find if the user is specifying a custom component
  14223. * @param paramsFromGrid: Params to be passed to the component and passed by ag-Grid. This will get merged with any params
  14224. * specified by the user in the configuration
  14225. * @returns {TParams} It merges the user agGridParams with the actual params specified by the user.
  14226. */
  14227. UserComponentFactory.prototype.createFinalParams = function (definitionObject, propertyName, paramsFromGrid, paramsFromSelector) {
  14228. if (paramsFromSelector === void 0) { paramsFromSelector = null; }
  14229. var params = {};
  14230. mergeDeep(params, paramsFromGrid);
  14231. var userParams = definitionObject ? definitionObject[propertyName + "Params"] : null;
  14232. if (userParams != null) {
  14233. if (typeof userParams === 'function') {
  14234. mergeDeep(params, userParams(paramsFromGrid));
  14235. }
  14236. else if (typeof userParams === 'object') {
  14237. mergeDeep(params, userParams);
  14238. }
  14239. }
  14240. mergeDeep(params, paramsFromSelector);
  14241. return params;
  14242. };
  14243. UserComponentFactory.prototype.createComponentInstance = function (holder, componentType, paramsForSelector, defaultComponentName, optional) {
  14244. var propertyName = componentType.propertyName;
  14245. var componentToUse = this.lookupComponentClassDef(holder, propertyName, paramsForSelector, defaultComponentName);
  14246. var missing = !componentToUse || !componentToUse.component;
  14247. if (missing) {
  14248. // to help the user, we print out the name they are looking for, rather than the default name.
  14249. // i don't know why the default name was originally printed out (that doesn't help the user)
  14250. var overrideName = holder ? holder[propertyName] : defaultComponentName;
  14251. var nameToReport = overrideName ? overrideName : defaultComponentName;
  14252. if (!optional) {
  14253. console.error("Could not find component " + nameToReport + ", did you forget to configure this component?");
  14254. }
  14255. return null;
  14256. }
  14257. var componentInstance;
  14258. if (componentToUse.componentFromFramework) {
  14259. // Using framework component
  14260. var FrameworkComponentRaw = componentToUse.component;
  14261. var thisComponentConfig = this.componentMetadataProvider.retrieve(propertyName);
  14262. componentInstance = this.frameworkComponentWrapper.wrap(FrameworkComponentRaw, thisComponentConfig.mandatoryMethodList, thisComponentConfig.optionalMethodList, componentType, defaultComponentName);
  14263. }
  14264. else {
  14265. // Using plain JavaScript component
  14266. componentInstance = new componentToUse.component();
  14267. }
  14268. return { componentInstance: componentInstance, paramsFromSelector: componentToUse.paramsFromSelector };
  14269. };
  14270. UserComponentFactory.prototype.initComponent = function (component, params) {
  14271. this.context.createBean(component);
  14272. if (component.init == null) {
  14273. return;
  14274. }
  14275. return component.init(params);
  14276. };
  14277. __decorate$l([
  14278. Autowired("gridOptions")
  14279. ], UserComponentFactory.prototype, "gridOptions", void 0);
  14280. __decorate$l([
  14281. Autowired("agComponentUtils")
  14282. ], UserComponentFactory.prototype, "agComponentUtils", void 0);
  14283. __decorate$l([
  14284. Autowired("componentMetadataProvider")
  14285. ], UserComponentFactory.prototype, "componentMetadataProvider", void 0);
  14286. __decorate$l([
  14287. Autowired("userComponentRegistry")
  14288. ], UserComponentFactory.prototype, "userComponentRegistry", void 0);
  14289. __decorate$l([
  14290. Optional("frameworkComponentWrapper")
  14291. ], UserComponentFactory.prototype, "frameworkComponentWrapper", void 0);
  14292. UserComponentFactory = __decorate$l([
  14293. Bean('userComponentFactory')
  14294. ], UserComponentFactory);
  14295. return UserComponentFactory;
  14296. }(BeanStub));
  14297. /**
  14298. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  14299. * @version v23.2.1
  14300. * @link http://www.ag-grid.com/
  14301. * @license MIT
  14302. */
  14303. var __extends$j = (undefined && undefined.__extends) || (function () {
  14304. var extendStatics = function (d, b) {
  14305. extendStatics = Object.setPrototypeOf ||
  14306. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  14307. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  14308. return extendStatics(d, b);
  14309. };
  14310. return function (d, b) {
  14311. extendStatics(d, b);
  14312. function __() { this.constructor = d; }
  14313. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  14314. };
  14315. })();
  14316. var __decorate$m = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  14317. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  14318. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  14319. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  14320. return c > 3 && r && Object.defineProperty(target, key, r), r;
  14321. };
  14322. var GroupCellRenderer = /** @class */ (function (_super) {
  14323. __extends$j(GroupCellRenderer, _super);
  14324. function GroupCellRenderer() {
  14325. return _super.call(this, GroupCellRenderer.TEMPLATE) || this;
  14326. }
  14327. GroupCellRenderer.prototype.init = function (params) {
  14328. this.params = params;
  14329. if (this.gridOptionsWrapper.isGroupIncludeTotalFooter()) {
  14330. this.assignBlankValueToGroupFooterCell(params);
  14331. }
  14332. var embeddedRowMismatch = this.isEmbeddedRowMismatch();
  14333. // This allows for empty strings to appear as groups since
  14334. // it will only return for null or undefined.
  14335. var nullValue = params.value == null;
  14336. var skipCell = false;
  14337. // if the groupCellRenderer is inside of a footer and groupHideOpenParents is true
  14338. // we should only display the groupCellRenderer if the current column is the rowGroupedColumn
  14339. if (this.gridOptionsWrapper.isGroupIncludeFooter() && this.gridOptionsWrapper.isGroupHideOpenParents()) {
  14340. var node = params.node;
  14341. if (node.footer) {
  14342. var showRowGroup = params.colDef && params.colDef.showRowGroup;
  14343. var rowGroupColumnId = node.rowGroupColumn && node.rowGroupColumn.getColId();
  14344. skipCell = showRowGroup !== rowGroupColumnId;
  14345. }
  14346. }
  14347. this.cellIsBlank = embeddedRowMismatch || nullValue || skipCell;
  14348. if (this.cellIsBlank) {
  14349. return;
  14350. }
  14351. this.setupDragOpenParents();
  14352. this.addExpandAndContract();
  14353. this.addCheckboxIfNeeded();
  14354. this.addValueElement();
  14355. this.setupIndent();
  14356. };
  14357. GroupCellRenderer.prototype.assignBlankValueToGroupFooterCell = function (params) {
  14358. // this is not ideal, but it was the only way we could get footer working for the root node
  14359. if (!params.value && params.node.level == -1) {
  14360. params.value = '';
  14361. }
  14362. };
  14363. // if we are doing embedded full width rows, we only show the renderer when
  14364. // in the body, or if pinning in the pinned section, or if pinning and RTL,
  14365. // in the right section. otherwise we would have the cell repeated in each section.
  14366. GroupCellRenderer.prototype.isEmbeddedRowMismatch = function () {
  14367. if (!this.params.fullWidth || !this.gridOptionsWrapper.isEmbedFullWidthRows()) {
  14368. return false;
  14369. }
  14370. var pinnedLeftCell = this.params.pinned === Constants.PINNED_LEFT;
  14371. var pinnedRightCell = this.params.pinned === Constants.PINNED_RIGHT;
  14372. var bodyCell = !pinnedLeftCell && !pinnedRightCell;
  14373. if (this.gridOptionsWrapper.isEnableRtl()) {
  14374. if (this.columnController.isPinningLeft()) {
  14375. return !pinnedRightCell;
  14376. }
  14377. return !bodyCell;
  14378. }
  14379. if (this.columnController.isPinningLeft()) {
  14380. return !pinnedLeftCell;
  14381. }
  14382. return !bodyCell;
  14383. };
  14384. GroupCellRenderer.prototype.setIndent = function () {
  14385. if (this.gridOptionsWrapper.isGroupHideOpenParents()) {
  14386. return;
  14387. }
  14388. var params = this.params;
  14389. var rowNode = params.node;
  14390. var paddingCount = rowNode.uiLevel;
  14391. var userProvidedPaddingPixelsTheDeprecatedWay = params.padding >= 0;
  14392. if (userProvidedPaddingPixelsTheDeprecatedWay) {
  14393. this.setPaddingDeprecatedWay(paddingCount, params.padding);
  14394. return;
  14395. }
  14396. if (this.indentClass) {
  14397. this.removeCssClass(this.indentClass);
  14398. }
  14399. this.indentClass = 'ag-row-group-indent-' + paddingCount;
  14400. this.addCssClass(this.indentClass);
  14401. };
  14402. GroupCellRenderer.prototype.setPaddingDeprecatedWay = function (paddingCount, padding) {
  14403. _.doOnce(function () { return console.warn('ag-Grid: since v14.2, configuring padding for groupCellRenderer should be done with Sass variables and themes. Please see the ag-Grid documentation page for Themes, in particular the property $row-group-indent-size.'); }, 'groupCellRenderer->doDeprecatedWay');
  14404. var paddingPx = paddingCount * padding;
  14405. var eGui = this.getGui();
  14406. var paddingSide = this.gridOptionsWrapper.isEnableRtl() ? 'paddingRight' : 'paddingLeft';
  14407. eGui.style[paddingSide] = paddingPx + "px";
  14408. };
  14409. GroupCellRenderer.prototype.setupIndent = function () {
  14410. // only do this if an indent - as this overwrites the padding that
  14411. // the theme set, which will make things look 'not aligned' for the
  14412. // first group level.
  14413. var node = this.params.node;
  14414. var suppressPadding = this.params.suppressPadding;
  14415. if (!suppressPadding) {
  14416. this.addManagedListener(node, RowNode.EVENT_UI_LEVEL_CHANGED, this.setIndent.bind(this));
  14417. this.setIndent();
  14418. }
  14419. };
  14420. GroupCellRenderer.prototype.addValueElement = function () {
  14421. var params = this.params;
  14422. var rowNode = this.displayedGroup;
  14423. if (rowNode.footer) {
  14424. this.createFooterCell();
  14425. }
  14426. else if (rowNode.hasChildren() ||
  14427. _.get(params.colDef, 'cellRendererParams.innerRenderer', null) ||
  14428. _.get(params.colDef, 'cellRendererParams.innerRendererFramework', null)) {
  14429. this.createGroupCell();
  14430. if (rowNode.hasChildren()) {
  14431. this.addChildCount();
  14432. }
  14433. }
  14434. else {
  14435. this.createLeafCell();
  14436. }
  14437. };
  14438. GroupCellRenderer.prototype.createFooterCell = function () {
  14439. var footerValueGetter = this.params.footerValueGetter;
  14440. var footerValue;
  14441. if (footerValueGetter) {
  14442. // params is same as we were given, except we set the value as the item to display
  14443. var paramsClone = _.cloneObject(this.params);
  14444. paramsClone.value = this.params.value;
  14445. if (typeof footerValueGetter === 'function') {
  14446. footerValue = footerValueGetter(paramsClone);
  14447. }
  14448. else if (typeof footerValueGetter === 'string') {
  14449. footerValue = this.expressionService.evaluate(footerValueGetter, paramsClone);
  14450. }
  14451. else {
  14452. console.warn('ag-Grid: footerValueGetter should be either a function or a string (expression)');
  14453. }
  14454. }
  14455. else {
  14456. footerValue = 'Total ' + this.params.value;
  14457. }
  14458. this.eValue.innerHTML = footerValue;
  14459. };
  14460. GroupCellRenderer.prototype.createGroupCell = function () {
  14461. var _this = this;
  14462. var params = this.params;
  14463. var rowGroupColumn = this.displayedGroup.rowGroupColumn;
  14464. // we try and use the cellRenderer of the column used for the grouping if we can
  14465. var columnToUse = rowGroupColumn ? rowGroupColumn : params.column;
  14466. var groupName = this.params.value;
  14467. var valueFormatted = columnToUse ?
  14468. this.valueFormatterService.formatValue(columnToUse, params.node, params.scope, groupName) : null;
  14469. params.valueFormatted = valueFormatted;
  14470. var rendererPromise;
  14471. rendererPromise = params.fullWidth
  14472. ? this.useFullWidth(params)
  14473. : this.useInnerRenderer(this.params.colDef.cellRendererParams, columnToUse.getColDef(), params);
  14474. // retain a reference to the created renderer - we'll use this later for cleanup (in destroy)
  14475. if (rendererPromise) {
  14476. rendererPromise.then(function (value) {
  14477. _this.innerCellRenderer = value;
  14478. });
  14479. }
  14480. };
  14481. GroupCellRenderer.prototype.useInnerRenderer = function (groupCellRendererParams, groupedColumnDef, // the column this group row is for, eg 'Country'
  14482. params) {
  14483. var _this = this;
  14484. // when grouping, the normal case is we use the cell renderer of the grouped column. eg if grouping by country
  14485. // and then rating, we will use the country cell renderer for each country group row and likewise the rating
  14486. // cell renderer for each rating group row.
  14487. //
  14488. // however if the user has innerCellRenderer defined, this gets preference and we don't use cell renderers
  14489. // of the grouped columns.
  14490. //
  14491. // so we check and use in the following order:
  14492. //
  14493. // 1) thisColDef.cellRendererParams.innerRenderer of the column showing the groups (eg auto group column)
  14494. // 2) groupedColDef.cellRenderer of the grouped column
  14495. // 3) groupedColDef.cellRendererParams.innerRenderer
  14496. var cellRendererPromise = null;
  14497. // we check if cell renderer provided for the group cell renderer, eg colDef.cellRendererParams.innerRenderer
  14498. var groupInnerRendererClass = this.userComponentFactory
  14499. .lookupComponentClassDef(groupCellRendererParams, "innerRenderer");
  14500. if (groupInnerRendererClass && groupInnerRendererClass.component != null
  14501. && groupInnerRendererClass.source != ComponentSource.DEFAULT) {
  14502. // use the renderer defined in cellRendererParams.innerRenderer
  14503. cellRendererPromise = this.userComponentFactory.newInnerCellRenderer(groupCellRendererParams, params);
  14504. }
  14505. else {
  14506. // otherwise see if we can use the cellRenderer of the column we are grouping by
  14507. var groupColumnRendererClass = this.userComponentFactory
  14508. .lookupComponentClassDef(groupedColumnDef, "cellRenderer");
  14509. if (groupColumnRendererClass &&
  14510. groupColumnRendererClass.source != ComponentSource.DEFAULT) {
  14511. // Only if the original column is using a specific renderer, it it is a using a DEFAULT one ignore it
  14512. cellRendererPromise = this.userComponentFactory.newCellRenderer(groupedColumnDef, params);
  14513. }
  14514. else if (groupColumnRendererClass &&
  14515. groupColumnRendererClass.source == ComponentSource.DEFAULT &&
  14516. (_.get(groupedColumnDef, 'cellRendererParams.innerRenderer', null))) {
  14517. // EDGE CASE - THIS COMES FROM A COLUMN WHICH HAS BEEN GROUPED DYNAMICALLY, THAT HAS AS RENDERER 'group'
  14518. // AND HAS A INNER CELL RENDERER
  14519. cellRendererPromise = this.userComponentFactory.newInnerCellRenderer(groupedColumnDef.cellRendererParams, params);
  14520. }
  14521. else {
  14522. // This forces the retrieval of the default plain cellRenderer that just renders the values.
  14523. cellRendererPromise = this.userComponentFactory.newCellRenderer({}, params);
  14524. }
  14525. }
  14526. if (cellRendererPromise != null) {
  14527. cellRendererPromise.then(function (rendererToUse) {
  14528. if (rendererToUse == null) {
  14529. _this.eValue.innerText = params.valueFormatted != null ? params.valueFormatted : params.value;
  14530. return;
  14531. }
  14532. _.bindCellRendererToHtmlElement(cellRendererPromise, _this.eValue);
  14533. });
  14534. }
  14535. else {
  14536. this.eValue.innerText = params.valueFormatted != null ? params.valueFormatted : params.value;
  14537. }
  14538. return cellRendererPromise;
  14539. };
  14540. GroupCellRenderer.prototype.useFullWidth = function (params) {
  14541. var cellRendererPromise = this.userComponentFactory.newFullWidthGroupRowInnerCellRenderer(params);
  14542. if (cellRendererPromise != null) {
  14543. _.bindCellRendererToHtmlElement(cellRendererPromise, this.eValue);
  14544. }
  14545. else {
  14546. this.eValue.innerText = params.valueFormatted != null ? params.valueFormatted : params.value;
  14547. }
  14548. return cellRendererPromise;
  14549. };
  14550. GroupCellRenderer.prototype.addChildCount = function () {
  14551. // only include the child count if it's included, eg if user doing custom aggregation,
  14552. // then this could be left out, or set to -1, ie no child count
  14553. if (this.params.suppressCount) {
  14554. return;
  14555. }
  14556. this.addManagedListener(this.displayedGroup, RowNode.EVENT_ALL_CHILDREN_COUNT_CHANGED, this.updateChildCount.bind(this));
  14557. // filtering changes the child count, so need to cater for it
  14558. this.updateChildCount();
  14559. };
  14560. GroupCellRenderer.prototype.updateChildCount = function () {
  14561. var allChildrenCount = this.displayedGroup.allChildrenCount;
  14562. this.eChildCount.innerHTML = allChildrenCount >= 0 ? "(" + allChildrenCount + ")" : "";
  14563. };
  14564. GroupCellRenderer.prototype.createLeafCell = function () {
  14565. if (_.exists(this.params.value)) {
  14566. this.eValue.innerText = this.params.valueFormatted ? this.params.valueFormatted : this.params.value;
  14567. }
  14568. };
  14569. GroupCellRenderer.prototype.isUserWantsSelected = function () {
  14570. var paramsCheckbox = this.params.checkbox;
  14571. if (typeof paramsCheckbox === 'function') {
  14572. return paramsCheckbox(this.params);
  14573. }
  14574. return paramsCheckbox === true;
  14575. };
  14576. GroupCellRenderer.prototype.addCheckboxIfNeeded = function () {
  14577. var _this = this;
  14578. var rowNode = this.displayedGroup;
  14579. var checkboxNeeded = this.isUserWantsSelected() &&
  14580. // footers cannot be selected
  14581. !rowNode.footer &&
  14582. // pinned rows cannot be selected
  14583. !rowNode.rowPinned &&
  14584. // details cannot be selected
  14585. !rowNode.detail;
  14586. if (checkboxNeeded) {
  14587. var cbSelectionComponent_1 = new CheckboxSelectionComponent();
  14588. this.getContext().createBean(cbSelectionComponent_1);
  14589. cbSelectionComponent_1.init({ rowNode: rowNode, column: this.params.column });
  14590. this.eCheckbox.appendChild(cbSelectionComponent_1.getGui());
  14591. this.addDestroyFunc(function () { return _this.getContext().destroyBean(cbSelectionComponent_1); });
  14592. }
  14593. _.addOrRemoveCssClass(this.eCheckbox, 'ag-invisible', !checkboxNeeded);
  14594. };
  14595. GroupCellRenderer.prototype.addExpandAndContract = function () {
  14596. var params = this.params;
  14597. var eGroupCell = params.eGridCell;
  14598. var eExpandedIcon = _.createIconNoSpan('groupExpanded', this.gridOptionsWrapper, null);
  14599. var eContractedIcon = _.createIconNoSpan('groupContracted', this.gridOptionsWrapper, null);
  14600. this.eExpanded.appendChild(eExpandedIcon);
  14601. this.eContracted.appendChild(eContractedIcon);
  14602. this.addManagedListener(this.eExpanded, 'click', this.onExpandClicked.bind(this));
  14603. this.addManagedListener(this.eContracted, 'click', this.onExpandClicked.bind(this));
  14604. // expand / contract as the user hits enter
  14605. this.addManagedListener(eGroupCell, 'keydown', this.onKeyDown.bind(this));
  14606. this.addManagedListener(params.node, RowNode.EVENT_EXPANDED_CHANGED, this.showExpandAndContractIcons.bind(this));
  14607. this.showExpandAndContractIcons();
  14608. // because we don't show the expand / contract when there are no children, we need to check every time
  14609. // the number of children change.
  14610. this.addManagedListener(this.displayedGroup, RowNode.EVENT_ALL_CHILDREN_COUNT_CHANGED, this.onRowNodeIsExpandableChanged.bind(this));
  14611. this.addManagedListener(this.displayedGroup, RowNode.EVENT_MASTER_CHANGED, this.onRowNodeIsExpandableChanged.bind(this));
  14612. // if editing groups, then double click is to start editing
  14613. if (!this.gridOptionsWrapper.isEnableGroupEdit() && this.isExpandable() && !params.suppressDoubleClickExpand) {
  14614. this.addManagedListener(eGroupCell, 'dblclick', this.onCellDblClicked.bind(this));
  14615. }
  14616. };
  14617. GroupCellRenderer.prototype.onRowNodeIsExpandableChanged = function () {
  14618. // maybe if no children now, we should hide the expand / contract icons
  14619. this.showExpandAndContractIcons();
  14620. // if we have no children, this impacts the indent
  14621. this.setIndent();
  14622. };
  14623. GroupCellRenderer.prototype.onKeyDown = function (event) {
  14624. var enterKeyPressed = _.isKeyPressed(event, Constants.KEY_ENTER);
  14625. if (!enterKeyPressed || this.params.suppressEnterExpand) {
  14626. return;
  14627. }
  14628. var cellEditable = this.params.column && this.params.column.isCellEditable(this.params.node);
  14629. if (cellEditable) {
  14630. return;
  14631. }
  14632. event.preventDefault();
  14633. this.onExpandOrContract();
  14634. };
  14635. GroupCellRenderer.prototype.setupDragOpenParents = function () {
  14636. var column = this.params.column;
  14637. var rowNode = this.params.node;
  14638. if (!this.gridOptionsWrapper.isGroupHideOpenParents()) {
  14639. this.draggedFromHideOpenParents = false;
  14640. }
  14641. else if (!rowNode.hasChildren()) {
  14642. // if we are here, and we are not a group, then we must of been dragged down,
  14643. // as otherwise the cell would be blank, and if cell is blank, this method is never called.
  14644. this.draggedFromHideOpenParents = true;
  14645. }
  14646. else {
  14647. var rowGroupColumn = rowNode.rowGroupColumn;
  14648. if (rowGroupColumn) {
  14649. // if the displayGroup column for this col matches the rowGroupColumn we grouped by for this node,
  14650. // then nothing was dragged down
  14651. this.draggedFromHideOpenParents = !column.isRowGroupDisplayed(rowGroupColumn.getId());
  14652. }
  14653. else {
  14654. // the only way we can end up here (no column, but a group) is if we are at the root node,
  14655. // which only happens when 'groupIncludeTotalFooter' is true. here, we are never dragging
  14656. this.draggedFromHideOpenParents = false;
  14657. }
  14658. }
  14659. if (this.draggedFromHideOpenParents) {
  14660. var pointer = rowNode.parent;
  14661. while (true) {
  14662. if (_.missing(pointer)) {
  14663. break;
  14664. }
  14665. if (pointer.rowGroupColumn && column.isRowGroupDisplayed(pointer.rowGroupColumn.getId())) {
  14666. this.displayedGroup = pointer;
  14667. break;
  14668. }
  14669. pointer = pointer.parent;
  14670. }
  14671. }
  14672. // if we didn't find a displayed group, set it to the row node
  14673. if (_.missing(this.displayedGroup)) {
  14674. this.displayedGroup = rowNode;
  14675. }
  14676. };
  14677. GroupCellRenderer.prototype.onExpandClicked = function (mouseEvent) {
  14678. if (_.isStopPropagationForAgGrid(mouseEvent)) {
  14679. return;
  14680. }
  14681. // so if we expand a node, it does not also get selected.
  14682. _.stopPropagationForAgGrid(mouseEvent);
  14683. this.onExpandOrContract();
  14684. };
  14685. GroupCellRenderer.prototype.onCellDblClicked = function (mouseEvent) {
  14686. if (_.isStopPropagationForAgGrid(mouseEvent)) {
  14687. return;
  14688. }
  14689. // we want to avoid acting on double click events on the expand / contract icon,
  14690. // as that icons already has expand / collapse functionality on it. otherwise if
  14691. // the icon was double clicked, we would get 'click', 'click', 'dblclick' which
  14692. // is open->close->open, however double click should be open->close only.
  14693. var targetIsExpandIcon = _.isElementInEventPath(this.eExpanded, mouseEvent)
  14694. || _.isElementInEventPath(this.eContracted, mouseEvent);
  14695. if (!targetIsExpandIcon) {
  14696. this.onExpandOrContract();
  14697. }
  14698. };
  14699. GroupCellRenderer.prototype.onExpandOrContract = function () {
  14700. // must use the displayedGroup, so if data was dragged down, we expand the parent, not this row
  14701. var rowNode = this.displayedGroup;
  14702. rowNode.setExpanded(!rowNode.expanded);
  14703. };
  14704. GroupCellRenderer.prototype.isExpandable = function () {
  14705. var rowNode = this.params.node;
  14706. var reducedLeafNode = this.columnController.isPivotMode() && rowNode.leafGroup;
  14707. return this.draggedFromHideOpenParents ||
  14708. (rowNode.isExpandable() && !rowNode.footer && !reducedLeafNode);
  14709. };
  14710. GroupCellRenderer.prototype.showExpandAndContractIcons = function () {
  14711. var rowNode = this.params.node;
  14712. if (this.isExpandable()) {
  14713. // if expandable, show one based on expand state.
  14714. // if we were dragged down, means our parent is always expanded
  14715. var expanded = this.draggedFromHideOpenParents ? true : rowNode.expanded;
  14716. _.setDisplayed(this.eContracted, !expanded);
  14717. _.setDisplayed(this.eExpanded, expanded);
  14718. }
  14719. else {
  14720. // it not expandable, show neither
  14721. _.setDisplayed(this.eExpanded, false);
  14722. _.setDisplayed(this.eContracted, false);
  14723. }
  14724. var displayedGroup = this.displayedGroup;
  14725. // compensation padding for leaf nodes, so there is blank space instead of the expand icon
  14726. var pivotModeAndLeafGroup = this.columnController.isPivotMode() && displayedGroup.leafGroup;
  14727. var notExpandable = !displayedGroup.isExpandable();
  14728. var addLeafIndentClass = displayedGroup.footer || notExpandable || pivotModeAndLeafGroup;
  14729. this.addOrRemoveCssClass('ag-row-group', !addLeafIndentClass);
  14730. this.addOrRemoveCssClass('ag-row-group-leaf-indent', addLeafIndentClass);
  14731. };
  14732. // this is a user component, and IComponent has "public destroy()" as part of the interface.
  14733. // so we need to have public here instead of private or protected
  14734. GroupCellRenderer.prototype.destroy = function () {
  14735. this.getContext().destroyBean(this.innerCellRenderer);
  14736. _super.prototype.destroy.call(this);
  14737. };
  14738. GroupCellRenderer.prototype.refresh = function () {
  14739. return false;
  14740. };
  14741. GroupCellRenderer.TEMPLATE = '<span class="ag-cell-wrapper">' +
  14742. '<span class="ag-group-expanded" ref="eExpanded"></span>' +
  14743. '<span class="ag-group-contracted" ref="eContracted"></span>' +
  14744. '<span class="ag-group-checkbox ag-invisible" ref="eCheckbox"></span>' +
  14745. '<span class="ag-group-value" ref="eValue"></span>' +
  14746. '<span class="ag-group-child-count" ref="eChildCount"></span>' +
  14747. '</span>';
  14748. __decorate$m([
  14749. Autowired('gridOptionsWrapper')
  14750. ], GroupCellRenderer.prototype, "gridOptionsWrapper", void 0);
  14751. __decorate$m([
  14752. Autowired('expressionService')
  14753. ], GroupCellRenderer.prototype, "expressionService", void 0);
  14754. __decorate$m([
  14755. Autowired('valueFormatterService')
  14756. ], GroupCellRenderer.prototype, "valueFormatterService", void 0);
  14757. __decorate$m([
  14758. Autowired('columnController')
  14759. ], GroupCellRenderer.prototype, "columnController", void 0);
  14760. __decorate$m([
  14761. Autowired('userComponentFactory')
  14762. ], GroupCellRenderer.prototype, "userComponentFactory", void 0);
  14763. __decorate$m([
  14764. RefSelector('eExpanded')
  14765. ], GroupCellRenderer.prototype, "eExpanded", void 0);
  14766. __decorate$m([
  14767. RefSelector('eContracted')
  14768. ], GroupCellRenderer.prototype, "eContracted", void 0);
  14769. __decorate$m([
  14770. RefSelector('eCheckbox')
  14771. ], GroupCellRenderer.prototype, "eCheckbox", void 0);
  14772. __decorate$m([
  14773. RefSelector('eValue')
  14774. ], GroupCellRenderer.prototype, "eValue", void 0);
  14775. __decorate$m([
  14776. RefSelector('eChildCount')
  14777. ], GroupCellRenderer.prototype, "eChildCount", void 0);
  14778. return GroupCellRenderer;
  14779. }(Component));
  14780. /**
  14781. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  14782. * @version v23.2.1
  14783. * @link http://www.ag-grid.com/
  14784. * @license MIT
  14785. */
  14786. var __extends$k = (undefined && undefined.__extends) || (function () {
  14787. var extendStatics = function (d, b) {
  14788. extendStatics = Object.setPrototypeOf ||
  14789. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  14790. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  14791. return extendStatics(d, b);
  14792. };
  14793. return function (d, b) {
  14794. extendStatics(d, b);
  14795. function __() { this.constructor = d; }
  14796. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  14797. };
  14798. })();
  14799. var __decorate$n = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  14800. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  14801. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  14802. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  14803. return c > 3 && r && Object.defineProperty(target, key, r), r;
  14804. };
  14805. var ARROW_UP = '\u2191';
  14806. var ARROW_DOWN = '\u2193';
  14807. var AnimateShowChangeCellRenderer = /** @class */ (function (_super) {
  14808. __extends$k(AnimateShowChangeCellRenderer, _super);
  14809. function AnimateShowChangeCellRenderer() {
  14810. var _this = _super.call(this, AnimateShowChangeCellRenderer.TEMPLATE) || this;
  14811. _this.refreshCount = 0;
  14812. return _this;
  14813. }
  14814. AnimateShowChangeCellRenderer.prototype.init = function (params) {
  14815. // this.params = params;
  14816. this.eValue = this.queryForHtmlElement('.ag-value-change-value');
  14817. this.eDelta = this.queryForHtmlElement('.ag-value-change-delta');
  14818. this.refresh(params);
  14819. };
  14820. AnimateShowChangeCellRenderer.prototype.showDelta = function (params, delta) {
  14821. var absDelta = Math.abs(delta);
  14822. var valueFormatted = params.formatValue(absDelta);
  14823. var valueToUse = _.exists(valueFormatted) ? valueFormatted : absDelta;
  14824. var deltaUp = (delta >= 0);
  14825. if (deltaUp) {
  14826. this.eDelta.innerHTML = ARROW_UP + valueToUse;
  14827. }
  14828. else {
  14829. // because negative, use ABS to remove sign
  14830. this.eDelta.innerHTML = ARROW_DOWN + valueToUse;
  14831. }
  14832. _.addOrRemoveCssClass(this.eDelta, 'ag-value-change-delta-up', deltaUp);
  14833. _.addOrRemoveCssClass(this.eDelta, 'ag-value-change-delta-down', !deltaUp);
  14834. };
  14835. AnimateShowChangeCellRenderer.prototype.setTimerToRemoveDelta = function () {
  14836. var _this = this;
  14837. // the refreshCount makes sure that if the value updates again while
  14838. // the below timer is waiting, then the below timer will realise it
  14839. // is not the most recent and will not try to remove the delta value.
  14840. this.refreshCount++;
  14841. var refreshCountCopy = this.refreshCount;
  14842. window.setTimeout(function () {
  14843. if (refreshCountCopy === _this.refreshCount) {
  14844. _this.hideDeltaValue();
  14845. }
  14846. }, 2000);
  14847. };
  14848. AnimateShowChangeCellRenderer.prototype.hideDeltaValue = function () {
  14849. _.removeCssClass(this.eValue, 'ag-value-change-value-highlight');
  14850. _.clearElement(this.eDelta);
  14851. };
  14852. AnimateShowChangeCellRenderer.prototype.refresh = function (params) {
  14853. var value = params.value;
  14854. if (value === this.lastValue) {
  14855. return;
  14856. }
  14857. if (_.exists(params.valueFormatted)) {
  14858. this.eValue.innerHTML = params.valueFormatted;
  14859. }
  14860. else if (_.exists(params.value)) {
  14861. this.eValue.innerHTML = value;
  14862. }
  14863. else {
  14864. _.clearElement(this.eValue);
  14865. }
  14866. // we don't show the delta if we are in the middle of a filter. see comment on FilterManager
  14867. // with regards processingFilterChange
  14868. if (this.filterManager.isSuppressFlashingCellsBecauseFiltering()) {
  14869. return;
  14870. }
  14871. if (typeof value === 'number' && typeof this.lastValue === 'number') {
  14872. var delta = value - this.lastValue;
  14873. this.showDelta(params, delta);
  14874. }
  14875. // highlight the current value, but only if it's not new, otherwise it
  14876. // would get highlighted first time the value is shown
  14877. if (this.lastValue) {
  14878. _.addCssClass(this.eValue, 'ag-value-change-value-highlight');
  14879. }
  14880. this.setTimerToRemoveDelta();
  14881. this.lastValue = value;
  14882. return true;
  14883. };
  14884. AnimateShowChangeCellRenderer.TEMPLATE = '<span>' +
  14885. '<span class="ag-value-change-delta"></span>' +
  14886. '<span class="ag-value-change-value"></span>' +
  14887. '</span>';
  14888. __decorate$n([
  14889. Autowired('filterManager')
  14890. ], AnimateShowChangeCellRenderer.prototype, "filterManager", void 0);
  14891. return AnimateShowChangeCellRenderer;
  14892. }(Component));
  14893. /**
  14894. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  14895. * @version v23.2.1
  14896. * @link http://www.ag-grid.com/
  14897. * @license MIT
  14898. */
  14899. var __extends$l = (undefined && undefined.__extends) || (function () {
  14900. var extendStatics = function (d, b) {
  14901. extendStatics = Object.setPrototypeOf ||
  14902. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  14903. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  14904. return extendStatics(d, b);
  14905. };
  14906. return function (d, b) {
  14907. extendStatics(d, b);
  14908. function __() { this.constructor = d; }
  14909. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  14910. };
  14911. })();
  14912. var __decorate$o = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  14913. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  14914. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  14915. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  14916. return c > 3 && r && Object.defineProperty(target, key, r), r;
  14917. };
  14918. var AnimateSlideCellRenderer = /** @class */ (function (_super) {
  14919. __extends$l(AnimateSlideCellRenderer, _super);
  14920. function AnimateSlideCellRenderer() {
  14921. var _this = _super.call(this, AnimateSlideCellRenderer.TEMPLATE) || this;
  14922. _this.refreshCount = 0;
  14923. _this.eCurrent = _this.queryForHtmlElement('.ag-value-slide-current');
  14924. return _this;
  14925. }
  14926. AnimateSlideCellRenderer.prototype.init = function (params) {
  14927. this.params = params;
  14928. this.refresh(params);
  14929. };
  14930. AnimateSlideCellRenderer.prototype.addSlideAnimation = function () {
  14931. var _this = this;
  14932. this.refreshCount++;
  14933. // below we keep checking this, and stop working on the animation
  14934. // if it no longer matches - this means another animation has started
  14935. // and this one is stale.
  14936. var refreshCountCopy = this.refreshCount;
  14937. // if old animation, remove it
  14938. if (this.ePrevious) {
  14939. this.getGui().removeChild(this.ePrevious);
  14940. }
  14941. this.ePrevious = _.loadTemplate('<span class="ag-value-slide-previous ag-value-slide-out"></span>');
  14942. this.ePrevious.innerHTML = this.eCurrent.innerHTML;
  14943. this.getGui().insertBefore(this.ePrevious, this.eCurrent);
  14944. // having timeout of 0 allows use to skip to the next css turn,
  14945. // so we know the previous css classes have been applied. so the
  14946. // complex set of setTimeout below creates the animation
  14947. window.setTimeout(function () {
  14948. if (refreshCountCopy !== _this.refreshCount) {
  14949. return;
  14950. }
  14951. _.addCssClass(_this.ePrevious, 'ag-value-slide-out-end');
  14952. }, 50);
  14953. window.setTimeout(function () {
  14954. if (refreshCountCopy !== _this.refreshCount) {
  14955. return;
  14956. }
  14957. _this.getGui().removeChild(_this.ePrevious);
  14958. _this.ePrevious = null;
  14959. }, 3000);
  14960. };
  14961. AnimateSlideCellRenderer.prototype.refresh = function (params) {
  14962. var value = params.value;
  14963. if (_.missing(value)) {
  14964. value = '';
  14965. }
  14966. if (value === this.lastValue) {
  14967. return;
  14968. }
  14969. // we don't show the delta if we are in the middle of a filter. see comment on FilterManager
  14970. // with regards processingFilterChange
  14971. if (this.filterManager.isSuppressFlashingCellsBecauseFiltering()) {
  14972. return;
  14973. }
  14974. this.addSlideAnimation();
  14975. this.lastValue = value;
  14976. if (_.exists(params.valueFormatted)) {
  14977. this.eCurrent.innerHTML = params.valueFormatted;
  14978. }
  14979. else if (_.exists(params.value)) {
  14980. this.eCurrent.innerHTML = value;
  14981. }
  14982. else {
  14983. _.clearElement(this.eCurrent);
  14984. }
  14985. return true;
  14986. };
  14987. AnimateSlideCellRenderer.TEMPLATE = '<span>' +
  14988. '<span class="ag-value-slide-current"></span>' +
  14989. '</span>';
  14990. __decorate$o([
  14991. Autowired('filterManager')
  14992. ], AnimateSlideCellRenderer.prototype, "filterManager", void 0);
  14993. return AnimateSlideCellRenderer;
  14994. }(Component));
  14995. /**
  14996. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  14997. * @version v23.2.1
  14998. * @link http://www.ag-grid.com/
  14999. * @license MIT
  15000. */
  15001. var __extends$m = (undefined && undefined.__extends) || (function () {
  15002. var extendStatics = function (d, b) {
  15003. extendStatics = Object.setPrototypeOf ||
  15004. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  15005. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  15006. return extendStatics(d, b);
  15007. };
  15008. return function (d, b) {
  15009. extendStatics(d, b);
  15010. function __() { this.constructor = d; }
  15011. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  15012. };
  15013. })();
  15014. var __decorate$p = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  15015. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  15016. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  15017. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  15018. return c > 3 && r && Object.defineProperty(target, key, r), r;
  15019. };
  15020. var LoadingCellRenderer = /** @class */ (function (_super) {
  15021. __extends$m(LoadingCellRenderer, _super);
  15022. function LoadingCellRenderer() {
  15023. return _super.call(this, LoadingCellRenderer.TEMPLATE) || this;
  15024. }
  15025. LoadingCellRenderer.prototype.init = function (params) {
  15026. var eLoadingIcon = _.createIconNoSpan('groupLoading', this.gridOptionsWrapper, null);
  15027. this.eLoadingIcon.appendChild(eLoadingIcon);
  15028. var localeTextFunc = this.gridOptionsWrapper.getLocaleTextFunc();
  15029. this.eLoadingText.innerText = localeTextFunc('loadingOoo', 'Loading');
  15030. };
  15031. LoadingCellRenderer.prototype.refresh = function (params) {
  15032. return false;
  15033. };
  15034. LoadingCellRenderer.TEMPLATE = "<div class=\"ag-loading\">\n <span class=\"ag-loading-icon\" ref=\"eLoadingIcon\"></span>\n <span class=\"ag-loading-text\" ref=\"eLoadingText\"></span>\n </div>";
  15035. __decorate$p([
  15036. Autowired('gridOptionsWrapper')
  15037. ], LoadingCellRenderer.prototype, "gridOptionsWrapper", void 0);
  15038. __decorate$p([
  15039. RefSelector('eLoadingIcon')
  15040. ], LoadingCellRenderer.prototype, "eLoadingIcon", void 0);
  15041. __decorate$p([
  15042. RefSelector('eLoadingText')
  15043. ], LoadingCellRenderer.prototype, "eLoadingText", void 0);
  15044. return LoadingCellRenderer;
  15045. }(Component));
  15046. /**
  15047. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  15048. * @version v23.2.1
  15049. * @link http://www.ag-grid.com/
  15050. * @license MIT
  15051. */
  15052. var __extends$n = (undefined && undefined.__extends) || (function () {
  15053. var extendStatics = function (d, b) {
  15054. extendStatics = Object.setPrototypeOf ||
  15055. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  15056. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  15057. return extendStatics(d, b);
  15058. };
  15059. return function (d, b) {
  15060. extendStatics(d, b);
  15061. function __() { this.constructor = d; }
  15062. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  15063. };
  15064. })();
  15065. var __decorate$q = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  15066. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  15067. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  15068. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  15069. return c > 3 && r && Object.defineProperty(target, key, r), r;
  15070. };
  15071. var SelectCellEditor = /** @class */ (function (_super) {
  15072. __extends$n(SelectCellEditor, _super);
  15073. function SelectCellEditor() {
  15074. return _super.call(this, '<div class="ag-cell-edit-wrapper"><ag-select class="ag-cell-editor" ref="eSelect"></ag-select></div>') || this;
  15075. }
  15076. SelectCellEditor.prototype.init = function (params) {
  15077. var _this = this;
  15078. this.focusAfterAttached = params.cellStartedEdit;
  15079. if (_.missing(params.values)) {
  15080. console.warn('ag-Grid: no values found for select cellEditor');
  15081. return;
  15082. }
  15083. params.values.forEach(function (value) {
  15084. var option = { value: value };
  15085. var valueFormatted = _this.valueFormatterService.formatValue(params.column, null, null, value);
  15086. var valueFormattedExits = valueFormatted !== null && valueFormatted !== undefined;
  15087. option.text = valueFormattedExits ? valueFormatted : value;
  15088. _this.eSelect.addOption(option);
  15089. });
  15090. this.eSelect.setValue(params.value, true);
  15091. // we don't want to add this if full row editing, otherwise selecting will stop the
  15092. // full row editing.
  15093. if (!this.gridOptionsWrapper.isFullRowEdit()) {
  15094. this.eSelect.onValueChange(function () { return params.stopEditing(); });
  15095. }
  15096. };
  15097. SelectCellEditor.prototype.afterGuiAttached = function () {
  15098. if (this.focusAfterAttached) {
  15099. this.eSelect.getFocusableElement().focus();
  15100. }
  15101. };
  15102. SelectCellEditor.prototype.focusIn = function () {
  15103. this.eSelect.getFocusableElement().focus();
  15104. };
  15105. SelectCellEditor.prototype.getValue = function () {
  15106. return this.eSelect.getValue();
  15107. };
  15108. SelectCellEditor.prototype.isPopup = function () {
  15109. return false;
  15110. };
  15111. __decorate$q([
  15112. Autowired('gridOptionsWrapper')
  15113. ], SelectCellEditor.prototype, "gridOptionsWrapper", void 0);
  15114. __decorate$q([
  15115. Autowired('valueFormatterService')
  15116. ], SelectCellEditor.prototype, "valueFormatterService", void 0);
  15117. __decorate$q([
  15118. RefSelector('eSelect')
  15119. ], SelectCellEditor.prototype, "eSelect", void 0);
  15120. return SelectCellEditor;
  15121. }(PopupComponent));
  15122. /**
  15123. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  15124. * @version v23.2.1
  15125. * @link http://www.ag-grid.com/
  15126. * @license MIT
  15127. */
  15128. var __extends$o = (undefined && undefined.__extends) || (function () {
  15129. var extendStatics = function (d, b) {
  15130. extendStatics = Object.setPrototypeOf ||
  15131. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  15132. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  15133. return extendStatics(d, b);
  15134. };
  15135. return function (d, b) {
  15136. extendStatics(d, b);
  15137. function __() { this.constructor = d; }
  15138. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  15139. };
  15140. })();
  15141. var PopupTextCellEditor = /** @class */ (function (_super) {
  15142. __extends$o(PopupTextCellEditor, _super);
  15143. function PopupTextCellEditor() {
  15144. return _super !== null && _super.apply(this, arguments) || this;
  15145. }
  15146. PopupTextCellEditor.prototype.isPopup = function () {
  15147. return true;
  15148. };
  15149. return PopupTextCellEditor;
  15150. }(TextCellEditor));
  15151. /**
  15152. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  15153. * @version v23.2.1
  15154. * @link http://www.ag-grid.com/
  15155. * @license MIT
  15156. */
  15157. var __extends$p = (undefined && undefined.__extends) || (function () {
  15158. var extendStatics = function (d, b) {
  15159. extendStatics = Object.setPrototypeOf ||
  15160. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  15161. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  15162. return extendStatics(d, b);
  15163. };
  15164. return function (d, b) {
  15165. extendStatics(d, b);
  15166. function __() { this.constructor = d; }
  15167. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  15168. };
  15169. })();
  15170. var PopupSelectCellEditor = /** @class */ (function (_super) {
  15171. __extends$p(PopupSelectCellEditor, _super);
  15172. function PopupSelectCellEditor() {
  15173. return _super !== null && _super.apply(this, arguments) || this;
  15174. }
  15175. PopupSelectCellEditor.prototype.isPopup = function () {
  15176. return true;
  15177. };
  15178. return PopupSelectCellEditor;
  15179. }(SelectCellEditor));
  15180. /**
  15181. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  15182. * @version v23.2.1
  15183. * @link http://www.ag-grid.com/
  15184. * @license MIT
  15185. */
  15186. var __extends$q = (undefined && undefined.__extends) || (function () {
  15187. var extendStatics = function (d, b) {
  15188. extendStatics = Object.setPrototypeOf ||
  15189. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  15190. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  15191. return extendStatics(d, b);
  15192. };
  15193. return function (d, b) {
  15194. extendStatics(d, b);
  15195. function __() { this.constructor = d; }
  15196. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  15197. };
  15198. })();
  15199. var __decorate$r = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  15200. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  15201. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  15202. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  15203. return c > 3 && r && Object.defineProperty(target, key, r), r;
  15204. };
  15205. var LargeTextCellEditor = /** @class */ (function (_super) {
  15206. __extends$q(LargeTextCellEditor, _super);
  15207. function LargeTextCellEditor() {
  15208. return _super.call(this, LargeTextCellEditor.TEMPLATE) || this;
  15209. }
  15210. LargeTextCellEditor.prototype.init = function (params) {
  15211. this.params = params;
  15212. this.focusAfterAttached = params.cellStartedEdit;
  15213. this.eTextArea
  15214. .setMaxLength(params.maxLength || 200)
  15215. .setCols(params.cols || 60)
  15216. .setRows(params.rows || 10);
  15217. if (_.exists(params.value)) {
  15218. this.eTextArea.setValue(params.value.toString(), true);
  15219. }
  15220. this.addGuiEventListener('keydown', this.onKeyDown.bind(this));
  15221. };
  15222. LargeTextCellEditor.prototype.onKeyDown = function (event) {
  15223. var key = event.which || event.keyCode;
  15224. if (key == Constants.KEY_LEFT ||
  15225. key == Constants.KEY_UP ||
  15226. key == Constants.KEY_RIGHT ||
  15227. key == Constants.KEY_DOWN ||
  15228. (event.shiftKey && key == Constants.KEY_ENTER)) { // shift+enter allows for newlines
  15229. event.stopPropagation();
  15230. }
  15231. };
  15232. LargeTextCellEditor.prototype.afterGuiAttached = function () {
  15233. if (this.focusAfterAttached) {
  15234. this.eTextArea.getFocusableElement().focus();
  15235. }
  15236. };
  15237. LargeTextCellEditor.prototype.getValue = function () {
  15238. return this.params.parseValue(this.eTextArea.getValue());
  15239. };
  15240. LargeTextCellEditor.TEMPLATE = "<div class=\"ag-large-text\" tabindex=\"0\">\n <ag-input-text-area ref=\"eTextArea\" class=\"ag-large-text-input\"></ag-input-text-area>\n </div>";
  15241. __decorate$r([
  15242. RefSelector("eTextArea")
  15243. ], LargeTextCellEditor.prototype, "eTextArea", void 0);
  15244. return LargeTextCellEditor;
  15245. }(PopupComponent));
  15246. /**
  15247. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  15248. * @version v23.2.1
  15249. * @link http://www.ag-grid.com/
  15250. * @license MIT
  15251. */
  15252. var __extends$r = (undefined && undefined.__extends) || (function () {
  15253. var extendStatics = function (d, b) {
  15254. extendStatics = Object.setPrototypeOf ||
  15255. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  15256. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  15257. return extendStatics(d, b);
  15258. };
  15259. return function (d, b) {
  15260. extendStatics(d, b);
  15261. function __() { this.constructor = d; }
  15262. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  15263. };
  15264. })();
  15265. var __decorate$s = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  15266. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  15267. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  15268. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  15269. return c > 3 && r && Object.defineProperty(target, key, r), r;
  15270. };
  15271. var NumberFilter = /** @class */ (function (_super) {
  15272. __extends$r(NumberFilter, _super);
  15273. function NumberFilter() {
  15274. return _super !== null && _super.apply(this, arguments) || this;
  15275. }
  15276. NumberFilter.prototype.mapRangeFromModel = function (filterModel) {
  15277. return {
  15278. from: filterModel.filter,
  15279. to: filterModel.filterTo
  15280. };
  15281. };
  15282. NumberFilter.prototype.getDefaultDebounceMs = function () {
  15283. return 500;
  15284. };
  15285. NumberFilter.prototype.resetUiToDefaults = function (silent) {
  15286. var _this = this;
  15287. return _super.prototype.resetUiToDefaults.call(this, silent).then(function () {
  15288. var fields = [_this.eValueFrom1, _this.eValueFrom2, _this.eValueTo1, _this.eValueTo2];
  15289. fields.forEach(function (field) { return field.setValue(null, silent); });
  15290. _this.resetPlaceholder();
  15291. });
  15292. };
  15293. NumberFilter.prototype.setConditionIntoUi = function (model, position) {
  15294. var positionOne = position === ConditionPosition.One;
  15295. var eValueFrom = positionOne ? this.eValueFrom1 : this.eValueFrom2;
  15296. var eValueTo = positionOne ? this.eValueTo1 : this.eValueTo2;
  15297. eValueFrom.setValue(model ? ('' + model.filter) : null);
  15298. eValueTo.setValue(model ? ('' + model.filterTo) : null);
  15299. };
  15300. NumberFilter.prototype.setValueFromFloatingFilter = function (value) {
  15301. this.eValueFrom1.setValue(value);
  15302. this.eValueFrom2.setValue(null);
  15303. this.eValueTo1.setValue(null);
  15304. this.eValueTo2.setValue(null);
  15305. };
  15306. NumberFilter.prototype.comparator = function () {
  15307. return function (left, right) {
  15308. if (left === right) {
  15309. return 0;
  15310. }
  15311. if (left < right) {
  15312. return 1;
  15313. }
  15314. return -1;
  15315. };
  15316. };
  15317. NumberFilter.prototype.setParams = function (params) {
  15318. _super.prototype.setParams.call(this, params);
  15319. this.addValueChangedListeners();
  15320. };
  15321. NumberFilter.prototype.addValueChangedListeners = function () {
  15322. var _this = this;
  15323. var listener = function () { return _this.onUiChanged(); };
  15324. this.eValueFrom1.onValueChange(listener);
  15325. this.eValueFrom2.onValueChange(listener);
  15326. this.eValueTo1.onValueChange(listener);
  15327. this.eValueTo2.onValueChange(listener);
  15328. };
  15329. NumberFilter.prototype.resetPlaceholder = function () {
  15330. var isRange1 = this.getCondition1Type() === ScalarFilter.IN_RANGE;
  15331. var isRange2 = this.getCondition2Type() === ScalarFilter.IN_RANGE;
  15332. this.eValueFrom1.setInputPlaceholder(this.translate(isRange1 ? 'inRangeStart' : 'filterOoo'));
  15333. this.eValueTo1.setInputPlaceholder(this.translate(isRange1 ? 'inRangeEnd' : 'filterOoo'));
  15334. this.eValueFrom2.setInputPlaceholder(this.translate(isRange2 ? 'inRangeStart' : 'filterOoo'));
  15335. this.eValueTo2.setInputPlaceholder(this.translate(isRange2 ? 'inRangeEnd' : 'filterOoo'));
  15336. };
  15337. NumberFilter.prototype.afterGuiAttached = function (params) {
  15338. _super.prototype.afterGuiAttached.call(this, params);
  15339. this.resetPlaceholder();
  15340. this.eValueFrom1.getInputElement().focus();
  15341. };
  15342. NumberFilter.prototype.getDefaultFilterOptions = function () {
  15343. return NumberFilter.DEFAULT_FILTER_OPTIONS;
  15344. };
  15345. NumberFilter.prototype.createValueTemplate = function (position) {
  15346. var positionOne = position === ConditionPosition.One;
  15347. var pos = positionOne ? '1' : '2';
  15348. return "<div class=\"ag-filter-body\" ref=\"eCondition" + pos + "Body\" role=\"presentation\">\n <ag-input-number-field class=\"ag-filter-from ag-filter-filter\" ref=\"eValueFrom" + pos + "\"></ag-input-number-field>\n <ag-input-number-field class=\"ag-filter-to ag-filter-filter\" ref=\"eValueTo" + pos + "\"></ag-input-number-field>\n </div>";
  15349. };
  15350. NumberFilter.prototype.isConditionUiComplete = function (position) {
  15351. var positionOne = position === ConditionPosition.One;
  15352. var option = positionOne ? this.getCondition1Type() : this.getCondition2Type();
  15353. var eValue = positionOne ? this.eValueFrom1 : this.eValueFrom2;
  15354. var eValueTo = positionOne ? this.eValueTo1 : this.eValueTo2;
  15355. var value = this.stringToFloat(eValue.getValue());
  15356. var valueTo = this.stringToFloat(eValueTo.getValue());
  15357. if (option === SimpleFilter.EMPTY) {
  15358. return false;
  15359. }
  15360. if (this.doesFilterHaveHiddenInput(option)) {
  15361. return true;
  15362. }
  15363. if (option === SimpleFilter.IN_RANGE) {
  15364. return value != null && valueTo != null;
  15365. }
  15366. return value != null;
  15367. };
  15368. NumberFilter.prototype.areSimpleModelsEqual = function (aSimple, bSimple) {
  15369. return aSimple.filter === bSimple.filter
  15370. && aSimple.filterTo === bSimple.filterTo
  15371. && aSimple.type === bSimple.type;
  15372. };
  15373. // needed for creating filter model
  15374. NumberFilter.prototype.getFilterType = function () {
  15375. return NumberFilter.FILTER_TYPE;
  15376. };
  15377. NumberFilter.prototype.stringToFloat = function (value) {
  15378. if (typeof value === 'number') {
  15379. return value;
  15380. }
  15381. var filterText = makeNull(value);
  15382. if (filterText && filterText.trim() === '') {
  15383. filterText = null;
  15384. }
  15385. var newFilter;
  15386. if (filterText !== null && filterText !== undefined) {
  15387. newFilter = parseFloat(filterText);
  15388. }
  15389. else {
  15390. newFilter = null;
  15391. }
  15392. return newFilter;
  15393. };
  15394. NumberFilter.prototype.createCondition = function (position) {
  15395. var positionOne = position === ConditionPosition.One;
  15396. var type = positionOne ? this.getCondition1Type() : this.getCondition2Type();
  15397. var eValue = positionOne ? this.eValueFrom1 : this.eValueFrom2;
  15398. var value = this.stringToFloat(eValue.getValue());
  15399. var eValueTo = positionOne ? this.eValueTo1 : this.eValueTo2;
  15400. var valueTo = this.stringToFloat(eValueTo.getValue());
  15401. var model = {
  15402. filterType: NumberFilter.FILTER_TYPE,
  15403. type: type
  15404. };
  15405. if (!this.doesFilterHaveHiddenInput(type)) {
  15406. model.filter = value;
  15407. model.filterTo = valueTo; // FIX - should only populate this when filter choice has 'to' option
  15408. }
  15409. return model;
  15410. };
  15411. NumberFilter.prototype.updateUiVisibility = function () {
  15412. _super.prototype.updateUiVisibility.call(this);
  15413. this.resetPlaceholder();
  15414. var showFrom1 = this.showValueFrom(this.getCondition1Type());
  15415. setDisplayed(this.eValueFrom1.getGui(), showFrom1);
  15416. var showTo1 = this.showValueTo(this.getCondition1Type());
  15417. setDisplayed(this.eValueTo1.getGui(), showTo1);
  15418. var showFrom2 = this.showValueFrom(this.getCondition2Type());
  15419. setDisplayed(this.eValueFrom2.getGui(), showFrom2);
  15420. var showTo2 = this.showValueTo(this.getCondition2Type());
  15421. setDisplayed(this.eValueTo2.getGui(), showTo2);
  15422. };
  15423. NumberFilter.FILTER_TYPE = 'number';
  15424. NumberFilter.DEFAULT_FILTER_OPTIONS = [
  15425. ScalarFilter.EQUALS,
  15426. ScalarFilter.NOT_EQUAL,
  15427. ScalarFilter.LESS_THAN,
  15428. ScalarFilter.LESS_THAN_OR_EQUAL,
  15429. ScalarFilter.GREATER_THAN,
  15430. ScalarFilter.GREATER_THAN_OR_EQUAL,
  15431. ScalarFilter.IN_RANGE
  15432. ];
  15433. __decorate$s([
  15434. RefSelector('eValueFrom1')
  15435. ], NumberFilter.prototype, "eValueFrom1", void 0);
  15436. __decorate$s([
  15437. RefSelector('eValueFrom2')
  15438. ], NumberFilter.prototype, "eValueFrom2", void 0);
  15439. __decorate$s([
  15440. RefSelector('eValueTo1')
  15441. ], NumberFilter.prototype, "eValueTo1", void 0);
  15442. __decorate$s([
  15443. RefSelector('eValueTo2')
  15444. ], NumberFilter.prototype, "eValueTo2", void 0);
  15445. return NumberFilter;
  15446. }(ScalarFilter));
  15447. /**
  15448. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  15449. * @version v23.2.1
  15450. * @link http://www.ag-grid.com/
  15451. * @license MIT
  15452. */
  15453. var __extends$s = (undefined && undefined.__extends) || (function () {
  15454. var extendStatics = function (d, b) {
  15455. extendStatics = Object.setPrototypeOf ||
  15456. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  15457. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  15458. return extendStatics(d, b);
  15459. };
  15460. return function (d, b) {
  15461. extendStatics(d, b);
  15462. function __() { this.constructor = d; }
  15463. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  15464. };
  15465. })();
  15466. var __decorate$t = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  15467. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  15468. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  15469. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  15470. return c > 3 && r && Object.defineProperty(target, key, r), r;
  15471. };
  15472. var LoadingOverlayComponent$1 = /** @class */ (function (_super) {
  15473. __extends$s(LoadingOverlayComponent, _super);
  15474. function LoadingOverlayComponent() {
  15475. return _super.call(this) || this;
  15476. }
  15477. // this is a user component, and IComponent has "public destroy()" as part of the interface.
  15478. // so we need to override destroy() just to make the method public.
  15479. LoadingOverlayComponent.prototype.destroy = function () {
  15480. _super.prototype.destroy.call(this);
  15481. };
  15482. LoadingOverlayComponent.prototype.init = function (params) {
  15483. var template = this.gridOptionsWrapper.getOverlayLoadingTemplate() ?
  15484. this.gridOptionsWrapper.getOverlayLoadingTemplate() : LoadingOverlayComponent.DEFAULT_LOADING_OVERLAY_TEMPLATE;
  15485. var localeTextFunc = this.gridOptionsWrapper.getLocaleTextFunc();
  15486. var localisedTemplate = template.replace('[LOADING...]', localeTextFunc('loadingOoo', 'Loading...'));
  15487. this.setTemplate(localisedTemplate);
  15488. };
  15489. LoadingOverlayComponent.DEFAULT_LOADING_OVERLAY_TEMPLATE = '<span class="ag-overlay-loading-center">[LOADING...]</span>';
  15490. __decorate$t([
  15491. Autowired('gridOptionsWrapper')
  15492. ], LoadingOverlayComponent.prototype, "gridOptionsWrapper", void 0);
  15493. return LoadingOverlayComponent;
  15494. }(Component));
  15495. /**
  15496. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  15497. * @version v23.2.1
  15498. * @link http://www.ag-grid.com/
  15499. * @license MIT
  15500. */
  15501. var __extends$t = (undefined && undefined.__extends) || (function () {
  15502. var extendStatics = function (d, b) {
  15503. extendStatics = Object.setPrototypeOf ||
  15504. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  15505. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  15506. return extendStatics(d, b);
  15507. };
  15508. return function (d, b) {
  15509. extendStatics(d, b);
  15510. function __() { this.constructor = d; }
  15511. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  15512. };
  15513. })();
  15514. var __decorate$u = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  15515. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  15516. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  15517. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  15518. return c > 3 && r && Object.defineProperty(target, key, r), r;
  15519. };
  15520. var NoRowsOverlayComponent$1 = /** @class */ (function (_super) {
  15521. __extends$t(NoRowsOverlayComponent, _super);
  15522. function NoRowsOverlayComponent() {
  15523. return _super.call(this) || this;
  15524. }
  15525. // this is a user component, and IComponent has "public destroy()" as part of the interface.
  15526. // so we need to override destroy() just to make the method public.
  15527. NoRowsOverlayComponent.prototype.destroy = function () {
  15528. _super.prototype.destroy.call(this);
  15529. };
  15530. NoRowsOverlayComponent.prototype.init = function (params) {
  15531. var template = this.gridOptionsWrapper.getOverlayNoRowsTemplate() ?
  15532. this.gridOptionsWrapper.getOverlayNoRowsTemplate() : NoRowsOverlayComponent.DEFAULT_NO_ROWS_TEMPLATE;
  15533. var localeTextFunc = this.gridOptionsWrapper.getLocaleTextFunc();
  15534. var localisedTemplate = template.replace('[NO_ROWS_TO_SHOW]', localeTextFunc('noRowsToShow', 'No Rows To Show'));
  15535. this.setTemplate(localisedTemplate);
  15536. };
  15537. NoRowsOverlayComponent.DEFAULT_NO_ROWS_TEMPLATE = '<span class="ag-overlay-no-rows-center">[NO_ROWS_TO_SHOW]</span>';
  15538. __decorate$u([
  15539. Autowired('gridOptionsWrapper')
  15540. ], NoRowsOverlayComponent.prototype, "gridOptionsWrapper", void 0);
  15541. return NoRowsOverlayComponent;
  15542. }(Component));
  15543. /**
  15544. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  15545. * @version v23.2.1
  15546. * @link http://www.ag-grid.com/
  15547. * @license MIT
  15548. */
  15549. var __extends$u = (undefined && undefined.__extends) || (function () {
  15550. var extendStatics = function (d, b) {
  15551. extendStatics = Object.setPrototypeOf ||
  15552. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  15553. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  15554. return extendStatics(d, b);
  15555. };
  15556. return function (d, b) {
  15557. extendStatics(d, b);
  15558. function __() { this.constructor = d; }
  15559. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  15560. };
  15561. })();
  15562. var TooltipComponent$1 = /** @class */ (function (_super) {
  15563. __extends$u(TooltipComponent, _super);
  15564. function TooltipComponent() {
  15565. return _super.call(this, /* html */ "<div class=\"ag-tooltip\"></div>") || this;
  15566. }
  15567. // will need to type params
  15568. TooltipComponent.prototype.init = function (params) {
  15569. var value = params.value;
  15570. this.getGui().innerHTML = value;
  15571. };
  15572. return TooltipComponent;
  15573. }(PopupComponent));
  15574. /**
  15575. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  15576. * @version v23.2.1
  15577. * @link http://www.ag-grid.com/
  15578. * @license MIT
  15579. */
  15580. var __extends$v = (undefined && undefined.__extends) || (function () {
  15581. var extendStatics = function (d, b) {
  15582. extendStatics = Object.setPrototypeOf ||
  15583. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  15584. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  15585. return extendStatics(d, b);
  15586. };
  15587. return function (d, b) {
  15588. extendStatics(d, b);
  15589. function __() { this.constructor = d; }
  15590. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  15591. };
  15592. })();
  15593. var __decorate$v = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  15594. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  15595. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  15596. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  15597. return c > 3 && r && Object.defineProperty(target, key, r), r;
  15598. };
  15599. var DefaultDateComponent = /** @class */ (function (_super) {
  15600. __extends$v(DefaultDateComponent, _super);
  15601. function DefaultDateComponent() {
  15602. return _super.call(this, /* html */ "\n <div class=\"ag-filter-filter\">\n <ag-input-text-field class=\"ag-date-filter\" ref=\"eDateInput\"></ag-input-text-field>\n </div>") || this;
  15603. }
  15604. // this is a user component, and IComponent has "public destroy()" as part of the interface.
  15605. // so we need to override destroy() just to make the method public.
  15606. DefaultDateComponent.prototype.destroy = function () {
  15607. _super.prototype.destroy.call(this);
  15608. };
  15609. DefaultDateComponent.prototype.init = function (params) {
  15610. var _this = this;
  15611. if (this.shouldUseBrowserDatePicker(params)) {
  15612. if (isBrowserIE()) {
  15613. console.warn('ag-grid: browserDatePicker is specified to true, but it is not supported in IE 11, reverting to plain text date picker');
  15614. }
  15615. else {
  15616. this.eDateInput.getInputElement().type = 'date';
  15617. }
  15618. }
  15619. this.listener = params.onDateChanged;
  15620. this.addManagedListener(this.eDateInput.getInputElement(), 'input', function (e) {
  15621. if (e.target !== document.activeElement) {
  15622. return;
  15623. }
  15624. _this.listener();
  15625. });
  15626. };
  15627. DefaultDateComponent.prototype.getDate = function () {
  15628. return parseDateTimeFromString(this.eDateInput.getValue());
  15629. };
  15630. DefaultDateComponent.prototype.setDate = function (date) {
  15631. this.eDateInput.setValue(serialiseDate(date, false));
  15632. };
  15633. DefaultDateComponent.prototype.setInputPlaceholder = function (placeholder) {
  15634. this.eDateInput.setInputPlaceholder(placeholder);
  15635. };
  15636. DefaultDateComponent.prototype.shouldUseBrowserDatePicker = function (params) {
  15637. if (params.filterParams && params.filterParams.browserDatePicker != null) {
  15638. return params.filterParams.browserDatePicker;
  15639. }
  15640. else {
  15641. return isBrowserChrome() || isBrowserFirefox();
  15642. }
  15643. };
  15644. __decorate$v([
  15645. RefSelector('eDateInput')
  15646. ], DefaultDateComponent.prototype, "eDateInput", void 0);
  15647. return DefaultDateComponent;
  15648. }(Component));
  15649. /**
  15650. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  15651. * @version v23.2.1
  15652. * @link http://www.ag-grid.com/
  15653. * @license MIT
  15654. */
  15655. var __extends$w = (undefined && undefined.__extends) || (function () {
  15656. var extendStatics = function (d, b) {
  15657. extendStatics = Object.setPrototypeOf ||
  15658. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  15659. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  15660. return extendStatics(d, b);
  15661. };
  15662. return function (d, b) {
  15663. extendStatics(d, b);
  15664. function __() { this.constructor = d; }
  15665. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  15666. };
  15667. })();
  15668. var SimpleFloatingFilter = /** @class */ (function (_super) {
  15669. __extends$w(SimpleFloatingFilter, _super);
  15670. function SimpleFloatingFilter() {
  15671. return _super !== null && _super.apply(this, arguments) || this;
  15672. }
  15673. SimpleFloatingFilter.prototype.getDefaultDebounceMs = function () {
  15674. return 0;
  15675. };
  15676. // this is a user component, and IComponent has "public destroy()" as part of the interface.
  15677. // so we need to override destroy() just to make the method public.
  15678. SimpleFloatingFilter.prototype.destroy = function () {
  15679. _super.prototype.destroy.call(this);
  15680. };
  15681. // used by:
  15682. // 1) NumberFloatingFilter & TextFloatingFilter: Always, for both when editable and read only.
  15683. // 2) DateFloatingFilter: Only when read only (as we show text rather than a date picker when read only)
  15684. SimpleFloatingFilter.prototype.getTextFromModel = function (model) {
  15685. if (!model) {
  15686. return null;
  15687. }
  15688. var isCombined = model.operator;
  15689. if (isCombined) {
  15690. var combinedModel = model;
  15691. var con1Str = this.conditionToString(combinedModel.condition1);
  15692. var con2Str = this.conditionToString(combinedModel.condition2);
  15693. return con1Str + " " + combinedModel.operator + " " + con2Str;
  15694. }
  15695. else {
  15696. var condition = model;
  15697. return this.conditionToString(condition);
  15698. }
  15699. };
  15700. SimpleFloatingFilter.prototype.isEventFromFloatingFilter = function (event) {
  15701. return event && event.afterFloatingFilter;
  15702. };
  15703. SimpleFloatingFilter.prototype.getLastType = function () {
  15704. return this.lastType;
  15705. };
  15706. SimpleFloatingFilter.prototype.setLastTypeFromModel = function (model) {
  15707. // if no model provided by the parent filter use default
  15708. if (!model) {
  15709. this.lastType = this.optionsFactory.getDefaultOption();
  15710. return;
  15711. }
  15712. var isCombined = model.operator;
  15713. var condition;
  15714. if (isCombined) {
  15715. var combinedModel = model;
  15716. condition = combinedModel.condition1;
  15717. }
  15718. else {
  15719. condition = model;
  15720. }
  15721. this.lastType = condition.type;
  15722. };
  15723. SimpleFloatingFilter.prototype.canWeEditAfterModelFromParentFilter = function (model) {
  15724. if (!model) {
  15725. // if no model, then we can edit as long as the lastType is something we can edit, as this
  15726. // is the type we will provide to the parent filter if the user decides to use the floating filter.
  15727. return this.isTypeEditable(this.lastType);
  15728. }
  15729. // never allow editing if the filter is combined (ie has two parts)
  15730. var isCombined = model.operator;
  15731. if (isCombined) {
  15732. return false;
  15733. }
  15734. var simpleModel = model;
  15735. return this.isTypeEditable(simpleModel.type);
  15736. };
  15737. SimpleFloatingFilter.prototype.init = function (params) {
  15738. this.optionsFactory = new OptionsFactory();
  15739. this.optionsFactory.init(params.filterParams, this.getDefaultFilterOptions());
  15740. this.lastType = this.optionsFactory.getDefaultOption();
  15741. // we are editable if:
  15742. // 1) there is a type (user has configured filter wrong if not type)
  15743. // AND
  15744. // 2) the default type is not 'in range'
  15745. var editable = this.isTypeEditable(this.lastType);
  15746. this.setEditable(editable);
  15747. };
  15748. SimpleFloatingFilter.prototype.doesFilterHaveHiddenInput = function (filterType) {
  15749. var customFilterOption = this.optionsFactory.getCustomOption(filterType);
  15750. return customFilterOption && customFilterOption.hideFilterInput;
  15751. };
  15752. SimpleFloatingFilter.prototype.isTypeEditable = function (type) {
  15753. return !this.doesFilterHaveHiddenInput(type) &&
  15754. type
  15755. && type !== SimpleFilter.IN_RANGE
  15756. && type !== SimpleFilter.EMPTY;
  15757. };
  15758. return SimpleFloatingFilter;
  15759. }(Component));
  15760. /**
  15761. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  15762. * @version v23.2.1
  15763. * @link http://www.ag-grid.com/
  15764. * @license MIT
  15765. */
  15766. var __extends$x = (undefined && undefined.__extends) || (function () {
  15767. var extendStatics = function (d, b) {
  15768. extendStatics = Object.setPrototypeOf ||
  15769. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  15770. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  15771. return extendStatics(d, b);
  15772. };
  15773. return function (d, b) {
  15774. extendStatics(d, b);
  15775. function __() { this.constructor = d; }
  15776. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  15777. };
  15778. })();
  15779. var __decorate$w = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  15780. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  15781. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  15782. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  15783. return c > 3 && r && Object.defineProperty(target, key, r), r;
  15784. };
  15785. var DateFloatingFilter = /** @class */ (function (_super) {
  15786. __extends$x(DateFloatingFilter, _super);
  15787. function DateFloatingFilter() {
  15788. return _super.call(this, /* html */ "\n <div class=\"ag-floating-filter-input\" role=\"presentation\">\n <ag-input-text-field ref=\"eReadOnlyText\"></ag-input-text-field>\n <div ref=\"eDateWrapper\" style=\"display: flex; overflow: hidden;\"></div>\n </div>") || this;
  15789. }
  15790. DateFloatingFilter.prototype.getDefaultFilterOptions = function () {
  15791. return DateFilter.DEFAULT_FILTER_OPTIONS;
  15792. };
  15793. DateFloatingFilter.prototype.conditionToString = function (condition) {
  15794. if (condition.type === SimpleFilter.IN_RANGE) {
  15795. return condition.dateFrom + "-" + condition.dateTo;
  15796. }
  15797. // cater for when the type doesn't need a value
  15798. if (condition.dateFrom != null) {
  15799. return "" + condition.dateFrom;
  15800. }
  15801. return "" + condition.type;
  15802. };
  15803. DateFloatingFilter.prototype.init = function (params) {
  15804. _super.prototype.init.call(this, params);
  15805. this.params = params;
  15806. this.createDateComponent();
  15807. this.eReadOnlyText
  15808. .setDisabled(true)
  15809. .setInputAriaLabel('Date Filter Input');
  15810. };
  15811. DateFloatingFilter.prototype.setEditable = function (editable) {
  15812. setDisplayed(this.eDateWrapper, editable);
  15813. setDisplayed(this.eReadOnlyText.getGui(), !editable);
  15814. };
  15815. DateFloatingFilter.prototype.onParentModelChanged = function (model, event) {
  15816. // We don't want to update the floating filter if the floating filter caused the change,
  15817. // because the UI is already in sync. if we didn't do this, the UI would behave strangely
  15818. // as it would be updating as the user is typing
  15819. if (this.isEventFromFloatingFilter(event)) {
  15820. return;
  15821. }
  15822. _super.prototype.setLastTypeFromModel.call(this, model);
  15823. var allowEditing = this.canWeEditAfterModelFromParentFilter(model);
  15824. this.setEditable(allowEditing);
  15825. if (allowEditing) {
  15826. if (model) {
  15827. var dateModel = model;
  15828. this.dateComp.setDate(parseDateTimeFromString(dateModel.dateFrom));
  15829. }
  15830. else {
  15831. this.dateComp.setDate(null);
  15832. }
  15833. this.eReadOnlyText.setValue('');
  15834. }
  15835. else {
  15836. this.eReadOnlyText.setValue(this.getTextFromModel(model));
  15837. this.dateComp.setDate(null);
  15838. }
  15839. };
  15840. DateFloatingFilter.prototype.onDateChanged = function () {
  15841. var _this = this;
  15842. var filterValueDate = this.dateComp.getDate();
  15843. var filterValueText = serialiseDate(filterValueDate);
  15844. this.params.parentFilterInstance(function (filterInstance) {
  15845. if (filterInstance) {
  15846. var simpleFilter = filterInstance;
  15847. simpleFilter.onFloatingFilterChanged(_this.getLastType(), filterValueText);
  15848. }
  15849. });
  15850. };
  15851. DateFloatingFilter.prototype.createDateComponent = function () {
  15852. var _this = this;
  15853. var debounceMs = ProvidedFilter.getDebounceMs(this.params.filterParams, this.getDefaultDebounceMs());
  15854. var dateComponentParams = {
  15855. onDateChanged: debounce(this.onDateChanged.bind(this), debounceMs),
  15856. filterParams: this.params.column.getColDef().filterParams
  15857. };
  15858. this.dateComp = new DateCompWrapper(this.getContext(), this.userComponentFactory, dateComponentParams, this.eDateWrapper);
  15859. this.addDestroyFunc(function () { return _this.dateComp.destroy(); });
  15860. };
  15861. __decorate$w([
  15862. Autowired('userComponentFactory')
  15863. ], DateFloatingFilter.prototype, "userComponentFactory", void 0);
  15864. __decorate$w([
  15865. RefSelector('eReadOnlyText')
  15866. ], DateFloatingFilter.prototype, "eReadOnlyText", void 0);
  15867. __decorate$w([
  15868. RefSelector('eDateWrapper')
  15869. ], DateFloatingFilter.prototype, "eDateWrapper", void 0);
  15870. return DateFloatingFilter;
  15871. }(SimpleFloatingFilter));
  15872. /**
  15873. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  15874. * @version v23.2.1
  15875. * @link http://www.ag-grid.com/
  15876. * @license MIT
  15877. */
  15878. var __extends$y = (undefined && undefined.__extends) || (function () {
  15879. var extendStatics = function (d, b) {
  15880. extendStatics = Object.setPrototypeOf ||
  15881. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  15882. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  15883. return extendStatics(d, b);
  15884. };
  15885. return function (d, b) {
  15886. extendStatics(d, b);
  15887. function __() { this.constructor = d; }
  15888. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  15889. };
  15890. })();
  15891. var __decorate$x = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  15892. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  15893. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  15894. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  15895. return c > 3 && r && Object.defineProperty(target, key, r), r;
  15896. };
  15897. var TextFilter = /** @class */ (function (_super) {
  15898. __extends$y(TextFilter, _super);
  15899. function TextFilter() {
  15900. return _super !== null && _super.apply(this, arguments) || this;
  15901. }
  15902. TextFilter.prototype.getDefaultDebounceMs = function () {
  15903. return 500;
  15904. };
  15905. TextFilter.prototype.getValue = function (inputField) {
  15906. var val = inputField.getValue();
  15907. val = makeNull(val);
  15908. if (val && val.trim() === '') {
  15909. val = null;
  15910. }
  15911. return val;
  15912. };
  15913. TextFilter.prototype.addValueChangedListeners = function () {
  15914. var _this = this;
  15915. var listener = function () { return _this.onUiChanged(); };
  15916. this.eValue1.onValueChange(listener);
  15917. this.eValue2.onValueChange(listener);
  15918. };
  15919. TextFilter.prototype.setParams = function (params) {
  15920. _super.prototype.setParams.call(this, params);
  15921. this.textFilterParams = params;
  15922. this.comparator = this.textFilterParams.textCustomComparator || TextFilter.DEFAULT_COMPARATOR;
  15923. this.formatter = this.textFilterParams.textFormatter ||
  15924. (this.textFilterParams.caseSensitive == true
  15925. ? TextFilter.DEFAULT_FORMATTER
  15926. : TextFilter.DEFAULT_LOWERCASE_FORMATTER);
  15927. this.addValueChangedListeners();
  15928. };
  15929. TextFilter.prototype.setConditionIntoUi = function (model, position) {
  15930. var positionOne = position === ConditionPosition.One;
  15931. var eValue = positionOne ? this.eValue1 : this.eValue2;
  15932. eValue.setValue(model ? model.filter : null);
  15933. };
  15934. TextFilter.prototype.createCondition = function (position) {
  15935. var positionOne = position === ConditionPosition.One;
  15936. var type = positionOne ? this.getCondition1Type() : this.getCondition2Type();
  15937. var eValue = positionOne ? this.eValue1 : this.eValue2;
  15938. var value = this.getValue(eValue);
  15939. var model = {
  15940. filterType: TextFilter.FILTER_TYPE,
  15941. type: type
  15942. };
  15943. if (!this.doesFilterHaveHiddenInput(type)) {
  15944. model.filter = value;
  15945. }
  15946. return model;
  15947. };
  15948. TextFilter.prototype.getFilterType = function () {
  15949. return TextFilter.FILTER_TYPE;
  15950. };
  15951. TextFilter.prototype.areSimpleModelsEqual = function (aSimple, bSimple) {
  15952. return aSimple.filter === bSimple.filter && aSimple.type === bSimple.type;
  15953. };
  15954. TextFilter.prototype.resetUiToDefaults = function (silent) {
  15955. var _this = this;
  15956. return _super.prototype.resetUiToDefaults.call(this, silent).then(function () {
  15957. _this.forEachInput(function (field) { return field.setValue(null, silent); });
  15958. _this.resetPlaceholder();
  15959. });
  15960. };
  15961. TextFilter.prototype.resetPlaceholder = function () {
  15962. var placeholder = this.translate('filterOoo');
  15963. this.forEachInput(function (field) { return field.setInputPlaceholder(placeholder); });
  15964. };
  15965. TextFilter.prototype.forEachInput = function (action) {
  15966. forEach([this.eValue1, this.eValue2], action);
  15967. };
  15968. TextFilter.prototype.setValueFromFloatingFilter = function (value) {
  15969. this.eValue1.setValue(value);
  15970. this.eValue2.setValue(null);
  15971. };
  15972. TextFilter.prototype.getDefaultFilterOptions = function () {
  15973. return TextFilter.DEFAULT_FILTER_OPTIONS;
  15974. };
  15975. TextFilter.prototype.createValueTemplate = function (position) {
  15976. var pos = position === ConditionPosition.One ? '1' : '2';
  15977. return /* html */ "\n <div class=\"ag-filter-body\" ref=\"eCondition" + pos + "Body\" role=\"presentation\">\n <ag-input-text-field class=\"ag-filter-filter\" ref=\"eValue" + pos + "\"></ag-input-text-field>\n </div>";
  15978. };
  15979. TextFilter.prototype.updateUiVisibility = function () {
  15980. _super.prototype.updateUiVisibility.call(this);
  15981. var showValue1 = this.showValueFrom(this.getCondition1Type());
  15982. setDisplayed(this.eValue1.getGui(), showValue1);
  15983. var showValue2 = this.showValueFrom(this.getCondition2Type());
  15984. setDisplayed(this.eValue2.getGui(), showValue2);
  15985. };
  15986. TextFilter.prototype.afterGuiAttached = function (params) {
  15987. _super.prototype.afterGuiAttached.call(this, params);
  15988. this.resetPlaceholder();
  15989. this.eValue1.getInputElement().focus();
  15990. };
  15991. TextFilter.prototype.isConditionUiComplete = function (position) {
  15992. var positionOne = position === ConditionPosition.One;
  15993. var option = positionOne ? this.getCondition1Type() : this.getCondition2Type();
  15994. if (option === SimpleFilter.EMPTY) {
  15995. return false;
  15996. }
  15997. if (this.doesFilterHaveHiddenInput(option)) {
  15998. return true;
  15999. }
  16000. return this.getValue(positionOne ? this.eValue1 : this.eValue2) != null;
  16001. };
  16002. TextFilter.prototype.individualConditionPasses = function (params, filterModel) {
  16003. var filterText = filterModel.filter;
  16004. var filterOption = filterModel.type;
  16005. var cellValue = this.textFilterParams.valueGetter(params.node);
  16006. var cellValueFormatted = this.formatter(cellValue);
  16007. var customFilterOption = this.optionsFactory.getCustomOption(filterOption);
  16008. if (customFilterOption) {
  16009. // only execute the custom filter if a value exists or a value isn't required, i.e. input is hidden
  16010. if (filterText != null || customFilterOption.hideFilterInput) {
  16011. return customFilterOption.test(filterText, cellValueFormatted);
  16012. }
  16013. }
  16014. if (cellValue == null) {
  16015. return filterOption === SimpleFilter.NOT_EQUAL || filterOption === SimpleFilter.NOT_CONTAINS;
  16016. }
  16017. var filterTextFormatted = this.formatter(filterText);
  16018. return this.comparator(filterOption, cellValueFormatted, filterTextFormatted);
  16019. };
  16020. TextFilter.FILTER_TYPE = 'text';
  16021. TextFilter.DEFAULT_FILTER_OPTIONS = [
  16022. SimpleFilter.CONTAINS,
  16023. SimpleFilter.NOT_CONTAINS,
  16024. SimpleFilter.EQUALS,
  16025. SimpleFilter.NOT_EQUAL,
  16026. SimpleFilter.STARTS_WITH,
  16027. SimpleFilter.ENDS_WITH
  16028. ];
  16029. TextFilter.DEFAULT_FORMATTER = function (from) { return from; };
  16030. TextFilter.DEFAULT_LOWERCASE_FORMATTER = function (from) {
  16031. return from == null ? null : from.toString().toLowerCase();
  16032. };
  16033. TextFilter.DEFAULT_COMPARATOR = function (filter, value, filterText) {
  16034. switch (filter) {
  16035. case TextFilter.CONTAINS:
  16036. return value.indexOf(filterText) >= 0;
  16037. case TextFilter.NOT_CONTAINS:
  16038. return value.indexOf(filterText) === -1;
  16039. case TextFilter.EQUALS:
  16040. return value === filterText;
  16041. case TextFilter.NOT_EQUAL:
  16042. return value != filterText;
  16043. case TextFilter.STARTS_WITH:
  16044. return value.indexOf(filterText) === 0;
  16045. case TextFilter.ENDS_WITH:
  16046. var index = value.lastIndexOf(filterText);
  16047. return index >= 0 && index === (value.length - filterText.length);
  16048. default:
  16049. // should never happen
  16050. console.warn('invalid filter type ' + filter);
  16051. return false;
  16052. }
  16053. };
  16054. __decorate$x([
  16055. RefSelector('eValue1')
  16056. ], TextFilter.prototype, "eValue1", void 0);
  16057. __decorate$x([
  16058. RefSelector('eValue2')
  16059. ], TextFilter.prototype, "eValue2", void 0);
  16060. return TextFilter;
  16061. }(SimpleFilter));
  16062. /**
  16063. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  16064. * @version v23.2.1
  16065. * @link http://www.ag-grid.com/
  16066. * @license MIT
  16067. */
  16068. var __extends$z = (undefined && undefined.__extends) || (function () {
  16069. var extendStatics = function (d, b) {
  16070. extendStatics = Object.setPrototypeOf ||
  16071. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  16072. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  16073. return extendStatics(d, b);
  16074. };
  16075. return function (d, b) {
  16076. extendStatics(d, b);
  16077. function __() { this.constructor = d; }
  16078. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  16079. };
  16080. })();
  16081. var __decorate$y = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  16082. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  16083. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  16084. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  16085. return c > 3 && r && Object.defineProperty(target, key, r), r;
  16086. };
  16087. var TextInputFloatingFilter = /** @class */ (function (_super) {
  16088. __extends$z(TextInputFloatingFilter, _super);
  16089. function TextInputFloatingFilter() {
  16090. return _super !== null && _super.apply(this, arguments) || this;
  16091. }
  16092. TextInputFloatingFilter.prototype.postConstruct = function () {
  16093. this.setTemplate(/* html */ "\n <div class=\"ag-floating-filter-input\" role=\"presentation\">\n <ag-input-text-field ref=\"eFloatingFilterInput\"></ag-input-text-field>\n </div>");
  16094. };
  16095. TextInputFloatingFilter.prototype.getDefaultDebounceMs = function () {
  16096. return 500;
  16097. };
  16098. TextInputFloatingFilter.prototype.onParentModelChanged = function (model, event) {
  16099. // we don't want to update the floating filter if the floating filter caused the change.
  16100. // as if it caused the change, the ui is already in sync. if we didn't do this, the UI
  16101. // would behave strange as it would be updating as the user is typing
  16102. if (this.isEventFromFloatingFilter(event)) {
  16103. return;
  16104. }
  16105. this.setLastTypeFromModel(model);
  16106. var modelString = this.getTextFromModel(model);
  16107. this.eFloatingFilterInput.setValue(modelString);
  16108. var editable = this.canWeEditAfterModelFromParentFilter(model);
  16109. this.setEditable(editable);
  16110. };
  16111. TextInputFloatingFilter.prototype.init = function (params) {
  16112. _super.prototype.init.call(this, params);
  16113. this.params = params;
  16114. this.applyActive = ProvidedFilter.isUseApplyButton(this.params.filterParams);
  16115. var debounceMs = ProvidedFilter.getDebounceMs(this.params.filterParams, this.getDefaultDebounceMs());
  16116. var toDebounce = debounce(this.syncUpWithParentFilter.bind(this), debounceMs);
  16117. var filterGui = this.eFloatingFilterInput.getGui();
  16118. this.addManagedListener(filterGui, 'input', toDebounce);
  16119. this.addManagedListener(filterGui, 'keypress', toDebounce);
  16120. this.addManagedListener(filterGui, 'keydown', toDebounce);
  16121. var columnDef = params.column.getDefinition();
  16122. if (columnDef.filterParams &&
  16123. columnDef.filterParams.filterOptions &&
  16124. columnDef.filterParams.filterOptions.length === 1 &&
  16125. columnDef.filterParams.filterOptions[0] === 'inRange') {
  16126. this.eFloatingFilterInput.setDisabled(true);
  16127. }
  16128. var displayName = this.columnController.getDisplayNameForColumn(params.column, 'header', true);
  16129. this.eFloatingFilterInput.setInputAriaLabel(displayName + " Filter Input");
  16130. };
  16131. TextInputFloatingFilter.prototype.syncUpWithParentFilter = function (e) {
  16132. var _this = this;
  16133. var value = this.eFloatingFilterInput.getValue();
  16134. var enterKeyPressed = isKeyPressed(e, Constants.KEY_ENTER);
  16135. if (this.applyActive && !enterKeyPressed) {
  16136. return;
  16137. }
  16138. this.params.parentFilterInstance(function (filterInstance) {
  16139. if (filterInstance) {
  16140. var simpleFilter = filterInstance;
  16141. simpleFilter.onFloatingFilterChanged(_this.getLastType(), value);
  16142. }
  16143. });
  16144. };
  16145. TextInputFloatingFilter.prototype.setEditable = function (editable) {
  16146. this.eFloatingFilterInput.setDisabled(!editable);
  16147. };
  16148. __decorate$y([
  16149. Autowired('columnController')
  16150. ], TextInputFloatingFilter.prototype, "columnController", void 0);
  16151. __decorate$y([
  16152. RefSelector('eFloatingFilterInput')
  16153. ], TextInputFloatingFilter.prototype, "eFloatingFilterInput", void 0);
  16154. __decorate$y([
  16155. PostConstruct
  16156. ], TextInputFloatingFilter.prototype, "postConstruct", null);
  16157. return TextInputFloatingFilter;
  16158. }(SimpleFloatingFilter));
  16159. /**
  16160. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  16161. * @version v23.2.1
  16162. * @link http://www.ag-grid.com/
  16163. * @license MIT
  16164. */
  16165. var __extends$A = (undefined && undefined.__extends) || (function () {
  16166. var extendStatics = function (d, b) {
  16167. extendStatics = Object.setPrototypeOf ||
  16168. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  16169. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  16170. return extendStatics(d, b);
  16171. };
  16172. return function (d, b) {
  16173. extendStatics(d, b);
  16174. function __() { this.constructor = d; }
  16175. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  16176. };
  16177. })();
  16178. var NumberFloatingFilter = /** @class */ (function (_super) {
  16179. __extends$A(NumberFloatingFilter, _super);
  16180. function NumberFloatingFilter() {
  16181. return _super !== null && _super.apply(this, arguments) || this;
  16182. }
  16183. NumberFloatingFilter.prototype.getDefaultFilterOptions = function () {
  16184. return NumberFilter.DEFAULT_FILTER_OPTIONS;
  16185. };
  16186. NumberFloatingFilter.prototype.conditionToString = function (condition) {
  16187. var isRange = condition.type == SimpleFilter.IN_RANGE;
  16188. if (isRange) {
  16189. return condition.filter + "-" + condition.filterTo;
  16190. }
  16191. // cater for when the type doesn't need a value
  16192. if (condition.filter != null) {
  16193. return "" + condition.filter;
  16194. }
  16195. return "" + condition.type;
  16196. };
  16197. return NumberFloatingFilter;
  16198. }(TextInputFloatingFilter));
  16199. /**
  16200. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  16201. * @version v23.2.1
  16202. * @link http://www.ag-grid.com/
  16203. * @license MIT
  16204. */
  16205. var __extends$B = (undefined && undefined.__extends) || (function () {
  16206. var extendStatics = function (d, b) {
  16207. extendStatics = Object.setPrototypeOf ||
  16208. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  16209. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  16210. return extendStatics(d, b);
  16211. };
  16212. return function (d, b) {
  16213. extendStatics(d, b);
  16214. function __() { this.constructor = d; }
  16215. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  16216. };
  16217. })();
  16218. var TextFloatingFilter = /** @class */ (function (_super) {
  16219. __extends$B(TextFloatingFilter, _super);
  16220. function TextFloatingFilter() {
  16221. return _super !== null && _super.apply(this, arguments) || this;
  16222. }
  16223. TextFloatingFilter.prototype.conditionToString = function (condition) {
  16224. // it's not possible to have 'in range' for string, so no need to check for it.
  16225. // also cater for when the type doesn't need a value
  16226. if (condition.filter != null) {
  16227. return "" + condition.filter;
  16228. }
  16229. else {
  16230. return "" + condition.type;
  16231. }
  16232. };
  16233. TextFloatingFilter.prototype.getDefaultFilterOptions = function () {
  16234. return TextFilter.DEFAULT_FILTER_OPTIONS;
  16235. };
  16236. return TextFloatingFilter;
  16237. }(TextInputFloatingFilter));
  16238. /**
  16239. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  16240. * @version v23.2.1
  16241. * @link http://www.ag-grid.com/
  16242. * @license MIT
  16243. */
  16244. var __extends$C = (undefined && undefined.__extends) || (function () {
  16245. var extendStatics = function (d, b) {
  16246. extendStatics = Object.setPrototypeOf ||
  16247. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  16248. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  16249. return extendStatics(d, b);
  16250. };
  16251. return function (d, b) {
  16252. extendStatics(d, b);
  16253. function __() { this.constructor = d; }
  16254. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  16255. };
  16256. })();
  16257. var __decorate$z = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  16258. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  16259. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  16260. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  16261. return c > 3 && r && Object.defineProperty(target, key, r), r;
  16262. };
  16263. var RegisteredComponentSource;
  16264. (function (RegisteredComponentSource) {
  16265. RegisteredComponentSource[RegisteredComponentSource["DEFAULT"] = 0] = "DEFAULT";
  16266. RegisteredComponentSource[RegisteredComponentSource["REGISTERED"] = 1] = "REGISTERED";
  16267. })(RegisteredComponentSource || (RegisteredComponentSource = {}));
  16268. var UserComponentRegistry = /** @class */ (function (_super) {
  16269. __extends$C(UserComponentRegistry, _super);
  16270. function UserComponentRegistry() {
  16271. var _this = _super !== null && _super.apply(this, arguments) || this;
  16272. _this.agGridDefaults = {
  16273. //date
  16274. agDateInput: DefaultDateComponent,
  16275. //header
  16276. agColumnHeader: HeaderComp,
  16277. agColumnGroupHeader: HeaderGroupComp,
  16278. //floating filters
  16279. agTextColumnFloatingFilter: TextFloatingFilter,
  16280. agNumberColumnFloatingFilter: NumberFloatingFilter,
  16281. agDateColumnFloatingFilter: DateFloatingFilter,
  16282. // renderers
  16283. agAnimateShowChangeCellRenderer: AnimateShowChangeCellRenderer,
  16284. agAnimateSlideCellRenderer: AnimateSlideCellRenderer,
  16285. agGroupCellRenderer: GroupCellRenderer,
  16286. agGroupRowRenderer: GroupCellRenderer,
  16287. agLoadingCellRenderer: LoadingCellRenderer,
  16288. //editors
  16289. agCellEditor: TextCellEditor,
  16290. agTextCellEditor: TextCellEditor,
  16291. agSelectCellEditor: SelectCellEditor,
  16292. agPopupTextCellEditor: PopupTextCellEditor,
  16293. agPopupSelectCellEditor: PopupSelectCellEditor,
  16294. agLargeTextCellEditor: LargeTextCellEditor,
  16295. //filter
  16296. agTextColumnFilter: TextFilter,
  16297. agNumberColumnFilter: NumberFilter,
  16298. agDateColumnFilter: DateFilter,
  16299. //overlays
  16300. agLoadingOverlay: LoadingOverlayComponent$1,
  16301. agNoRowsOverlay: NoRowsOverlayComponent$1,
  16302. // tooltips
  16303. agTooltipComponent: TooltipComponent$1
  16304. };
  16305. _this.agDeprecatedNames = {
  16306. set: {
  16307. newComponentName: 'agSetColumnFilter',
  16308. propertyHolder: 'filter'
  16309. },
  16310. text: {
  16311. newComponentName: 'agTextColumnFilter',
  16312. propertyHolder: 'filter'
  16313. },
  16314. number: {
  16315. newComponentName: 'agNumberColumnFilter',
  16316. propertyHolder: 'filter'
  16317. },
  16318. date: {
  16319. newComponentName: 'agDateColumnFilter',
  16320. propertyHolder: 'filter'
  16321. },
  16322. group: {
  16323. newComponentName: 'agGroupCellRenderer',
  16324. propertyHolder: 'cellRenderer'
  16325. },
  16326. animateShowChange: {
  16327. newComponentName: 'agAnimateShowChangeCellRenderer',
  16328. propertyHolder: 'cellRenderer'
  16329. },
  16330. animateSlide: {
  16331. newComponentName: 'agAnimateSlideCellRenderer',
  16332. propertyHolder: 'cellRenderer'
  16333. },
  16334. select: {
  16335. newComponentName: 'agSelectCellEditor',
  16336. propertyHolder: 'cellEditor'
  16337. },
  16338. largeText: {
  16339. newComponentName: 'agLargeTextCellEditor',
  16340. propertyHolder: 'cellEditor'
  16341. },
  16342. popupSelect: {
  16343. newComponentName: 'agPopupSelectCellEditor',
  16344. propertyHolder: 'cellEditor'
  16345. },
  16346. popupText: {
  16347. newComponentName: 'agPopupTextCellEditor',
  16348. propertyHolder: 'cellEditor'
  16349. },
  16350. richSelect: {
  16351. newComponentName: 'agRichSelectCellEditor',
  16352. propertyHolder: 'cellEditor'
  16353. },
  16354. headerComponent: {
  16355. newComponentName: 'agColumnHeader',
  16356. propertyHolder: 'headerComponent'
  16357. }
  16358. };
  16359. _this.jsComponents = {};
  16360. _this.frameworkComponents = {};
  16361. return _this;
  16362. }
  16363. UserComponentRegistry.prototype.init = function () {
  16364. var _this = this;
  16365. if (this.gridOptions.components != null) {
  16366. Object.keys(this.gridOptions.components).forEach(function (it) {
  16367. _this.registerComponent(it, _this.gridOptions.components[it]);
  16368. });
  16369. }
  16370. if (this.gridOptions.frameworkComponents != null) {
  16371. Object.keys(this.gridOptions.frameworkComponents).forEach(function (it) {
  16372. _this.registerFwComponent(it, _this.gridOptions.frameworkComponents[it]);
  16373. });
  16374. }
  16375. };
  16376. UserComponentRegistry.prototype.registerDefaultComponent = function (rawName, component) {
  16377. var name = this.translateIfDeprecated(rawName);
  16378. if (this.agGridDefaults[name]) {
  16379. console.error("Trying to overwrite a default component. You should call registerComponent");
  16380. return;
  16381. }
  16382. this.agGridDefaults[name] = component;
  16383. };
  16384. UserComponentRegistry.prototype.registerComponent = function (rawName, component) {
  16385. var name = this.translateIfDeprecated(rawName);
  16386. if (this.frameworkComponents[name]) {
  16387. console.error("Trying to register a component that you have already registered for frameworks: " + name);
  16388. return;
  16389. }
  16390. this.jsComponents[name] = component;
  16391. };
  16392. /**
  16393. * B the business interface (ie IHeader)
  16394. * A the agGridComponent interface (ie IHeaderComp). The final object acceptable by ag-grid
  16395. */
  16396. UserComponentRegistry.prototype.registerFwComponent = function (rawName, component) {
  16397. var name = this.translateIfDeprecated(rawName);
  16398. if (this.jsComponents[name]) {
  16399. console.error("Trying to register a component that you have already registered for plain javascript: " + name);
  16400. return;
  16401. }
  16402. this.frameworkComponents[name] = component;
  16403. };
  16404. /**
  16405. * B the business interface (ie IHeader)
  16406. * A the agGridComponent interface (ie IHeaderComp). The final object acceptable by ag-grid
  16407. */
  16408. UserComponentRegistry.prototype.retrieve = function (rawName) {
  16409. var name = this.translateIfDeprecated(rawName);
  16410. if (this.frameworkComponents[name]) {
  16411. return {
  16412. componentFromFramework: true,
  16413. component: this.frameworkComponents[name],
  16414. source: RegisteredComponentSource.REGISTERED
  16415. };
  16416. }
  16417. if (this.jsComponents[name]) {
  16418. return {
  16419. componentFromFramework: false,
  16420. component: this.jsComponents[name],
  16421. source: RegisteredComponentSource.REGISTERED
  16422. };
  16423. }
  16424. if (this.agGridDefaults[name]) {
  16425. return this.agGridDefaults[name] ?
  16426. {
  16427. componentFromFramework: false,
  16428. component: this.agGridDefaults[name],
  16429. source: RegisteredComponentSource.DEFAULT
  16430. } :
  16431. null;
  16432. }
  16433. if (Object.keys(this.agGridDefaults).indexOf(name) < 0) {
  16434. console.warn("ag-Grid: Looking for component [" + name + "] but it wasn't found.");
  16435. }
  16436. return null;
  16437. };
  16438. UserComponentRegistry.prototype.translateIfDeprecated = function (raw) {
  16439. var deprecatedInfo = this.agDeprecatedNames[raw];
  16440. if (deprecatedInfo != null) {
  16441. _.doOnce(function () {
  16442. console.warn("ag-grid. Since v15.0 component names have been renamed to be namespaced. You should rename " + deprecatedInfo.propertyHolder + ":" + raw + " to " + deprecatedInfo.propertyHolder + ":" + deprecatedInfo.newComponentName);
  16443. }, 'DEPRECATE_COMPONENT_' + raw);
  16444. return deprecatedInfo.newComponentName;
  16445. }
  16446. return raw;
  16447. };
  16448. __decorate$z([
  16449. Autowired('gridOptions')
  16450. ], UserComponentRegistry.prototype, "gridOptions", void 0);
  16451. __decorate$z([
  16452. PostConstruct
  16453. ], UserComponentRegistry.prototype, "init", null);
  16454. UserComponentRegistry = __decorate$z([
  16455. Bean('userComponentRegistry')
  16456. ], UserComponentRegistry);
  16457. return UserComponentRegistry;
  16458. }(BeanStub));
  16459. /**
  16460. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  16461. * @version v23.2.1
  16462. * @link http://www.ag-grid.com/
  16463. * @license MIT
  16464. */
  16465. // when doing transactions, or change detection, and grouping is present
  16466. // in the data, there is no need for the ClientSideRowModel to update each
  16467. // group after an update, ony parts that were impacted by the change.
  16468. // this class keeps track of all groups that were impacted by a transaction.
  16469. // the the different CSRM operations (filter, sort etc) use the forEach method
  16470. // to visit each group that was changed.
  16471. var ChangedPath = /** @class */ (function () {
  16472. function ChangedPath(keepingColumns, rootNode) {
  16473. // whether changed path is active of not. it is active when a) doing
  16474. // a transaction update or b) doing change detection. if we are doing
  16475. // a CSRM refresh for other reasons (after sort or filter, or user calling
  16476. // setRowData() without delta mode) then we are not active. we are also
  16477. // marked as not active if secondary columns change in pivot (as this impacts
  16478. // aggregations)
  16479. this.active = true;
  16480. // for each node in the change path, we also store which columns need
  16481. // to be re-aggregated.
  16482. this.nodeIdsToColumns = {};
  16483. // for quick lookup, all items in the change path are mapped by nodeId
  16484. this.mapToItems = {};
  16485. this.keepingColumns = keepingColumns;
  16486. this.pathRoot = {
  16487. rowNode: rootNode,
  16488. children: null
  16489. };
  16490. this.mapToItems[rootNode.id] = this.pathRoot;
  16491. }
  16492. // can be set inactive by:
  16493. // a) ClientSideRowModel, if no transactions or
  16494. // b) PivotService, if secondary columns changed
  16495. ChangedPath.prototype.setInactive = function () {
  16496. this.active = false;
  16497. };
  16498. ChangedPath.prototype.isActive = function () {
  16499. return this.active;
  16500. };
  16501. ChangedPath.prototype.depthFirstSearchChangedPath = function (pathItem, callback) {
  16502. if (pathItem.children) {
  16503. for (var i = 0; i < pathItem.children.length; i++) {
  16504. this.depthFirstSearchChangedPath(pathItem.children[i], callback);
  16505. }
  16506. }
  16507. callback(pathItem.rowNode);
  16508. };
  16509. ChangedPath.prototype.depthFirstSearchEverything = function (rowNode, callback, traverseEverything) {
  16510. if (rowNode.childrenAfterGroup) {
  16511. for (var i = 0; i < rowNode.childrenAfterGroup.length; i++) {
  16512. var childNode = rowNode.childrenAfterGroup[i];
  16513. if (childNode.childrenAfterGroup) {
  16514. this.depthFirstSearchEverything(rowNode.childrenAfterGroup[i], callback, traverseEverything);
  16515. }
  16516. else if (traverseEverything) {
  16517. callback(childNode);
  16518. }
  16519. }
  16520. }
  16521. callback(rowNode);
  16522. };
  16523. // traverseLeafNodes -> used when NOT doing changed path, ie traversing everything. the callback
  16524. // will be called for child nodes in addition to parent nodes.
  16525. ChangedPath.prototype.forEachChangedNodeDepthFirst = function (callback, traverseLeafNodes) {
  16526. if (traverseLeafNodes === void 0) { traverseLeafNodes = false; }
  16527. if (this.active) {
  16528. // if we are active, then use the change path to callback
  16529. // only for updated groups
  16530. this.depthFirstSearchChangedPath(this.pathRoot, callback);
  16531. }
  16532. else {
  16533. // we are not active, so callback for everything, walk the entire path
  16534. this.depthFirstSearchEverything(this.pathRoot.rowNode, callback, traverseLeafNodes);
  16535. }
  16536. };
  16537. ChangedPath.prototype.executeFromRootNode = function (callback) {
  16538. callback(this.pathRoot.rowNode);
  16539. };
  16540. ChangedPath.prototype.createPathItems = function (rowNode) {
  16541. var pointer = rowNode;
  16542. var newEntryCount = 0;
  16543. while (!this.mapToItems[pointer.id]) {
  16544. var newEntry = {
  16545. rowNode: pointer,
  16546. children: null
  16547. };
  16548. this.mapToItems[pointer.id] = newEntry;
  16549. newEntryCount++;
  16550. pointer = pointer.parent;
  16551. }
  16552. return newEntryCount;
  16553. };
  16554. ChangedPath.prototype.populateColumnsMap = function (rowNode, columns) {
  16555. var _this = this;
  16556. if (!this.keepingColumns || !columns) {
  16557. return;
  16558. }
  16559. var pointer = rowNode;
  16560. while (pointer) {
  16561. // if columns, add the columns in all the way to parent, merging
  16562. // in any other columns that might be there already
  16563. if (!this.nodeIdsToColumns[pointer.id]) {
  16564. this.nodeIdsToColumns[pointer.id] = {};
  16565. }
  16566. columns.forEach(function (col) { return _this.nodeIdsToColumns[pointer.id][col.getId()] = true; });
  16567. pointer = pointer.parent;
  16568. }
  16569. };
  16570. ChangedPath.prototype.linkPathItems = function (rowNode, newEntryCount) {
  16571. var pointer = rowNode;
  16572. for (var i = 0; i < newEntryCount; i++) {
  16573. var thisItem = this.mapToItems[pointer.id];
  16574. var parentItem = this.mapToItems[pointer.parent.id];
  16575. if (!parentItem.children) {
  16576. parentItem.children = [];
  16577. }
  16578. parentItem.children.push(thisItem);
  16579. pointer = pointer.parent;
  16580. }
  16581. };
  16582. // called by
  16583. // 1) change detection (provides cols) and
  16584. // 2) groupStage if doing transaction update (doesn't provide cols)
  16585. ChangedPath.prototype.addParentNode = function (rowNode, columns) {
  16586. if (!rowNode || rowNode.isRowPinned()) {
  16587. return;
  16588. }
  16589. // we cannot do both steps below in the same loop as
  16590. // the second loop has a dependency on the first loop.
  16591. // ie the hierarchy cannot be stitched up yet because
  16592. // we don't have it built yet
  16593. // create the new PathItem objects.
  16594. var newEntryCount = this.createPathItems(rowNode);
  16595. // link in the node items
  16596. this.linkPathItems(rowNode, newEntryCount);
  16597. // update columns
  16598. this.populateColumnsMap(rowNode, columns);
  16599. };
  16600. ChangedPath.prototype.canSkip = function (rowNode) {
  16601. return this.active && !this.mapToItems[rowNode.id];
  16602. };
  16603. ChangedPath.prototype.getValueColumnsForNode = function (rowNode, valueColumns) {
  16604. if (!this.keepingColumns) {
  16605. return valueColumns;
  16606. }
  16607. var colsForThisNode = this.nodeIdsToColumns[rowNode.id];
  16608. var result = valueColumns.filter(function (col) { return colsForThisNode[col.getId()]; });
  16609. return result;
  16610. };
  16611. ChangedPath.prototype.getNotValueColumnsForNode = function (rowNode, valueColumns) {
  16612. if (!this.keepingColumns) {
  16613. return null;
  16614. }
  16615. var colsForThisNode = this.nodeIdsToColumns[rowNode.id];
  16616. var result = valueColumns.filter(function (col) { return !colsForThisNode[col.getId()]; });
  16617. return result;
  16618. };
  16619. return ChangedPath;
  16620. }());
  16621. /**
  16622. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  16623. * @version v23.2.1
  16624. * @link http://www.ag-grid.com/
  16625. * @license MIT
  16626. */
  16627. var __extends$D = (undefined && undefined.__extends) || (function () {
  16628. var extendStatics = function (d, b) {
  16629. extendStatics = Object.setPrototypeOf ||
  16630. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  16631. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  16632. return extendStatics(d, b);
  16633. };
  16634. return function (d, b) {
  16635. extendStatics(d, b);
  16636. function __() { this.constructor = d; }
  16637. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  16638. };
  16639. })();
  16640. var __decorate$A = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  16641. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  16642. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  16643. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  16644. return c > 3 && r && Object.defineProperty(target, key, r), r;
  16645. };
  16646. var __param$4 = (undefined && undefined.__param) || function (paramIndex, decorator) {
  16647. return function (target, key) { decorator(target, key, paramIndex); }
  16648. };
  16649. var SelectionController = /** @class */ (function (_super) {
  16650. __extends$D(SelectionController, _super);
  16651. function SelectionController() {
  16652. return _super !== null && _super.apply(this, arguments) || this;
  16653. }
  16654. SelectionController.prototype.setBeans = function (loggerFactory) {
  16655. this.logger = loggerFactory.create('SelectionController');
  16656. this.reset();
  16657. if (this.gridOptionsWrapper.isRowModelDefault()) {
  16658. this.addManagedListener(this.eventService, Events.EVENT_ROW_DATA_CHANGED, this.reset.bind(this));
  16659. }
  16660. };
  16661. SelectionController.prototype.init = function () {
  16662. this.groupSelectsChildren = this.gridOptionsWrapper.isGroupSelectsChildren();
  16663. this.addManagedListener(this.eventService, Events.EVENT_ROW_SELECTED, this.onRowSelected.bind(this));
  16664. };
  16665. SelectionController.prototype.setLastSelectedNode = function (rowNode) {
  16666. this.lastSelectedNode = rowNode;
  16667. };
  16668. SelectionController.prototype.getLastSelectedNode = function () {
  16669. return this.lastSelectedNode;
  16670. };
  16671. SelectionController.prototype.getSelectedNodes = function () {
  16672. var selectedNodes = [];
  16673. _.iterateObject(this.selectedNodes, function (key, rowNode) {
  16674. if (rowNode) {
  16675. selectedNodes.push(rowNode);
  16676. }
  16677. });
  16678. return selectedNodes;
  16679. };
  16680. SelectionController.prototype.getSelectedRows = function () {
  16681. var selectedRows = [];
  16682. _.iterateObject(this.selectedNodes, function (key, rowNode) {
  16683. if (rowNode && rowNode.data) {
  16684. selectedRows.push(rowNode.data);
  16685. }
  16686. });
  16687. return selectedRows;
  16688. };
  16689. SelectionController.prototype.removeGroupsFromSelection = function () {
  16690. var _this = this;
  16691. _.iterateObject(this.selectedNodes, function (key, rowNode) {
  16692. if (rowNode && rowNode.group) {
  16693. _this.selectedNodes[rowNode.id] = undefined;
  16694. }
  16695. });
  16696. };
  16697. // should only be called if groupSelectsChildren=true
  16698. SelectionController.prototype.updateGroupsFromChildrenSelections = function (changedPath) {
  16699. // we only do this when group selection state depends on selected children
  16700. if (!this.gridOptionsWrapper.isGroupSelectsChildren()) {
  16701. return;
  16702. }
  16703. // also only do it if CSRM (code should never allow this anyway)
  16704. if (this.rowModel.getType() !== Constants.ROW_MODEL_TYPE_CLIENT_SIDE) {
  16705. return;
  16706. }
  16707. var clientSideRowModel = this.rowModel;
  16708. var rootNode = clientSideRowModel.getRootNode();
  16709. if (!changedPath) {
  16710. changedPath = new ChangedPath(true, rootNode);
  16711. changedPath.setInactive();
  16712. }
  16713. changedPath.forEachChangedNodeDepthFirst(function (rowNode) {
  16714. if (rowNode !== rootNode) {
  16715. rowNode.calculateSelectedFromChildren();
  16716. }
  16717. });
  16718. // clientSideRowModel.getTopLevelNodes()!.forEach((rowNode: RowNode) => {
  16719. // rowNode.depthFirstSearch((node) => {
  16720. // if (node.group) {
  16721. // }
  16722. // });
  16723. // });
  16724. };
  16725. SelectionController.prototype.getNodeForIdIfSelected = function (id) {
  16726. return this.selectedNodes[id];
  16727. };
  16728. SelectionController.prototype.clearOtherNodes = function (rowNodeToKeepSelected) {
  16729. var _this = this;
  16730. var groupsToRefresh = {};
  16731. var updatedCount = 0;
  16732. _.iterateObject(this.selectedNodes, function (key, otherRowNode) {
  16733. if (otherRowNode && otherRowNode.id !== rowNodeToKeepSelected.id) {
  16734. var rowNode = _this.selectedNodes[otherRowNode.id];
  16735. updatedCount += rowNode.setSelectedParams({
  16736. newValue: false,
  16737. clearSelection: false,
  16738. suppressFinishActions: true
  16739. });
  16740. if (_this.groupSelectsChildren && otherRowNode.parent) {
  16741. groupsToRefresh[otherRowNode.parent.id] = otherRowNode.parent;
  16742. }
  16743. }
  16744. });
  16745. _.iterateObject(groupsToRefresh, function (key, group) {
  16746. group.calculateSelectedFromChildren();
  16747. });
  16748. return updatedCount;
  16749. };
  16750. SelectionController.prototype.onRowSelected = function (event) {
  16751. var rowNode = event.node;
  16752. // we do not store the group rows when the groups select children
  16753. if (this.groupSelectsChildren && rowNode.group) {
  16754. return;
  16755. }
  16756. if (rowNode.isSelected()) {
  16757. this.selectedNodes[rowNode.id] = rowNode;
  16758. }
  16759. else {
  16760. this.selectedNodes[rowNode.id] = undefined;
  16761. }
  16762. };
  16763. SelectionController.prototype.syncInRowNode = function (rowNode, oldNode) {
  16764. this.syncInOldRowNode(rowNode, oldNode);
  16765. this.syncInNewRowNode(rowNode);
  16766. };
  16767. // if the id has changed for the node, then this means the rowNode
  16768. // is getting used for a different data item, which breaks
  16769. // our selectedNodes, as the node now is mapped by the old id
  16770. // which is inconsistent. so to keep the old node as selected,
  16771. // we swap in the clone (with the old id and old data). this means
  16772. // the oldNode is effectively a daemon we keep a reference to,
  16773. // so if client calls api.getSelectedNodes(), it gets the daemon
  16774. // in the result. when the client un-selects, the reference to the
  16775. // daemon is removed. the daemon, because it's an oldNode, is not
  16776. // used by the grid for rendering, it's a copy of what the node used
  16777. // to be like before the id was changed.
  16778. SelectionController.prototype.syncInOldRowNode = function (rowNode, oldNode) {
  16779. var oldNodeHasDifferentId = _.exists(oldNode) && (rowNode.id !== oldNode.id);
  16780. if (oldNodeHasDifferentId) {
  16781. var oldNodeSelected = _.exists(this.selectedNodes[oldNode.id]);
  16782. if (oldNodeSelected) {
  16783. this.selectedNodes[oldNode.id] = oldNode;
  16784. }
  16785. }
  16786. };
  16787. SelectionController.prototype.syncInNewRowNode = function (rowNode) {
  16788. if (_.exists(this.selectedNodes[rowNode.id])) {
  16789. rowNode.setSelectedInitialValue(true);
  16790. this.selectedNodes[rowNode.id] = rowNode;
  16791. }
  16792. else {
  16793. rowNode.setSelectedInitialValue(false);
  16794. }
  16795. };
  16796. SelectionController.prototype.reset = function () {
  16797. this.logger.log('reset');
  16798. this.selectedNodes = {};
  16799. this.lastSelectedNode = null;
  16800. };
  16801. // returns a list of all nodes at 'best cost' - a feature to be used
  16802. // with groups / trees. if a group has all it's children selected,
  16803. // then the group appears in the result, but not the children.
  16804. // Designed for use with 'children' as the group selection type,
  16805. // where groups don't actually appear in the selection normally.
  16806. SelectionController.prototype.getBestCostNodeSelection = function () {
  16807. if (this.rowModel.getType() !== Constants.ROW_MODEL_TYPE_CLIENT_SIDE) {
  16808. console.warn('getBestCostNodeSelection is only available when using normal row model');
  16809. return;
  16810. }
  16811. var clientSideRowModel = this.rowModel;
  16812. var topLevelNodes = clientSideRowModel.getTopLevelNodes();
  16813. if (topLevelNodes === null) {
  16814. console.warn('selectAll not available doing rowModel=virtual');
  16815. return;
  16816. }
  16817. var result = [];
  16818. // recursive function, to find the selected nodes
  16819. function traverse(nodes) {
  16820. for (var i = 0, l = nodes.length; i < l; i++) {
  16821. var node = nodes[i];
  16822. if (node.isSelected()) {
  16823. result.push(node);
  16824. }
  16825. else {
  16826. // if not selected, then if it's a group, and the group
  16827. // has children, continue to search for selections
  16828. if (node.group && node.children) {
  16829. traverse(node.children);
  16830. }
  16831. }
  16832. }
  16833. }
  16834. traverse(topLevelNodes);
  16835. return result;
  16836. };
  16837. SelectionController.prototype.setRowModel = function (rowModel) {
  16838. this.rowModel = rowModel;
  16839. };
  16840. SelectionController.prototype.isEmpty = function () {
  16841. var count = 0;
  16842. _.iterateObject(this.selectedNodes, function (nodeId, rowNode) {
  16843. if (rowNode) {
  16844. count++;
  16845. }
  16846. });
  16847. return count === 0;
  16848. };
  16849. SelectionController.prototype.deselectAllRowNodes = function (justFiltered) {
  16850. if (justFiltered === void 0) { justFiltered = false; }
  16851. var callback = function (rowNode) { return rowNode.selectThisNode(false); };
  16852. var rowModelClientSide = this.rowModel.getType() === Constants.ROW_MODEL_TYPE_CLIENT_SIDE;
  16853. if (justFiltered) {
  16854. if (!rowModelClientSide) {
  16855. console.error('ag-Grid: selecting just filtered only works with In Memory Row Model');
  16856. return;
  16857. }
  16858. var clientSideRowModel = this.rowModel;
  16859. clientSideRowModel.forEachNodeAfterFilter(callback);
  16860. }
  16861. else {
  16862. _.iterateObject(this.selectedNodes, function (id, rowNode) {
  16863. // remember the reference can be to null, as we never 'delete' from the map
  16864. if (rowNode) {
  16865. callback(rowNode);
  16866. }
  16867. });
  16868. // this clears down the map (whereas above only sets the items in map to 'undefined')
  16869. this.reset();
  16870. }
  16871. // the above does not clean up the parent rows if they are selected
  16872. if (rowModelClientSide && this.groupSelectsChildren) {
  16873. this.updateGroupsFromChildrenSelections();
  16874. }
  16875. var event = {
  16876. type: Events.EVENT_SELECTION_CHANGED,
  16877. api: this.gridApi,
  16878. columnApi: this.columnApi
  16879. };
  16880. this.eventService.dispatchEvent(event);
  16881. };
  16882. SelectionController.prototype.selectAllRowNodes = function (justFiltered) {
  16883. if (justFiltered === void 0) { justFiltered = false; }
  16884. if (this.rowModel.getType() !== Constants.ROW_MODEL_TYPE_CLIENT_SIDE) {
  16885. throw new Error("selectAll only available with normal row model, ie not " + this.rowModel.getType());
  16886. }
  16887. var clientSideRowModel = this.rowModel;
  16888. var callback = function (rowNode) { return rowNode.selectThisNode(true); };
  16889. if (justFiltered) {
  16890. clientSideRowModel.forEachNodeAfterFilter(callback);
  16891. }
  16892. else {
  16893. clientSideRowModel.forEachNode(callback);
  16894. }
  16895. // the above does not clean up the parent rows if they are selected
  16896. if (this.rowModel.getType() === Constants.ROW_MODEL_TYPE_CLIENT_SIDE && this.groupSelectsChildren) {
  16897. this.updateGroupsFromChildrenSelections();
  16898. }
  16899. var event = {
  16900. type: Events.EVENT_SELECTION_CHANGED,
  16901. api: this.gridApi,
  16902. columnApi: this.columnApi
  16903. };
  16904. this.eventService.dispatchEvent(event);
  16905. };
  16906. /**
  16907. * @method
  16908. * @deprecated
  16909. */
  16910. SelectionController.prototype.selectNode = function (rowNode, tryMulti) {
  16911. if (rowNode) {
  16912. rowNode.setSelectedParams({ newValue: true, clearSelection: !tryMulti });
  16913. }
  16914. };
  16915. /**
  16916. * @method
  16917. * @deprecated
  16918. */
  16919. SelectionController.prototype.deselectIndex = function (rowIndex) {
  16920. var node = this.rowModel.getRow(rowIndex);
  16921. this.deselectNode(node);
  16922. };
  16923. /**
  16924. * @method
  16925. * @deprecated
  16926. */
  16927. SelectionController.prototype.deselectNode = function (rowNode) {
  16928. if (rowNode) {
  16929. rowNode.setSelectedParams({ newValue: false, clearSelection: false });
  16930. }
  16931. };
  16932. /**
  16933. * @method
  16934. * @deprecated
  16935. */
  16936. SelectionController.prototype.selectIndex = function (index, tryMulti) {
  16937. var node = this.rowModel.getRow(index);
  16938. this.selectNode(node, tryMulti);
  16939. };
  16940. __decorate$A([
  16941. Autowired('rowModel')
  16942. ], SelectionController.prototype, "rowModel", void 0);
  16943. __decorate$A([
  16944. Autowired('gridOptionsWrapper')
  16945. ], SelectionController.prototype, "gridOptionsWrapper", void 0);
  16946. __decorate$A([
  16947. Autowired('columnApi')
  16948. ], SelectionController.prototype, "columnApi", void 0);
  16949. __decorate$A([
  16950. Autowired('gridApi')
  16951. ], SelectionController.prototype, "gridApi", void 0);
  16952. __decorate$A([
  16953. __param$4(0, Qualifier('loggerFactory'))
  16954. ], SelectionController.prototype, "setBeans", null);
  16955. __decorate$A([
  16956. PostConstruct
  16957. ], SelectionController.prototype, "init", null);
  16958. SelectionController = __decorate$A([
  16959. Bean('selectionController')
  16960. ], SelectionController);
  16961. return SelectionController;
  16962. }(BeanStub));
  16963. /**
  16964. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  16965. * @version v23.2.1
  16966. * @link http://www.ag-grid.com/
  16967. * @license MIT
  16968. */
  16969. var __decorate$B = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  16970. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  16971. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  16972. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  16973. return c > 3 && r && Object.defineProperty(target, key, r), r;
  16974. };
  16975. var ColumnApi = /** @class */ (function () {
  16976. function ColumnApi() {
  16977. }
  16978. ColumnApi.prototype.sizeColumnsToFit = function (gridWidth) {
  16979. // AG-3403 validate that gridWidth is provided because this method has the same name as
  16980. // a method on the grid API that takes no arguments, and it's easy to confuse the two
  16981. if (typeof gridWidth === "undefined") {
  16982. console.error('ag-Grid: missing parameter to columnApi.sizeColumnsToFit(gridWidth)');
  16983. }
  16984. this.columnController.sizeColumnsToFit(gridWidth, 'api');
  16985. };
  16986. ColumnApi.prototype.setColumnGroupOpened = function (group, newValue) { this.columnController.setColumnGroupOpened(group, newValue, 'api'); };
  16987. ColumnApi.prototype.getColumnGroup = function (name, instanceId) { return this.columnController.getColumnGroup(name, instanceId); };
  16988. ColumnApi.prototype.getOriginalColumnGroup = function (name) { return this.columnController.getOriginalColumnGroup(name); };
  16989. ColumnApi.prototype.getDisplayNameForColumn = function (column, location) { return this.columnController.getDisplayNameForColumn(column, location) || ''; };
  16990. ColumnApi.prototype.getDisplayNameForColumnGroup = function (columnGroup, location) { return this.columnController.getDisplayNameForColumnGroup(columnGroup, location) || ''; };
  16991. ColumnApi.prototype.getColumn = function (key) { return this.columnController.getPrimaryColumn(key); };
  16992. ColumnApi.prototype.setColumnState = function (columnState) { return this.columnController.setColumnState(columnState, false, 'api'); };
  16993. ColumnApi.prototype.getColumnState = function () { return this.columnController.getColumnState(); };
  16994. ColumnApi.prototype.resetColumnState = function () { this.columnController.resetColumnState(false, 'api'); };
  16995. ColumnApi.prototype.getColumnGroupState = function () { return this.columnController.getColumnGroupState(); };
  16996. ColumnApi.prototype.setColumnGroupState = function (stateItems) { this.columnController.setColumnGroupState(stateItems, 'api'); };
  16997. ColumnApi.prototype.resetColumnGroupState = function () { this.columnController.resetColumnGroupState('api'); };
  16998. ColumnApi.prototype.isPinning = function () { return this.columnController.isPinningLeft() || this.columnController.isPinningRight(); };
  16999. ColumnApi.prototype.isPinningLeft = function () { return this.columnController.isPinningLeft(); };
  17000. ColumnApi.prototype.isPinningRight = function () { return this.columnController.isPinningRight(); };
  17001. ColumnApi.prototype.getDisplayedColAfter = function (col) { return this.columnController.getDisplayedColAfter(col); };
  17002. ColumnApi.prototype.getDisplayedColBefore = function (col) { return this.columnController.getDisplayedColBefore(col); };
  17003. ColumnApi.prototype.setColumnVisible = function (key, visible) { this.columnController.setColumnVisible(key, visible, 'api'); };
  17004. ColumnApi.prototype.setColumnsVisible = function (keys, visible) { this.columnController.setColumnsVisible(keys, visible, 'api'); };
  17005. ColumnApi.prototype.setColumnPinned = function (key, pinned) { this.columnController.setColumnPinned(key, pinned, 'api'); };
  17006. ColumnApi.prototype.setColumnsPinned = function (keys, pinned) { this.columnController.setColumnsPinned(keys, pinned, 'api'); };
  17007. ColumnApi.prototype.getAllColumns = function () { return this.columnController.getAllPrimaryColumns(); };
  17008. ColumnApi.prototype.getAllGridColumns = function () { return this.columnController.getAllGridColumns(); };
  17009. ColumnApi.prototype.getDisplayedLeftColumns = function () { return this.columnController.getDisplayedLeftColumns(); };
  17010. ColumnApi.prototype.getDisplayedCenterColumns = function () { return this.columnController.getDisplayedCenterColumns(); };
  17011. ColumnApi.prototype.getDisplayedRightColumns = function () { return this.columnController.getDisplayedRightColumns(); };
  17012. ColumnApi.prototype.getAllDisplayedColumns = function () { return this.columnController.getAllDisplayedColumns(); };
  17013. ColumnApi.prototype.getAllDisplayedVirtualColumns = function () { return this.columnController.getAllDisplayedVirtualColumns(); };
  17014. ColumnApi.prototype.moveColumn = function (key, toIndex) {
  17015. if (typeof key === 'number') {
  17016. // moveColumn used to take indexes, so this is advising user who hasn't moved to new method name
  17017. console.warn('ag-Grid: you are using moveColumn(fromIndex, toIndex) - moveColumn takes a column key and a destination index, not two indexes, to move with indexes use moveColumnByIndex(from,to) instead');
  17018. this.columnController.moveColumnByIndex(key, toIndex, 'api');
  17019. }
  17020. else {
  17021. this.columnController.moveColumn(key, toIndex, 'api');
  17022. }
  17023. };
  17024. ColumnApi.prototype.moveColumnByIndex = function (fromIndex, toIndex) { this.columnController.moveColumnByIndex(fromIndex, toIndex, 'api'); };
  17025. ColumnApi.prototype.moveColumns = function (columnsToMoveKeys, toIndex) { this.columnController.moveColumns(columnsToMoveKeys, toIndex, 'api'); };
  17026. ColumnApi.prototype.moveRowGroupColumn = function (fromIndex, toIndex) { this.columnController.moveRowGroupColumn(fromIndex, toIndex); };
  17027. ColumnApi.prototype.setColumnAggFunc = function (column, aggFunc) { this.columnController.setColumnAggFunc(column, aggFunc); };
  17028. ColumnApi.prototype.setColumnWidth = function (key, newWidth, finished) {
  17029. if (finished === void 0) { finished = true; }
  17030. this.columnController.setColumnWidths([{ key: key, newWidth: newWidth }], false, finished);
  17031. };
  17032. ColumnApi.prototype.setColumnWidths = function (columnWidths, finished) {
  17033. if (finished === void 0) { finished = true; }
  17034. this.columnController.setColumnWidths(columnWidths, false, finished);
  17035. };
  17036. ColumnApi.prototype.setPivotMode = function (pivotMode) { this.columnController.setPivotMode(pivotMode); };
  17037. ColumnApi.prototype.isPivotMode = function () { return this.columnController.isPivotMode(); };
  17038. ColumnApi.prototype.getSecondaryPivotColumn = function (pivotKeys, valueColKey) { return this.columnController.getSecondaryPivotColumn(pivotKeys, valueColKey); };
  17039. ColumnApi.prototype.setValueColumns = function (colKeys) { this.columnController.setValueColumns(colKeys, 'api'); };
  17040. ColumnApi.prototype.getValueColumns = function () { return this.columnController.getValueColumns(); };
  17041. ColumnApi.prototype.removeValueColumn = function (colKey) { this.columnController.removeValueColumn(colKey, 'api'); };
  17042. ColumnApi.prototype.removeValueColumns = function (colKeys) { this.columnController.removeValueColumns(colKeys, 'api'); };
  17043. ColumnApi.prototype.addValueColumn = function (colKey) { this.columnController.addValueColumn(colKey, 'api'); };
  17044. ColumnApi.prototype.addValueColumns = function (colKeys) { this.columnController.addValueColumns(colKeys, 'api'); };
  17045. ColumnApi.prototype.setRowGroupColumns = function (colKeys) { this.columnController.setRowGroupColumns(colKeys, 'api'); };
  17046. ColumnApi.prototype.removeRowGroupColumn = function (colKey) { this.columnController.removeRowGroupColumn(colKey, 'api'); };
  17047. ColumnApi.prototype.removeRowGroupColumns = function (colKeys) { this.columnController.removeRowGroupColumns(colKeys, 'api'); };
  17048. ColumnApi.prototype.addRowGroupColumn = function (colKey) { this.columnController.addRowGroupColumn(colKey, 'api'); };
  17049. ColumnApi.prototype.addRowGroupColumns = function (colKeys) { this.columnController.addRowGroupColumns(colKeys, 'api'); };
  17050. ColumnApi.prototype.getRowGroupColumns = function () { return this.columnController.getRowGroupColumns(); };
  17051. ColumnApi.prototype.setPivotColumns = function (colKeys) { this.columnController.setPivotColumns(colKeys, 'api'); };
  17052. ColumnApi.prototype.removePivotColumn = function (colKey) { this.columnController.removePivotColumn(colKey, 'api'); };
  17053. ColumnApi.prototype.removePivotColumns = function (colKeys) { this.columnController.removePivotColumns(colKeys, 'api'); };
  17054. ColumnApi.prototype.addPivotColumn = function (colKey) { this.columnController.addPivotColumn(colKey, 'api'); };
  17055. ColumnApi.prototype.addPivotColumns = function (colKeys) { this.columnController.addPivotColumns(colKeys, 'api'); };
  17056. ColumnApi.prototype.getPivotColumns = function () { return this.columnController.getPivotColumns(); };
  17057. ColumnApi.prototype.getLeftDisplayedColumnGroups = function () { return this.columnController.getLeftDisplayedColumnGroups(); };
  17058. ColumnApi.prototype.getCenterDisplayedColumnGroups = function () { return this.columnController.getCenterDisplayedColumnGroups(); };
  17059. ColumnApi.prototype.getRightDisplayedColumnGroups = function () { return this.columnController.getRightDisplayedColumnGroups(); };
  17060. ColumnApi.prototype.getAllDisplayedColumnGroups = function () { return this.columnController.getAllDisplayedColumnGroups(); };
  17061. ColumnApi.prototype.autoSizeColumn = function (key, skipHeader) { return this.columnController.autoSizeColumn(key, skipHeader, 'api'); };
  17062. ColumnApi.prototype.autoSizeColumns = function (keys, skipHeader) { return this.columnController.autoSizeColumns(keys, skipHeader, 'api'); };
  17063. ColumnApi.prototype.autoSizeAllColumns = function (skipHeader) { this.columnController.autoSizeAllColumns(skipHeader, 'api'); };
  17064. ColumnApi.prototype.setSecondaryColumns = function (colDefs) { this.columnController.setSecondaryColumns(colDefs, 'api'); };
  17065. ColumnApi.prototype.getSecondaryColumns = function () { return this.columnController.getSecondaryColumns(); };
  17066. ColumnApi.prototype.getPrimaryColumns = function () { return this.columnController.getAllPrimaryColumns(); };
  17067. // below goes through deprecated items, prints message to user, then calls the new version of the same method
  17068. ColumnApi.prototype.columnGroupOpened = function (group, newValue) {
  17069. console.error('ag-Grid: columnGroupOpened no longer exists, use setColumnGroupOpened');
  17070. this.setColumnGroupOpened(group, newValue);
  17071. };
  17072. ColumnApi.prototype.hideColumns = function (colIds, hide) {
  17073. console.error('ag-Grid: hideColumns is deprecated, use setColumnsVisible');
  17074. this.columnController.setColumnsVisible(colIds, !hide, 'api');
  17075. };
  17076. ColumnApi.prototype.hideColumn = function (colId, hide) {
  17077. console.error('ag-Grid: hideColumn is deprecated, use setColumnVisible');
  17078. this.columnController.setColumnVisible(colId, !hide, 'api');
  17079. };
  17080. ColumnApi.prototype.setState = function (columnState) {
  17081. console.error('ag-Grid: setState is deprecated, use setColumnState');
  17082. return this.setColumnState(columnState);
  17083. };
  17084. ColumnApi.prototype.getState = function () {
  17085. console.error('ag-Grid: getState is deprecated, use getColumnState');
  17086. return this.getColumnState();
  17087. };
  17088. ColumnApi.prototype.resetState = function () {
  17089. console.error('ag-Grid: resetState is deprecated, use resetColumnState');
  17090. this.resetColumnState();
  17091. };
  17092. ColumnApi.prototype.getAggregationColumns = function () {
  17093. console.error('ag-Grid: getAggregationColumns is deprecated, use getValueColumns');
  17094. return this.columnController.getValueColumns();
  17095. };
  17096. ColumnApi.prototype.removeAggregationColumn = function (colKey) {
  17097. console.error('ag-Grid: removeAggregationColumn is deprecated, use removeValueColumn');
  17098. this.columnController.removeValueColumn(colKey, 'api');
  17099. };
  17100. ColumnApi.prototype.removeAggregationColumns = function (colKeys) {
  17101. console.error('ag-Grid: removeAggregationColumns is deprecated, use removeValueColumns');
  17102. this.columnController.removeValueColumns(colKeys, 'api');
  17103. };
  17104. ColumnApi.prototype.addAggregationColumn = function (colKey) {
  17105. console.error('ag-Grid: addAggregationColumn is deprecated, use addValueColumn');
  17106. this.columnController.addValueColumn(colKey, 'api');
  17107. };
  17108. ColumnApi.prototype.addAggregationColumns = function (colKeys) {
  17109. console.error('ag-Grid: addAggregationColumns is deprecated, use addValueColumns');
  17110. this.columnController.addValueColumns(colKeys, 'api');
  17111. };
  17112. ColumnApi.prototype.setColumnAggFunction = function (column, aggFunc) {
  17113. console.error('ag-Grid: setColumnAggFunction is deprecated, use setColumnAggFunc');
  17114. this.columnController.setColumnAggFunc(column, aggFunc, 'api');
  17115. };
  17116. ColumnApi.prototype.getDisplayNameForCol = function (column) {
  17117. console.error('ag-Grid: getDisplayNameForCol is deprecated, use getDisplayNameForColumn');
  17118. return this.getDisplayNameForColumn(column, null);
  17119. };
  17120. __decorate$B([
  17121. Autowired('columnController')
  17122. ], ColumnApi.prototype, "columnController", void 0);
  17123. ColumnApi = __decorate$B([
  17124. Bean('columnApi')
  17125. ], ColumnApi);
  17126. return ColumnApi;
  17127. }());
  17128. /**
  17129. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  17130. * @version v23.2.1
  17131. * @link http://www.ag-grid.com/
  17132. * @license MIT
  17133. */
  17134. (function (SelectionHandleType) {
  17135. SelectionHandleType[SelectionHandleType["FILL"] = 0] = "FILL";
  17136. SelectionHandleType[SelectionHandleType["RANGE"] = 1] = "RANGE";
  17137. })(exports.SelectionHandleType || (exports.SelectionHandleType = {}));
  17138. (function (CellRangeType) {
  17139. CellRangeType[CellRangeType["VALUE"] = 0] = "VALUE";
  17140. CellRangeType[CellRangeType["DIMENSION"] = 1] = "DIMENSION";
  17141. })(exports.CellRangeType || (exports.CellRangeType = {}));
  17142. /**
  17143. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  17144. * @version v23.2.1
  17145. * @link http://www.ag-grid.com/
  17146. * @license MIT
  17147. */
  17148. var __extends$E = (undefined && undefined.__extends) || (function () {
  17149. var extendStatics = function (d, b) {
  17150. extendStatics = Object.setPrototypeOf ||
  17151. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  17152. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  17153. return extendStatics(d, b);
  17154. };
  17155. return function (d, b) {
  17156. extendStatics(d, b);
  17157. function __() { this.constructor = d; }
  17158. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  17159. };
  17160. })();
  17161. var __decorate$C = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  17162. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  17163. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  17164. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  17165. return c > 3 && r && Object.defineProperty(target, key, r), r;
  17166. };
  17167. (function (DragSourceType) {
  17168. DragSourceType[DragSourceType["ToolPanel"] = 0] = "ToolPanel";
  17169. DragSourceType[DragSourceType["HeaderCell"] = 1] = "HeaderCell";
  17170. DragSourceType[DragSourceType["RowDrag"] = 2] = "RowDrag";
  17171. DragSourceType[DragSourceType["ChartPanel"] = 3] = "ChartPanel";
  17172. })(exports.DragSourceType || (exports.DragSourceType = {}));
  17173. (function (VerticalDirection) {
  17174. VerticalDirection[VerticalDirection["Up"] = 0] = "Up";
  17175. VerticalDirection[VerticalDirection["Down"] = 1] = "Down";
  17176. })(exports.VerticalDirection || (exports.VerticalDirection = {}));
  17177. (function (HorizontalDirection) {
  17178. HorizontalDirection[HorizontalDirection["Left"] = 0] = "Left";
  17179. HorizontalDirection[HorizontalDirection["Right"] = 1] = "Right";
  17180. })(exports.HorizontalDirection || (exports.HorizontalDirection = {}));
  17181. var DragAndDropService = /** @class */ (function (_super) {
  17182. __extends$E(DragAndDropService, _super);
  17183. function DragAndDropService() {
  17184. var _this = _super !== null && _super.apply(this, arguments) || this;
  17185. _this.dragSourceAndParamsList = [];
  17186. _this.dropTargets = [];
  17187. return _this;
  17188. }
  17189. DragAndDropService_1 = DragAndDropService;
  17190. DragAndDropService.prototype.init = function () {
  17191. this.ePinnedIcon = _.createIcon('columnMovePin', this.gridOptionsWrapper, null);
  17192. this.eHideIcon = _.createIcon('columnMoveHide', this.gridOptionsWrapper, null);
  17193. this.eMoveIcon = _.createIcon('columnMoveMove', this.gridOptionsWrapper, null);
  17194. this.eLeftIcon = _.createIcon('columnMoveLeft', this.gridOptionsWrapper, null);
  17195. this.eRightIcon = _.createIcon('columnMoveRight', this.gridOptionsWrapper, null);
  17196. this.eGroupIcon = _.createIcon('columnMoveGroup', this.gridOptionsWrapper, null);
  17197. this.eAggregateIcon = _.createIcon('columnMoveValue', this.gridOptionsWrapper, null);
  17198. this.ePivotIcon = _.createIcon('columnMovePivot', this.gridOptionsWrapper, null);
  17199. this.eDropNotAllowedIcon = _.createIcon('dropNotAllowed', this.gridOptionsWrapper, null);
  17200. };
  17201. DragAndDropService.prototype.addDragSource = function (dragSource, allowTouch) {
  17202. if (allowTouch === void 0) { allowTouch = false; }
  17203. var params = {
  17204. eElement: dragSource.eElement,
  17205. dragStartPixels: dragSource.dragStartPixels,
  17206. onDragStart: this.onDragStart.bind(this, dragSource),
  17207. onDragStop: this.onDragStop.bind(this),
  17208. onDragging: this.onDragging.bind(this)
  17209. };
  17210. this.dragSourceAndParamsList.push({ params: params, dragSource: dragSource });
  17211. this.dragService.addDragSource(params, allowTouch);
  17212. };
  17213. DragAndDropService.prototype.removeDragSource = function (dragSource) {
  17214. var sourceAndParams = _.find(this.dragSourceAndParamsList, function (item) { return item.dragSource === dragSource; });
  17215. if (sourceAndParams) {
  17216. this.dragService.removeDragSource(sourceAndParams.params);
  17217. _.removeFromArray(this.dragSourceAndParamsList, sourceAndParams);
  17218. }
  17219. };
  17220. DragAndDropService.prototype.clearDragSourceParamsList = function () {
  17221. var _this = this;
  17222. this.dragSourceAndParamsList.forEach(function (sourceAndParams) { return _this.dragService.removeDragSource(sourceAndParams.params); });
  17223. this.dragSourceAndParamsList.length = 0;
  17224. };
  17225. DragAndDropService.prototype.nudge = function () {
  17226. if (this.dragging) {
  17227. this.onDragging(this.eventLastTime, true);
  17228. }
  17229. };
  17230. DragAndDropService.prototype.onDragStart = function (dragSource, mouseEvent) {
  17231. this.dragging = true;
  17232. this.dragSource = dragSource;
  17233. this.eventLastTime = mouseEvent;
  17234. this.dragItem = this.dragSource.getDragItem();
  17235. this.lastDropTarget = this.dragSource.dragSourceDropTarget;
  17236. if (this.dragSource.onDragStarted) {
  17237. this.dragSource.onDragStarted();
  17238. }
  17239. this.createGhost();
  17240. };
  17241. DragAndDropService.prototype.onDragStop = function (mouseEvent) {
  17242. this.eventLastTime = null;
  17243. this.dragging = false;
  17244. if (this.dragSource.onDragStopped) {
  17245. this.dragSource.onDragStopped();
  17246. }
  17247. if (this.lastDropTarget && this.lastDropTarget.onDragStop) {
  17248. var draggingEvent = this.createDropTargetEvent(this.lastDropTarget, mouseEvent, null, null, false);
  17249. this.lastDropTarget.onDragStop(draggingEvent);
  17250. }
  17251. this.lastDropTarget = null;
  17252. this.dragItem = null;
  17253. this.removeGhost();
  17254. };
  17255. DragAndDropService.prototype.onDragging = function (mouseEvent, fromNudge) {
  17256. var hDirection = this.getHorizontalDirection(mouseEvent);
  17257. var vDirection = this.getVerticalDirection(mouseEvent);
  17258. this.eventLastTime = mouseEvent;
  17259. this.positionGhost(mouseEvent);
  17260. // check if mouseEvent intersects with any of the drop targets
  17261. var dropTarget = _.find(this.dropTargets, this.isMouseOnDropTarget.bind(this, mouseEvent));
  17262. if (dropTarget !== this.lastDropTarget) {
  17263. this.leaveLastTargetIfExists(mouseEvent, hDirection, vDirection, fromNudge);
  17264. this.enterDragTargetIfExists(dropTarget, mouseEvent, hDirection, vDirection, fromNudge);
  17265. this.lastDropTarget = dropTarget;
  17266. }
  17267. else if (dropTarget && dropTarget.onDragging) {
  17268. var draggingEvent = this.createDropTargetEvent(dropTarget, mouseEvent, hDirection, vDirection, fromNudge);
  17269. dropTarget.onDragging(draggingEvent);
  17270. }
  17271. };
  17272. DragAndDropService.prototype.enterDragTargetIfExists = function (dropTarget, mouseEvent, hDirection, vDirection, fromNudge) {
  17273. if (!dropTarget) {
  17274. return;
  17275. }
  17276. if (dropTarget.onDragEnter) {
  17277. var dragEnterEvent = this.createDropTargetEvent(dropTarget, mouseEvent, hDirection, vDirection, fromNudge);
  17278. dropTarget.onDragEnter(dragEnterEvent);
  17279. }
  17280. this.setGhostIcon(dropTarget.getIconName ? dropTarget.getIconName() : null);
  17281. };
  17282. DragAndDropService.prototype.leaveLastTargetIfExists = function (mouseEvent, hDirection, vDirection, fromNudge) {
  17283. if (!this.lastDropTarget) {
  17284. return;
  17285. }
  17286. if (this.lastDropTarget.onDragLeave) {
  17287. var dragLeaveEvent = this.createDropTargetEvent(this.lastDropTarget, mouseEvent, hDirection, vDirection, fromNudge);
  17288. this.lastDropTarget.onDragLeave(dragLeaveEvent);
  17289. }
  17290. this.setGhostIcon(null);
  17291. };
  17292. DragAndDropService.prototype.getAllContainersFromDropTarget = function (dropTarget) {
  17293. var containers = [dropTarget.getContainer()];
  17294. var secondaryContainers = dropTarget.getSecondaryContainers ? dropTarget.getSecondaryContainers() : null;
  17295. if (secondaryContainers) {
  17296. containers = containers.concat(secondaryContainers);
  17297. }
  17298. return containers;
  17299. };
  17300. // checks if the mouse is on the drop target. it checks eContainer and eSecondaryContainers
  17301. DragAndDropService.prototype.isMouseOnDropTarget = function (mouseEvent, dropTarget) {
  17302. var mouseOverTarget = false;
  17303. this.getAllContainersFromDropTarget(dropTarget)
  17304. .filter(function (eContainer) { return eContainer; }) // secondary can be missing
  17305. .forEach(function (eContainer) {
  17306. var rect = eContainer.getBoundingClientRect();
  17307. // if element is not visible, then width and height are zero
  17308. if (rect.width === 0 || rect.height === 0) {
  17309. return;
  17310. }
  17311. var horizontalFit = mouseEvent.clientX >= rect.left && mouseEvent.clientX <= rect.right;
  17312. var verticalFit = mouseEvent.clientY >= rect.top && mouseEvent.clientY <= rect.bottom;
  17313. if (horizontalFit && verticalFit) {
  17314. mouseOverTarget = true;
  17315. }
  17316. });
  17317. return mouseOverTarget && dropTarget.isInterestedIn(this.dragSource.type);
  17318. };
  17319. DragAndDropService.prototype.addDropTarget = function (dropTarget) {
  17320. this.dropTargets.push(dropTarget);
  17321. };
  17322. DragAndDropService.prototype.removeDropTarget = function (dropTarget) {
  17323. this.dropTargets = this.dropTargets.filter(function (target) { return target.getContainer() !== dropTarget.getContainer(); });
  17324. };
  17325. DragAndDropService.prototype.hasExternalDropZones = function () {
  17326. return this.dropTargets.some(function (zones) { return zones.external; });
  17327. };
  17328. DragAndDropService.prototype.findExternalZone = function (params) {
  17329. var externalTargets = this.dropTargets.filter(function (target) { return target.external; });
  17330. return _.find(externalTargets, function (zone) { return zone.getContainer() === params.getContainer(); });
  17331. };
  17332. DragAndDropService.prototype.getHorizontalDirection = function (event) {
  17333. var clientX = this.eventLastTime.clientX;
  17334. var eClientX = event.clientX;
  17335. if (clientX === eClientX) {
  17336. return null;
  17337. }
  17338. return clientX > eClientX ? exports.HorizontalDirection.Left : exports.HorizontalDirection.Right;
  17339. };
  17340. DragAndDropService.prototype.getVerticalDirection = function (event) {
  17341. var clientY = this.eventLastTime.clientY;
  17342. var eClientY = event.clientY;
  17343. if (clientY === eClientY) {
  17344. return null;
  17345. }
  17346. return clientY > eClientY ? exports.VerticalDirection.Up : exports.VerticalDirection.Down;
  17347. };
  17348. DragAndDropService.prototype.createDropTargetEvent = function (dropTarget, event, hDirection, vDirection, fromNudge) {
  17349. // localise x and y to the target
  17350. var dropZoneTarget = dropTarget.getContainer();
  17351. var rect = dropZoneTarget.getBoundingClientRect();
  17352. var _a = this, api = _a.gridApi, columnApi = _a.columnApi, dragItem = _a.dragItem, dragSource = _a.dragSource;
  17353. var x = event.clientX - rect.left;
  17354. var y = event.clientY - rect.top;
  17355. return { event: event, x: x, y: y, vDirection: vDirection, hDirection: hDirection, dragSource: dragSource, fromNudge: fromNudge, dragItem: dragItem, api: api, columnApi: columnApi, dropZoneTarget: dropZoneTarget };
  17356. };
  17357. DragAndDropService.prototype.positionGhost = function (event) {
  17358. var ghost = this.eGhost;
  17359. var ghostRect = ghost.getBoundingClientRect();
  17360. var ghostHeight = ghostRect.height;
  17361. // for some reason, without the '-2', it still overlapped by 1 or 2 pixels, which
  17362. // then brought in scrollbars to the browser. no idea why, but putting in -2 here
  17363. // works around it which is good enough for me.
  17364. var browserWidth = _.getBodyWidth() - 2;
  17365. var browserHeight = _.getBodyHeight() - 2;
  17366. var top = event.pageY - (ghostHeight / 2);
  17367. var left = event.pageX - 10;
  17368. var usrDocument = this.gridOptionsWrapper.getDocument();
  17369. var windowScrollY = window.pageYOffset || usrDocument.documentElement.scrollTop;
  17370. var windowScrollX = window.pageXOffset || usrDocument.documentElement.scrollLeft;
  17371. // check ghost is not positioned outside of the browser
  17372. if (browserWidth > 0 && ((left + ghost.clientWidth) > (browserWidth + windowScrollX))) {
  17373. left = browserWidth + windowScrollX - ghost.clientWidth;
  17374. }
  17375. if (left < 0) {
  17376. left = 0;
  17377. }
  17378. if (browserHeight > 0 && ((top + ghost.clientHeight) > (browserHeight + windowScrollY))) {
  17379. top = browserHeight + windowScrollY - ghost.clientHeight;
  17380. }
  17381. if (top < 0) {
  17382. top = 0;
  17383. }
  17384. ghost.style.left = left + "px";
  17385. ghost.style.top = top + "px";
  17386. };
  17387. DragAndDropService.prototype.removeGhost = function () {
  17388. if (this.eGhost && this.eGhostParent) {
  17389. this.eGhostParent.removeChild(this.eGhost);
  17390. }
  17391. this.eGhost = null;
  17392. };
  17393. DragAndDropService.prototype.createGhost = function () {
  17394. this.eGhost = _.loadTemplate(DragAndDropService_1.GHOST_TEMPLATE);
  17395. var theme = this.environment.getTheme().theme;
  17396. if (theme) {
  17397. _.addCssClass(this.eGhost, theme);
  17398. }
  17399. this.eGhostIcon = this.eGhost.querySelector('.ag-dnd-ghost-icon');
  17400. this.setGhostIcon(null);
  17401. var eText = this.eGhost.querySelector('.ag-dnd-ghost-label');
  17402. var dragItemName = this.dragSource.dragItemName;
  17403. if (_.isFunction(dragItemName)) {
  17404. dragItemName = dragItemName();
  17405. }
  17406. eText.innerHTML = _.escape(dragItemName);
  17407. this.eGhost.style.height = '25px';
  17408. this.eGhost.style.top = '20px';
  17409. this.eGhost.style.left = '20px';
  17410. var usrDocument = this.gridOptionsWrapper.getDocument();
  17411. this.eGhostParent = usrDocument.querySelector('body');
  17412. if (!this.eGhostParent) {
  17413. console.warn('ag-Grid: could not find document body, it is needed for dragging columns');
  17414. }
  17415. else {
  17416. this.eGhostParent.appendChild(this.eGhost);
  17417. }
  17418. };
  17419. DragAndDropService.prototype.setGhostIcon = function (iconName, shake) {
  17420. if (shake === void 0) { shake = false; }
  17421. _.clearElement(this.eGhostIcon);
  17422. var eIcon;
  17423. if (!iconName) {
  17424. iconName = this.dragSource.defaultIconName || DragAndDropService_1.ICON_NOT_ALLOWED;
  17425. }
  17426. switch (iconName) {
  17427. case DragAndDropService_1.ICON_PINNED:
  17428. eIcon = this.ePinnedIcon;
  17429. break;
  17430. case DragAndDropService_1.ICON_MOVE:
  17431. eIcon = this.eMoveIcon;
  17432. break;
  17433. case DragAndDropService_1.ICON_LEFT:
  17434. eIcon = this.eLeftIcon;
  17435. break;
  17436. case DragAndDropService_1.ICON_RIGHT:
  17437. eIcon = this.eRightIcon;
  17438. break;
  17439. case DragAndDropService_1.ICON_GROUP:
  17440. eIcon = this.eGroupIcon;
  17441. break;
  17442. case DragAndDropService_1.ICON_AGGREGATE:
  17443. eIcon = this.eAggregateIcon;
  17444. break;
  17445. case DragAndDropService_1.ICON_PIVOT:
  17446. eIcon = this.ePivotIcon;
  17447. break;
  17448. case DragAndDropService_1.ICON_NOT_ALLOWED:
  17449. eIcon = this.eDropNotAllowedIcon;
  17450. break;
  17451. case DragAndDropService_1.ICON_HIDE:
  17452. eIcon = this.eHideIcon;
  17453. break;
  17454. }
  17455. _.addOrRemoveCssClass(this.eGhostIcon, 'ag-shake-left-to-right', shake);
  17456. if (eIcon === this.eHideIcon && this.gridOptionsWrapper.isSuppressDragLeaveHidesColumns()) {
  17457. return;
  17458. }
  17459. if (eIcon) {
  17460. this.eGhostIcon.appendChild(eIcon);
  17461. }
  17462. };
  17463. var DragAndDropService_1;
  17464. DragAndDropService.ICON_PINNED = 'pinned';
  17465. DragAndDropService.ICON_MOVE = 'move';
  17466. DragAndDropService.ICON_LEFT = 'left';
  17467. DragAndDropService.ICON_RIGHT = 'right';
  17468. DragAndDropService.ICON_GROUP = 'group';
  17469. DragAndDropService.ICON_AGGREGATE = 'aggregate';
  17470. DragAndDropService.ICON_PIVOT = 'pivot';
  17471. DragAndDropService.ICON_NOT_ALLOWED = 'notAllowed';
  17472. DragAndDropService.ICON_HIDE = 'hide';
  17473. DragAndDropService.GHOST_TEMPLATE = "<div class=\"ag-dnd-ghost ag-unselectable\">\n <span class=\"ag-dnd-ghost-icon ag-shake-left-to-right\"></span>\n <div class=\"ag-dnd-ghost-label\"></div>\n </div>";
  17474. __decorate$C([
  17475. Autowired('gridOptionsWrapper')
  17476. ], DragAndDropService.prototype, "gridOptionsWrapper", void 0);
  17477. __decorate$C([
  17478. Autowired('dragService')
  17479. ], DragAndDropService.prototype, "dragService", void 0);
  17480. __decorate$C([
  17481. Autowired('environment')
  17482. ], DragAndDropService.prototype, "environment", void 0);
  17483. __decorate$C([
  17484. Autowired('columnApi')
  17485. ], DragAndDropService.prototype, "columnApi", void 0);
  17486. __decorate$C([
  17487. Autowired('gridApi')
  17488. ], DragAndDropService.prototype, "gridApi", void 0);
  17489. __decorate$C([
  17490. PostConstruct
  17491. ], DragAndDropService.prototype, "init", null);
  17492. __decorate$C([
  17493. PreDestroy
  17494. ], DragAndDropService.prototype, "clearDragSourceParamsList", null);
  17495. DragAndDropService = DragAndDropService_1 = __decorate$C([
  17496. Bean('dragAndDropService')
  17497. ], DragAndDropService);
  17498. return DragAndDropService;
  17499. }(BeanStub));
  17500. /**
  17501. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  17502. * @version v23.2.1
  17503. * @link http://www.ag-grid.com/
  17504. * @license MIT
  17505. */
  17506. var __extends$F = (undefined && undefined.__extends) || (function () {
  17507. var extendStatics = function (d, b) {
  17508. extendStatics = Object.setPrototypeOf ||
  17509. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  17510. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  17511. return extendStatics(d, b);
  17512. };
  17513. return function (d, b) {
  17514. extendStatics(d, b);
  17515. function __() { this.constructor = d; }
  17516. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  17517. };
  17518. })();
  17519. var __decorate$D = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  17520. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  17521. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  17522. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  17523. return c > 3 && r && Object.defineProperty(target, key, r), r;
  17524. };
  17525. var RowDragComp = /** @class */ (function (_super) {
  17526. __extends$F(RowDragComp, _super);
  17527. function RowDragComp(rowNode, column, cellValue, beans) {
  17528. var _this = _super.call(this, "<div class=\"ag-drag-handle ag-row-drag\" role=\"presentation\"></div>") || this;
  17529. _this.rowNode = rowNode;
  17530. _this.column = column;
  17531. _this.cellValue = cellValue;
  17532. _this.beans = beans;
  17533. return _this;
  17534. }
  17535. RowDragComp.prototype.postConstruct = function () {
  17536. var eGui = this.getGui();
  17537. eGui.appendChild(_.createIconNoSpan('rowDrag', this.beans.gridOptionsWrapper, null));
  17538. this.addDragSource();
  17539. this.checkCompatibility();
  17540. var strategy = this.beans.gridOptionsWrapper.isRowDragManaged() ?
  17541. new ManagedVisibilityStrategy(this, this.beans, this.rowNode, this.column) :
  17542. new NonManagedVisibilityStrategy(this, this.beans, this.rowNode, this.column);
  17543. this.createManagedBean(strategy, this.beans.context);
  17544. };
  17545. RowDragComp.prototype.getSelectedCount = function () {
  17546. var multiRowEnabled = this.beans.gridOptionsWrapper.isEnableMultiRowDragging();
  17547. if (!multiRowEnabled) {
  17548. return 1;
  17549. }
  17550. var selection = this.beans.selectionController.getSelectedNodes();
  17551. return selection.indexOf(this.rowNode) !== -1 ? selection.length : 1;
  17552. };
  17553. // returns true if all compatibility items work out
  17554. RowDragComp.prototype.checkCompatibility = function () {
  17555. var managed = this.beans.gridOptionsWrapper.isRowDragManaged();
  17556. var treeData = this.beans.gridOptionsWrapper.isTreeData();
  17557. if (treeData && managed) {
  17558. _.doOnce(function () {
  17559. return console.warn('ag-Grid: If using row drag with tree data, you cannot have rowDragManaged=true');
  17560. }, 'RowDragComp.managedAndTreeData');
  17561. }
  17562. };
  17563. RowDragComp.prototype.addDragSource = function () {
  17564. var _this = this;
  17565. var dragItem = {
  17566. rowNode: this.rowNode,
  17567. columns: [this.column],
  17568. defaultTextValue: this.cellValue,
  17569. };
  17570. var rowDragText = this.column.getColDef().rowDragText;
  17571. var dragSource = {
  17572. type: exports.DragSourceType.RowDrag,
  17573. eElement: this.getGui(),
  17574. dragItemName: function () {
  17575. var dragItemCount = _this.getSelectedCount();
  17576. if (rowDragText) {
  17577. return rowDragText(dragItem, dragItemCount);
  17578. }
  17579. return dragItemCount === 1 ? _this.cellValue : dragItemCount + " rows";
  17580. },
  17581. getDragItem: function () { return dragItem; },
  17582. dragStartPixels: 0
  17583. };
  17584. this.beans.dragAndDropService.addDragSource(dragSource, true);
  17585. this.addDestroyFunc(function () { return _this.beans.dragAndDropService.removeDragSource(dragSource); });
  17586. };
  17587. __decorate$D([
  17588. PostConstruct
  17589. ], RowDragComp.prototype, "postConstruct", null);
  17590. return RowDragComp;
  17591. }(Component));
  17592. var VisibilityStrategy = /** @class */ (function (_super) {
  17593. __extends$F(VisibilityStrategy, _super);
  17594. function VisibilityStrategy(parent, rowNode, column) {
  17595. var _this = _super.call(this) || this;
  17596. _this.parent = parent;
  17597. _this.column = column;
  17598. _this.rowNode = rowNode;
  17599. return _this;
  17600. }
  17601. VisibilityStrategy.prototype.setDisplayedOrVisible = function (neverDisplayed) {
  17602. if (neverDisplayed) {
  17603. this.parent.setDisplayed(false);
  17604. }
  17605. else {
  17606. var shown = this.column.isRowDrag(this.rowNode);
  17607. var isShownSometimes = _.isFunction(this.column.getColDef().rowDrag);
  17608. // if shown sometimes, them some rows can have drag handle while other don't,
  17609. // so we use setVisible to keep the handles horizontally aligned (as setVisible
  17610. // keeps the empty space, whereas setDisplayed looses the space)
  17611. if (isShownSometimes) {
  17612. this.parent.setDisplayed(true);
  17613. this.parent.setVisible(shown);
  17614. }
  17615. else {
  17616. this.parent.setDisplayed(shown);
  17617. }
  17618. }
  17619. };
  17620. return VisibilityStrategy;
  17621. }(BeanStub));
  17622. // when non managed, the visibility depends on suppressRowDrag property only
  17623. var NonManagedVisibilityStrategy = /** @class */ (function (_super) {
  17624. __extends$F(NonManagedVisibilityStrategy, _super);
  17625. function NonManagedVisibilityStrategy(parent, beans, rowNode, column) {
  17626. var _this = _super.call(this, parent, rowNode, column) || this;
  17627. _this.beans = beans;
  17628. return _this;
  17629. }
  17630. NonManagedVisibilityStrategy.prototype.postConstruct = function () {
  17631. this.addManagedListener(this.beans.gridOptionsWrapper, 'suppressRowDrag', this.onSuppressRowDrag.bind(this));
  17632. // in case data changes, then we need to update visibility of drag item
  17633. this.addManagedListener(this.rowNode, RowNode.EVENT_DATA_CHANGED, this.workOutVisibility.bind(this));
  17634. this.addManagedListener(this.rowNode, RowNode.EVENT_CELL_CHANGED, this.workOutVisibility.bind(this));
  17635. this.workOutVisibility();
  17636. };
  17637. NonManagedVisibilityStrategy.prototype.onSuppressRowDrag = function () {
  17638. this.workOutVisibility();
  17639. };
  17640. NonManagedVisibilityStrategy.prototype.workOutVisibility = function () {
  17641. // only show the drag if both sort and filter are not present
  17642. var neverDisplayed = this.beans.gridOptionsWrapper.isSuppressRowDrag();
  17643. this.setDisplayedOrVisible(neverDisplayed);
  17644. };
  17645. __decorate$D([
  17646. PostConstruct
  17647. ], NonManagedVisibilityStrategy.prototype, "postConstruct", null);
  17648. return NonManagedVisibilityStrategy;
  17649. }(VisibilityStrategy));
  17650. // when managed, the visibility depends on sort, filter and row group, as well as suppressRowDrag property
  17651. var ManagedVisibilityStrategy = /** @class */ (function (_super) {
  17652. __extends$F(ManagedVisibilityStrategy, _super);
  17653. function ManagedVisibilityStrategy(parent, beans, rowNode, column) {
  17654. var _this = _super.call(this, parent, rowNode, column) || this;
  17655. _this.beans = beans;
  17656. return _this;
  17657. }
  17658. ManagedVisibilityStrategy.prototype.postConstruct = function () {
  17659. // we do not show the component if sort, filter or grouping is active
  17660. this.addManagedListener(this.beans.eventService, Events.EVENT_SORT_CHANGED, this.workOutVisibility.bind(this));
  17661. this.addManagedListener(this.beans.eventService, Events.EVENT_FILTER_CHANGED, this.workOutVisibility.bind(this));
  17662. this.addManagedListener(this.beans.eventService, Events.EVENT_COLUMN_ROW_GROUP_CHANGED, this.workOutVisibility.bind(this));
  17663. // in case data changes, then we need to update visibility of drag item
  17664. this.addManagedListener(this.rowNode, RowNode.EVENT_DATA_CHANGED, this.workOutVisibility.bind(this));
  17665. this.addManagedListener(this.rowNode, RowNode.EVENT_CELL_CHANGED, this.workOutVisibility.bind(this));
  17666. this.addManagedListener(this.beans.gridOptionsWrapper, 'suppressRowDrag', this.onSuppressRowDrag.bind(this));
  17667. this.workOutVisibility();
  17668. };
  17669. ManagedVisibilityStrategy.prototype.onSuppressRowDrag = function () {
  17670. this.workOutVisibility();
  17671. };
  17672. ManagedVisibilityStrategy.prototype.workOutVisibility = function () {
  17673. // only show the drag if both sort and filter are not present
  17674. var rowDragFeature = this.beans.gridPanel.getRowDragFeature();
  17675. var shouldPreventRowMove = rowDragFeature && rowDragFeature.shouldPreventRowMove();
  17676. var suppressRowDrag = this.beans.gridOptionsWrapper.isSuppressRowDrag();
  17677. var hasExternalDropZones = this.beans.dragAndDropService.hasExternalDropZones();
  17678. var neverDisplayed = (shouldPreventRowMove && !hasExternalDropZones) || suppressRowDrag;
  17679. this.setDisplayedOrVisible(neverDisplayed);
  17680. };
  17681. __decorate$D([
  17682. PostConstruct
  17683. ], ManagedVisibilityStrategy.prototype, "postConstruct", null);
  17684. return ManagedVisibilityStrategy;
  17685. }(VisibilityStrategy));
  17686. /**
  17687. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  17688. * @version v23.2.1
  17689. * @link http://www.ag-grid.com/
  17690. * @license MIT
  17691. */
  17692. var __extends$G = (undefined && undefined.__extends) || (function () {
  17693. var extendStatics = function (d, b) {
  17694. extendStatics = Object.setPrototypeOf ||
  17695. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  17696. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  17697. return extendStatics(d, b);
  17698. };
  17699. return function (d, b) {
  17700. extendStatics(d, b);
  17701. function __() { this.constructor = d; }
  17702. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  17703. };
  17704. })();
  17705. var __decorate$E = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  17706. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  17707. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  17708. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  17709. return c > 3 && r && Object.defineProperty(target, key, r), r;
  17710. };
  17711. var PopupEditorWrapper = /** @class */ (function (_super) {
  17712. __extends$G(PopupEditorWrapper, _super);
  17713. function PopupEditorWrapper(cellEditor) {
  17714. var _this = _super.call(this, "<div class=\"ag-popup-editor\" tabindex=\"-1\"/>") || this;
  17715. _this.getGuiCalledOnChild = false;
  17716. _this.cellEditor = cellEditor;
  17717. return _this;
  17718. }
  17719. PopupEditorWrapper.prototype.onKeyDown = function (event) {
  17720. if (!_.isUserSuppressingKeyboardEvent(this.gridOptionsWrapper, event, this.params.node, this.params.column, true)) {
  17721. this.params.onKeyDown(event);
  17722. }
  17723. };
  17724. PopupEditorWrapper.prototype.getGui = function () {
  17725. // we call getGui() on child here (rather than in the constructor)
  17726. // as we should wait for 'init' to be called on child first.
  17727. if (!this.getGuiCalledOnChild) {
  17728. this.appendChild(this.cellEditor.getGui());
  17729. this.getGuiCalledOnChild = true;
  17730. }
  17731. return _super.prototype.getGui.call(this);
  17732. };
  17733. PopupEditorWrapper.prototype.init = function (params) {
  17734. var _this = this;
  17735. this.params = params;
  17736. this.gridOptionsWrapper.setDomData(this.getGui(), PopupEditorWrapper.DOM_KEY_POPUP_EDITOR_WRAPPER, true);
  17737. this.addDestroyFunc(function () { return _this.destroyBean(_this.cellEditor); });
  17738. this.addManagedListener(
  17739. // this needs to be 'super' and not 'this' as if we call 'this',
  17740. // it ends up called 'getGui()' on the child before 'init' was called,
  17741. // which is not good
  17742. _super.prototype.getGui.call(this), 'keydown', this.onKeyDown.bind(this));
  17743. };
  17744. PopupEditorWrapper.prototype.afterGuiAttached = function () {
  17745. if (this.cellEditor.afterGuiAttached) {
  17746. this.cellEditor.afterGuiAttached();
  17747. }
  17748. };
  17749. PopupEditorWrapper.prototype.getValue = function () {
  17750. return this.cellEditor.getValue();
  17751. };
  17752. PopupEditorWrapper.prototype.isCancelBeforeStart = function () {
  17753. if (this.cellEditor.isCancelBeforeStart) {
  17754. return this.cellEditor.isCancelBeforeStart();
  17755. }
  17756. };
  17757. PopupEditorWrapper.prototype.isCancelAfterEnd = function () {
  17758. if (this.cellEditor.isCancelAfterEnd) {
  17759. return this.cellEditor.isCancelAfterEnd();
  17760. }
  17761. };
  17762. PopupEditorWrapper.prototype.getPopupPosition = function () {
  17763. if (this.cellEditor.getPopupPosition) {
  17764. return this.cellEditor.getPopupPosition();
  17765. }
  17766. };
  17767. PopupEditorWrapper.prototype.focusIn = function () {
  17768. if (this.cellEditor.focusIn) {
  17769. this.cellEditor.focusIn();
  17770. }
  17771. };
  17772. PopupEditorWrapper.prototype.focusOut = function () {
  17773. if (this.cellEditor.focusOut) {
  17774. this.cellEditor.focusOut();
  17775. }
  17776. };
  17777. PopupEditorWrapper.DOM_KEY_POPUP_EDITOR_WRAPPER = 'popupEditorWrapper';
  17778. __decorate$E([
  17779. Autowired('gridOptionsWrapper')
  17780. ], PopupEditorWrapper.prototype, "gridOptionsWrapper", void 0);
  17781. return PopupEditorWrapper;
  17782. }(PopupComponent));
  17783. /**
  17784. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  17785. * @version v23.2.1
  17786. * @link http://www.ag-grid.com/
  17787. * @license MIT
  17788. */
  17789. var __extends$H = (undefined && undefined.__extends) || (function () {
  17790. var extendStatics = function (d, b) {
  17791. extendStatics = Object.setPrototypeOf ||
  17792. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  17793. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  17794. return extendStatics(d, b);
  17795. };
  17796. return function (d, b) {
  17797. extendStatics(d, b);
  17798. function __() { this.constructor = d; }
  17799. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  17800. };
  17801. })();
  17802. var __decorate$F = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  17803. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  17804. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  17805. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  17806. return c > 3 && r && Object.defineProperty(target, key, r), r;
  17807. };
  17808. var DndSourceComp = /** @class */ (function (_super) {
  17809. __extends$H(DndSourceComp, _super);
  17810. function DndSourceComp(rowNode, column, cellValue, beans, eCell) {
  17811. var _this = _super.call(this, "<div class=\"ag-drag-handle ag-row-drag\" draggable=\"true\"></div>") || this;
  17812. _this.rowNode = rowNode;
  17813. _this.column = column;
  17814. _this.cellValue = cellValue;
  17815. _this.beans = beans;
  17816. _this.eCell = eCell;
  17817. return _this;
  17818. }
  17819. DndSourceComp.prototype.postConstruct = function () {
  17820. var eGui = this.getGui();
  17821. eGui.appendChild(_.createIconNoSpan('rowDrag', this.beans.gridOptionsWrapper, null));
  17822. this.addDragSource();
  17823. this.checkVisibility();
  17824. };
  17825. DndSourceComp.prototype.addDragSource = function () {
  17826. this.addGuiEventListener('dragstart', this.onDragStart.bind(this));
  17827. };
  17828. DndSourceComp.prototype.onDragStart = function (dragEvent) {
  17829. var _this = this;
  17830. var providedOnRowDrag = this.column.getColDef().dndSourceOnRowDrag;
  17831. var isIE = _.isBrowserIE();
  17832. if (!isIE) {
  17833. dragEvent.dataTransfer.setDragImage(this.eCell, 0, 0);
  17834. }
  17835. // default behaviour is to convert data to json and set into drag component
  17836. var defaultOnRowDrag = function () {
  17837. try {
  17838. var jsonData = JSON.stringify(_this.rowNode.data);
  17839. if (isIE) {
  17840. dragEvent.dataTransfer.setData('text', jsonData);
  17841. }
  17842. else {
  17843. dragEvent.dataTransfer.setData('application/json', jsonData);
  17844. dragEvent.dataTransfer.setData('text/plain', jsonData);
  17845. }
  17846. }
  17847. catch (e) {
  17848. // if we cannot convert the data to json, then we do not set the type
  17849. }
  17850. };
  17851. if (providedOnRowDrag) {
  17852. providedOnRowDrag({ rowNode: this.rowNode, dragEvent: dragEvent });
  17853. }
  17854. else {
  17855. defaultOnRowDrag();
  17856. }
  17857. };
  17858. DndSourceComp.prototype.checkVisibility = function () {
  17859. var visible = this.column.isDndSource(this.rowNode);
  17860. this.setDisplayed(visible);
  17861. };
  17862. __decorate$F([
  17863. PostConstruct
  17864. ], DndSourceComp.prototype, "postConstruct", null);
  17865. return DndSourceComp;
  17866. }(Component));
  17867. /**
  17868. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  17869. * @version v23.2.1
  17870. * @link http://www.ag-grid.com/
  17871. * @license MIT
  17872. */
  17873. var __extends$I = (undefined && undefined.__extends) || (function () {
  17874. var extendStatics = function (d, b) {
  17875. extendStatics = Object.setPrototypeOf ||
  17876. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  17877. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  17878. return extendStatics(d, b);
  17879. };
  17880. return function (d, b) {
  17881. extendStatics(d, b);
  17882. function __() { this.constructor = d; }
  17883. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  17884. };
  17885. })();
  17886. var __decorate$G = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  17887. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  17888. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  17889. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  17890. return c > 3 && r && Object.defineProperty(target, key, r), r;
  17891. };
  17892. var TooltipStates;
  17893. (function (TooltipStates) {
  17894. TooltipStates[TooltipStates["NOTHING"] = 0] = "NOTHING";
  17895. TooltipStates[TooltipStates["WAITING_TO_SHOW"] = 1] = "WAITING_TO_SHOW";
  17896. TooltipStates[TooltipStates["SHOWING"] = 2] = "SHOWING";
  17897. })(TooltipStates || (TooltipStates = {}));
  17898. var TooltipFeature = /** @class */ (function (_super) {
  17899. __extends$I(TooltipFeature, _super);
  17900. function TooltipFeature(parentComp, location) {
  17901. var _this = _super.call(this) || this;
  17902. _this.DEFAULT_HIDE_TOOLTIP_TIMEOUT = 10000;
  17903. _this.SHOW_QUICK_TOOLTIP_DIFF = 1000;
  17904. _this.FADE_OUT_TOOLTIP_TIMEOUT = 1000;
  17905. _this.state = TooltipStates.NOTHING;
  17906. // when showing the tooltip, we need to make sure it's the most recent instance we request, as due to
  17907. // async we could request two tooltips before the first instance returns, in which case we should
  17908. // disregard the second instance.
  17909. _this.tooltipInstanceCount = 0;
  17910. _this.tooltipMouseTrack = false;
  17911. _this.parentComp = parentComp;
  17912. _this.location = location;
  17913. return _this;
  17914. }
  17915. TooltipFeature.prototype.postConstruct = function () {
  17916. this.tooltipShowDelay = this.gridOptionsWrapper.getTooltipShowDelay() || 2000;
  17917. this.tooltipMouseTrack = this.gridOptionsWrapper.isTooltipMouseTrack();
  17918. var el = this.parentComp.getGui();
  17919. this.addManagedListener(el, 'mouseenter', this.onMouseEnter.bind(this));
  17920. this.addManagedListener(el, 'mouseleave', this.onMouseLeave.bind(this));
  17921. this.addManagedListener(el, 'mousemove', this.onMouseMove.bind(this));
  17922. this.addManagedListener(el, 'mousedown', this.onMouseDown.bind(this));
  17923. };
  17924. TooltipFeature.prototype.destroy = function () {
  17925. // if this component gets destroyed while tooltip is showing, need to make sure
  17926. // we don't end with no mouseLeave event resulting in zombie tooltip
  17927. this.setToDoNothing();
  17928. _super.prototype.destroy.call(this);
  17929. };
  17930. TooltipFeature.prototype.onMouseEnter = function (e) {
  17931. // if another tooltip was hidden very recently, we only wait 200ms to show, not the normal waiting time
  17932. var delay = this.isLastTooltipHiddenRecently() ? 200 : this.tooltipShowDelay;
  17933. this.showTooltipTimeoutId = window.setTimeout(this.showTooltip.bind(this), delay);
  17934. this.lastMouseEvent = e;
  17935. this.state = TooltipStates.WAITING_TO_SHOW;
  17936. };
  17937. TooltipFeature.prototype.onMouseLeave = function () {
  17938. this.setToDoNothing();
  17939. };
  17940. TooltipFeature.prototype.setToDoNothing = function () {
  17941. if (this.state === TooltipStates.SHOWING) {
  17942. this.hideTooltip();
  17943. }
  17944. this.clearTimeouts();
  17945. this.state = TooltipStates.NOTHING;
  17946. };
  17947. TooltipFeature.prototype.onMouseMove = function (e) {
  17948. // there is a delay from the time we mouseOver a component and the time the
  17949. // tooltip is displayed, so we need to track mousemove to be able to correctly
  17950. // position the tooltip when showTooltip is called.
  17951. this.lastMouseEvent = e;
  17952. if (this.tooltipMouseTrack &&
  17953. this.state === TooltipStates.SHOWING &&
  17954. this.tooltipComp) {
  17955. this.positionTooltipUnderLastMouseEvent();
  17956. }
  17957. };
  17958. TooltipFeature.prototype.onMouseDown = function () {
  17959. this.setToDoNothing();
  17960. };
  17961. TooltipFeature.prototype.hideTooltip = function () {
  17962. // check if comp exists - due to async, although we asked for
  17963. // one, the instance may not be back yet
  17964. if (this.tooltipComp) {
  17965. this.destroyTooltipComp();
  17966. TooltipFeature.lastTooltipHideTime = new Date().getTime();
  17967. }
  17968. this.state = TooltipStates.NOTHING;
  17969. };
  17970. TooltipFeature.prototype.destroyTooltipComp = function () {
  17971. var _this = this;
  17972. // add class to fade out the tooltip
  17973. _.addCssClass(this.tooltipComp.getGui(), 'ag-tooltip-hiding');
  17974. // make local copies of these variables, as we use them in the async function below,
  17975. // and we clear then to 'undefined' later, so need to take a copy before they are undefined.
  17976. var tooltipPopupDestroyFunc = this.tooltipPopupDestroyFunc;
  17977. var tooltipComp = this.tooltipComp;
  17978. window.setTimeout(function () {
  17979. tooltipPopupDestroyFunc();
  17980. _this.getContext().destroyBean(tooltipComp);
  17981. }, this.FADE_OUT_TOOLTIP_TIMEOUT);
  17982. this.tooltipPopupDestroyFunc = undefined;
  17983. this.tooltipComp = undefined;
  17984. };
  17985. TooltipFeature.prototype.isLastTooltipHiddenRecently = function () {
  17986. // return true if <1000ms since last time we hid a tooltip
  17987. var now = new Date().getTime();
  17988. var then = TooltipFeature.lastTooltipHideTime;
  17989. return (now - then) < this.SHOW_QUICK_TOOLTIP_DIFF;
  17990. };
  17991. TooltipFeature.prototype.showTooltip = function () {
  17992. var tooltipText = this.parentComp.getTooltipText();
  17993. if (!tooltipText) {
  17994. this.setToDoNothing();
  17995. return;
  17996. }
  17997. this.state = TooltipStates.SHOWING;
  17998. this.tooltipInstanceCount++;
  17999. var params = {
  18000. location: this.location,
  18001. api: this.gridApi,
  18002. columnApi: this.columnApi,
  18003. colDef: this.parentComp.getComponentHolder(),
  18004. column: this.parentComp.getColumn,
  18005. context: this.gridOptionsWrapper.getContext(),
  18006. rowIndex: this.parentComp.getCellPosition && this.parentComp.getCellPosition().rowIndex,
  18007. value: tooltipText
  18008. };
  18009. // we pass in tooltipInstanceCount so the callback knows what the count was when
  18010. // we requested the tooltip, so if another tooltip was requested in the mean time
  18011. // we disregard it
  18012. var callback = this.newTooltipComponentCallback.bind(this, this.tooltipInstanceCount);
  18013. this.userComponentFactory.newTooltipComponent(params).then(callback);
  18014. };
  18015. TooltipFeature.prototype.newTooltipComponentCallback = function (tooltipInstanceCopy, tooltipComp) {
  18016. var compNoLongerNeeded = this.state !== TooltipStates.SHOWING || this.tooltipInstanceCount !== tooltipInstanceCopy;
  18017. if (compNoLongerNeeded) {
  18018. this.getContext().destroyBean(tooltipComp);
  18019. return;
  18020. }
  18021. var eGui = tooltipComp.getGui();
  18022. this.tooltipComp = tooltipComp;
  18023. if (!_.containsClass(eGui, 'ag-tooltip')) {
  18024. _.addCssClass(eGui, 'ag-tooltip-custom');
  18025. }
  18026. this.tooltipPopupDestroyFunc = this.popupService.addPopup(false, eGui, false);
  18027. this.positionTooltipUnderLastMouseEvent();
  18028. this.hideTooltipTimeoutId = window.setTimeout(this.hideTooltip.bind(this), this.DEFAULT_HIDE_TOOLTIP_TIMEOUT);
  18029. };
  18030. TooltipFeature.prototype.positionTooltipUnderLastMouseEvent = function () {
  18031. this.popupService.positionPopupUnderMouseEvent({
  18032. type: 'tooltip',
  18033. mouseEvent: this.lastMouseEvent,
  18034. ePopup: this.tooltipComp.getGui(),
  18035. nudgeY: 18
  18036. });
  18037. };
  18038. TooltipFeature.prototype.clearTimeouts = function () {
  18039. if (this.showTooltipTimeoutId) {
  18040. window.clearTimeout(this.showTooltipTimeoutId);
  18041. this.showTooltipTimeoutId = undefined;
  18042. }
  18043. if (this.hideTooltipTimeoutId) {
  18044. window.clearTimeout(this.hideTooltipTimeoutId);
  18045. this.hideTooltipTimeoutId = undefined;
  18046. }
  18047. };
  18048. __decorate$G([
  18049. Autowired('popupService')
  18050. ], TooltipFeature.prototype, "popupService", void 0);
  18051. __decorate$G([
  18052. Autowired('userComponentFactory')
  18053. ], TooltipFeature.prototype, "userComponentFactory", void 0);
  18054. __decorate$G([
  18055. Autowired('columnApi')
  18056. ], TooltipFeature.prototype, "columnApi", void 0);
  18057. __decorate$G([
  18058. Autowired('gridApi')
  18059. ], TooltipFeature.prototype, "gridApi", void 0);
  18060. __decorate$G([
  18061. Autowired('gridOptionsWrapper')
  18062. ], TooltipFeature.prototype, "gridOptionsWrapper", void 0);
  18063. __decorate$G([
  18064. PostConstruct
  18065. ], TooltipFeature.prototype, "postConstruct", null);
  18066. return TooltipFeature;
  18067. }(BeanStub));
  18068. /**
  18069. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  18070. * @version v23.2.1
  18071. * @link http://www.ag-grid.com/
  18072. * @license MIT
  18073. */
  18074. var __extends$J = (undefined && undefined.__extends) || (function () {
  18075. var extendStatics = function (d, b) {
  18076. extendStatics = Object.setPrototypeOf ||
  18077. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  18078. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  18079. return extendStatics(d, b);
  18080. };
  18081. return function (d, b) {
  18082. extendStatics(d, b);
  18083. function __() { this.constructor = d; }
  18084. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  18085. };
  18086. })();
  18087. var __assign$1 = (undefined && undefined.__assign) || function () {
  18088. __assign$1 = Object.assign || function(t) {
  18089. for (var s, i = 1, n = arguments.length; i < n; i++) {
  18090. s = arguments[i];
  18091. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
  18092. t[p] = s[p];
  18093. }
  18094. return t;
  18095. };
  18096. return __assign$1.apply(this, arguments);
  18097. };
  18098. var CellComp = /** @class */ (function (_super) {
  18099. __extends$J(CellComp, _super);
  18100. function CellComp(scope, beans, column, rowNode, rowComp, autoHeightCell, printLayout) {
  18101. var _this = _super.call(this) || this;
  18102. _this.hasChartRange = false;
  18103. _this.editingCell = false;
  18104. _this.suppressRefreshCell = false;
  18105. _this.scope = null;
  18106. // every time we go into edit mode, or back again, this gets incremented.
  18107. // it's the components way of dealing with the async nature of framework components,
  18108. // so if a framework component takes a while to be created, we know if the object
  18109. // is still relevant when creating is finished. eg we could click edit / un-edit 20
  18110. // times before the first React edit component comes back - we should discard
  18111. // the first 19.
  18112. _this.cellEditorVersion = 0;
  18113. _this.cellRendererVersion = 0;
  18114. _this.scope = scope;
  18115. _this.beans = beans;
  18116. _this.column = column;
  18117. _this.rowNode = rowNode;
  18118. _this.rowComp = rowComp;
  18119. _this.autoHeightCell = autoHeightCell;
  18120. _this.printLayout = printLayout;
  18121. _this.createGridCellVo();
  18122. _this.rangeSelectionEnabled = _this.beans.rangeController && beans.gridOptionsWrapper.isEnableRangeSelection();
  18123. _this.cellFocused = _this.beans.focusController.isCellFocused(_this.cellPosition);
  18124. _this.firstRightPinned = _this.column.isFirstRightPinned();
  18125. _this.lastLeftPinned = _this.column.isLastLeftPinned();
  18126. if (_this.rangeSelectionEnabled && _this.beans.rangeController) {
  18127. var rangeController = _this.beans.rangeController;
  18128. _this.rangeCount = rangeController.getCellRangeCount(_this.cellPosition);
  18129. _this.hasChartRange = _this.getHasChartRange();
  18130. }
  18131. _this.getValueAndFormat();
  18132. _this.setUsingWrapper();
  18133. _this.chooseCellRenderer();
  18134. _this.setupColSpan();
  18135. _this.rowSpan = _this.column.getRowSpan(_this.rowNode);
  18136. return _this;
  18137. }
  18138. CellComp.prototype.getCreateTemplate = function () {
  18139. var unselectable = !this.beans.gridOptionsWrapper.isEnableCellTextSelection() ? 'unselectable="on"' : '';
  18140. var templateParts = [];
  18141. var col = this.column;
  18142. var width = this.getCellWidth();
  18143. var left = this.modifyLeftForPrintLayout(this.getCellLeft());
  18144. var valueToRender = this.getInitialValueToRender();
  18145. var valueSanitised = _.get(this.column, 'colDef.template', null) ? valueToRender : _.escape(valueToRender);
  18146. this.tooltip = this.getToolTip();
  18147. var tooltipSanitised = _.escape(this.tooltip);
  18148. var colIdSanitised = _.escape(col.getId());
  18149. var wrapperStartTemplate = '';
  18150. var wrapperEndTemplate = '';
  18151. var stylesFromColDef = this.preProcessStylesFromColDef();
  18152. var cssClasses = this.getInitialCssClasses();
  18153. var stylesForRowSpanning = this.getStylesForRowSpanning();
  18154. var colIdxSanitised = _.escape(this.getAriaColumnIndex());
  18155. if (this.usingWrapper) {
  18156. wrapperStartTemplate = "<div ref=\"eCellWrapper\" class=\"ag-cell-wrapper\" role=\"presentation\">\n <span ref=\"eCellValue\" role=\"gridcell\" aria-colindex=\"" + colIdxSanitised + "\" class=\"ag-cell-value\" " + unselectable + ">";
  18157. wrapperEndTemplate = '</span></div>';
  18158. }
  18159. templateParts.push("<div");
  18160. templateParts.push(" tabindex=\"-1\"");
  18161. templateParts.push(" " + unselectable); // THIS IS FOR IE ONLY so text selection doesn't bubble outside of the grid
  18162. templateParts.push(" role=\"" + (this.usingWrapper ? 'presentation' : 'gridcell') + "\"");
  18163. if (!this.usingWrapper) {
  18164. templateParts.push(" aria-colindex=" + colIdxSanitised);
  18165. }
  18166. templateParts.push(" comp-id=\"" + this.getCompId() + "\" ");
  18167. templateParts.push(" col-id=\"" + colIdSanitised + "\"");
  18168. templateParts.push(" class=\"" + _.escape(cssClasses.join(' ')) + "\"");
  18169. if (this.beans.gridOptionsWrapper.isEnableBrowserTooltips() && _.exists(tooltipSanitised)) {
  18170. templateParts.push("title=\"" + tooltipSanitised + "\"");
  18171. }
  18172. templateParts.push(" style=\"width: " + Number(width) + "px; left: " + Number(left) + "px; " + _.escape(stylesFromColDef) + " " + _.escape(stylesForRowSpanning) + "\" >");
  18173. templateParts.push(wrapperStartTemplate);
  18174. if (_.exists(valueSanitised, true)) {
  18175. templateParts.push(valueSanitised);
  18176. }
  18177. templateParts.push(wrapperEndTemplate);
  18178. templateParts.push("</div>");
  18179. return templateParts.join('');
  18180. };
  18181. CellComp.prototype.getStylesForRowSpanning = function () {
  18182. if (this.rowSpan === 1) {
  18183. return '';
  18184. }
  18185. var singleRowHeight = this.beans.gridOptionsWrapper.getRowHeightAsNumber();
  18186. var totalRowHeight = singleRowHeight * this.rowSpan;
  18187. return "height: " + totalRowHeight + "px; z-index: 1;";
  18188. };
  18189. CellComp.prototype.afterAttached = function () {
  18190. var querySelector = "[comp-id=\"" + this.getCompId() + "\"]";
  18191. var eGui = this.eParentRow.querySelector(querySelector);
  18192. this.setGui(eGui);
  18193. // all of these have dependencies on the eGui, so only do them after eGui is set
  18194. this.addDomData();
  18195. this.populateTemplate();
  18196. this.createCellRendererInstance(true);
  18197. this.angular1Compile();
  18198. this.refreshHandle();
  18199. if (_.exists(this.tooltip) && !this.beans.gridOptionsWrapper.isEnableBrowserTooltips()) {
  18200. this.createManagedBean(new TooltipFeature(this, 'cell'), this.beans.context);
  18201. }
  18202. };
  18203. CellComp.prototype.onColumnHover = function () {
  18204. var isHovered = this.beans.columnHoverService.isHovered(this.column);
  18205. _.addOrRemoveCssClass(this.getGui(), 'ag-column-hover', isHovered);
  18206. };
  18207. CellComp.prototype.onCellChanged = function (event) {
  18208. var eventImpactsThisCell = event.column === this.column;
  18209. if (eventImpactsThisCell) {
  18210. this.refreshCell({});
  18211. }
  18212. };
  18213. CellComp.prototype.getCellLeft = function () {
  18214. var mostLeftCol;
  18215. if (this.beans.gridOptionsWrapper.isEnableRtl() && this.colsSpanning) {
  18216. mostLeftCol = _.last(this.colsSpanning);
  18217. }
  18218. else {
  18219. mostLeftCol = this.column;
  18220. }
  18221. return mostLeftCol.getLeft();
  18222. };
  18223. CellComp.prototype.getCellWidth = function () {
  18224. if (!this.colsSpanning) {
  18225. return this.column.getActualWidth();
  18226. }
  18227. return this.colsSpanning.reduce(function (width, col) { return width + col.getActualWidth(); }, 0);
  18228. };
  18229. CellComp.prototype.onFlashCells = function (event) {
  18230. var cellId = this.beans.cellPositionUtils.createId(this.cellPosition);
  18231. var shouldFlash = event.cells[cellId];
  18232. if (shouldFlash) {
  18233. this.animateCell('highlight');
  18234. }
  18235. };
  18236. CellComp.prototype.setupColSpan = function () {
  18237. // if no col span is active, then we don't set it up, as it would be wasteful of CPU
  18238. if (_.missing(this.getComponentHolder().colSpan)) {
  18239. return;
  18240. }
  18241. // because we are col spanning, a reorder of the cols can change what cols we are spanning over
  18242. this.addManagedListener(this.beans.eventService, Events.EVENT_DISPLAYED_COLUMNS_CHANGED, this.onDisplayColumnsChanged.bind(this));
  18243. // because we are spanning over multiple cols, we check for width any time any cols width changes.
  18244. // this is expensive - really we should be explicitly checking only the cols we are spanning over
  18245. // instead of every col, however it would be tricky code to track the cols we are spanning over, so
  18246. // because hardly anyone will be using colSpan, am favouring this easier way for more maintainable code.
  18247. this.addManagedListener(this.beans.eventService, Events.EVENT_DISPLAYED_COLUMNS_WIDTH_CHANGED, this.onWidthChanged.bind(this));
  18248. this.colsSpanning = this.getColSpanningList();
  18249. };
  18250. CellComp.prototype.getColSpanningList = function () {
  18251. var colSpan = this.column.getColSpan(this.rowNode);
  18252. var colsSpanning = [];
  18253. // if just one col, the col span is just the column we are in
  18254. if (colSpan === 1) {
  18255. colsSpanning.push(this.column);
  18256. }
  18257. else {
  18258. var pointer = this.column;
  18259. var pinned = this.column.getPinned();
  18260. for (var i = 0; pointer && i < colSpan; i++) {
  18261. colsSpanning.push(pointer);
  18262. pointer = this.beans.columnController.getDisplayedColAfter(pointer);
  18263. if (!pointer || _.missing(pointer)) {
  18264. break;
  18265. }
  18266. // we do not allow col spanning to span outside of pinned areas
  18267. if (pinned !== pointer.getPinned()) {
  18268. break;
  18269. }
  18270. }
  18271. }
  18272. return colsSpanning;
  18273. };
  18274. CellComp.prototype.onDisplayColumnsChanged = function () {
  18275. var colsSpanning = this.getColSpanningList();
  18276. if (!_.areEqual(this.colsSpanning, colsSpanning)) {
  18277. this.colsSpanning = colsSpanning;
  18278. this.onWidthChanged();
  18279. this.onLeftChanged(); // left changes when doing RTL
  18280. }
  18281. };
  18282. CellComp.prototype.getAriaColumnIndex = function () {
  18283. var allColumns = this.beans.columnController.getAllDisplayedColumns();
  18284. return (allColumns.indexOf(this.column) + 1).toString();
  18285. };
  18286. CellComp.prototype.refreshAriaIndex = function () {
  18287. var colIdx = this.getAriaColumnIndex();
  18288. var el = this.usingWrapper ? this.eCellValue : this.getGui();
  18289. el.setAttribute('aria-colindex', colIdx);
  18290. };
  18291. CellComp.prototype.getInitialCssClasses = function () {
  18292. var cssClasses = ["ag-cell", "ag-cell-not-inline-editing"];
  18293. // if we are putting the cell into a dummy container, to work out it's height,
  18294. // then we don't put the height css in, as we want cell to fit height in that case.
  18295. if (!this.autoHeightCell) {
  18296. cssClasses.push('ag-cell-auto-height');
  18297. }
  18298. var doingFocusCss = !this.beans.gridOptionsWrapper.isSuppressCellSelection();
  18299. if (doingFocusCss && this.cellFocused) {
  18300. // otherwise the class depends on the focus state
  18301. cssClasses.push('ag-cell-focus');
  18302. }
  18303. if (this.firstRightPinned) {
  18304. cssClasses.push('ag-cell-first-right-pinned');
  18305. }
  18306. if (this.lastLeftPinned) {
  18307. cssClasses.push('ag-cell-last-left-pinned');
  18308. }
  18309. if (this.beans.columnHoverService.isHovered(this.column)) {
  18310. cssClasses.push('ag-column-hover');
  18311. }
  18312. _.pushAll(cssClasses, this.preProcessClassesFromColDef());
  18313. _.pushAll(cssClasses, this.preProcessCellClassRules());
  18314. _.pushAll(cssClasses, this.getInitialRangeClasses());
  18315. // if using the wrapper, this class goes on the wrapper instead
  18316. if (!this.usingWrapper) {
  18317. cssClasses.push('ag-cell-value');
  18318. }
  18319. return cssClasses;
  18320. };
  18321. CellComp.prototype.getInitialValueToRender = function () {
  18322. // if using a cellRenderer, then render the html from the cell renderer if it exists
  18323. if (this.usingCellRenderer) {
  18324. if (typeof this.cellRendererGui === 'string') {
  18325. return this.cellRendererGui;
  18326. }
  18327. return '';
  18328. }
  18329. var colDef = this.getComponentHolder();
  18330. if (colDef.template) {
  18331. // template is really only used for angular 1 - as people using ng1 are used to providing templates with
  18332. // bindings in it. in ng2, people will hopefully want to provide components, not templates.
  18333. return colDef.template;
  18334. }
  18335. if (colDef.templateUrl) {
  18336. // likewise for templateUrl - it's for ng1 really - when we move away from ng1, we can take these out.
  18337. // niall was pro angular 1 when writing template and templateUrl, if writing from scratch now, would
  18338. // not do these, but would follow a pattern that was friendly towards components, not templates.
  18339. var template = this.beans.templateService.getTemplate(colDef.templateUrl, this.refreshCell.bind(this, true));
  18340. return template || '';
  18341. }
  18342. return this.getValueToUse();
  18343. };
  18344. CellComp.prototype.getRenderedRow = function () {
  18345. return this.rowComp;
  18346. };
  18347. CellComp.prototype.isSuppressNavigable = function () {
  18348. return this.column.isSuppressNavigable(this.rowNode);
  18349. };
  18350. CellComp.prototype.getCellRenderer = function () {
  18351. return this.cellRenderer;
  18352. };
  18353. CellComp.prototype.getCellEditor = function () {
  18354. return this.cellEditor;
  18355. };
  18356. // + stop editing {forceRefresh: true, suppressFlash: true}
  18357. // + event cellChanged {}
  18358. // + cellRenderer.params.refresh() {} -> method passes 'as is' to the cellRenderer, so params could be anything
  18359. // + rowComp: event dataChanged {animate: update, newData: !update}
  18360. // + rowComp: api refreshCells() {animate: true/false}
  18361. // + rowRenderer: api softRefreshView() {}
  18362. CellComp.prototype.refreshCell = function (params) {
  18363. // if we are in the middle of 'stopEditing', then we don't refresh here, as refresh gets called explicitly
  18364. if (this.suppressRefreshCell || this.editingCell) {
  18365. return;
  18366. }
  18367. var colDef = this.getComponentHolder();
  18368. var newData = params && params.newData;
  18369. var suppressFlash = (params && params.suppressFlash) || colDef.suppressCellFlash;
  18370. var forceRefresh = params && params.forceRefresh;
  18371. var oldValue = this.value;
  18372. // get latest value without invoking the value formatter as we may not be updating the cell
  18373. this.value = this.getValue();
  18374. // for simple values only (not objects), see if the value is the same, and if it is, skip the refresh.
  18375. // when never allow skipping after an edit, as after editing, we need to put the GUI back to the way
  18376. // if was before the edit.
  18377. var valuesDifferent = !this.valuesAreEqual(oldValue, this.value);
  18378. var dataNeedsUpdating = forceRefresh || valuesDifferent;
  18379. if (dataNeedsUpdating) {
  18380. // now invoke the value formatter as we are going to update cell
  18381. this.valueFormatted = this.beans.valueFormatterService.formatValue(this.column, this.rowNode, this.scope, this.value);
  18382. // if it's 'new data', then we don't refresh the cellRenderer, even if refresh method is available.
  18383. // this is because if the whole data is new (ie we are showing stock price 'BBA' now and not 'SSD')
  18384. // then we are not showing a movement in the stock price, rather we are showing different stock.
  18385. var cellRendererRefreshed = newData ? false : this.attemptCellRendererRefresh();
  18386. // we do the replace if not doing refresh, or if refresh was unsuccessful.
  18387. // the refresh can be unsuccessful if we are using a framework (eg ng2 or react) and the framework
  18388. // wrapper has the refresh method, but the underlying component doesn't
  18389. if (!cellRendererRefreshed) {
  18390. this.replaceContentsAfterRefresh();
  18391. }
  18392. // we don't want to flash the cells when processing a filter change, as otherwise the UI would
  18393. // be to busy. see comment in FilterManager with regards processingFilterChange
  18394. var processingFilterChange = this.beans.filterManager.isSuppressFlashingCellsBecauseFiltering();
  18395. var flashCell = !suppressFlash && !processingFilterChange &&
  18396. (this.beans.gridOptionsWrapper.isEnableCellChangeFlash() || colDef.enableCellChangeFlash);
  18397. if (flashCell) {
  18398. this.flashCell();
  18399. }
  18400. // need to check rules. note, we ignore colDef classes and styles, these are assumed to be static
  18401. this.postProcessStylesFromColDef();
  18402. this.postProcessClassesFromColDef();
  18403. }
  18404. // we can't readily determine if the data in an angularjs template has changed, so here we just update
  18405. // and recompile (if applicable)
  18406. this.updateAngular1ScopeAndCompile();
  18407. this.refreshToolTip();
  18408. // we do cellClassRules even if the value has not changed, so that users who have rules that
  18409. // look at other parts of the row (where the other part of the row might of changed) will work.
  18410. this.postProcessCellClassRules();
  18411. };
  18412. // user can also call this via API
  18413. CellComp.prototype.flashCell = function (delays) {
  18414. var flashDelay = delays && delays.flashDelay;
  18415. var fadeDelay = delays && delays.fadeDelay;
  18416. this.animateCell('data-changed', flashDelay, fadeDelay);
  18417. };
  18418. CellComp.prototype.animateCell = function (cssName, flashDelay, fadeDelay) {
  18419. var fullName = "ag-cell-" + cssName;
  18420. var animationFullName = "ag-cell-" + cssName + "-animation";
  18421. var element = this.getGui();
  18422. var gridOptionsWrapper = this.beans.gridOptionsWrapper;
  18423. if (!flashDelay) {
  18424. flashDelay = gridOptionsWrapper.getCellFlashDelay();
  18425. }
  18426. if (!fadeDelay) {
  18427. fadeDelay = gridOptionsWrapper.getCellFadeDelay();
  18428. }
  18429. // we want to highlight the cells, without any animation
  18430. _.addCssClass(element, fullName);
  18431. _.removeCssClass(element, animationFullName);
  18432. // then once that is applied, we remove the highlight with animation
  18433. window.setTimeout(function () {
  18434. _.removeCssClass(element, fullName);
  18435. _.addCssClass(element, animationFullName);
  18436. element.style.transition = "background-color " + fadeDelay + "ms";
  18437. window.setTimeout(function () {
  18438. // and then to leave things as we got them, we remove the animation
  18439. _.removeCssClass(element, animationFullName);
  18440. element.style.transition = null;
  18441. }, fadeDelay);
  18442. }, flashDelay);
  18443. };
  18444. CellComp.prototype.replaceContentsAfterRefresh = function () {
  18445. // otherwise we rip out the cell and replace it
  18446. _.clearElement(this.eParentOfValue);
  18447. // remove old renderer component if it exists
  18448. this.cellRenderer = this.beans.context.destroyBean(this.cellRenderer);
  18449. this.cellRendererGui = null;
  18450. // populate
  18451. this.putDataIntoCellAfterRefresh();
  18452. this.updateAngular1ScopeAndCompile();
  18453. };
  18454. CellComp.prototype.updateAngular1ScopeAndCompile = function () {
  18455. if (this.beans.gridOptionsWrapper.isAngularCompileRows() && this.scope) {
  18456. this.scope.data = __assign$1({}, this.rowNode.data);
  18457. this.angular1Compile();
  18458. }
  18459. };
  18460. CellComp.prototype.angular1Compile = function () {
  18461. // if angular compiling, then need to also compile the cell again (angular compiling sucks, please wait...)
  18462. if (this.beans.gridOptionsWrapper.isAngularCompileRows()) {
  18463. var eGui = this.getGui();
  18464. // only compile the node if it hasn't already been done
  18465. // this prevents "orphaned" node leaks
  18466. if (!eGui.classList.contains('ng-scope') || eGui.childElementCount === 0) {
  18467. var compiledElement_1 = this.beans.$compile(eGui)(this.scope);
  18468. this.addDestroyFunc(function () { return compiledElement_1.remove(); });
  18469. }
  18470. }
  18471. };
  18472. CellComp.prototype.postProcessStylesFromColDef = function () {
  18473. var stylesToUse = this.processStylesFromColDef();
  18474. if (stylesToUse) {
  18475. _.addStylesToElement(this.getGui(), stylesToUse);
  18476. }
  18477. };
  18478. CellComp.prototype.preProcessStylesFromColDef = function () {
  18479. return _.cssStyleObjectToMarkup(this.processStylesFromColDef());
  18480. };
  18481. CellComp.prototype.processStylesFromColDef = function () {
  18482. var colDef = this.getComponentHolder();
  18483. if (colDef.cellStyle) {
  18484. var cssToUse = void 0;
  18485. if (typeof colDef.cellStyle === 'function') {
  18486. var cellStyleParams = {
  18487. value: this.value,
  18488. data: this.rowNode.data,
  18489. node: this.rowNode,
  18490. colDef: colDef,
  18491. column: this.column,
  18492. $scope: this.scope,
  18493. context: this.beans.gridOptionsWrapper.getContext(),
  18494. api: this.beans.gridOptionsWrapper.getApi()
  18495. };
  18496. var cellStyleFunc = colDef.cellStyle;
  18497. cssToUse = cellStyleFunc(cellStyleParams);
  18498. }
  18499. else {
  18500. cssToUse = colDef.cellStyle;
  18501. }
  18502. return cssToUse;
  18503. }
  18504. };
  18505. CellComp.prototype.postProcessClassesFromColDef = function () {
  18506. var _this = this;
  18507. this.processClassesFromColDef(function (className) { return _.addCssClass(_this.getGui(), className); });
  18508. };
  18509. CellComp.prototype.preProcessClassesFromColDef = function () {
  18510. var res = [];
  18511. this.processClassesFromColDef(function (className) { return res.push(className); });
  18512. return res;
  18513. };
  18514. CellComp.prototype.processClassesFromColDef = function (onApplicableClass) {
  18515. var colDef = this.getComponentHolder();
  18516. this.beans.stylingService.processStaticCellClasses(colDef, {
  18517. value: this.value,
  18518. data: this.rowNode.data,
  18519. node: this.rowNode,
  18520. colDef: colDef,
  18521. rowIndex: this.rowNode.rowIndex,
  18522. $scope: this.scope,
  18523. api: this.beans.gridOptionsWrapper.getApi(),
  18524. columnApi: this.beans.gridOptionsWrapper.getColumnApi(),
  18525. context: this.beans.gridOptionsWrapper.getContext()
  18526. }, onApplicableClass);
  18527. };
  18528. CellComp.prototype.putDataIntoCellAfterRefresh = function () {
  18529. // template gets preference, then cellRenderer, then do it ourselves
  18530. var colDef = this.getComponentHolder();
  18531. if (colDef.template) {
  18532. // template is really only used for angular 1 - as people using ng1 are used to providing templates with
  18533. // bindings in it. in ng2, people will hopefully want to provide components, not templates.
  18534. this.eParentOfValue.innerHTML = colDef.template;
  18535. }
  18536. else if (colDef.templateUrl) {
  18537. // likewise for templateUrl - it's for ng1 really - when we move away from ng1, we can take these out.
  18538. // niall was pro angular 1 when writing template and templateUrl, if writing from scratch now, would
  18539. // not do these, but would follow a pattern that was friendly towards components, not templates.
  18540. var template = this.beans.templateService.getTemplate(colDef.templateUrl, this.refreshCell.bind(this, true));
  18541. if (template) {
  18542. this.eParentOfValue.innerHTML = template;
  18543. }
  18544. }
  18545. else {
  18546. // we can switch from using a cell renderer back to the default if a user
  18547. // is using cellRendererSelect
  18548. this.chooseCellRenderer();
  18549. if (this.usingCellRenderer) {
  18550. this.createCellRendererInstance();
  18551. }
  18552. else {
  18553. var valueToUse = this.getValueToUse();
  18554. if (valueToUse != null) {
  18555. this.eParentOfValue.innerHTML = _.escape(valueToUse);
  18556. }
  18557. }
  18558. }
  18559. };
  18560. CellComp.prototype.attemptCellRendererRefresh = function () {
  18561. if (_.missing(this.cellRenderer) || !this.cellRenderer || _.missing(this.cellRenderer.refresh)) {
  18562. return false;
  18563. }
  18564. // if the cell renderer has a refresh method, we call this instead of doing a refresh
  18565. var params = this.createCellRendererParams();
  18566. // take any custom params off of the user
  18567. var finalParams = this.beans.userComponentFactory.createFinalParams(this.getComponentHolder(), this.cellRendererType, params);
  18568. var result = this.cellRenderer.refresh(finalParams);
  18569. // NOTE on undefined: previous version of the cellRenderer.refresh() interface
  18570. // returned nothing, if the method existed, we assumed it refreshed. so for
  18571. // backwards compatibility, we assume if method exists and returns nothing,
  18572. // that it was successful.
  18573. return result === true || result === undefined;
  18574. };
  18575. CellComp.prototype.refreshToolTip = function () {
  18576. var newTooltip = this.getToolTip();
  18577. if (this.tooltip === newTooltip) {
  18578. return;
  18579. }
  18580. var hasNewTooltip = _.exists(newTooltip);
  18581. if (hasNewTooltip && this.tooltip === newTooltip.toString()) {
  18582. return;
  18583. }
  18584. var hadTooltip = _.exists(this.tooltip);
  18585. this.tooltip = newTooltip;
  18586. if (this.beans.gridOptionsWrapper.isEnableBrowserTooltips()) {
  18587. if (hasNewTooltip) {
  18588. this.eParentOfValue.setAttribute('title', this.tooltip);
  18589. }
  18590. else {
  18591. this.eParentOfValue.removeAttribute('title');
  18592. }
  18593. }
  18594. };
  18595. CellComp.prototype.valuesAreEqual = function (val1, val2) {
  18596. // if the user provided an equals method, use that, otherwise do simple comparison
  18597. var colDef = this.getComponentHolder();
  18598. var equalsMethod = colDef ? colDef.equals : null;
  18599. return equalsMethod ? equalsMethod(val1, val2) : val1 === val2;
  18600. };
  18601. CellComp.prototype.getToolTip = function () {
  18602. var colDef = this.getComponentHolder();
  18603. var data = this.rowNode.data;
  18604. if (colDef.tooltipField && _.exists(data)) {
  18605. return _.getValueUsingField(data, colDef.tooltipField, this.column.isTooltipFieldContainsDots());
  18606. }
  18607. var valueGetter = colDef.tooltipValueGetter || colDef.tooltip;
  18608. if (valueGetter) {
  18609. return valueGetter({
  18610. api: this.beans.gridOptionsWrapper.getApi(),
  18611. columnApi: this.beans.gridOptionsWrapper.getColumnApi(),
  18612. colDef: colDef,
  18613. column: this.getColumn(),
  18614. context: this.beans.gridOptionsWrapper.getContext(),
  18615. value: this.value,
  18616. valueFormatted: this.valueFormatted,
  18617. rowIndex: this.cellPosition.rowIndex,
  18618. node: this.rowNode,
  18619. data: this.rowNode.data
  18620. });
  18621. }
  18622. return null;
  18623. };
  18624. CellComp.prototype.getTooltipText = function (escape) {
  18625. if (escape === void 0) { escape = true; }
  18626. return escape ? _.escape(this.tooltip) : this.tooltip;
  18627. };
  18628. CellComp.prototype.processCellClassRules = function (onApplicableClass, onNotApplicableClass) {
  18629. var colDef = this.getComponentHolder();
  18630. this.beans.stylingService.processClassRules(colDef.cellClassRules, {
  18631. value: this.value,
  18632. data: this.rowNode.data,
  18633. node: this.rowNode,
  18634. colDef: colDef,
  18635. rowIndex: this.cellPosition.rowIndex,
  18636. api: this.beans.gridOptionsWrapper.getApi(),
  18637. columnApi: this.beans.gridOptionsWrapper.getColumnApi(),
  18638. $scope: this.scope,
  18639. context: this.beans.gridOptionsWrapper.getContext()
  18640. }, onApplicableClass, onNotApplicableClass);
  18641. };
  18642. CellComp.prototype.postProcessCellClassRules = function () {
  18643. var _this = this;
  18644. this.processCellClassRules(function (className) { return _.addCssClass(_this.getGui(), className); }, function (className) { return _.removeCssClass(_this.getGui(), className); });
  18645. };
  18646. CellComp.prototype.preProcessCellClassRules = function () {
  18647. var res = [];
  18648. this.processCellClassRules(function (className) { return res.push(className); }, function (_) {
  18649. // not catered for, if creating, no need
  18650. // to remove class as it was never there
  18651. });
  18652. return res;
  18653. };
  18654. // a wrapper is used when we are putting a selection checkbox in the cell with the value
  18655. CellComp.prototype.setUsingWrapper = function () {
  18656. var colDef = this.getComponentHolder();
  18657. // never allow selection or dragging on pinned rows
  18658. if (this.rowNode.rowPinned) {
  18659. this.usingWrapper = false;
  18660. this.includeSelectionComponent = false;
  18661. this.includeRowDraggingComponent = false;
  18662. this.includeDndSourceComponent = false;
  18663. return;
  18664. }
  18665. var cbSelectionIsFunc = typeof colDef.checkboxSelection === 'function';
  18666. var rowDraggableIsFunc = typeof colDef.rowDrag === 'function';
  18667. var dndSourceIsFunc = typeof colDef.dndSource === 'function';
  18668. this.includeSelectionComponent = cbSelectionIsFunc || colDef.checkboxSelection === true;
  18669. this.includeRowDraggingComponent = rowDraggableIsFunc || colDef.rowDrag === true;
  18670. this.includeDndSourceComponent = dndSourceIsFunc || colDef.dndSource === true;
  18671. var enableTextSelection = this.beans.gridOptionsWrapper.isEnableCellTextSelection();
  18672. this.usingWrapper = enableTextSelection || this.includeRowDraggingComponent || this.includeSelectionComponent || this.includeDndSourceComponent;
  18673. };
  18674. CellComp.prototype.chooseCellRenderer = function () {
  18675. // template gets preference, then cellRenderer, then do it ourselves
  18676. var colDef = this.getComponentHolder();
  18677. // templates are for ng1, ideally we wouldn't have these, they are ng1 support
  18678. // inside the core which is bad
  18679. if (colDef.template || colDef.templateUrl) {
  18680. this.usingCellRenderer = false;
  18681. return;
  18682. }
  18683. var params = this.createCellRendererParams();
  18684. var cellRenderer = this.beans.userComponentFactory.lookupComponentClassDef(colDef, 'cellRenderer', params);
  18685. var pinnedRowCellRenderer = this.beans.userComponentFactory.lookupComponentClassDef(colDef, 'pinnedRowCellRenderer', params);
  18686. if (pinnedRowCellRenderer && this.rowNode.rowPinned) {
  18687. this.cellRendererType = CellComp.CELL_RENDERER_TYPE_PINNED;
  18688. this.usingCellRenderer = true;
  18689. }
  18690. else if (cellRenderer) {
  18691. this.cellRendererType = CellComp.CELL_RENDERER_TYPE_NORMAL;
  18692. this.usingCellRenderer = true;
  18693. }
  18694. else {
  18695. this.usingCellRenderer = false;
  18696. }
  18697. };
  18698. CellComp.prototype.createCellRendererInstance = function (useTaskService) {
  18699. var _this = this;
  18700. if (useTaskService === void 0) { useTaskService = false; }
  18701. if (!this.usingCellRenderer) {
  18702. return;
  18703. }
  18704. // never use task service if angularCompileRows=true, as that assume the cell renderers
  18705. // are finished when the row is created. also we never use it if animation frame service
  18706. // is turned off.
  18707. // and lastly we never use it if doing auto-height, as the auto-height service checks the
  18708. // row height directly after the cell is created, it doesn't wait around for the tasks to complete
  18709. var angularCompileRows = this.beans.gridOptionsWrapper.isAngularCompileRows();
  18710. var suppressAnimationFrame = this.beans.gridOptionsWrapper.isSuppressAnimationFrame();
  18711. if (angularCompileRows || suppressAnimationFrame || this.autoHeightCell) {
  18712. useTaskService = false;
  18713. }
  18714. var params = this.createCellRendererParams();
  18715. this.cellRendererVersion++;
  18716. var callback = this.afterCellRendererCreated.bind(this, this.cellRendererVersion);
  18717. var cellRendererTypeNormal = this.cellRendererType === CellComp.CELL_RENDERER_TYPE_NORMAL;
  18718. this.createCellRendererFunc = function () {
  18719. _this.createCellRendererFunc = null;
  18720. // this can return null in the event that the user has switched from a renderer component to nothing, for example
  18721. // when using a cellRendererSelect to return a component or null depending on row data etc
  18722. var componentPromise = _this.beans.userComponentFactory.newCellRenderer(_this.getComponentHolder(), params, !cellRendererTypeNormal);
  18723. if (componentPromise) {
  18724. componentPromise.then(callback);
  18725. }
  18726. };
  18727. if (useTaskService) {
  18728. this.beans.taskQueue.createTask(this.createCellRendererFunc, this.rowNode.rowIndex, 'createTasksP2');
  18729. }
  18730. else {
  18731. this.createCellRendererFunc();
  18732. }
  18733. };
  18734. CellComp.prototype.afterCellRendererCreated = function (cellRendererVersion, cellRenderer) {
  18735. var cellRendererNotRequired = !this.isAlive() || (cellRendererVersion !== this.cellRendererVersion);
  18736. if (cellRendererNotRequired) {
  18737. this.beans.context.destroyBean(cellRenderer);
  18738. return;
  18739. }
  18740. this.cellRenderer = cellRenderer;
  18741. this.cellRendererGui = this.cellRenderer.getGui();
  18742. if (_.missing(this.cellRendererGui)) {
  18743. return;
  18744. }
  18745. // if async components, then it's possible the user started editing since this call was made
  18746. if (!this.editingCell) {
  18747. this.eParentOfValue.appendChild(this.cellRendererGui);
  18748. }
  18749. };
  18750. CellComp.prototype.createCellRendererParams = function () {
  18751. var _this = this;
  18752. return {
  18753. value: this.value,
  18754. valueFormatted: this.valueFormatted,
  18755. getValue: this.getValue.bind(this),
  18756. setValue: function (value) { return _this.beans.valueService.setValue(_this.rowNode, _this.column, value); },
  18757. formatValue: this.formatValue.bind(this),
  18758. data: this.rowNode.data,
  18759. node: this.rowNode,
  18760. colDef: this.getComponentHolder(),
  18761. column: this.column,
  18762. $scope: this.scope,
  18763. rowIndex: this.cellPosition.rowIndex,
  18764. api: this.beans.gridOptionsWrapper.getApi(),
  18765. columnApi: this.beans.gridOptionsWrapper.getColumnApi(),
  18766. context: this.beans.gridOptionsWrapper.getContext(),
  18767. refreshCell: this.refreshCell.bind(this),
  18768. eGridCell: this.getGui(),
  18769. eParentOfValue: this.eParentOfValue,
  18770. // these bits are not documented anywhere, so we could drop them?
  18771. // it was in the olden days to allow user to register for when rendered
  18772. // row was removed (the row comp was removed), however now that the user
  18773. // can provide components for cells, the destroy method gets call when this
  18774. // happens so no longer need to fire event.
  18775. addRowCompListener: this.rowComp ? this.rowComp.addEventListener.bind(this.rowComp) : null,
  18776. addRenderedRowListener: function (eventType, listener) {
  18777. console.warn('ag-Grid: since ag-Grid .v11, params.addRenderedRowListener() is now params.addRowCompListener()');
  18778. if (_this.rowComp) {
  18779. _this.rowComp.addEventListener(eventType, listener);
  18780. }
  18781. }
  18782. };
  18783. };
  18784. CellComp.prototype.formatValue = function (value) {
  18785. var valueFormatted = this.beans.valueFormatterService.formatValue(this.column, this.rowNode, this.scope, value);
  18786. return valueFormatted != null ? valueFormatted : value;
  18787. };
  18788. CellComp.prototype.getValueToUse = function () {
  18789. return this.valueFormatted != null ? this.valueFormatted : this.value;
  18790. };
  18791. CellComp.prototype.getValueAndFormat = function () {
  18792. this.value = this.getValue();
  18793. this.valueFormatted = this.beans.valueFormatterService.formatValue(this.column, this.rowNode, this.scope, this.value);
  18794. };
  18795. CellComp.prototype.getValue = function () {
  18796. // if we don't check this, then the grid will render leaf groups as open even if we are not
  18797. // allowing the user to open leaf groups. confused? remember for pivot mode we don't allow
  18798. // opening leaf groups, so we have to force leafGroups to be closed in case the user expanded
  18799. // them via the API, or user user expanded them in the UI before turning on pivot mode
  18800. var lockedClosedGroup = this.rowNode.leafGroup && this.beans.columnController.isPivotMode();
  18801. var isOpenGroup = this.rowNode.group && this.rowNode.expanded && !this.rowNode.footer && !lockedClosedGroup;
  18802. // are we showing group footers
  18803. var groupFootersEnabled = this.beans.gridOptionsWrapper.isGroupIncludeFooter();
  18804. // if doing footers, we normally don't show agg data at group level when group is open
  18805. var groupAlwaysShowAggData = this.beans.gridOptionsWrapper.isGroupSuppressBlankHeader();
  18806. // if doing grouping and footers, we don't want to include the agg value
  18807. // in the header when the group is open
  18808. var ignoreAggData = (isOpenGroup && groupFootersEnabled) && !groupAlwaysShowAggData;
  18809. return this.beans.valueService.getValue(this.column, this.rowNode, false, ignoreAggData);
  18810. };
  18811. CellComp.prototype.onMouseEvent = function (eventName, mouseEvent) {
  18812. if (_.isStopPropagationForAgGrid(mouseEvent)) {
  18813. return;
  18814. }
  18815. switch (eventName) {
  18816. case 'click':
  18817. this.onCellClicked(mouseEvent);
  18818. break;
  18819. case 'mousedown':
  18820. this.onMouseDown(mouseEvent);
  18821. break;
  18822. case 'dblclick':
  18823. this.onCellDoubleClicked(mouseEvent);
  18824. break;
  18825. case 'mouseout':
  18826. this.onMouseOut(mouseEvent);
  18827. break;
  18828. case 'mouseover':
  18829. this.onMouseOver(mouseEvent);
  18830. break;
  18831. }
  18832. };
  18833. CellComp.prototype.dispatchCellContextMenuEvent = function (event) {
  18834. var colDef = this.getComponentHolder();
  18835. var cellContextMenuEvent = this.createEvent(event, Events.EVENT_CELL_CONTEXT_MENU);
  18836. this.beans.eventService.dispatchEvent(cellContextMenuEvent);
  18837. if (colDef.onCellContextMenu) {
  18838. // to make the callback async, do in a timeout
  18839. window.setTimeout(function () { return colDef.onCellContextMenu(cellContextMenuEvent); }, 0);
  18840. }
  18841. };
  18842. CellComp.prototype.createEvent = function (domEvent, eventType) {
  18843. var event = {
  18844. node: this.rowNode,
  18845. data: this.rowNode.data,
  18846. value: this.value,
  18847. column: this.column,
  18848. colDef: this.getComponentHolder(),
  18849. context: this.beans.gridOptionsWrapper.getContext(),
  18850. api: this.beans.gridApi,
  18851. columnApi: this.beans.columnApi,
  18852. rowPinned: this.rowNode.rowPinned,
  18853. event: domEvent,
  18854. type: eventType,
  18855. rowIndex: this.rowNode.rowIndex
  18856. };
  18857. // because we are hacking in $scope for angular 1, we have to de-reference
  18858. if (this.scope) {
  18859. event.$scope = this.scope;
  18860. }
  18861. return event;
  18862. };
  18863. CellComp.prototype.onMouseOut = function (mouseEvent) {
  18864. var cellMouseOutEvent = this.createEvent(mouseEvent, Events.EVENT_CELL_MOUSE_OUT);
  18865. this.beans.eventService.dispatchEvent(cellMouseOutEvent);
  18866. this.beans.columnHoverService.clearMouseOver();
  18867. };
  18868. CellComp.prototype.onMouseOver = function (mouseEvent) {
  18869. var cellMouseOverEvent = this.createEvent(mouseEvent, Events.EVENT_CELL_MOUSE_OVER);
  18870. this.beans.eventService.dispatchEvent(cellMouseOverEvent);
  18871. this.beans.columnHoverService.setMouseOver([this.column]);
  18872. };
  18873. CellComp.prototype.onCellDoubleClicked = function (mouseEvent) {
  18874. var colDef = this.getComponentHolder();
  18875. // always dispatch event to eventService
  18876. var cellDoubleClickedEvent = this.createEvent(mouseEvent, Events.EVENT_CELL_DOUBLE_CLICKED);
  18877. this.beans.eventService.dispatchEvent(cellDoubleClickedEvent);
  18878. // check if colDef also wants to handle event
  18879. if (typeof colDef.onCellDoubleClicked === 'function') {
  18880. // to make the callback async, do in a timeout
  18881. window.setTimeout(function () { return colDef.onCellDoubleClicked(cellDoubleClickedEvent); }, 0);
  18882. }
  18883. var editOnDoubleClick = !this.beans.gridOptionsWrapper.isSingleClickEdit()
  18884. && !this.beans.gridOptionsWrapper.isSuppressClickEdit();
  18885. if (editOnDoubleClick) {
  18886. this.startRowOrCellEdit();
  18887. }
  18888. };
  18889. // called by rowRenderer when user navigates via tab key
  18890. CellComp.prototype.startRowOrCellEdit = function (keyPress, charPress) {
  18891. if (this.beans.gridOptionsWrapper.isFullRowEdit()) {
  18892. this.rowComp.startRowEditing(keyPress, charPress, this);
  18893. }
  18894. else {
  18895. this.startEditingIfEnabled(keyPress, charPress, true);
  18896. }
  18897. };
  18898. CellComp.prototype.isCellEditable = function () {
  18899. return this.column.isCellEditable(this.rowNode);
  18900. };
  18901. // either called internally if single cell editing, or called by rowRenderer if row editing
  18902. CellComp.prototype.startEditingIfEnabled = function (keyPress, charPress, cellStartedEdit) {
  18903. if (keyPress === void 0) { keyPress = null; }
  18904. if (charPress === void 0) { charPress = null; }
  18905. if (cellStartedEdit === void 0) { cellStartedEdit = false; }
  18906. // don't do it if not editable
  18907. if (!this.isCellEditable()) {
  18908. return;
  18909. }
  18910. // don't do it if already editing
  18911. if (this.editingCell) {
  18912. return;
  18913. }
  18914. this.editingCell = true;
  18915. this.cellEditorVersion++;
  18916. var callback = this.afterCellEditorCreated.bind(this, this.cellEditorVersion);
  18917. var params = this.createCellEditorParams(keyPress, charPress, cellStartedEdit);
  18918. this.createCellEditor(params).then(callback);
  18919. // if we don't do this, and editor component is async, then there will be a period
  18920. // when the component isn't present and keyboard navigation won't work - so example
  18921. // of user hitting tab quickly (more quickly than renderers getting created) won't work
  18922. var cellEditorAsync = _.missing(this.cellEditor);
  18923. if (cellEditorAsync && cellStartedEdit) {
  18924. this.focusCell(true);
  18925. }
  18926. };
  18927. CellComp.prototype.createCellEditor = function (params) {
  18928. var _this = this;
  18929. var cellEditorPromise = this.beans.userComponentFactory.newCellEditor(this.column.getColDef(), params);
  18930. return cellEditorPromise.then(function (cellEditor) {
  18931. var isPopup = cellEditor.isPopup && cellEditor.isPopup();
  18932. if (!isPopup) {
  18933. return cellEditor;
  18934. }
  18935. if (_this.beans.gridOptionsWrapper.isFullRowEdit()) {
  18936. console.warn('ag-Grid: popup cellEditor does not work with fullRowEdit - you cannot use them both ' +
  18937. '- either turn off fullRowEdit, or stop using popup editors.');
  18938. }
  18939. // if a popup, then we wrap in a popup editor and return the popup
  18940. var popupEditorWrapper = new PopupEditorWrapper(cellEditor);
  18941. _this.beans.context.createBean(popupEditorWrapper);
  18942. popupEditorWrapper.init(params);
  18943. return popupEditorWrapper;
  18944. });
  18945. };
  18946. CellComp.prototype.afterCellEditorCreated = function (cellEditorVersion, cellEditor) {
  18947. // if editingCell=false, means user cancelled the editor before component was ready.
  18948. // if versionMismatch, then user cancelled the edit, then started the edit again, and this
  18949. // is the first editor which is now stale.
  18950. var versionMismatch = cellEditorVersion !== this.cellEditorVersion;
  18951. var cellEditorNotNeeded = versionMismatch || !this.editingCell;
  18952. if (cellEditorNotNeeded) {
  18953. this.beans.context.destroyBean(cellEditor);
  18954. return;
  18955. }
  18956. var editingCancelledByUserComp = cellEditor.isCancelBeforeStart && cellEditor.isCancelBeforeStart();
  18957. if (editingCancelledByUserComp) {
  18958. this.beans.context.destroyBean(cellEditor);
  18959. this.editingCell = false;
  18960. return;
  18961. }
  18962. if (!cellEditor.getGui) {
  18963. console.warn("ag-Grid: cellEditor for column " + this.column.getId() + " is missing getGui() method");
  18964. // no getGui, for React guys, see if they attached a react component directly
  18965. if (cellEditor.render) {
  18966. console.warn("ag-Grid: we found 'render' on the component, are you trying to set a React renderer but added it as colDef.cellEditor instead of colDef.cellEditorFmk?");
  18967. }
  18968. this.beans.context.destroyBean(cellEditor);
  18969. this.editingCell = false;
  18970. return;
  18971. }
  18972. this.cellEditor = cellEditor;
  18973. this.cellEditorInPopup = cellEditor.isPopup !== undefined && cellEditor.isPopup();
  18974. this.setInlineEditingClass();
  18975. if (this.cellEditorInPopup) {
  18976. this.addPopupCellEditor();
  18977. }
  18978. else {
  18979. this.addInCellEditor();
  18980. }
  18981. if (cellEditor.afterGuiAttached) {
  18982. cellEditor.afterGuiAttached();
  18983. }
  18984. var event = this.createEvent(null, Events.EVENT_CELL_EDITING_STARTED);
  18985. this.beans.eventService.dispatchEvent(event);
  18986. };
  18987. CellComp.prototype.addInCellEditor = function () {
  18988. _.clearElement(this.getGui());
  18989. if (this.cellEditor) {
  18990. this.getGui().appendChild(this.cellEditor.getGui());
  18991. }
  18992. this.angular1Compile();
  18993. };
  18994. CellComp.prototype.addPopupCellEditor = function () {
  18995. var _this = this;
  18996. var ePopupGui = this.cellEditor ? this.cellEditor.getGui() : null;
  18997. var useModelPopup = this.beans.gridOptionsWrapper.isStopEditingWhenGridLosesFocus();
  18998. this.hideEditorPopup = this.beans.popupService.addPopup(useModelPopup, ePopupGui, true,
  18999. // callback for when popup disappears
  19000. function () {
  19001. _this.onPopupEditorClosed();
  19002. });
  19003. var params = {
  19004. column: this.column,
  19005. rowNode: this.rowNode,
  19006. type: 'popupCellEditor',
  19007. eventSource: this.getGui(),
  19008. ePopup: ePopupGui,
  19009. keepWithinBounds: true
  19010. };
  19011. var position = this.cellEditor && this.cellEditor.getPopupPosition ? this.cellEditor.getPopupPosition() : 'over';
  19012. if (position === 'under') {
  19013. this.beans.popupService.positionPopupUnderComponent(params);
  19014. }
  19015. else {
  19016. this.beans.popupService.positionPopupOverComponent(params);
  19017. }
  19018. this.angular1Compile();
  19019. };
  19020. CellComp.prototype.onPopupEditorClosed = function () {
  19021. // we only call stopEditing if we are editing, as
  19022. // it's possible the popup called 'stop editing'
  19023. // before this, eg if 'enter key' was pressed on
  19024. // the editor.
  19025. if (this.editingCell) {
  19026. // note: this only happens when use clicks outside of the grid. if use clicks on another
  19027. // cell, then the editing will have already stopped on this cell
  19028. this.stopRowOrCellEdit();
  19029. // we only focus cell again if this cell is still focused. it is possible
  19030. // it is not focused if the user cancelled the edit by clicking on another
  19031. // cell outside of this one
  19032. if (this.beans.focusController.isCellFocused(this.cellPosition)) {
  19033. this.focusCell(true);
  19034. }
  19035. }
  19036. };
  19037. // if we are editing inline, then we don't have the padding in the cell (set in the themes)
  19038. // to allow the text editor full access to the entire cell
  19039. CellComp.prototype.setInlineEditingClass = function () {
  19040. if (!this.isAlive()) {
  19041. return;
  19042. }
  19043. // ag-cell-inline-editing - appears when user is inline editing
  19044. // ag-cell-not-inline-editing - appears when user is no inline editing
  19045. // ag-cell-popup-editing - appears when user is editing cell in popup (appears on the cell, not on the popup)
  19046. // note: one of {ag-cell-inline-editing, ag-cell-not-inline-editing} is always present, they toggle.
  19047. // however {ag-cell-popup-editing} shows when popup, so you have both {ag-cell-popup-editing}
  19048. // and {ag-cell-not-inline-editing} showing at the same time.
  19049. var editingInline = this.editingCell && !this.cellEditorInPopup;
  19050. var popupEditorShowing = this.editingCell && this.cellEditorInPopup;
  19051. _.addOrRemoveCssClass(this.getGui(), "ag-cell-inline-editing", editingInline);
  19052. _.addOrRemoveCssClass(this.getGui(), "ag-cell-not-inline-editing", !editingInline);
  19053. _.addOrRemoveCssClass(this.getGui(), "ag-cell-popup-editing", popupEditorShowing);
  19054. _.addOrRemoveCssClass(this.getGui().parentNode, "ag-row-inline-editing", editingInline);
  19055. _.addOrRemoveCssClass(this.getGui().parentNode, "ag-row-not-inline-editing", !editingInline);
  19056. };
  19057. CellComp.prototype.createCellEditorParams = function (keyPress, charPress, cellStartedEdit) {
  19058. return {
  19059. value: this.getValue(),
  19060. keyPress: keyPress,
  19061. charPress: charPress,
  19062. column: this.column,
  19063. colDef: this.column.getColDef(),
  19064. rowIndex: this.cellPosition.rowIndex,
  19065. node: this.rowNode,
  19066. data: this.rowNode.data,
  19067. api: this.beans.gridOptionsWrapper.getApi(),
  19068. cellStartedEdit: cellStartedEdit,
  19069. columnApi: this.beans.gridOptionsWrapper.getColumnApi(),
  19070. context: this.beans.gridOptionsWrapper.getContext(),
  19071. $scope: this.scope,
  19072. onKeyDown: this.onKeyDown.bind(this),
  19073. stopEditing: this.stopEditingAndFocus.bind(this),
  19074. eGridCell: this.getGui(),
  19075. parseValue: this.parseValue.bind(this),
  19076. formatValue: this.formatValue.bind(this)
  19077. };
  19078. };
  19079. // cell editors call this, when they want to stop for reasons other
  19080. // than what we pick up on. eg selecting from a dropdown ends editing.
  19081. CellComp.prototype.stopEditingAndFocus = function (suppressNavigateAfterEdit) {
  19082. if (suppressNavigateAfterEdit === void 0) { suppressNavigateAfterEdit = false; }
  19083. this.stopRowOrCellEdit();
  19084. this.focusCell(true);
  19085. if (!suppressNavigateAfterEdit) {
  19086. this.navigateAfterEdit();
  19087. }
  19088. };
  19089. CellComp.prototype.parseValue = function (newValue) {
  19090. var colDef = this.getComponentHolder();
  19091. var params = {
  19092. node: this.rowNode,
  19093. data: this.rowNode.data,
  19094. oldValue: this.value,
  19095. newValue: newValue,
  19096. colDef: colDef,
  19097. column: this.column,
  19098. api: this.beans.gridOptionsWrapper.getApi(),
  19099. columnApi: this.beans.gridOptionsWrapper.getColumnApi(),
  19100. context: this.beans.gridOptionsWrapper.getContext()
  19101. };
  19102. var valueParser = colDef.valueParser;
  19103. return _.exists(valueParser) ? this.beans.expressionService.evaluate(valueParser, params) : newValue;
  19104. };
  19105. CellComp.prototype.focusCell = function (forceBrowserFocus) {
  19106. if (forceBrowserFocus === void 0) { forceBrowserFocus = false; }
  19107. this.beans.focusController.setFocusedCell(this.cellPosition.rowIndex, this.column, this.rowNode.rowPinned, forceBrowserFocus);
  19108. };
  19109. CellComp.prototype.setFocusInOnEditor = function () {
  19110. if (this.editingCell) {
  19111. if (this.cellEditor && this.cellEditor.focusIn) {
  19112. // if the editor is present, then we just focus it
  19113. this.cellEditor.focusIn();
  19114. }
  19115. else {
  19116. // if the editor is not present, it means async cell editor (eg React fibre)
  19117. // and we are trying to set focus before the cell editor is present, so we
  19118. // focus the cell instead
  19119. this.focusCell(true);
  19120. }
  19121. }
  19122. };
  19123. CellComp.prototype.isEditing = function () {
  19124. return this.editingCell;
  19125. };
  19126. CellComp.prototype.onKeyDown = function (event) {
  19127. var key = event.which || event.keyCode;
  19128. switch (key) {
  19129. case Constants.KEY_ENTER:
  19130. this.onEnterKeyDown(event);
  19131. break;
  19132. case Constants.KEY_F2:
  19133. this.onF2KeyDown();
  19134. break;
  19135. case Constants.KEY_ESCAPE:
  19136. this.onEscapeKeyDown();
  19137. break;
  19138. case Constants.KEY_TAB:
  19139. this.onTabKeyDown(event);
  19140. break;
  19141. case Constants.KEY_BACKSPACE:
  19142. case Constants.KEY_DELETE:
  19143. this.onBackspaceOrDeleteKeyPressed(key);
  19144. break;
  19145. case Constants.KEY_DOWN:
  19146. case Constants.KEY_UP:
  19147. case Constants.KEY_RIGHT:
  19148. case Constants.KEY_LEFT:
  19149. this.onNavigationKeyPressed(event, key);
  19150. break;
  19151. }
  19152. };
  19153. CellComp.prototype.setFocusOutOnEditor = function () {
  19154. if (this.editingCell && this.cellEditor && this.cellEditor.focusOut) {
  19155. this.cellEditor.focusOut();
  19156. }
  19157. };
  19158. CellComp.prototype.onNavigationKeyPressed = function (event, key) {
  19159. if (this.editingCell) {
  19160. return;
  19161. }
  19162. if (event.shiftKey && this.rangeSelectionEnabled) {
  19163. this.onShiftRangeSelect(key);
  19164. }
  19165. else {
  19166. this.beans.rowRenderer.navigateToNextCell(event, key, this.cellPosition, true);
  19167. }
  19168. // if we don't prevent default, the grid will scroll with the navigation keys
  19169. event.preventDefault();
  19170. };
  19171. CellComp.prototype.onShiftRangeSelect = function (key) {
  19172. if (!this.beans.rangeController) {
  19173. return;
  19174. }
  19175. var endCell = this.beans.rangeController.extendLatestRangeInDirection(key);
  19176. if (endCell) {
  19177. this.beans.rowRenderer.ensureCellVisible(endCell);
  19178. }
  19179. };
  19180. CellComp.prototype.onTabKeyDown = function (event) {
  19181. this.beans.rowRenderer.onTabKeyDown(this, event);
  19182. };
  19183. CellComp.prototype.onBackspaceOrDeleteKeyPressed = function (key) {
  19184. if (!this.editingCell) {
  19185. this.startRowOrCellEdit(key);
  19186. }
  19187. };
  19188. CellComp.prototype.onEnterKeyDown = function (e) {
  19189. if (this.editingCell || this.rowComp.isEditing()) {
  19190. this.stopEditingAndFocus();
  19191. }
  19192. else {
  19193. if (this.beans.gridOptionsWrapper.isEnterMovesDown()) {
  19194. this.beans.rowRenderer.navigateToNextCell(null, Constants.KEY_DOWN, this.cellPosition, false);
  19195. }
  19196. else {
  19197. e.preventDefault();
  19198. this.startRowOrCellEdit(Constants.KEY_ENTER);
  19199. }
  19200. }
  19201. };
  19202. CellComp.prototype.navigateAfterEdit = function () {
  19203. var fullRowEdit = this.beans.gridOptionsWrapper.isFullRowEdit();
  19204. if (fullRowEdit) {
  19205. return;
  19206. }
  19207. var enterMovesDownAfterEdit = this.beans.gridOptionsWrapper.isEnterMovesDownAfterEdit();
  19208. if (enterMovesDownAfterEdit) {
  19209. this.beans.rowRenderer.navigateToNextCell(null, Constants.KEY_DOWN, this.cellPosition, false);
  19210. }
  19211. };
  19212. CellComp.prototype.onF2KeyDown = function () {
  19213. if (!this.editingCell) {
  19214. this.startRowOrCellEdit(Constants.KEY_F2);
  19215. }
  19216. };
  19217. CellComp.prototype.onEscapeKeyDown = function () {
  19218. if (this.editingCell) {
  19219. this.stopRowOrCellEdit(true);
  19220. this.focusCell(true);
  19221. }
  19222. };
  19223. CellComp.prototype.onKeyPress = function (event) {
  19224. // check this, in case focus is on a (for example) a text field inside the cell,
  19225. // in which cse we should not be listening for these key pressed
  19226. var eventTarget = _.getTarget(event);
  19227. var eventOnChildComponent = eventTarget !== this.getGui();
  19228. if (eventOnChildComponent || this.editingCell) {
  19229. return;
  19230. }
  19231. var pressedChar = String.fromCharCode(event.charCode);
  19232. if (pressedChar === ' ') {
  19233. this.onSpaceKeyPressed(event);
  19234. }
  19235. else if (_.isEventFromPrintableCharacter(event)) {
  19236. this.startRowOrCellEdit(null, pressedChar);
  19237. // if we don't prevent default, then the keypress also gets applied to the text field
  19238. // (at least when doing the default editor), but we need to allow the editor to decide
  19239. // what it wants to do. we only do this IF editing was started - otherwise it messes
  19240. // up when the use is not doing editing, but using rendering with text fields in cellRenderer
  19241. // (as it would block the the user from typing into text fields).
  19242. event.preventDefault();
  19243. }
  19244. };
  19245. CellComp.prototype.onSpaceKeyPressed = function (event) {
  19246. var gridOptionsWrapper = this.beans.gridOptionsWrapper;
  19247. if (!this.editingCell && gridOptionsWrapper.isRowSelection()) {
  19248. var newSelection = !this.rowNode.isSelected();
  19249. if (newSelection || gridOptionsWrapper.isRowDeselection()) {
  19250. this.rowNode.setSelected(newSelection);
  19251. }
  19252. }
  19253. // prevent default as space key, by default, moves browser scroll down
  19254. event.preventDefault();
  19255. };
  19256. CellComp.prototype.onMouseDown = function (mouseEvent) {
  19257. var ctrlKey = mouseEvent.ctrlKey, metaKey = mouseEvent.metaKey, shiftKey = mouseEvent.shiftKey;
  19258. var target = mouseEvent.target;
  19259. var _a = this.beans, eventService = _a.eventService, rangeController = _a.rangeController;
  19260. // do not change the range for right-clicks inside an existing range
  19261. if (this.isRightClickInExistingRange(mouseEvent)) {
  19262. return;
  19263. }
  19264. if (!shiftKey || (rangeController && !rangeController.getCellRanges().length)) {
  19265. // We only need to pass true to focusCell when the browser is IE/Edge and we are trying
  19266. // to focus the cell itself. This should never be true if the mousedown was triggered
  19267. // due to a click on a cell editor for example.
  19268. var forceBrowserFocus = (_.isBrowserIE() || _.isBrowserEdge()) && !this.editingCell;
  19269. this.focusCell(forceBrowserFocus);
  19270. }
  19271. else {
  19272. // if a range is being changed, we need to make sure the focused cell does not change.
  19273. mouseEvent.preventDefault();
  19274. }
  19275. // if we are clicking on a checkbox, we need to make sure the cell wrapping that checkbox
  19276. // is focused but we don't want to change the range selection, so return here.
  19277. if (this.containsWidget(target)) {
  19278. return;
  19279. }
  19280. if (rangeController) {
  19281. var thisCell = this.cellPosition;
  19282. if (shiftKey) {
  19283. rangeController.extendLatestRangeToCell(thisCell);
  19284. }
  19285. else {
  19286. var ctrlKeyPressed = ctrlKey || metaKey;
  19287. rangeController.setRangeToCell(thisCell, ctrlKeyPressed);
  19288. }
  19289. }
  19290. eventService.dispatchEvent(this.createEvent(mouseEvent, Events.EVENT_CELL_MOUSE_DOWN));
  19291. };
  19292. CellComp.prototype.isRightClickInExistingRange = function (mouseEvent) {
  19293. var rangeController = this.beans.rangeController;
  19294. if (rangeController) {
  19295. var cellInRange = rangeController.isCellInAnyRange(this.getCellPosition());
  19296. if (cellInRange && mouseEvent.button === 2) {
  19297. return true;
  19298. }
  19299. }
  19300. return false;
  19301. };
  19302. CellComp.prototype.containsWidget = function (target) {
  19303. return _.isElementChildOfClass(target, 'ag-selection-checkbox', 3);
  19304. };
  19305. // returns true if on iPad and this is second 'click' event in 200ms
  19306. CellComp.prototype.isDoubleClickOnIPad = function () {
  19307. if (!_.isIOSUserAgent() || _.isEventSupported('dblclick')) {
  19308. return false;
  19309. }
  19310. var nowMillis = new Date().getTime();
  19311. var res = nowMillis - this.lastIPadMouseClickEvent < 200;
  19312. this.lastIPadMouseClickEvent = nowMillis;
  19313. return res;
  19314. };
  19315. CellComp.prototype.onCellClicked = function (mouseEvent) {
  19316. // iPad doesn't have double click - so we need to mimic it to enable editing for iPad.
  19317. if (this.isDoubleClickOnIPad()) {
  19318. this.onCellDoubleClicked(mouseEvent);
  19319. mouseEvent.preventDefault(); // if we don't do this, then iPad zooms in
  19320. return;
  19321. }
  19322. var _a = this.beans, eventService = _a.eventService, gridOptionsWrapper = _a.gridOptionsWrapper;
  19323. var cellClickedEvent = this.createEvent(mouseEvent, Events.EVENT_CELL_CLICKED);
  19324. eventService.dispatchEvent(cellClickedEvent);
  19325. var colDef = this.getComponentHolder();
  19326. if (colDef.onCellClicked) {
  19327. // to make callback async, do in a timeout
  19328. window.setTimeout(function () { return colDef.onCellClicked(cellClickedEvent); }, 0);
  19329. }
  19330. var editOnSingleClick = (gridOptionsWrapper.isSingleClickEdit() || colDef.singleClickEdit)
  19331. && !gridOptionsWrapper.isSuppressClickEdit();
  19332. if (editOnSingleClick) {
  19333. this.startRowOrCellEdit();
  19334. }
  19335. };
  19336. CellComp.prototype.createGridCellVo = function () {
  19337. this.cellPosition = {
  19338. rowIndex: this.rowNode.rowIndex,
  19339. rowPinned: this.rowNode.rowPinned,
  19340. column: this.column
  19341. };
  19342. };
  19343. CellComp.prototype.getCellPosition = function () {
  19344. return this.cellPosition;
  19345. };
  19346. CellComp.prototype.getParentRow = function () {
  19347. return this.eParentRow;
  19348. };
  19349. CellComp.prototype.setParentRow = function (eParentRow) {
  19350. this.eParentRow = eParentRow;
  19351. };
  19352. CellComp.prototype.getColumn = function () {
  19353. return this.column;
  19354. };
  19355. CellComp.prototype.getComponentHolder = function () {
  19356. return this.column.getColDef();
  19357. };
  19358. CellComp.prototype.detach = function () {
  19359. this.eParentRow.removeChild(this.getGui());
  19360. };
  19361. // if the row is also getting destroyed, then we don't need to remove from dom,
  19362. // as the row will also get removed, so no need to take out the cells from the row
  19363. // if the row is going (removing is an expensive operation, so only need to remove
  19364. // the top part)
  19365. //
  19366. // note - this is NOT called by context, as we don't wire / unwire the CellComp for performance reasons.
  19367. CellComp.prototype.destroy = function () {
  19368. if (this.createCellRendererFunc) {
  19369. this.beans.taskQueue.cancelTask(this.createCellRendererFunc);
  19370. }
  19371. this.stopEditing();
  19372. this.cellRenderer = this.beans.context.destroyBean(this.cellRenderer);
  19373. this.beans.context.destroyBean(this.selectionHandle);
  19374. _super.prototype.destroy.call(this);
  19375. };
  19376. CellComp.prototype.onLeftChanged = function () {
  19377. var left = this.modifyLeftForPrintLayout(this.getCellLeft());
  19378. this.getGui().style.left = left + 'px';
  19379. this.refreshAriaIndex();
  19380. };
  19381. CellComp.prototype.modifyLeftForPrintLayout = function (leftPosition) {
  19382. if (!this.printLayout || this.column.getPinned() === Constants.PINNED_LEFT) {
  19383. return leftPosition;
  19384. }
  19385. if (this.column.getPinned() === Constants.PINNED_RIGHT) {
  19386. var leftWidth_1 = this.beans.columnController.getPinnedLeftContainerWidth();
  19387. var bodyWidth = this.beans.columnController.getBodyContainerWidth();
  19388. return leftWidth_1 + bodyWidth + leftPosition;
  19389. }
  19390. // is in body
  19391. var leftWidth = this.beans.columnController.getPinnedLeftContainerWidth();
  19392. return leftWidth + leftPosition;
  19393. };
  19394. CellComp.prototype.onWidthChanged = function () {
  19395. var width = this.getCellWidth();
  19396. this.getGui().style.width = width + 'px';
  19397. };
  19398. CellComp.prototype.getRangeBorders = function () {
  19399. var _this = this;
  19400. var isRtl = this.beans.gridOptionsWrapper.isEnableRtl();
  19401. var top = false;
  19402. var right = false;
  19403. var bottom = false;
  19404. var left = false;
  19405. var thisCol = this.cellPosition.column;
  19406. var _a = this.beans, rangeController = _a.rangeController, columnController = _a.columnController;
  19407. var leftCol;
  19408. var rightCol;
  19409. if (isRtl) {
  19410. leftCol = columnController.getDisplayedColAfter(thisCol);
  19411. rightCol = columnController.getDisplayedColBefore(thisCol);
  19412. }
  19413. else {
  19414. leftCol = columnController.getDisplayedColBefore(thisCol);
  19415. rightCol = columnController.getDisplayedColAfter(thisCol);
  19416. }
  19417. var ranges = rangeController.getCellRanges().filter(function (range) { return rangeController.isCellInSpecificRange(_this.cellPosition, range); });
  19418. // this means we are the first column in the grid
  19419. if (!leftCol) {
  19420. left = true;
  19421. }
  19422. // this means we are the last column in the grid
  19423. if (!rightCol) {
  19424. right = true;
  19425. }
  19426. for (var i = 0; i < ranges.length; i++) {
  19427. if (top && right && bottom && left) {
  19428. break;
  19429. }
  19430. var range = ranges[i];
  19431. var startRow = rangeController.getRangeStartRow(range);
  19432. var endRow = rangeController.getRangeEndRow(range);
  19433. if (!top && this.beans.rowPositionUtils.sameRow(startRow, this.cellPosition)) {
  19434. top = true;
  19435. }
  19436. if (!bottom && this.beans.rowPositionUtils.sameRow(endRow, this.cellPosition)) {
  19437. bottom = true;
  19438. }
  19439. if (!left && range.columns.indexOf(leftCol) < 0) {
  19440. left = true;
  19441. }
  19442. if (!right && range.columns.indexOf(rightCol) < 0) {
  19443. right = true;
  19444. }
  19445. }
  19446. return { top: top, right: right, bottom: bottom, left: left };
  19447. };
  19448. CellComp.prototype.getInitialRangeClasses = function () {
  19449. var classes = [];
  19450. if (!this.rangeSelectionEnabled || !this.rangeCount) {
  19451. return classes;
  19452. }
  19453. classes.push('ag-cell-range-selected');
  19454. if (this.hasChartRange) {
  19455. classes.push('ag-cell-range-chart');
  19456. }
  19457. var count = Math.min(this.rangeCount, 4);
  19458. classes.push("ag-cell-range-selected-" + count);
  19459. if (this.isSingleCell()) {
  19460. classes.push('ag-cell-range-single-cell');
  19461. }
  19462. if (this.rangeCount > 0) {
  19463. var borders = this.getRangeBorders();
  19464. if (borders.top) {
  19465. classes.push('ag-cell-range-top');
  19466. }
  19467. if (borders.right) {
  19468. classes.push('ag-cell-range-right');
  19469. }
  19470. if (borders.bottom) {
  19471. classes.push('ag-cell-range-bottom');
  19472. }
  19473. if (borders.left) {
  19474. classes.push('ag-cell-range-left');
  19475. }
  19476. }
  19477. if (!!this.selectionHandle) {
  19478. classes.push('ag-cell-range-handle');
  19479. }
  19480. return classes;
  19481. };
  19482. CellComp.prototype.onRowIndexChanged = function () {
  19483. // when index changes, this influences items that need the index, so we update the
  19484. // grid cell so they are working off the new index.
  19485. this.createGridCellVo();
  19486. // when the index of the row changes, ie means the cell may have lost or gained focus
  19487. this.onCellFocused();
  19488. // check range selection
  19489. this.onRangeSelectionChanged();
  19490. };
  19491. CellComp.prototype.onRangeSelectionChanged = function () {
  19492. var rangeController = this.beans.rangeController;
  19493. if (!rangeController) {
  19494. return;
  19495. }
  19496. var _a = this, cellPosition = _a.cellPosition, rangeCount = _a.rangeCount;
  19497. var newRangeCount = rangeController.getCellRangeCount(cellPosition);
  19498. var element = this.getGui();
  19499. if (rangeCount !== newRangeCount) {
  19500. _.addOrRemoveCssClass(element, 'ag-cell-range-selected', newRangeCount !== 0);
  19501. _.addOrRemoveCssClass(element, 'ag-cell-range-selected-1', newRangeCount === 1);
  19502. _.addOrRemoveCssClass(element, 'ag-cell-range-selected-2', newRangeCount === 2);
  19503. _.addOrRemoveCssClass(element, 'ag-cell-range-selected-3', newRangeCount === 3);
  19504. _.addOrRemoveCssClass(element, 'ag-cell-range-selected-4', newRangeCount >= 4);
  19505. this.rangeCount = newRangeCount;
  19506. }
  19507. var hasChartRange = this.getHasChartRange();
  19508. if (hasChartRange !== this.hasChartRange) {
  19509. this.hasChartRange = hasChartRange;
  19510. _.addOrRemoveCssClass(element, 'ag-cell-range-chart', this.hasChartRange);
  19511. }
  19512. this.updateRangeBorders();
  19513. _.addOrRemoveCssClass(element, 'ag-cell-range-single-cell', this.isSingleCell());
  19514. this.refreshHandle();
  19515. };
  19516. CellComp.prototype.getHasChartRange = function () {
  19517. var rangeController = this.beans.rangeController;
  19518. if (!this.rangeCount || !rangeController) {
  19519. return false;
  19520. }
  19521. var cellRanges = rangeController.getCellRanges();
  19522. return cellRanges.length > 0 && cellRanges.every(function (range) { return _.includes([exports.CellRangeType.DIMENSION, exports.CellRangeType.VALUE], range.type); });
  19523. };
  19524. CellComp.prototype.shouldHaveSelectionHandle = function () {
  19525. var _a = this.beans, gridOptionsWrapper = _a.gridOptionsWrapper, rangeController = _a.rangeController;
  19526. var cellRanges = rangeController.getCellRanges();
  19527. var rangesLen = cellRanges.length;
  19528. if (this.rangeCount < 1 || rangesLen < 1) {
  19529. return false;
  19530. }
  19531. var cellRange = _.last(cellRanges);
  19532. var cellPosition = this.getCellPosition();
  19533. var fillHandleIsAvailable = rangesLen === 1 &&
  19534. (gridOptionsWrapper.isEnableFillHandle() || gridOptionsWrapper.isEnableRangeHandle()) &&
  19535. !this.editingCell;
  19536. if (this.hasChartRange) {
  19537. var hasCategoryRange = cellRanges[0].type === exports.CellRangeType.DIMENSION;
  19538. var isCategoryCell = hasCategoryRange && rangeController.isCellInSpecificRange(cellPosition, cellRanges[0]);
  19539. _.addOrRemoveCssClass(this.getGui(), 'ag-cell-range-chart-category', isCategoryCell);
  19540. fillHandleIsAvailable = cellRange.type === exports.CellRangeType.VALUE;
  19541. }
  19542. return fillHandleIsAvailable &&
  19543. cellRange.endRow != null &&
  19544. rangeController.isContiguousRange(cellRange) &&
  19545. rangeController.isBottomRightCell(cellRange, cellPosition);
  19546. };
  19547. CellComp.prototype.addSelectionHandle = function () {
  19548. var _a = this.beans, gridOptionsWrapper = _a.gridOptionsWrapper, context = _a.context, rangeController = _a.rangeController;
  19549. var cellRangeType = _.last(rangeController.getCellRanges()).type;
  19550. var selectionHandleFill = gridOptionsWrapper.isEnableFillHandle() && _.missing(cellRangeType);
  19551. var type = selectionHandleFill ? exports.SelectionHandleType.FILL : exports.SelectionHandleType.RANGE;
  19552. if (this.selectionHandle && this.selectionHandle.getType() !== type) {
  19553. this.selectionHandle = this.beans.context.destroyBean(this.selectionHandle);
  19554. }
  19555. if (!this.selectionHandle) {
  19556. this.selectionHandle = this.beans.selectionHandleFactory.createSelectionHandle(type);
  19557. }
  19558. this.selectionHandle.refresh(this);
  19559. };
  19560. CellComp.prototype.updateRangeBordersIfRangeCount = function () {
  19561. // we only need to update range borders if we are in a range
  19562. if (this.rangeCount > 0) {
  19563. this.updateRangeBorders();
  19564. this.refreshHandle();
  19565. }
  19566. };
  19567. CellComp.prototype.refreshHandle = function () {
  19568. if (!this.beans.rangeController) {
  19569. return;
  19570. }
  19571. var shouldHaveSelectionHandle = this.shouldHaveSelectionHandle();
  19572. if (this.selectionHandle && !shouldHaveSelectionHandle) {
  19573. this.selectionHandle = this.beans.context.destroyBean(this.selectionHandle);
  19574. }
  19575. if (shouldHaveSelectionHandle) {
  19576. this.addSelectionHandle();
  19577. }
  19578. _.addOrRemoveCssClass(this.getGui(), 'ag-cell-range-handle', !!this.selectionHandle);
  19579. };
  19580. CellComp.prototype.updateRangeBorders = function () {
  19581. var rangeBorders = this.getRangeBorders();
  19582. var isSingleCell = this.isSingleCell();
  19583. var isTop = !isSingleCell && rangeBorders.top;
  19584. var isRight = !isSingleCell && rangeBorders.right;
  19585. var isBottom = !isSingleCell && rangeBorders.bottom;
  19586. var isLeft = !isSingleCell && rangeBorders.left;
  19587. var element = this.getGui();
  19588. _.addOrRemoveCssClass(element, 'ag-cell-range-top', isTop);
  19589. _.addOrRemoveCssClass(element, 'ag-cell-range-right', isRight);
  19590. _.addOrRemoveCssClass(element, 'ag-cell-range-bottom', isBottom);
  19591. _.addOrRemoveCssClass(element, 'ag-cell-range-left', isLeft);
  19592. };
  19593. CellComp.prototype.onFirstRightPinnedChanged = function () {
  19594. var firstRightPinned = this.column.isFirstRightPinned();
  19595. if (this.firstRightPinned !== firstRightPinned) {
  19596. this.firstRightPinned = firstRightPinned;
  19597. _.addOrRemoveCssClass(this.getGui(), 'ag-cell-first-right-pinned', firstRightPinned);
  19598. }
  19599. };
  19600. CellComp.prototype.onLastLeftPinnedChanged = function () {
  19601. var lastLeftPinned = this.column.isLastLeftPinned();
  19602. if (this.lastLeftPinned !== lastLeftPinned) {
  19603. this.lastLeftPinned = lastLeftPinned;
  19604. _.addOrRemoveCssClass(this.getGui(), 'ag-cell-last-left-pinned', lastLeftPinned);
  19605. }
  19606. };
  19607. CellComp.prototype.populateTemplate = function () {
  19608. if (this.usingWrapper) {
  19609. this.eParentOfValue = this.getRefElement('eCellValue');
  19610. this.eCellWrapper = this.getRefElement('eCellWrapper');
  19611. this.eCellValue = this.getRefElement('eCellValue');
  19612. if (this.includeRowDraggingComponent) {
  19613. this.addRowDragging();
  19614. }
  19615. if (this.includeDndSourceComponent) {
  19616. this.addDndSource();
  19617. }
  19618. if (this.includeSelectionComponent) {
  19619. this.addSelectionCheckbox();
  19620. }
  19621. }
  19622. else {
  19623. this.eParentOfValue = this.getGui();
  19624. }
  19625. };
  19626. CellComp.prototype.getFrameworkOverrides = function () {
  19627. return this.beans.frameworkOverrides;
  19628. };
  19629. CellComp.prototype.addRowDragging = function () {
  19630. var pagination = this.beans.gridOptionsWrapper.isPagination();
  19631. var rowDragManaged = this.beans.gridOptionsWrapper.isRowDragManaged();
  19632. var clientSideRowModelActive = this.beans.gridOptionsWrapper.isRowModelDefault();
  19633. if (rowDragManaged) {
  19634. // row dragging only available in default row model
  19635. if (!clientSideRowModelActive) {
  19636. _.doOnce(function () { return console.warn('ag-Grid: managed row dragging is only allowed in the Client Side Row Model'); }, 'CellComp.addRowDragging');
  19637. return;
  19638. }
  19639. if (pagination) {
  19640. _.doOnce(function () { return console.warn('ag-Grid: managed row dragging is not possible when doing pagination'); }, 'CellComp.addRowDragging');
  19641. return;
  19642. }
  19643. }
  19644. var rowDraggingComp = new RowDragComp(this.rowNode, this.column, this.getValueToUse(), this.beans);
  19645. this.createManagedBean(rowDraggingComp, this.beans.context);
  19646. // put the checkbox in before the value
  19647. this.eCellWrapper.insertBefore(rowDraggingComp.getGui(), this.eParentOfValue);
  19648. };
  19649. CellComp.prototype.addDndSource = function () {
  19650. var dndSourceComp = new DndSourceComp(this.rowNode, this.column, this.getValueToUse(), this.beans, this.getGui());
  19651. this.createManagedBean(dndSourceComp, this.beans.context);
  19652. // put the checkbox in before the value
  19653. this.eCellWrapper.insertBefore(dndSourceComp.getGui(), this.eParentOfValue);
  19654. };
  19655. CellComp.prototype.addSelectionCheckbox = function () {
  19656. var _this = this;
  19657. var cbSelectionComponent = new CheckboxSelectionComponent();
  19658. this.beans.context.createBean(cbSelectionComponent);
  19659. var visibleFunc = this.getComponentHolder().checkboxSelection;
  19660. visibleFunc = typeof visibleFunc === 'function' ? visibleFunc : null;
  19661. cbSelectionComponent.init({ rowNode: this.rowNode, column: this.column, visibleFunc: visibleFunc });
  19662. this.addDestroyFunc(function () { return _this.beans.context.destroyBean(cbSelectionComponent); });
  19663. // put the checkbox in before the value
  19664. this.eCellWrapper.insertBefore(cbSelectionComponent.getGui(), this.eParentOfValue);
  19665. };
  19666. CellComp.prototype.addDomData = function () {
  19667. var _this = this;
  19668. var element = this.getGui();
  19669. this.beans.gridOptionsWrapper.setDomData(element, CellComp.DOM_DATA_KEY_CELL_COMP, this);
  19670. this.addDestroyFunc(function () { return _this.beans.gridOptionsWrapper.setDomData(element, CellComp.DOM_DATA_KEY_CELL_COMP, null); });
  19671. };
  19672. CellComp.prototype.isSingleCell = function () {
  19673. var rangeController = this.beans.rangeController;
  19674. return this.rangeCount === 1 && rangeController && !rangeController.isMoreThanOneCell();
  19675. };
  19676. CellComp.prototype.onCellFocused = function (event) {
  19677. var cellFocused = this.beans.focusController.isCellFocused(this.cellPosition);
  19678. // see if we need to change the classes on this cell
  19679. if (cellFocused !== this.cellFocused) {
  19680. // if we are not doing cell selection, then the focus class does not change
  19681. var doingFocusCss = !this.beans.gridOptionsWrapper.isSuppressCellSelection();
  19682. if (doingFocusCss) {
  19683. _.addOrRemoveCssClass(this.getGui(), 'ag-cell-focus', cellFocused);
  19684. }
  19685. this.cellFocused = cellFocused;
  19686. }
  19687. // see if we need to force browser focus - this can happen if focus is programmatically set
  19688. if (cellFocused && event && event.forceBrowserFocus) {
  19689. var focusEl = this.getFocusableElement();
  19690. focusEl.focus();
  19691. // Fix for AG-3465 "IE11 - After editing cell's content, selection doesn't go one cell below on enter"
  19692. // IE can fail to focus the cell after the first call to focus(), and needs a second call
  19693. if (!document.activeElement || document.activeElement === document.body) {
  19694. focusEl.focus();
  19695. }
  19696. }
  19697. // if another cell was focused, and we are editing, then stop editing
  19698. var fullRowEdit = this.beans.gridOptionsWrapper.isFullRowEdit();
  19699. if (!cellFocused && !fullRowEdit && this.editingCell) {
  19700. this.stopRowOrCellEdit();
  19701. }
  19702. };
  19703. // pass in 'true' to cancel the editing.
  19704. CellComp.prototype.stopRowOrCellEdit = function (cancel) {
  19705. if (cancel === void 0) { cancel = false; }
  19706. if (this.beans.gridOptionsWrapper.isFullRowEdit()) {
  19707. this.rowComp.stopRowEditing(cancel);
  19708. }
  19709. else {
  19710. this.stopEditing(cancel);
  19711. }
  19712. };
  19713. CellComp.prototype.stopEditing = function (cancel) {
  19714. if (cancel === void 0) { cancel = false; }
  19715. if (!this.editingCell) {
  19716. return;
  19717. }
  19718. // if no cell editor, this means due to async, that the cell editor never got initialised,
  19719. // so we just carry on regardless as if the editing was never started.
  19720. if (!this.cellEditor) {
  19721. this.editingCell = false;
  19722. return;
  19723. }
  19724. var oldValue = this.getValue();
  19725. var newValueExists = false;
  19726. var newValue;
  19727. if (!cancel) {
  19728. // also have another option here to cancel after editing, so for example user could have a popup editor and
  19729. // it is closed by user clicking outside the editor. then the editor will close automatically (with false
  19730. // passed above) and we need to see if the editor wants to accept the new value.
  19731. var userWantsToCancel = this.cellEditor.isCancelAfterEnd && this.cellEditor.isCancelAfterEnd();
  19732. if (!userWantsToCancel) {
  19733. newValue = this.cellEditor.getValue();
  19734. newValueExists = true;
  19735. }
  19736. }
  19737. // it is important we set this after setValue() above, as otherwise the cell will flash
  19738. // when editing stops. the 'refresh' method checks editing, and doesn't refresh editing cells.
  19739. // thus it will skip the refresh on this cell until the end of this method where we call
  19740. // refresh directly and we suppress the flash.
  19741. this.editingCell = false;
  19742. // important to clear this out - as parts of the code will check for
  19743. // this to see if an async cellEditor has yet to be created
  19744. this.cellEditor = this.beans.context.destroyBean(this.cellEditor);
  19745. this.cellEditor = null;
  19746. if (this.cellEditorInPopup && this.hideEditorPopup) {
  19747. this.hideEditorPopup();
  19748. this.hideEditorPopup = null;
  19749. }
  19750. else {
  19751. _.clearElement(this.getGui());
  19752. // put the cell back the way it was before editing
  19753. if (this.usingWrapper) {
  19754. // if wrapper, then put the wrapper back
  19755. this.getGui().appendChild(this.eCellWrapper);
  19756. }
  19757. else if (this.cellRenderer) {
  19758. // if cellRenderer, then put the gui back in. if the renderer has
  19759. // a refresh, it will be called. however if it doesn't, then later
  19760. // the renderer will be destroyed and a new one will be created.
  19761. // we know it's a dom element (not a string) because we converted
  19762. // it after the gui was attached if it was a string.
  19763. var eCell = this.cellRendererGui;
  19764. // can be null if cell was previously null / contained empty string,
  19765. // this will result in new value not being rendered.
  19766. if (eCell) {
  19767. this.getGui().appendChild(eCell);
  19768. }
  19769. }
  19770. }
  19771. this.setInlineEditingClass();
  19772. this.refreshHandle();
  19773. if (newValueExists && newValue !== oldValue) {
  19774. // we suppressRefreshCell because the call to rowNode.setDataValue() results in change detection
  19775. // getting triggered, which results in all cells getting refreshed. we do not want this refresh
  19776. // to happen on this call as we want to call it explicitly below. otherwise refresh gets called twice.
  19777. // if we only did this refresh (and not the one below) then the cell would flash and not be forced.
  19778. this.suppressRefreshCell = true;
  19779. this.rowNode.setDataValue(this.column, newValue);
  19780. this.suppressRefreshCell = false;
  19781. }
  19782. // we suppress the flash, as it is not correct to flash the cell the user has finished editing,
  19783. // the user doesn't need to flash as they were the one who did the edit, the flash is pointless
  19784. // (as the flash is meant to draw the user to a change that they didn't manually do themselves).
  19785. this.refreshCell({ forceRefresh: true, suppressFlash: true });
  19786. var event = this.createEvent(null, Events.EVENT_CELL_EDITING_STOPPED);
  19787. this.beans.eventService.dispatchEvent(event);
  19788. };
  19789. CellComp.DOM_DATA_KEY_CELL_COMP = 'cellComp';
  19790. CellComp.CELL_RENDERER_TYPE_NORMAL = 'cellRenderer';
  19791. CellComp.CELL_RENDERER_TYPE_PINNED = 'pinnedRowCellRenderer';
  19792. return CellComp;
  19793. }(Component));
  19794. /**
  19795. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  19796. * @version v23.2.1
  19797. * @link http://www.ag-grid.com/
  19798. * @license MIT
  19799. */
  19800. var __extends$K = (undefined && undefined.__extends) || (function () {
  19801. var extendStatics = function (d, b) {
  19802. extendStatics = Object.setPrototypeOf ||
  19803. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  19804. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  19805. return extendStatics(d, b);
  19806. };
  19807. return function (d, b) {
  19808. extendStatics(d, b);
  19809. function __() { this.constructor = d; }
  19810. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  19811. };
  19812. })();
  19813. var __assign$2 = (undefined && undefined.__assign) || function () {
  19814. __assign$2 = Object.assign || function(t) {
  19815. for (var s, i = 1, n = arguments.length; i < n; i++) {
  19816. s = arguments[i];
  19817. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
  19818. t[p] = s[p];
  19819. }
  19820. return t;
  19821. };
  19822. return __assign$2.apply(this, arguments);
  19823. };
  19824. var RowComp = /** @class */ (function (_super) {
  19825. __extends$K(RowComp, _super);
  19826. function RowComp(parentScope, bodyContainerComp, pinnedLeftContainerComp, pinnedRightContainerComp, fullWidthContainerComp, rowNode, beans, animateIn, useAnimationFrameForCreate, printLayout, embedFullWidth) {
  19827. var _this = _super.call(this) || this;
  19828. _this.eAllRowContainers = [];
  19829. _this.active = true;
  19830. _this.rowContainerReadyCount = 0;
  19831. _this.refreshNeeded = false;
  19832. _this.columnRefreshPending = false;
  19833. _this.cellComps = {};
  19834. // for animations, there are bits we want done in the next VM turn, to all DOM to update first.
  19835. // instead of each row doing a setTimeout(func,0), we put the functions here and the rowRenderer
  19836. // executes them all in one timeout
  19837. _this.createSecondPassFuncs = [];
  19838. // these get called before the row is destroyed - they set up the DOM for the remove animation (ie they
  19839. // set the DOM up for the animation), then the delayedDestroyFunctions get called when the animation is
  19840. // complete (ie removes from the dom).
  19841. _this.removeFirstPassFuncs = [];
  19842. // for animations, these functions get called 400ms after the row is cleared, called by the rowRenderer
  19843. // so each row isn't setting up it's own timeout
  19844. _this.removeSecondPassFuncs = [];
  19845. _this.initialised = false;
  19846. _this.elementOrderChanged = false;
  19847. _this.lastMouseDownOnDragger = false;
  19848. _this.parentScope = parentScope;
  19849. _this.beans = beans;
  19850. _this.bodyContainerComp = bodyContainerComp;
  19851. _this.pinnedLeftContainerComp = pinnedLeftContainerComp;
  19852. _this.pinnedRightContainerComp = pinnedRightContainerComp;
  19853. _this.fullWidthContainerComp = fullWidthContainerComp;
  19854. _this.rowNode = rowNode;
  19855. _this.rowIsEven = _this.rowNode.rowIndex % 2 === 0;
  19856. _this.paginationPage = _this.beans.paginationProxy.getCurrentPage();
  19857. _this.useAnimationFrameForCreate = useAnimationFrameForCreate;
  19858. _this.printLayout = printLayout;
  19859. _this.embedFullWidth = embedFullWidth;
  19860. _this.setAnimateFlags(animateIn);
  19861. return _this;
  19862. }
  19863. RowComp.prototype.init = function () {
  19864. var _this = this;
  19865. this.rowFocused = this.beans.focusController.isRowFocused(this.rowNode.rowIndex, this.rowNode.rowPinned);
  19866. this.scope = this.createChildScopeOrNull(this.rowNode.data);
  19867. this.setupRowContainers();
  19868. this.addListeners();
  19869. if (this.slideRowIn) {
  19870. this.createSecondPassFuncs.push(function () {
  19871. _this.onTopChanged();
  19872. });
  19873. }
  19874. if (this.fadeRowIn) {
  19875. this.createSecondPassFuncs.push(function () {
  19876. _this.eAllRowContainers.forEach(function (eRow) { return _.removeCssClass(eRow, 'ag-opacity-zero'); });
  19877. });
  19878. }
  19879. };
  19880. RowComp.prototype.createTemplate = function (contents, extraCssClass) {
  19881. if (extraCssClass === void 0) { extraCssClass = null; }
  19882. var templateParts = [];
  19883. var rowHeight = this.rowNode.rowHeight;
  19884. var rowClasses = this.getInitialRowClasses(extraCssClass).join(' ');
  19885. var rowIdSanitised = _.escape(this.rowNode.id);
  19886. var userRowStyles = this.preProcessStylesFromGridOptions();
  19887. var businessKey = this.getRowBusinessKey();
  19888. var businessKeySanitised = _.escape(businessKey);
  19889. var rowTopStyle = this.getInitialRowTopStyle();
  19890. var rowIdx = this.rowNode.getRowIndexString();
  19891. var headerRowCount = this.beans.headerNavigationService.getHeaderRowCount();
  19892. templateParts.push("<div");
  19893. templateParts.push(" role=\"row\"");
  19894. templateParts.push(" row-index=\"" + rowIdx + "\" aria-rowindex=\"" + (headerRowCount + this.rowNode.rowIndex + 1) + "\"");
  19895. templateParts.push(rowIdSanitised ? " row-id=\"" + rowIdSanitised + "\"" : "");
  19896. templateParts.push(businessKey ? " row-business-key=\"" + businessKeySanitised + "\"" : "");
  19897. templateParts.push(" comp-id=\"" + this.getCompId() + "\"");
  19898. templateParts.push(" class=\"" + rowClasses + "\"");
  19899. templateParts.push(" style=\"height: " + rowHeight + "px; " + rowTopStyle + " " + userRowStyles + "\">");
  19900. // add in the template for the cells
  19901. templateParts.push(contents);
  19902. templateParts.push("</div>");
  19903. return templateParts.join('');
  19904. };
  19905. RowComp.prototype.getCellForCol = function (column) {
  19906. var cellComp = this.cellComps[column.getColId()];
  19907. return cellComp ? cellComp.getGui() : null;
  19908. };
  19909. RowComp.prototype.afterFlush = function () {
  19910. if (this.initialised) {
  19911. return;
  19912. }
  19913. this.initialised = true;
  19914. this.executeProcessRowPostCreateFunc();
  19915. };
  19916. RowComp.prototype.executeProcessRowPostCreateFunc = function () {
  19917. var func = this.beans.gridOptionsWrapper.getProcessRowPostCreateFunc();
  19918. if (!func) {
  19919. return;
  19920. }
  19921. var params = {
  19922. eRow: this.eBodyRow,
  19923. ePinnedLeftRow: this.ePinnedLeftRow,
  19924. ePinnedRightRow: this.ePinnedRightRow,
  19925. node: this.rowNode,
  19926. api: this.beans.gridOptionsWrapper.getApi(),
  19927. rowIndex: this.rowNode.rowIndex,
  19928. addRenderedRowListener: this.addEventListener.bind(this),
  19929. columnApi: this.beans.gridOptionsWrapper.getColumnApi(),
  19930. context: this.beans.gridOptionsWrapper.getContext()
  19931. };
  19932. func(params);
  19933. };
  19934. RowComp.prototype.getInitialRowTopStyle = function () {
  19935. // print layout uses normal flow layout for row positioning
  19936. if (this.printLayout) {
  19937. return '';
  19938. }
  19939. // if sliding in, we take the old row top. otherwise we just set the current row top.
  19940. var pixels = this.slideRowIn ? this.roundRowTopToBounds(this.rowNode.oldRowTop) : this.rowNode.rowTop;
  19941. var afterPaginationPixels = this.applyPaginationOffset(pixels);
  19942. var afterScalingPixels = this.beans.maxDivHeightScaler.getRealPixelPosition(afterPaginationPixels);
  19943. var isSuppressRowTransform = this.beans.gridOptionsWrapper.isSuppressRowTransform();
  19944. return isSuppressRowTransform ? "top: " + afterScalingPixels + "px; " : "transform: translateY(" + afterScalingPixels + "px);";
  19945. };
  19946. RowComp.prototype.getRowBusinessKey = function () {
  19947. var businessKeyForNodeFunc = this.beans.gridOptionsWrapper.getBusinessKeyForNodeFunc();
  19948. if (typeof businessKeyForNodeFunc !== 'function') {
  19949. return;
  19950. }
  19951. return businessKeyForNodeFunc(this.rowNode);
  19952. };
  19953. RowComp.prototype.areAllContainersReady = function () {
  19954. return this.rowContainerReadyCount === 3;
  19955. };
  19956. RowComp.prototype.lazyCreateCells = function (cols, eRow) {
  19957. if (!this.active) {
  19958. return;
  19959. }
  19960. var cellTemplatesAndComps = this.createCells(cols);
  19961. eRow.innerHTML = cellTemplatesAndComps.template;
  19962. this.callAfterRowAttachedOnCells(cellTemplatesAndComps.cellComps, eRow);
  19963. this.rowContainerReadyCount++;
  19964. if (this.areAllContainersReady() && this.refreshNeeded) {
  19965. this.refreshCells();
  19966. }
  19967. };
  19968. RowComp.prototype.createRowContainer = function (rowContainerComp, cols, callback) {
  19969. var _this = this;
  19970. var useAnimationsFrameForCreate = this.useAnimationFrameForCreate;
  19971. var cellTemplatesAndComps = useAnimationsFrameForCreate ? { cellComps: [], template: '' } : this.createCells(cols);
  19972. var rowTemplate = this.createTemplate(cellTemplatesAndComps.template);
  19973. // the RowRenderer is probably inserting many rows. rather than inserting each template one
  19974. // at a time, the grid inserts all rows together - so the callback here is called by the
  19975. // rowRenderer when all RowComps are created, then all the HTML is inserted in one go,
  19976. // and then all the callbacks are called. this is NOT done in an animation frame.
  19977. rowContainerComp.appendRowTemplate(rowTemplate, function () {
  19978. var eRow = rowContainerComp.getRowElement(_this.getCompId());
  19979. _this.afterRowAttached(rowContainerComp, eRow);
  19980. callback(eRow);
  19981. if (useAnimationsFrameForCreate) {
  19982. _this.beans.taskQueue.createTask(_this.lazyCreateCells.bind(_this, cols, eRow), _this.rowNode.rowIndex, 'createTasksP1');
  19983. }
  19984. else {
  19985. _this.callAfterRowAttachedOnCells(cellTemplatesAndComps.cellComps, eRow);
  19986. _this.rowContainerReadyCount = 3;
  19987. }
  19988. });
  19989. };
  19990. RowComp.prototype.createChildScopeOrNull = function (data) {
  19991. var isAngularCompileRows = this.beans.gridOptionsWrapper.isAngularCompileRows();
  19992. if (!isAngularCompileRows) {
  19993. return null;
  19994. }
  19995. var newChildScope = this.parentScope.$new();
  19996. newChildScope.data = __assign$2({}, data);
  19997. newChildScope.rowNode = this.rowNode;
  19998. newChildScope.context = this.beans.gridOptionsWrapper.getContext();
  19999. this.addDestroyFunc(function () {
  20000. newChildScope.$destroy();
  20001. newChildScope.data = null;
  20002. newChildScope.rowNode = null;
  20003. newChildScope.context = null;
  20004. });
  20005. return newChildScope;
  20006. };
  20007. RowComp.prototype.setupRowContainers = function () {
  20008. var isFullWidthCell = this.rowNode.isFullWidthCell();
  20009. var isDetailCell = this.beans.doingMasterDetail && this.rowNode.detail;
  20010. var pivotMode = this.beans.columnController.isPivotMode();
  20011. // we only use full width for groups, not footers. it wouldn't make sense to include footers if not looking
  20012. // for totals. if users complain about this, then we should introduce a new property 'footerUseEntireRow'
  20013. // so each can be set independently (as a customer complained about footers getting full width, hence
  20014. // introducing this logic)
  20015. var isGroupRow = this.rowNode.group && !this.rowNode.footer;
  20016. var isFullWidthGroup = isGroupRow && this.beans.gridOptionsWrapper.isGroupUseEntireRow(pivotMode);
  20017. if (this.rowNode.stub) {
  20018. this.createFullWidthRows(RowComp.LOADING_CELL_RENDERER, RowComp.LOADING_CELL_RENDERER_COMP_NAME);
  20019. }
  20020. else if (isDetailCell) {
  20021. this.createFullWidthRows(RowComp.DETAIL_CELL_RENDERER, RowComp.DETAIL_CELL_RENDERER_COMP_NAME);
  20022. }
  20023. else if (isFullWidthCell) {
  20024. this.createFullWidthRows(RowComp.FULL_WIDTH_CELL_RENDERER, null);
  20025. }
  20026. else if (isFullWidthGroup) {
  20027. this.createFullWidthRows(RowComp.GROUP_ROW_RENDERER, RowComp.GROUP_ROW_RENDERER_COMP_NAME);
  20028. }
  20029. else {
  20030. this.setupNormalRowContainers();
  20031. }
  20032. };
  20033. RowComp.prototype.setupNormalRowContainers = function () {
  20034. var _this = this;
  20035. var centerCols;
  20036. var leftCols = [];
  20037. var rightCols = [];
  20038. if (this.printLayout) {
  20039. centerCols = this.beans.columnController.getAllDisplayedColumns();
  20040. }
  20041. else {
  20042. centerCols = this.beans.columnController.getAllDisplayedCenterVirtualColumnsForRow(this.rowNode);
  20043. leftCols = this.beans.columnController.getDisplayedLeftColumnsForRow(this.rowNode);
  20044. rightCols = this.beans.columnController.getDisplayedRightColumnsForRow(this.rowNode);
  20045. }
  20046. this.createRowContainer(this.bodyContainerComp, centerCols, function (eRow) { return _this.eBodyRow = eRow; });
  20047. this.createRowContainer(this.pinnedRightContainerComp, rightCols, function (eRow) { return _this.ePinnedRightRow = eRow; });
  20048. this.createRowContainer(this.pinnedLeftContainerComp, leftCols, function (eRow) { return _this.ePinnedLeftRow = eRow; });
  20049. };
  20050. RowComp.prototype.createFullWidthRows = function (type, name) {
  20051. var _this = this;
  20052. this.fullWidthRow = true;
  20053. if (this.embedFullWidth) {
  20054. this.createFullWidthRowContainer(this.bodyContainerComp, null, null, type, name, function (eRow) {
  20055. _this.eFullWidthRowBody = eRow;
  20056. }, function (cellRenderer) {
  20057. _this.fullWidthRowComponentBody = cellRenderer;
  20058. });
  20059. // printLayout doesn't put components into the pinned sections
  20060. if (this.printLayout) {
  20061. return;
  20062. }
  20063. this.createFullWidthRowContainer(this.pinnedLeftContainerComp, Constants.PINNED_LEFT, 'ag-cell-last-left-pinned', type, name, function (eRow) {
  20064. _this.eFullWidthRowLeft = eRow;
  20065. }, function (cellRenderer) {
  20066. _this.fullWidthRowComponentLeft = cellRenderer;
  20067. });
  20068. this.createFullWidthRowContainer(this.pinnedRightContainerComp, Constants.PINNED_RIGHT, 'ag-cell-first-right-pinned', type, name, function (eRow) {
  20069. _this.eFullWidthRowRight = eRow;
  20070. }, function (cellRenderer) {
  20071. _this.fullWidthRowComponentRight = cellRenderer;
  20072. });
  20073. }
  20074. else {
  20075. // otherwise we add to the fullWidth container as normal
  20076. // let previousFullWidth = ensureDomOrder ? this.lastPlacedElements.eFullWidth : null;
  20077. this.createFullWidthRowContainer(this.fullWidthContainerComp, null, null, type, name, function (eRow) {
  20078. _this.eFullWidthRow = eRow;
  20079. }, function (cellRenderer) {
  20080. _this.fullWidthRowComponent = cellRenderer;
  20081. });
  20082. }
  20083. };
  20084. RowComp.prototype.setAnimateFlags = function (animateIn) {
  20085. if (animateIn) {
  20086. var oldRowTopExists = _.exists(this.rowNode.oldRowTop);
  20087. // if the row had a previous position, we slide it in (animate row top)
  20088. this.slideRowIn = oldRowTopExists;
  20089. // if the row had no previous position, we fade it in (animate
  20090. this.fadeRowIn = !oldRowTopExists;
  20091. }
  20092. else {
  20093. this.slideRowIn = false;
  20094. this.fadeRowIn = false;
  20095. }
  20096. };
  20097. RowComp.prototype.isEditing = function () {
  20098. return this.editingRow;
  20099. };
  20100. RowComp.prototype.stopRowEditing = function (cancel) {
  20101. this.stopEditing(cancel);
  20102. };
  20103. RowComp.prototype.isFullWidth = function () {
  20104. return this.fullWidthRow;
  20105. };
  20106. RowComp.prototype.refreshFullWidth = function () {
  20107. var _this = this;
  20108. // returns 'true' if refresh succeeded
  20109. var tryRefresh = function (eRow, eCellComp, pinned) {
  20110. if (!eRow || !eCellComp) {
  20111. return true;
  20112. } // no refresh needed
  20113. // no refresh method present, so can't refresh, hard refresh needed
  20114. if (!eCellComp.refresh) {
  20115. return false;
  20116. }
  20117. var params = _this.createFullWidthParams(eRow, pinned);
  20118. var refreshSucceeded = eCellComp.refresh(params);
  20119. return refreshSucceeded;
  20120. };
  20121. var normalSuccess = tryRefresh(this.eFullWidthRow, this.fullWidthRowComponent, null);
  20122. var bodySuccess = tryRefresh(this.eFullWidthRowBody, this.fullWidthRowComponentBody, null);
  20123. var leftSuccess = tryRefresh(this.eFullWidthRowLeft, this.fullWidthRowComponentLeft, Constants.PINNED_LEFT);
  20124. var rightSuccess = tryRefresh(this.eFullWidthRowRight, this.fullWidthRowComponentRight, Constants.PINNED_RIGHT);
  20125. var allFullWidthRowsRefreshed = normalSuccess && bodySuccess && leftSuccess && rightSuccess;
  20126. return allFullWidthRowsRefreshed;
  20127. };
  20128. RowComp.prototype.addListeners = function () {
  20129. this.addManagedListener(this.rowNode, RowNode.EVENT_HEIGHT_CHANGED, this.onRowHeightChanged.bind(this));
  20130. this.addManagedListener(this.rowNode, RowNode.EVENT_ROW_SELECTED, this.onRowSelected.bind(this));
  20131. this.addManagedListener(this.rowNode, RowNode.EVENT_ROW_INDEX_CHANGED, this.onRowIndexChanged.bind(this));
  20132. this.addManagedListener(this.rowNode, RowNode.EVENT_TOP_CHANGED, this.onTopChanged.bind(this));
  20133. this.addManagedListener(this.rowNode, RowNode.EVENT_EXPANDED_CHANGED, this.onExpandedChanged.bind(this));
  20134. this.addManagedListener(this.rowNode, RowNode.EVENT_DATA_CHANGED, this.onRowNodeDataChanged.bind(this));
  20135. this.addManagedListener(this.rowNode, RowNode.EVENT_CELL_CHANGED, this.onRowNodeCellChanged.bind(this));
  20136. this.addManagedListener(this.rowNode, RowNode.EVENT_HIGHLIGHT_CHANGED, this.onRowNodeHighlightChanged.bind(this));
  20137. this.addManagedListener(this.rowNode, RowNode.EVENT_DRAGGING_CHANGED, this.onRowNodeDraggingChanged.bind(this));
  20138. var eventService = this.beans.eventService;
  20139. this.addManagedListener(eventService, Events.EVENT_HEIGHT_SCALE_CHANGED, this.onTopChanged.bind(this));
  20140. this.addManagedListener(eventService, Events.EVENT_DISPLAYED_COLUMNS_CHANGED, this.onDisplayedColumnsChanged.bind(this));
  20141. this.addManagedListener(eventService, Events.EVENT_VIRTUAL_COLUMNS_CHANGED, this.onVirtualColumnsChanged.bind(this));
  20142. this.addManagedListener(eventService, Events.EVENT_COLUMN_RESIZED, this.onColumnResized.bind(this));
  20143. this.addManagedListener(eventService, Events.EVENT_CELL_FOCUSED, this.onCellFocusChanged.bind(this));
  20144. this.addManagedListener(eventService, Events.EVENT_PAGINATION_CHANGED, this.onPaginationChanged.bind(this));
  20145. this.addManagedListener(eventService, Events.EVENT_MODEL_UPDATED, this.onModelUpdated.bind(this));
  20146. this.addManagedListener(eventService, Events.EVENT_COLUMN_MOVED, this.onColumnMoved.bind(this));
  20147. this.addListenersForCellComps();
  20148. };
  20149. RowComp.prototype.addListenersForCellComps = function () {
  20150. var _this = this;
  20151. this.addManagedListener(this.rowNode, RowNode.EVENT_ROW_INDEX_CHANGED, function () {
  20152. _this.forEachCellComp(function (cellComp) { return cellComp.onRowIndexChanged(); });
  20153. });
  20154. this.addManagedListener(this.rowNode, RowNode.EVENT_CELL_CHANGED, function (event) {
  20155. _this.forEachCellComp(function (cellComp) { return cellComp.onCellChanged(event); });
  20156. });
  20157. };
  20158. RowComp.prototype.onRowNodeDataChanged = function (event) {
  20159. // if this is an update, we want to refresh, as this will allow the user to put in a transition
  20160. // into the cellRenderer refresh method. otherwise this might be completely new data, in which case
  20161. // we will want to completely replace the cells
  20162. this.forEachCellComp(function (cellComp) {
  20163. return cellComp.refreshCell({
  20164. suppressFlash: !event.update,
  20165. newData: !event.update
  20166. });
  20167. });
  20168. // check for selected also, as this could be after lazy loading of the row data, in which case
  20169. // the id might of just gotten set inside the row and the row selected state may of changed
  20170. // as a result. this is what happens when selected rows are loaded in virtual pagination.
  20171. // - niall note - since moving to the stub component, this may no longer be true, as replacing
  20172. // the stub component now replaces the entire row
  20173. this.onRowSelected();
  20174. // as data has changed, then the style and class needs to be recomputed
  20175. this.postProcessCss();
  20176. };
  20177. RowComp.prototype.onRowNodeCellChanged = function () {
  20178. // as data has changed, then the style and class needs to be recomputed
  20179. this.postProcessCss();
  20180. };
  20181. RowComp.prototype.postProcessCss = function () {
  20182. this.postProcessStylesFromGridOptions();
  20183. this.postProcessClassesFromGridOptions();
  20184. this.postProcessRowClassRules();
  20185. this.postProcessRowDragging();
  20186. };
  20187. RowComp.prototype.onRowNodeHighlightChanged = function () {
  20188. var highlighted = this.rowNode.highlighted;
  20189. this.eAllRowContainers.forEach(function (row) {
  20190. _.removeCssClass(row, 'ag-row-highlight-above');
  20191. _.removeCssClass(row, 'ag-row-highlight-below');
  20192. if (highlighted) {
  20193. _.addCssClass(row, 'ag-row-highlight-' + highlighted);
  20194. }
  20195. });
  20196. };
  20197. RowComp.prototype.onRowNodeDraggingChanged = function () {
  20198. this.postProcessRowDragging();
  20199. };
  20200. RowComp.prototype.postProcessRowDragging = function () {
  20201. var dragging = this.rowNode.dragging;
  20202. this.eAllRowContainers.forEach(function (row) { return _.addOrRemoveCssClass(row, 'ag-row-dragging', dragging); });
  20203. };
  20204. RowComp.prototype.onExpandedChanged = function () {
  20205. var rowNode = this.rowNode;
  20206. this.eAllRowContainers.forEach(function (row) { return _.addOrRemoveCssClass(row, 'ag-row-group-expanded', rowNode.expanded); });
  20207. this.eAllRowContainers.forEach(function (row) { return _.addOrRemoveCssClass(row, 'ag-row-group-contracted', !rowNode.expanded); });
  20208. };
  20209. RowComp.prototype.onDisplayedColumnsChanged = function () {
  20210. if (this.fullWidthRow) {
  20211. return;
  20212. }
  20213. this.refreshCells();
  20214. };
  20215. RowComp.prototype.destroyFullWidthComponents = function () {
  20216. if (this.fullWidthRowComponent) {
  20217. this.beans.detailRowCompCache.addOrDestroy(this.rowNode, null, this.fullWidthRowComponent);
  20218. this.fullWidthRowComponent = null;
  20219. }
  20220. if (this.fullWidthRowComponentBody) {
  20221. this.beans.detailRowCompCache.addOrDestroy(this.rowNode, null, this.fullWidthRowComponentBody);
  20222. this.fullWidthRowComponent = null;
  20223. }
  20224. if (this.fullWidthRowComponentLeft) {
  20225. this.beans.detailRowCompCache.addOrDestroy(this.rowNode, Constants.PINNED_LEFT, this.fullWidthRowComponentLeft);
  20226. this.fullWidthRowComponentLeft = null;
  20227. }
  20228. if (this.fullWidthRowComponentRight) {
  20229. this.beans.detailRowCompCache.addOrDestroy(this.rowNode, Constants.PINNED_RIGHT, this.fullWidthRowComponentRight);
  20230. this.fullWidthRowComponent = null;
  20231. }
  20232. };
  20233. RowComp.prototype.getContainerForCell = function (pinnedType) {
  20234. switch (pinnedType) {
  20235. case Constants.PINNED_LEFT: return this.ePinnedLeftRow;
  20236. case Constants.PINNED_RIGHT: return this.ePinnedRightRow;
  20237. default: return this.eBodyRow;
  20238. }
  20239. };
  20240. RowComp.prototype.onVirtualColumnsChanged = function () {
  20241. if (this.fullWidthRow) {
  20242. return;
  20243. }
  20244. this.refreshCells();
  20245. };
  20246. RowComp.prototype.onColumnResized = function () {
  20247. if (this.fullWidthRow) {
  20248. return;
  20249. }
  20250. this.refreshCells();
  20251. };
  20252. RowComp.prototype.refreshCells = function () {
  20253. if (!this.areAllContainersReady()) {
  20254. this.refreshNeeded = true;
  20255. return;
  20256. }
  20257. var suppressAnimationFrame = this.beans.gridOptionsWrapper.isSuppressAnimationFrame();
  20258. var skipAnimationFrame = suppressAnimationFrame || this.printLayout;
  20259. if (skipAnimationFrame) {
  20260. this.refreshCellsInAnimationFrame();
  20261. }
  20262. else {
  20263. if (this.columnRefreshPending) {
  20264. return;
  20265. }
  20266. this.beans.taskQueue.createTask(this.refreshCellsInAnimationFrame.bind(this), this.rowNode.rowIndex, 'createTasksP1');
  20267. }
  20268. };
  20269. RowComp.prototype.refreshCellsInAnimationFrame = function () {
  20270. if (!this.active) {
  20271. return;
  20272. }
  20273. this.columnRefreshPending = false;
  20274. var centerCols;
  20275. var leftCols;
  20276. var rightCols;
  20277. if (this.printLayout) {
  20278. centerCols = this.beans.columnController.getAllDisplayedColumns();
  20279. leftCols = [];
  20280. rightCols = [];
  20281. }
  20282. else {
  20283. centerCols = this.beans.columnController.getAllDisplayedCenterVirtualColumnsForRow(this.rowNode);
  20284. leftCols = this.beans.columnController.getDisplayedLeftColumnsForRow(this.rowNode);
  20285. rightCols = this.beans.columnController.getDisplayedRightColumnsForRow(this.rowNode);
  20286. }
  20287. this.insertCellsIntoContainer(this.eBodyRow, centerCols);
  20288. this.insertCellsIntoContainer(this.ePinnedLeftRow, leftCols);
  20289. this.insertCellsIntoContainer(this.ePinnedRightRow, rightCols);
  20290. this.elementOrderChanged = false;
  20291. var colIdsToRemove = Object.keys(this.cellComps);
  20292. centerCols.forEach(function (col) { return _.removeFromArray(colIdsToRemove, col.getId()); });
  20293. leftCols.forEach(function (col) { return _.removeFromArray(colIdsToRemove, col.getId()); });
  20294. rightCols.forEach(function (col) { return _.removeFromArray(colIdsToRemove, col.getId()); });
  20295. // we never remove editing cells, as this would cause the cells to loose their values while editing
  20296. // as the grid is scrolling horizontally.
  20297. var eligibleToBeRemoved = colIdsToRemove.filter(this.isCellEligibleToBeRemoved.bind(this));
  20298. // remove old cells from gui, but we don't destroy them, we might use them again
  20299. this.removeRenderedCells(eligibleToBeRemoved);
  20300. };
  20301. RowComp.prototype.onColumnMoved = function () {
  20302. this.elementOrderChanged = true;
  20303. };
  20304. RowComp.prototype.removeRenderedCells = function (colIds) {
  20305. var _this = this;
  20306. colIds.forEach(function (key) {
  20307. var cellComp = _this.cellComps[key];
  20308. // could be old reference, ie removed cell
  20309. if (_.missing(cellComp)) {
  20310. return;
  20311. }
  20312. cellComp.detach();
  20313. cellComp.destroy();
  20314. _this.cellComps[key] = null;
  20315. });
  20316. };
  20317. RowComp.prototype.isCellEligibleToBeRemoved = function (indexStr) {
  20318. var displayedColumns = this.beans.columnController.getAllDisplayedColumns();
  20319. var REMOVE_CELL = true;
  20320. var KEEP_CELL = false;
  20321. var renderedCell = this.cellComps[indexStr];
  20322. // always remove the cell if it's not rendered or if it's in the wrong pinned location
  20323. if (!renderedCell || this.isCellInWrongRow(renderedCell)) {
  20324. return REMOVE_CELL;
  20325. }
  20326. // we want to try and keep editing and focused cells
  20327. var editing = renderedCell.isEditing();
  20328. var focused = this.beans.focusController.isCellFocused(renderedCell.getCellPosition());
  20329. var mightWantToKeepCell = editing || focused;
  20330. if (mightWantToKeepCell) {
  20331. var column = renderedCell.getColumn();
  20332. var cellStillDisplayed = displayedColumns.indexOf(column) >= 0;
  20333. return cellStillDisplayed ? KEEP_CELL : REMOVE_CELL;
  20334. }
  20335. return REMOVE_CELL;
  20336. };
  20337. RowComp.prototype.ensureCellInCorrectContainer = function (cellComp) {
  20338. // for print layout, we always put cells into centre, otherwise we put in correct pinned section
  20339. if (this.printLayout) {
  20340. return;
  20341. }
  20342. var element = cellComp.getGui();
  20343. var column = cellComp.getColumn();
  20344. var pinnedType = column.getPinned();
  20345. var eContainer = this.getContainerForCell(pinnedType);
  20346. // if in wrong container, remove it
  20347. var eOldContainer = cellComp.getParentRow();
  20348. var inWrongRow = eOldContainer !== eContainer;
  20349. if (inWrongRow) {
  20350. // take out from old row
  20351. if (eOldContainer) {
  20352. eOldContainer.removeChild(element);
  20353. }
  20354. eContainer.appendChild(element);
  20355. cellComp.setParentRow(eContainer);
  20356. this.elementOrderChanged = true;
  20357. }
  20358. };
  20359. RowComp.prototype.isCellInWrongRow = function (cellComp) {
  20360. var column = cellComp.getColumn();
  20361. var rowWeWant = this.getContainerForCell(column.getPinned());
  20362. var oldRow = cellComp.getParentRow(); // if in wrong container, remove it
  20363. return oldRow !== rowWeWant;
  20364. };
  20365. RowComp.prototype.insertCellsIntoContainer = function (eRow, cols) {
  20366. var _this = this;
  20367. if (!eRow) {
  20368. return;
  20369. }
  20370. var cellTemplates = [];
  20371. var newCellComps = [];
  20372. cols.forEach(function (col) {
  20373. var colId = col.getId();
  20374. var existingCell = _this.cellComps[colId];
  20375. if (existingCell) {
  20376. _this.ensureCellInCorrectContainer(existingCell);
  20377. }
  20378. else {
  20379. _this.createNewCell(col, eRow, cellTemplates, newCellComps);
  20380. }
  20381. });
  20382. if (cellTemplates.length > 0) {
  20383. _.appendHtml(eRow, cellTemplates.join(''));
  20384. this.callAfterRowAttachedOnCells(newCellComps, eRow);
  20385. }
  20386. if (this.elementOrderChanged && this.beans.gridOptionsWrapper.isEnsureDomOrder()) {
  20387. var correctChildOrder = cols.map(function (col) { return _this.getCellForCol(col); });
  20388. _.setDomChildOrder(eRow, correctChildOrder);
  20389. }
  20390. };
  20391. RowComp.prototype.addDomData = function (eRowContainer) {
  20392. var gow = this.beans.gridOptionsWrapper;
  20393. gow.setDomData(eRowContainer, RowComp.DOM_DATA_KEY_RENDERED_ROW, this);
  20394. this.addDestroyFunc(function () {
  20395. gow.setDomData(eRowContainer, RowComp.DOM_DATA_KEY_RENDERED_ROW, null);
  20396. });
  20397. };
  20398. RowComp.prototype.createNewCell = function (col, eContainer, cellTemplates, newCellComps) {
  20399. var newCellComp = new CellComp(this.scope, this.beans, col, this.rowNode, this, false, this.printLayout);
  20400. var cellTemplate = newCellComp.getCreateTemplate();
  20401. cellTemplates.push(cellTemplate);
  20402. newCellComps.push(newCellComp);
  20403. this.cellComps[col.getId()] = newCellComp;
  20404. newCellComp.setParentRow(eContainer);
  20405. this.elementOrderChanged = true;
  20406. };
  20407. RowComp.prototype.onMouseEvent = function (eventName, mouseEvent) {
  20408. switch (eventName) {
  20409. case 'dblclick':
  20410. this.onRowDblClick(mouseEvent);
  20411. break;
  20412. case 'click':
  20413. this.onRowClick(mouseEvent);
  20414. break;
  20415. case 'mousedown':
  20416. this.onRowMouseDown(mouseEvent);
  20417. break;
  20418. }
  20419. };
  20420. RowComp.prototype.createRowEvent = function (type, domEvent) {
  20421. return {
  20422. type: type,
  20423. node: this.rowNode,
  20424. data: this.rowNode.data,
  20425. rowIndex: this.rowNode.rowIndex,
  20426. rowPinned: this.rowNode.rowPinned,
  20427. context: this.beans.gridOptionsWrapper.getContext(),
  20428. api: this.beans.gridOptionsWrapper.getApi(),
  20429. columnApi: this.beans.gridOptionsWrapper.getColumnApi(),
  20430. event: domEvent
  20431. };
  20432. };
  20433. RowComp.prototype.createRowEventWithSource = function (type, domEvent) {
  20434. var event = this.createRowEvent(type, domEvent);
  20435. // when first developing this, we included the rowComp in the event.
  20436. // this seems very weird. so when introducing the event types, i left the 'source'
  20437. // out of the type, and just include the source in the two places where this event
  20438. // was fired (rowClicked and rowDoubleClicked). it doesn't make sense for any
  20439. // users to be using this, as the rowComp isn't an object we expose, so would be
  20440. // very surprising if a user was using it.
  20441. event.source = this;
  20442. return event;
  20443. };
  20444. RowComp.prototype.onRowDblClick = function (mouseEvent) {
  20445. if (_.isStopPropagationForAgGrid(mouseEvent)) {
  20446. return;
  20447. }
  20448. var agEvent = this.createRowEventWithSource(Events.EVENT_ROW_DOUBLE_CLICKED, mouseEvent);
  20449. this.beans.eventService.dispatchEvent(agEvent);
  20450. };
  20451. RowComp.prototype.onRowMouseDown = function (mouseEvent) {
  20452. this.lastMouseDownOnDragger = _.isElementChildOfClass(mouseEvent.target, 'ag-row-drag', 3);
  20453. };
  20454. RowComp.prototype.onRowClick = function (mouseEvent) {
  20455. var stop = _.isStopPropagationForAgGrid(mouseEvent) || this.lastMouseDownOnDragger;
  20456. if (stop) {
  20457. return;
  20458. }
  20459. var agEvent = this.createRowEventWithSource(Events.EVENT_ROW_CLICKED, mouseEvent);
  20460. this.beans.eventService.dispatchEvent(agEvent);
  20461. // ctrlKey for windows, metaKey for Apple
  20462. var multiSelectKeyPressed = mouseEvent.ctrlKey || mouseEvent.metaKey;
  20463. var shiftKeyPressed = mouseEvent.shiftKey;
  20464. if (
  20465. // we do not allow selecting groups by clicking (as the click here expands the group), or if it's a detail row,
  20466. // so return if it's a group row
  20467. this.rowNode.group ||
  20468. // this is needed so we don't unselect other rows when we click this row, eg if this row is not selectable,
  20469. // and we click it, the selection should not change (ie any currently selected row should stay selected)
  20470. !this.rowNode.selectable ||
  20471. // we also don't allow selection of pinned rows
  20472. this.rowNode.rowPinned ||
  20473. // if no selection method enabled, do nothing
  20474. !this.beans.gridOptionsWrapper.isRowSelection() ||
  20475. // if click selection suppressed, do nothing
  20476. this.beans.gridOptionsWrapper.isSuppressRowClickSelection()) {
  20477. return;
  20478. }
  20479. var multiSelectOnClick = this.beans.gridOptionsWrapper.isRowMultiSelectWithClick();
  20480. var rowDeselectionWithCtrl = this.beans.gridOptionsWrapper.isRowDeselection();
  20481. if (this.rowNode.isSelected()) {
  20482. if (multiSelectOnClick) {
  20483. this.rowNode.setSelectedParams({ newValue: false });
  20484. }
  20485. else if (multiSelectKeyPressed) {
  20486. if (rowDeselectionWithCtrl) {
  20487. this.rowNode.setSelectedParams({ newValue: false });
  20488. }
  20489. }
  20490. else {
  20491. // selected with no multi key, must make sure anything else is unselected
  20492. this.rowNode.setSelectedParams({ newValue: true, clearSelection: true });
  20493. }
  20494. }
  20495. else {
  20496. var clearSelection = multiSelectOnClick ? false : !multiSelectKeyPressed;
  20497. this.rowNode.setSelectedParams({ newValue: true, clearSelection: clearSelection, rangeSelect: shiftKeyPressed });
  20498. }
  20499. };
  20500. RowComp.prototype.createFullWidthRowContainer = function (rowContainerComp, pinned, extraCssClass, cellRendererType, cellRendererName, eRowCallback, cellRendererCallback) {
  20501. var _this = this;
  20502. var rowTemplate = this.createTemplate('', extraCssClass);
  20503. rowContainerComp.appendRowTemplate(rowTemplate, function () {
  20504. var eRow = rowContainerComp.getRowElement(_this.getCompId());
  20505. var params = _this.createFullWidthParams(eRow, pinned);
  20506. var callback = function (cellRenderer) {
  20507. if (_this.isAlive()) {
  20508. var gui = cellRenderer.getGui();
  20509. eRow.appendChild(gui);
  20510. cellRendererCallback(cellRenderer);
  20511. }
  20512. else {
  20513. _this.beans.context.destroyBean(cellRenderer);
  20514. }
  20515. };
  20516. // if doing master detail, it's possible we have a cached row comp from last time detail was displayed
  20517. var cachedRowComp = _this.beans.detailRowCompCache.get(_this.rowNode, pinned);
  20518. if (cachedRowComp) {
  20519. callback(cachedRowComp);
  20520. }
  20521. else {
  20522. var res = _this.beans.userComponentFactory.newFullWidthCellRenderer(params, cellRendererType, cellRendererName);
  20523. if (!res) {
  20524. var masterDetailModuleLoaded = ModuleRegistry.isRegistered(exports.ModuleNames.MasterDetailModule);
  20525. if (cellRendererName === 'agDetailCellRenderer' && !masterDetailModuleLoaded) {
  20526. console.warn("ag-Grid: cell renderer agDetailCellRenderer (for master detail) not found. Did you forget to include the master detail module?");
  20527. }
  20528. else {
  20529. console.error("ag-Grid: fullWidthCellRenderer " + cellRendererName + " not found");
  20530. }
  20531. return;
  20532. }
  20533. res.then(callback);
  20534. }
  20535. _this.afterRowAttached(rowContainerComp, eRow);
  20536. eRowCallback(eRow);
  20537. _this.angular1Compile(eRow);
  20538. });
  20539. };
  20540. RowComp.prototype.angular1Compile = function (element) {
  20541. if (!this.scope) {
  20542. return;
  20543. }
  20544. this.beans.$compile(element)(this.scope);
  20545. };
  20546. RowComp.prototype.createFullWidthParams = function (eRow, pinned) {
  20547. var params = {
  20548. fullWidth: true,
  20549. data: this.rowNode.data,
  20550. node: this.rowNode,
  20551. value: this.rowNode.key,
  20552. $scope: this.scope ? this.scope : this.parentScope,
  20553. $compile: this.beans.$compile,
  20554. rowIndex: this.rowNode.rowIndex,
  20555. api: this.beans.gridOptionsWrapper.getApi(),
  20556. columnApi: this.beans.gridOptionsWrapper.getColumnApi(),
  20557. context: this.beans.gridOptionsWrapper.getContext(),
  20558. // these need to be taken out, as part of 'afterAttached' now
  20559. eGridCell: eRow,
  20560. eParentOfValue: eRow,
  20561. pinned: pinned,
  20562. addRenderedRowListener: this.addEventListener.bind(this)
  20563. };
  20564. return params;
  20565. };
  20566. RowComp.prototype.getInitialRowClasses = function (extraCssClass) {
  20567. var classes = [];
  20568. var isTreeData = this.beans.gridOptionsWrapper.isTreeData();
  20569. var rowNode = this.rowNode;
  20570. if (_.exists(extraCssClass)) {
  20571. classes.push(extraCssClass);
  20572. }
  20573. classes.push('ag-row');
  20574. classes.push(this.rowFocused ? 'ag-row-focus' : 'ag-row-no-focus');
  20575. if (this.fadeRowIn) {
  20576. classes.push('ag-opacity-zero');
  20577. }
  20578. classes.push(this.rowIsEven ? 'ag-row-even' : 'ag-row-odd');
  20579. if (rowNode.isRowPinned()) {
  20580. classes.push('ag-row-pinned');
  20581. }
  20582. if (rowNode.isSelected()) {
  20583. classes.push('ag-row-selected');
  20584. }
  20585. if (rowNode.group) {
  20586. classes.push('ag-row-group');
  20587. // if a group, put the level of the group in
  20588. classes.push('ag-row-level-' + rowNode.level);
  20589. if (rowNode.footer) {
  20590. classes.push('ag-row-footer');
  20591. }
  20592. }
  20593. else {
  20594. // if a leaf, and a parent exists, put a level of the parent, else put level of 0 for top level item
  20595. classes.push('ag-row-level-' + (rowNode.parent ? (rowNode.parent.level + 1) : '0'));
  20596. }
  20597. if (rowNode.stub) {
  20598. classes.push('ag-row-loading');
  20599. }
  20600. if (this.fullWidthRow) {
  20601. classes.push('ag-full-width-row');
  20602. }
  20603. var addExpandedClass = isTreeData ?
  20604. // if doing tree data, we add the expanded classes if any children, as any node can be a parent
  20605. rowNode.allChildrenCount :
  20606. // if normal row grouping, we add expanded classes to groups only
  20607. rowNode.group && !rowNode.footer;
  20608. if (addExpandedClass) {
  20609. classes.push(rowNode.expanded ? 'ag-row-group-expanded' : 'ag-row-group-contracted');
  20610. }
  20611. if (rowNode.dragging) {
  20612. classes.push('ag-row-dragging');
  20613. }
  20614. _.pushAll(classes, this.processClassesFromGridOptions());
  20615. _.pushAll(classes, this.preProcessRowClassRules());
  20616. // we use absolute position unless we are doing print layout
  20617. classes.push(this.printLayout ? 'ag-row-position-relative' : 'ag-row-position-absolute');
  20618. this.firstRowOnPage = this.isFirstRowOnPage();
  20619. this.lastRowOnPage = this.isLastRowOnPage();
  20620. if (this.firstRowOnPage) {
  20621. classes.push('ag-row-first');
  20622. }
  20623. if (this.lastRowOnPage) {
  20624. classes.push('ag-row-last');
  20625. }
  20626. return classes;
  20627. };
  20628. RowComp.prototype.isFirstRowOnPage = function () {
  20629. return this.rowNode.rowIndex === this.beans.paginationProxy.getPageFirstRow();
  20630. };
  20631. RowComp.prototype.isLastRowOnPage = function () {
  20632. return this.rowNode.rowIndex === this.beans.paginationProxy.getPageLastRow();
  20633. };
  20634. RowComp.prototype.onModelUpdated = function () {
  20635. var newFirst = this.isFirstRowOnPage();
  20636. var newLast = this.isLastRowOnPage();
  20637. if (this.firstRowOnPage !== newFirst) {
  20638. this.firstRowOnPage = newFirst;
  20639. this.eAllRowContainers.forEach(function (row) { return _.addOrRemoveCssClass(row, 'ag-row-first', newFirst); });
  20640. }
  20641. if (this.lastRowOnPage !== newLast) {
  20642. this.lastRowOnPage = newLast;
  20643. this.eAllRowContainers.forEach(function (row) { return _.addOrRemoveCssClass(row, 'ag-row-last', newLast); });
  20644. }
  20645. };
  20646. RowComp.prototype.preProcessRowClassRules = function () {
  20647. var res = [];
  20648. this.processRowClassRules(function (className) {
  20649. res.push(className);
  20650. }, function (className) {
  20651. // not catered for, if creating, no need
  20652. // to remove class as it was never there
  20653. });
  20654. return res;
  20655. };
  20656. RowComp.prototype.processRowClassRules = function (onApplicableClass, onNotApplicableClass) {
  20657. this.beans.stylingService.processClassRules(this.beans.gridOptionsWrapper.rowClassRules(), {
  20658. value: undefined,
  20659. colDef: undefined,
  20660. data: this.rowNode.data,
  20661. node: this.rowNode,
  20662. rowIndex: this.rowNode.rowIndex,
  20663. api: this.beans.gridOptionsWrapper.getApi(),
  20664. columnApi: this.beans.gridOptionsWrapper.getColumnApi(),
  20665. $scope: this.scope,
  20666. context: this.beans.gridOptionsWrapper.getContext()
  20667. }, onApplicableClass, onNotApplicableClass);
  20668. };
  20669. RowComp.prototype.stopEditing = function (cancel) {
  20670. if (cancel === void 0) { cancel = false; }
  20671. this.forEachCellComp(function (renderedCell) {
  20672. renderedCell.stopEditing(cancel);
  20673. });
  20674. if (!this.editingRow) {
  20675. return;
  20676. }
  20677. if (!cancel) {
  20678. var event_1 = this.createRowEvent(Events.EVENT_ROW_VALUE_CHANGED);
  20679. this.beans.eventService.dispatchEvent(event_1);
  20680. }
  20681. this.setEditingRow(false);
  20682. };
  20683. RowComp.prototype.setEditingRow = function (value) {
  20684. this.editingRow = value;
  20685. this.eAllRowContainers.forEach(function (row) { return _.addOrRemoveCssClass(row, 'ag-row-editing', value); });
  20686. var event = value ?
  20687. this.createRowEvent(Events.EVENT_ROW_EDITING_STARTED)
  20688. : this.createRowEvent(Events.EVENT_ROW_EDITING_STOPPED);
  20689. this.beans.eventService.dispatchEvent(event);
  20690. };
  20691. RowComp.prototype.startRowEditing = function (keyPress, charPress, sourceRenderedCell) {
  20692. if (keyPress === void 0) { keyPress = null; }
  20693. if (charPress === void 0) { charPress = null; }
  20694. if (sourceRenderedCell === void 0) { sourceRenderedCell = null; }
  20695. // don't do it if already editing
  20696. if (this.editingRow) {
  20697. return;
  20698. }
  20699. this.forEachCellComp(function (renderedCell) {
  20700. var cellStartedEdit = renderedCell === sourceRenderedCell;
  20701. if (cellStartedEdit) {
  20702. renderedCell.startEditingIfEnabled(keyPress, charPress, cellStartedEdit);
  20703. }
  20704. else {
  20705. renderedCell.startEditingIfEnabled(null, null, cellStartedEdit);
  20706. }
  20707. });
  20708. this.setEditingRow(true);
  20709. };
  20710. RowComp.prototype.forEachCellComp = function (callback) {
  20711. _.iterateObject(this.cellComps, function (key, cellComp) {
  20712. if (!cellComp) {
  20713. return;
  20714. }
  20715. callback(cellComp);
  20716. });
  20717. };
  20718. RowComp.prototype.postProcessClassesFromGridOptions = function () {
  20719. var _this = this;
  20720. var cssClasses = this.processClassesFromGridOptions();
  20721. if (!cssClasses || !cssClasses.length) {
  20722. return;
  20723. }
  20724. cssClasses.forEach(function (classStr) {
  20725. _this.eAllRowContainers.forEach(function (row) { return _.addCssClass(row, classStr); });
  20726. });
  20727. };
  20728. RowComp.prototype.postProcessRowClassRules = function () {
  20729. var _this = this;
  20730. this.processRowClassRules(function (className) {
  20731. _this.eAllRowContainers.forEach(function (row) { return _.addCssClass(row, className); });
  20732. }, function (className) {
  20733. _this.eAllRowContainers.forEach(function (row) { return _.removeCssClass(row, className); });
  20734. });
  20735. };
  20736. RowComp.prototype.processClassesFromGridOptions = function () {
  20737. var res = [];
  20738. var process = function (rowCls) {
  20739. if (typeof rowCls === 'string') {
  20740. res.push(rowCls);
  20741. }
  20742. else if (Array.isArray(rowCls)) {
  20743. rowCls.forEach(function (e) { return res.push(e); });
  20744. }
  20745. };
  20746. // part 1 - rowClass
  20747. var rowClass = this.beans.gridOptionsWrapper.getRowClass();
  20748. if (rowClass) {
  20749. if (typeof rowClass === 'function') {
  20750. console.warn('ag-Grid: rowClass should not be a function, please use getRowClass instead');
  20751. return;
  20752. }
  20753. process(rowClass);
  20754. }
  20755. // part 2 - rowClassFunc
  20756. var rowClassFunc = this.beans.gridOptionsWrapper.getRowClassFunc();
  20757. if (rowClassFunc) {
  20758. var params = {
  20759. node: this.rowNode,
  20760. data: this.rowNode.data,
  20761. rowIndex: this.rowNode.rowIndex,
  20762. context: this.beans.gridOptionsWrapper.getContext(),
  20763. api: this.beans.gridOptionsWrapper.getApi()
  20764. };
  20765. var rowClassFuncResult = rowClassFunc(params);
  20766. process(rowClassFuncResult);
  20767. }
  20768. return res;
  20769. };
  20770. RowComp.prototype.preProcessStylesFromGridOptions = function () {
  20771. var rowStyles = this.processStylesFromGridOptions();
  20772. return _.cssStyleObjectToMarkup(rowStyles);
  20773. };
  20774. RowComp.prototype.postProcessStylesFromGridOptions = function () {
  20775. var rowStyles = this.processStylesFromGridOptions();
  20776. this.eAllRowContainers.forEach(function (row) { return _.addStylesToElement(row, rowStyles); });
  20777. };
  20778. RowComp.prototype.processStylesFromGridOptions = function () {
  20779. // part 1 - rowStyle
  20780. var rowStyle = this.beans.gridOptionsWrapper.getRowStyle();
  20781. if (rowStyle && typeof rowStyle === 'function') {
  20782. console.warn('ag-Grid: rowStyle should be an object of key/value styles, not be a function, use getRowStyle() instead');
  20783. return;
  20784. }
  20785. // part 1 - rowStyleFunc
  20786. var rowStyleFunc = this.beans.gridOptionsWrapper.getRowStyleFunc();
  20787. var rowStyleFuncResult;
  20788. if (rowStyleFunc) {
  20789. var params = {
  20790. data: this.rowNode.data,
  20791. node: this.rowNode,
  20792. api: this.beans.gridOptionsWrapper.getApi(),
  20793. context: this.beans.gridOptionsWrapper.getContext(),
  20794. $scope: this.scope
  20795. };
  20796. rowStyleFuncResult = rowStyleFunc(params);
  20797. }
  20798. return _.assign({}, rowStyle, rowStyleFuncResult);
  20799. };
  20800. RowComp.prototype.createCells = function (cols) {
  20801. var _this = this;
  20802. var templateParts = [];
  20803. var newCellComps = [];
  20804. cols.forEach(function (col) {
  20805. var newCellComp = new CellComp(_this.scope, _this.beans, col, _this.rowNode, _this, false, _this.printLayout);
  20806. var cellTemplate = newCellComp.getCreateTemplate();
  20807. templateParts.push(cellTemplate);
  20808. newCellComps.push(newCellComp);
  20809. _this.cellComps[col.getId()] = newCellComp;
  20810. });
  20811. var templateAndComps = {
  20812. template: templateParts.join(''),
  20813. cellComps: newCellComps
  20814. };
  20815. return templateAndComps;
  20816. };
  20817. RowComp.prototype.onRowSelected = function () {
  20818. var selected = this.rowNode.isSelected();
  20819. this.eAllRowContainers.forEach(function (row) { return _.addOrRemoveCssClass(row, 'ag-row-selected', selected); });
  20820. };
  20821. // called:
  20822. // + after row created for first time
  20823. // + after horizontal scroll, so new cells due to column virtualisation
  20824. RowComp.prototype.callAfterRowAttachedOnCells = function (newCellComps, eRow) {
  20825. var _this = this;
  20826. newCellComps.forEach(function (cellComp) {
  20827. cellComp.setParentRow(eRow);
  20828. cellComp.afterAttached();
  20829. // if we are editing the row, then the cell needs to turn
  20830. // into edit mode
  20831. if (_this.editingRow) {
  20832. cellComp.startEditingIfEnabled();
  20833. }
  20834. });
  20835. };
  20836. RowComp.prototype.afterRowAttached = function (rowContainerComp, eRow) {
  20837. var _this = this;
  20838. this.addDomData(eRow);
  20839. this.removeSecondPassFuncs.push(function () {
  20840. rowContainerComp.removeRowElement(eRow);
  20841. });
  20842. this.removeFirstPassFuncs.push(function () {
  20843. if (_.exists(_this.rowNode.rowTop)) {
  20844. // the row top is updated anyway, however we set it here again
  20845. // to something more reasonable for the animation - ie if the
  20846. // row top is 10000px away, the row will flash out, so this
  20847. // gives it a rounded value, so row animates out more slowly
  20848. var rowTop = _this.roundRowTopToBounds(_this.rowNode.rowTop);
  20849. _this.setRowTop(rowTop);
  20850. }
  20851. else {
  20852. _.addCssClass(eRow, 'ag-opacity-zero');
  20853. }
  20854. });
  20855. this.eAllRowContainers.push(eRow);
  20856. // adding hover functionality adds listener to this row, so we
  20857. // do it lazily in an animation frame
  20858. if (this.useAnimationFrameForCreate) {
  20859. this.beans.taskQueue.createTask(this.addHoverFunctionality.bind(this, eRow), this.rowNode.rowIndex, 'createTasksP2');
  20860. }
  20861. else {
  20862. this.addHoverFunctionality(eRow);
  20863. }
  20864. };
  20865. RowComp.prototype.addHoverFunctionality = function (eRow) {
  20866. var _this = this;
  20867. // because we use animation frames to do this, it's possible the row no longer exists
  20868. // by the time we get to add it
  20869. if (!this.active) {
  20870. return;
  20871. }
  20872. // because mouseenter and mouseleave do not propagate, we cannot listen on the gridPanel
  20873. // like we do for all the other mouse events.
  20874. // because of the pinning, we cannot simply add / remove the class based on the eRow. we
  20875. // have to check all eRow's (body & pinned). so the trick is if any of the rows gets a
  20876. // mouse hover, it sets such in the rowNode, and then all three reflect the change as
  20877. // all are listening for event on the row node.
  20878. // step 1 - add listener, to set flag on row node
  20879. this.addManagedListener(eRow, 'mouseenter', function () { return _this.rowNode.onMouseEnter(); });
  20880. this.addManagedListener(eRow, 'mouseleave', function () { return _this.rowNode.onMouseLeave(); });
  20881. // step 2 - listen for changes on row node (which any eRow can trigger)
  20882. this.addManagedListener(this.rowNode, RowNode.EVENT_MOUSE_ENTER, function () {
  20883. // if hover turned off, we don't add the class. we do this here so that if the application
  20884. // toggles this property mid way, we remove the hover form the last row, but we stop
  20885. // adding hovers from that point onwards.
  20886. if (!_this.beans.gridOptionsWrapper.isSuppressRowHoverHighlight()) {
  20887. _.addCssClass(eRow, 'ag-row-hover');
  20888. }
  20889. });
  20890. this.addManagedListener(this.rowNode, RowNode.EVENT_MOUSE_LEAVE, function () {
  20891. _.removeCssClass(eRow, 'ag-row-hover');
  20892. });
  20893. };
  20894. // for animation, we don't want to animate entry or exit to a very far away pixel,
  20895. // otherwise the row would move so fast, it would appear to disappear. so this method
  20896. // moves the row closer to the viewport if it is far away, so the row slide in / out
  20897. // at a speed the user can see.
  20898. RowComp.prototype.roundRowTopToBounds = function (rowTop) {
  20899. var range = this.beans.gridPanel.getVScrollPosition();
  20900. var minPixel = this.applyPaginationOffset(range.top, true) - 100;
  20901. var maxPixel = this.applyPaginationOffset(range.bottom, true) + 100;
  20902. return Math.min(Math.max(minPixel, rowTop), maxPixel);
  20903. };
  20904. RowComp.prototype.getFrameworkOverrides = function () {
  20905. return this.beans.frameworkOverrides;
  20906. };
  20907. RowComp.prototype.onRowHeightChanged = function () {
  20908. // check for exists first - if the user is resetting the row height, then
  20909. // it will be null (or undefined) momentarily until the next time the flatten
  20910. // stage is called where the row will then update again with a new height
  20911. if (_.exists(this.rowNode.rowHeight)) {
  20912. var heightPx_1 = this.rowNode.rowHeight + "px";
  20913. this.eAllRowContainers.forEach(function (row) { return row.style.height = heightPx_1; });
  20914. }
  20915. };
  20916. RowComp.prototype.addEventListener = function (eventType, listener) {
  20917. if (eventType === 'renderedRowRemoved' || eventType === 'rowRemoved') {
  20918. eventType = Events.EVENT_VIRTUAL_ROW_REMOVED;
  20919. console.warn('ag-Grid: Since version 11, event renderedRowRemoved is now called ' + Events.EVENT_VIRTUAL_ROW_REMOVED);
  20920. }
  20921. _super.prototype.addEventListener.call(this, eventType, listener);
  20922. };
  20923. RowComp.prototype.removeEventListener = function (eventType, listener) {
  20924. if (eventType === 'renderedRowRemoved' || eventType === 'rowRemoved') {
  20925. eventType = Events.EVENT_VIRTUAL_ROW_REMOVED;
  20926. console.warn('ag-Grid: Since version 11, event renderedRowRemoved and rowRemoved is now called ' + Events.EVENT_VIRTUAL_ROW_REMOVED);
  20927. }
  20928. _super.prototype.removeEventListener.call(this, eventType, listener);
  20929. };
  20930. // note - this is NOT called by context, as we don't wire / unwire the CellComp for performance reasons.
  20931. RowComp.prototype.destroy = function (animate) {
  20932. if (animate === void 0) { animate = false; }
  20933. this.active = false;
  20934. // why do we have this method? shouldn't everything below be added as a destroy func beside
  20935. // the corresponding create logic?
  20936. this.destroyFullWidthComponents();
  20937. if (animate) {
  20938. this.removeFirstPassFuncs.forEach(function (func) { return func(); });
  20939. this.removeSecondPassFuncs.push(this.destroyContainingCells.bind(this));
  20940. }
  20941. else {
  20942. this.destroyContainingCells();
  20943. // we are not animating, so execute the second stage of removal now.
  20944. // we call getAndClear, so that they are only called once
  20945. var delayedDestroyFunctions = this.getAndClearDelayedDestroyFunctions();
  20946. delayedDestroyFunctions.forEach(function (func) { return func(); });
  20947. }
  20948. var event = this.createRowEvent(Events.EVENT_VIRTUAL_ROW_REMOVED);
  20949. this.dispatchEvent(event);
  20950. this.beans.eventService.dispatchEvent(event);
  20951. _super.prototype.destroy.call(this);
  20952. };
  20953. RowComp.prototype.destroyContainingCells = function () {
  20954. this.forEachCellComp(function (renderedCell) { return renderedCell.destroy(); });
  20955. this.destroyFullWidthComponents();
  20956. };
  20957. // we clear so that the functions are never executed twice
  20958. RowComp.prototype.getAndClearDelayedDestroyFunctions = function () {
  20959. var result = this.removeSecondPassFuncs;
  20960. this.removeSecondPassFuncs = [];
  20961. return result;
  20962. };
  20963. RowComp.prototype.onCellFocusChanged = function () {
  20964. var rowFocused = this.beans.focusController.isRowFocused(this.rowNode.rowIndex, this.rowNode.rowPinned);
  20965. if (rowFocused !== this.rowFocused) {
  20966. this.eAllRowContainers.forEach(function (row) { return _.addOrRemoveCssClass(row, 'ag-row-focus', rowFocused); });
  20967. this.eAllRowContainers.forEach(function (row) { return _.addOrRemoveCssClass(row, 'ag-row-no-focus', !rowFocused); });
  20968. this.rowFocused = rowFocused;
  20969. }
  20970. // if we are editing, then moving the focus out of a row will stop editing
  20971. if (!rowFocused && this.editingRow) {
  20972. this.stopEditing(false);
  20973. }
  20974. };
  20975. RowComp.prototype.onPaginationChanged = function () {
  20976. var currentPage = this.beans.paginationProxy.getCurrentPage();
  20977. // it is possible this row is in the new page, but the page number has changed, which means
  20978. // it needs to reposition itself relative to the new page
  20979. if (this.paginationPage !== currentPage) {
  20980. this.paginationPage = currentPage;
  20981. this.onTopChanged();
  20982. }
  20983. };
  20984. RowComp.prototype.onTopChanged = function () {
  20985. this.setRowTop(this.rowNode.rowTop);
  20986. };
  20987. // applies pagination offset, eg if on second page, and page height is 500px, then removes
  20988. // 500px from the top position, so a row with rowTop 600px is displayed at location 100px.
  20989. // reverse will take the offset away rather than add.
  20990. RowComp.prototype.applyPaginationOffset = function (topPx, reverse) {
  20991. if (reverse === void 0) { reverse = false; }
  20992. if (this.rowNode.isRowPinned()) {
  20993. return topPx;
  20994. }
  20995. var pixelOffset = this.beans.paginationProxy.getPixelOffset();
  20996. var multiplier = reverse ? 1 : -1;
  20997. return topPx + (pixelOffset * multiplier);
  20998. };
  20999. RowComp.prototype.setRowTop = function (pixels) {
  21000. // print layout uses normal flow layout for row positioning
  21001. if (this.printLayout) {
  21002. return;
  21003. }
  21004. // need to make sure rowTop is not null, as this can happen if the node was once
  21005. // visible (ie parent group was expanded) but is now not visible
  21006. if (_.exists(pixels)) {
  21007. var afterPaginationPixels = this.applyPaginationOffset(pixels);
  21008. var afterScalingPixels = this.beans.maxDivHeightScaler.getRealPixelPosition(afterPaginationPixels);
  21009. var topPx_1 = afterScalingPixels + "px";
  21010. if (this.beans.gridOptionsWrapper.isSuppressRowTransform()) {
  21011. this.eAllRowContainers.forEach(function (row) { return row.style.top = topPx_1; });
  21012. }
  21013. else {
  21014. this.eAllRowContainers.forEach(function (row) { return row.style.transform = "translateY(" + topPx_1 + ")"; });
  21015. }
  21016. }
  21017. };
  21018. // we clear so that the functions are never executed twice
  21019. RowComp.prototype.getAndClearNextVMTurnFunctions = function () {
  21020. var result = this.createSecondPassFuncs;
  21021. this.createSecondPassFuncs = [];
  21022. return result;
  21023. };
  21024. RowComp.prototype.getRowNode = function () {
  21025. return this.rowNode;
  21026. };
  21027. RowComp.prototype.getRenderedCellForColumn = function (column) {
  21028. var _this = this;
  21029. var cellComp = this.cellComps[column.getColId()];
  21030. if (cellComp) {
  21031. return cellComp;
  21032. }
  21033. var spanList = Object.keys(this.cellComps)
  21034. .map(function (name) { return _this.cellComps[name]; })
  21035. .filter(function (cmp) { return cmp && cmp.getColSpanningList().indexOf(column) !== -1; });
  21036. return spanList.length ? spanList[0] : undefined;
  21037. };
  21038. RowComp.prototype.onRowIndexChanged = function () {
  21039. // we only bother updating if the rowIndex is present. if it is not present, it means this row
  21040. // is child of a group node, and the group node was closed, it's the only way to have no row index.
  21041. // when this happens, row is about to be de-rendered, so we don't care, rowComp is about to die!
  21042. if (this.rowNode.rowIndex != null) {
  21043. this.onCellFocusChanged();
  21044. this.updateRowIndexes();
  21045. }
  21046. };
  21047. RowComp.prototype.updateRowIndexes = function () {
  21048. var _this = this;
  21049. var rowIndexStr = this.rowNode.getRowIndexString();
  21050. var rowIsEven = this.rowNode.rowIndex % 2 === 0;
  21051. var rowIsEvenChanged = this.rowIsEven !== rowIsEven;
  21052. var headerRowCount = this.beans.headerNavigationService.getHeaderRowCount();
  21053. if (rowIsEvenChanged) {
  21054. this.rowIsEven = rowIsEven;
  21055. }
  21056. this.eAllRowContainers.forEach(function (eRow) {
  21057. eRow.setAttribute('row-index', rowIndexStr);
  21058. eRow.setAttribute('aria-rowindex', (headerRowCount + _this.rowNode.rowIndex + 1).toString());
  21059. if (!rowIsEvenChanged) {
  21060. return;
  21061. }
  21062. _.addOrRemoveCssClass(eRow, 'ag-row-even', rowIsEven);
  21063. _.addOrRemoveCssClass(eRow, 'ag-row-odd', !rowIsEven);
  21064. });
  21065. };
  21066. RowComp.prototype.ensureDomOrder = function () {
  21067. var sides = [
  21068. {
  21069. el: this.getBodyRowElement(),
  21070. ct: this.bodyContainerComp
  21071. },
  21072. {
  21073. el: this.getPinnedLeftRowElement(),
  21074. ct: this.pinnedLeftContainerComp
  21075. }, {
  21076. el: this.getPinnedRightRowElement(),
  21077. ct: this.pinnedRightContainerComp
  21078. }, {
  21079. el: this.getFullWidthRowElement(),
  21080. ct: this.fullWidthContainerComp
  21081. }
  21082. ];
  21083. sides.forEach(function (side) {
  21084. if (!side.el) {
  21085. return;
  21086. }
  21087. side.ct.ensureDomOrder(side.el);
  21088. });
  21089. };
  21090. // returns the pinned left container, either the normal one, or the embedded full with one if exists
  21091. RowComp.prototype.getPinnedLeftRowElement = function () {
  21092. return this.ePinnedLeftRow ? this.ePinnedLeftRow : this.eFullWidthRowLeft;
  21093. };
  21094. // returns the pinned right container, either the normal one, or the embedded full with one if exists
  21095. RowComp.prototype.getPinnedRightRowElement = function () {
  21096. return this.ePinnedRightRow ? this.ePinnedRightRow : this.eFullWidthRowRight;
  21097. };
  21098. // returns the body container, either the normal one, or the embedded full with one if exists
  21099. RowComp.prototype.getBodyRowElement = function () {
  21100. return this.eBodyRow ? this.eBodyRow : this.eFullWidthRowBody;
  21101. };
  21102. // returns the full width container
  21103. RowComp.prototype.getFullWidthRowElement = function () {
  21104. return this.eFullWidthRow;
  21105. };
  21106. RowComp.DOM_DATA_KEY_RENDERED_ROW = 'renderedRow';
  21107. RowComp.FULL_WIDTH_CELL_RENDERER = 'fullWidthCellRenderer';
  21108. RowComp.GROUP_ROW_RENDERER = 'groupRowRenderer';
  21109. RowComp.GROUP_ROW_RENDERER_COMP_NAME = 'agGroupRowRenderer';
  21110. RowComp.LOADING_CELL_RENDERER = 'loadingCellRenderer';
  21111. RowComp.LOADING_CELL_RENDERER_COMP_NAME = 'agLoadingCellRenderer';
  21112. RowComp.DETAIL_CELL_RENDERER = 'detailCellRenderer';
  21113. RowComp.DETAIL_CELL_RENDERER_COMP_NAME = 'agDetailCellRenderer';
  21114. return RowComp;
  21115. }(Component));
  21116. /**
  21117. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  21118. * @version v23.2.1
  21119. * @link http://www.ag-grid.com/
  21120. * @license MIT
  21121. */
  21122. var __extends$L = (undefined && undefined.__extends) || (function () {
  21123. var extendStatics = function (d, b) {
  21124. extendStatics = Object.setPrototypeOf ||
  21125. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  21126. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  21127. return extendStatics(d, b);
  21128. };
  21129. return function (d, b) {
  21130. extendStatics(d, b);
  21131. function __() { this.constructor = d; }
  21132. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  21133. };
  21134. })();
  21135. var __decorate$H = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  21136. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  21137. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  21138. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  21139. return c > 3 && r && Object.defineProperty(target, key, r), r;
  21140. };
  21141. var __param$5 = (undefined && undefined.__param) || function (paramIndex, decorator) {
  21142. return function (target, key) { decorator(target, key, paramIndex); }
  21143. };
  21144. var RowRenderer = /** @class */ (function (_super) {
  21145. __extends$L(RowRenderer, _super);
  21146. function RowRenderer() {
  21147. var _this = _super !== null && _super.apply(this, arguments) || this;
  21148. _this.destroyFuncsForColumnListeners = [];
  21149. // map of row ids to row objects. keeps track of which elements
  21150. // are rendered for which rows in the dom.
  21151. _this.rowCompsByIndex = {};
  21152. _this.floatingTopRowComps = [];
  21153. _this.floatingBottomRowComps = [];
  21154. // we only allow one refresh at a time, otherwise the internal memory structure here
  21155. // will get messed up. this can happen if the user has a cellRenderer, and inside the
  21156. // renderer they call an API method that results in another pass of the refresh,
  21157. // then it will be trying to draw rows in the middle of a refresh.
  21158. _this.refreshInProgress = false;
  21159. return _this;
  21160. }
  21161. RowRenderer.prototype.registerGridCore = function (gridCore) {
  21162. this.gridCore = gridCore;
  21163. };
  21164. RowRenderer.prototype.getGridCore = function () {
  21165. return this.gridCore;
  21166. };
  21167. RowRenderer.prototype.agWire = function (loggerFactory) {
  21168. this.logger = loggerFactory.create("RowRenderer");
  21169. };
  21170. RowRenderer.prototype.registerGridComp = function (gridPanel) {
  21171. this.gridPanel = gridPanel;
  21172. this.rowContainers = this.gridPanel.getRowContainers();
  21173. this.addManagedListener(this.eventService, Events.EVENT_PAGINATION_CHANGED, this.onPageLoaded.bind(this));
  21174. this.addManagedListener(this.eventService, Events.EVENT_PINNED_ROW_DATA_CHANGED, this.onPinnedRowDataChanged.bind(this));
  21175. this.addManagedListener(this.eventService, Events.EVENT_DISPLAYED_COLUMNS_CHANGED, this.onDisplayedColumnsChanged.bind(this));
  21176. this.addManagedListener(this.eventService, Events.EVENT_BODY_SCROLL, this.redrawAfterScroll.bind(this));
  21177. this.addManagedListener(this.eventService, Events.EVENT_BODY_HEIGHT_CHANGED, this.redrawAfterScroll.bind(this));
  21178. this.addManagedListener(this.gridOptionsWrapper, GridOptionsWrapper.PROP_DOM_LAYOUT, this.onDomLayoutChanged.bind(this));
  21179. this.registerCellEventListeners();
  21180. this.printLayout = this.gridOptionsWrapper.getDomLayout() === Constants.DOM_LAYOUT_PRINT;
  21181. this.embedFullWidthRows = this.printLayout || this.gridOptionsWrapper.isEmbedFullWidthRows();
  21182. this.redrawAfterModelUpdate();
  21183. };
  21184. // in a clean design, each cell would register for each of these events. however when scrolling, all the cells
  21185. // registering and de-registering for events is a performance bottleneck. so we register here once and inform
  21186. // all active cells.
  21187. RowRenderer.prototype.registerCellEventListeners = function () {
  21188. var _this = this;
  21189. this.addManagedListener(this.eventService, Events.EVENT_CELL_FOCUSED, function (event) {
  21190. _this.forEachCellComp(function (cellComp) { return cellComp.onCellFocused(event); });
  21191. });
  21192. this.addManagedListener(this.eventService, Events.EVENT_FLASH_CELLS, function (event) {
  21193. _this.forEachCellComp(function (cellComp) { return cellComp.onFlashCells(event); });
  21194. });
  21195. this.addManagedListener(this.eventService, Events.EVENT_COLUMN_HOVER_CHANGED, function () {
  21196. _this.forEachCellComp(function (cellComp) { return cellComp.onColumnHover(); });
  21197. });
  21198. // only for printLayout - because we are rendering all the cells in the same row, regardless of pinned state,
  21199. // then changing the width of the containers will impact left position. eg the center cols all have their
  21200. // left position adjusted by the width of the left pinned column, so if the pinned left column width changes,
  21201. // all the center cols need to be shifted to accommodate this. when in normal layout, the pinned cols are
  21202. // in different containers so doesn't impact.
  21203. this.addManagedListener(this.eventService, Events.EVENT_DISPLAYED_COLUMNS_WIDTH_CHANGED, function () {
  21204. if (_this.printLayout) {
  21205. _this.forEachCellComp(function (cellComp) { return cellComp.onLeftChanged(); });
  21206. }
  21207. });
  21208. var rangeSelectionEnabled = this.gridOptionsWrapper.isEnableRangeSelection();
  21209. if (rangeSelectionEnabled) {
  21210. this.addManagedListener(this.eventService, Events.EVENT_RANGE_SELECTION_CHANGED, function () {
  21211. _this.forEachCellComp(function (cellComp) { return cellComp.onRangeSelectionChanged(); });
  21212. });
  21213. this.addManagedListener(this.eventService, Events.EVENT_COLUMN_MOVED, function () {
  21214. _this.forEachCellComp(function (cellComp) { return cellComp.updateRangeBordersIfRangeCount(); });
  21215. });
  21216. this.addManagedListener(this.eventService, Events.EVENT_COLUMN_PINNED, function () {
  21217. _this.forEachCellComp(function (cellComp) { return cellComp.updateRangeBordersIfRangeCount(); });
  21218. });
  21219. this.addManagedListener(this.eventService, Events.EVENT_COLUMN_VISIBLE, function () {
  21220. _this.forEachCellComp(function (cellComp) { return cellComp.updateRangeBordersIfRangeCount(); });
  21221. });
  21222. }
  21223. // add listeners to the grid columns
  21224. this.refreshListenersToColumnsForCellComps();
  21225. // if the grid columns change, then refresh the listeners again
  21226. this.addManagedListener(this.eventService, Events.EVENT_GRID_COLUMNS_CHANGED, this.refreshListenersToColumnsForCellComps.bind(this));
  21227. this.addDestroyFunc(this.removeGridColumnListeners.bind(this));
  21228. };
  21229. // executes all functions in destroyFuncsForColumnListeners and then clears the list
  21230. RowRenderer.prototype.removeGridColumnListeners = function () {
  21231. this.destroyFuncsForColumnListeners.forEach(function (func) { return func(); });
  21232. this.destroyFuncsForColumnListeners.length = 0;
  21233. };
  21234. // this function adds listeners onto all the grid columns, which are the column that we could have cellComps for.
  21235. // when the grid columns change, we add listeners again. in an ideal design, each CellComp would just register to
  21236. // the column it belongs to on creation, however this was a bottleneck with the number of cells, so do it here
  21237. // once instead.
  21238. RowRenderer.prototype.refreshListenersToColumnsForCellComps = function () {
  21239. var _this = this;
  21240. this.removeGridColumnListeners();
  21241. var cols = this.columnController.getAllGridColumns();
  21242. if (!cols) {
  21243. return;
  21244. }
  21245. cols.forEach(function (col) {
  21246. var forEachCellWithThisCol = function (callback) {
  21247. _this.forEachCellComp(function (cellComp) {
  21248. if (cellComp.getColumn() === col) {
  21249. callback(cellComp);
  21250. }
  21251. });
  21252. };
  21253. var leftChangedListener = function () {
  21254. forEachCellWithThisCol(function (cellComp) { return cellComp.onLeftChanged(); });
  21255. };
  21256. var widthChangedListener = function () {
  21257. forEachCellWithThisCol(function (cellComp) { return cellComp.onWidthChanged(); });
  21258. };
  21259. var firstRightPinnedChangedListener = function () {
  21260. forEachCellWithThisCol(function (cellComp) { return cellComp.onFirstRightPinnedChanged(); });
  21261. };
  21262. var lastLeftPinnedChangedListener = function () {
  21263. forEachCellWithThisCol(function (cellComp) { return cellComp.onLastLeftPinnedChanged(); });
  21264. };
  21265. col.addEventListener(Column.EVENT_LEFT_CHANGED, leftChangedListener);
  21266. col.addEventListener(Column.EVENT_WIDTH_CHANGED, widthChangedListener);
  21267. col.addEventListener(Column.EVENT_FIRST_RIGHT_PINNED_CHANGED, firstRightPinnedChangedListener);
  21268. col.addEventListener(Column.EVENT_LAST_LEFT_PINNED_CHANGED, lastLeftPinnedChangedListener);
  21269. _this.destroyFuncsForColumnListeners.push(function () {
  21270. col.removeEventListener(Column.EVENT_LEFT_CHANGED, leftChangedListener);
  21271. col.removeEventListener(Column.EVENT_WIDTH_CHANGED, widthChangedListener);
  21272. col.removeEventListener(Column.EVENT_FIRST_RIGHT_PINNED_CHANGED, firstRightPinnedChangedListener);
  21273. col.removeEventListener(Column.EVENT_LAST_LEFT_PINNED_CHANGED, lastLeftPinnedChangedListener);
  21274. });
  21275. });
  21276. };
  21277. RowRenderer.prototype.onDomLayoutChanged = function () {
  21278. var printLayout = this.gridOptionsWrapper.getDomLayout() === Constants.DOM_LAYOUT_PRINT;
  21279. var embedFullWidthRows = printLayout || this.gridOptionsWrapper.isEmbedFullWidthRows();
  21280. // if moving towards or away from print layout, means we need to destroy all rows, as rows are not laid
  21281. // out using absolute positioning when doing print layout
  21282. var destroyRows = embedFullWidthRows !== this.embedFullWidthRows || this.printLayout !== printLayout;
  21283. this.printLayout = printLayout;
  21284. this.embedFullWidthRows = embedFullWidthRows;
  21285. if (destroyRows) {
  21286. this.redrawAfterModelUpdate();
  21287. }
  21288. };
  21289. // for row models that have datasources, when we update the datasource, we need to force the rowRenderer
  21290. // to redraw all rows. otherwise the old rows from the old datasource will stay displayed.
  21291. RowRenderer.prototype.datasourceChanged = function () {
  21292. this.firstRenderedRow = 0;
  21293. this.lastRenderedRow = -1;
  21294. var rowIndexesToRemove = Object.keys(this.rowCompsByIndex);
  21295. this.removeRowComps(rowIndexesToRemove);
  21296. };
  21297. RowRenderer.prototype.onPageLoaded = function (refreshEvent) {
  21298. if (_.missing(refreshEvent)) {
  21299. refreshEvent = {
  21300. type: Events.EVENT_MODEL_UPDATED,
  21301. api: this.gridApi,
  21302. columnApi: this.columnApi,
  21303. animate: false,
  21304. keepRenderedRows: false,
  21305. newData: false,
  21306. newPage: false
  21307. };
  21308. }
  21309. this.onModelUpdated(refreshEvent);
  21310. };
  21311. RowRenderer.prototype.getAllCellsForColumn = function (column) {
  21312. var eCells = [];
  21313. function callback(key, rowComp) {
  21314. var eCell = rowComp.getCellForCol(column);
  21315. if (eCell) {
  21316. eCells.push(eCell);
  21317. }
  21318. }
  21319. _.iterateObject(this.rowCompsByIndex, callback);
  21320. _.iterateObject(this.floatingBottomRowComps, callback);
  21321. _.iterateObject(this.floatingTopRowComps, callback);
  21322. return eCells;
  21323. };
  21324. RowRenderer.prototype.refreshFloatingRowComps = function () {
  21325. this.refreshFloatingRows(this.floatingTopRowComps, this.pinnedRowModel.getPinnedTopRowData(), this.rowContainers.floatingTopPinnedLeft, this.rowContainers.floatingTopPinnedRight, this.rowContainers.floatingTop, this.rowContainers.floatingTopFullWidth);
  21326. this.refreshFloatingRows(this.floatingBottomRowComps, this.pinnedRowModel.getPinnedBottomRowData(), this.rowContainers.floatingBottomPinnedLeft, this.rowContainers.floatingBottomPinnedRight, this.rowContainers.floatingBottom, this.rowContainers.floatingBottomFullWidth);
  21327. };
  21328. RowRenderer.prototype.refreshFloatingRows = function (rowComps, rowNodes, pinnedLeftContainerComp, pinnedRightContainerComp, bodyContainerComp, fullWidthContainerComp) {
  21329. var _this = this;
  21330. rowComps.forEach(function (row) {
  21331. row.destroy();
  21332. });
  21333. rowComps.length = 0;
  21334. if (rowNodes) {
  21335. rowNodes.forEach(function (node) {
  21336. var rowComp = new RowComp(_this.$scope, bodyContainerComp, pinnedLeftContainerComp, pinnedRightContainerComp, fullWidthContainerComp, node, _this.beans, false, false, _this.printLayout, _this.embedFullWidthRows);
  21337. rowComp.init();
  21338. rowComps.push(rowComp);
  21339. });
  21340. }
  21341. this.flushContainers(rowComps);
  21342. };
  21343. RowRenderer.prototype.onPinnedRowDataChanged = function () {
  21344. // recycling rows in order to ensure cell editing is not cancelled
  21345. var params = {
  21346. recycleRows: true
  21347. };
  21348. this.redrawAfterModelUpdate(params);
  21349. };
  21350. RowRenderer.prototype.onModelUpdated = function (refreshEvent) {
  21351. var params = {
  21352. recycleRows: refreshEvent.keepRenderedRows,
  21353. animate: refreshEvent.animate,
  21354. newData: refreshEvent.newData,
  21355. newPage: refreshEvent.newPage,
  21356. // because this is a model updated event (not pinned rows), we
  21357. // can skip updating the pinned rows. this is needed so that if user
  21358. // is doing transaction updates, the pinned rows are not getting constantly
  21359. // trashed - or editing cells in pinned rows are not refreshed and put into read mode
  21360. onlyBody: true
  21361. };
  21362. this.redrawAfterModelUpdate(params);
  21363. };
  21364. // if the row nodes are not rendered, no index is returned
  21365. RowRenderer.prototype.getRenderedIndexesForRowNodes = function (rowNodes) {
  21366. var result = [];
  21367. if (_.missing(rowNodes)) {
  21368. return result;
  21369. }
  21370. _.iterateObject(this.rowCompsByIndex, function (index, renderedRow) {
  21371. var rowNode = renderedRow.getRowNode();
  21372. if (rowNodes.indexOf(rowNode) >= 0) {
  21373. result.push(index);
  21374. }
  21375. });
  21376. return result;
  21377. };
  21378. RowRenderer.prototype.redrawRows = function (rowNodes) {
  21379. if (!rowNodes || rowNodes.length == 0) {
  21380. return;
  21381. }
  21382. // we only need to be worried about rendered rows, as this method is
  21383. // called to what's rendered. if the row isn't rendered, we don't care
  21384. var indexesToRemove = this.getRenderedIndexesForRowNodes(rowNodes);
  21385. // remove the rows
  21386. this.removeRowComps(indexesToRemove);
  21387. // add draw them again
  21388. this.redrawAfterModelUpdate({
  21389. recycleRows: true
  21390. });
  21391. };
  21392. RowRenderer.prototype.getCellToRestoreFocusToAfterRefresh = function (params) {
  21393. var focusedCell = params.suppressKeepFocus ? null : this.focusController.getFocusCellToUseAfterRefresh();
  21394. if (_.missing(focusedCell)) {
  21395. return null;
  21396. }
  21397. // if the dom is not actually focused on a cell, then we don't try to refocus. the problem this
  21398. // solves is with editing - if the user is editing, eg focus is on a text field, and not on the
  21399. // cell itself, then the cell can be registered as having focus, however it's the text field that
  21400. // has the focus and not the cell div. therefore, when the refresh is finished, the grid will focus
  21401. // the cell, and not the textfield. that means if the user is in a text field, and the grid refreshes,
  21402. // the focus is lost from the text field. we do not want this.
  21403. var activeElement = document.activeElement;
  21404. var domData = this.gridOptionsWrapper.getDomData(activeElement, CellComp.DOM_DATA_KEY_CELL_COMP);
  21405. var elementIsNotACellDev = _.missing(domData);
  21406. return elementIsNotACellDev ? null : focusedCell;
  21407. };
  21408. // gets called after changes to the model.
  21409. RowRenderer.prototype.redrawAfterModelUpdate = function (params) {
  21410. if (params === void 0) { params = {}; }
  21411. this.getLockOnRefresh();
  21412. var focusedCell = this.getCellToRestoreFocusToAfterRefresh(params);
  21413. this.sizeContainerToPageHeight();
  21414. this.scrollToTopIfNewData(params);
  21415. // never recycle rows when print layout, we draw each row again from scratch. this is because print layout
  21416. // uses normal dom layout to put cells into dom - it doesn't allow reordering rows.
  21417. var recycleRows = !this.printLayout && params.recycleRows;
  21418. var animate = params.animate && this.gridOptionsWrapper.isAnimateRows();
  21419. var rowsToRecycle = this.binRowComps(recycleRows);
  21420. this.redraw(rowsToRecycle, animate);
  21421. if (!params.onlyBody) {
  21422. this.refreshFloatingRowComps();
  21423. }
  21424. this.restoreFocusedCell(focusedCell);
  21425. this.releaseLockOnRefresh();
  21426. };
  21427. RowRenderer.prototype.scrollToTopIfNewData = function (params) {
  21428. var scrollToTop = params.newData || params.newPage;
  21429. var suppressScrollToTop = this.gridOptionsWrapper.isSuppressScrollOnNewData();
  21430. if (scrollToTop && !suppressScrollToTop) {
  21431. this.gridPanel.scrollToTop();
  21432. }
  21433. };
  21434. RowRenderer.prototype.sizeContainerToPageHeight = function () {
  21435. var containers = [
  21436. this.rowContainers.body,
  21437. this.rowContainers.fullWidth,
  21438. this.rowContainers.pinnedLeft,
  21439. this.rowContainers.pinnedRight
  21440. ];
  21441. if (this.printLayout) {
  21442. containers.forEach(function (container) { return container.setHeight(null); });
  21443. return;
  21444. }
  21445. var containerHeight = this.paginationProxy.getCurrentPageHeight();
  21446. // we need at least 1 pixel for the horizontal scroll to work. so if there are now rows,
  21447. // we still want the scroll to be present, otherwise there would be no way to scroll the header
  21448. // which might be needed us user wants to access columns
  21449. // on the RHS - and if that was where the filter was that cause no rows to be presented, there
  21450. // is no way to remove the filter.
  21451. if (containerHeight === 0) {
  21452. containerHeight = 1;
  21453. }
  21454. this.maxDivHeightScaler.setModelHeight(containerHeight);
  21455. var realHeight = this.maxDivHeightScaler.getUiContainerHeight();
  21456. containers.forEach(function (container) { return container.setHeight(realHeight); });
  21457. };
  21458. RowRenderer.prototype.getLockOnRefresh = function () {
  21459. if (this.refreshInProgress) {
  21460. throw new Error("ag-Grid: cannot get grid to draw rows when it is in the middle of drawing rows. " +
  21461. "Your code probably called a grid API method while the grid was in the render stage. To overcome " +
  21462. "this, put the API call into a timeout, eg instead of api.refreshView(), " +
  21463. "call setTimeout(function(){api.refreshView(),0}). To see what part of your code " +
  21464. "that caused the refresh check this stacktrace.");
  21465. }
  21466. this.refreshInProgress = true;
  21467. };
  21468. RowRenderer.prototype.releaseLockOnRefresh = function () {
  21469. this.refreshInProgress = false;
  21470. };
  21471. // sets the focus to the provided cell, if the cell is provided. this way, the user can call refresh without
  21472. // worry about the focus been lost. this is important when the user is using keyboard navigation to do edits
  21473. // and the cellEditor is calling 'refresh' to get other cells to update (as other cells might depend on the
  21474. // edited cell).
  21475. RowRenderer.prototype.restoreFocusedCell = function (cellPosition) {
  21476. if (cellPosition) {
  21477. this.focusController.setFocusedCell(cellPosition.rowIndex, cellPosition.column, cellPosition.rowPinned, true);
  21478. }
  21479. };
  21480. RowRenderer.prototype.stopEditing = function (cancel) {
  21481. if (cancel === void 0) { cancel = false; }
  21482. this.forEachRowComp(function (key, rowComp) {
  21483. rowComp.stopEditing(cancel);
  21484. });
  21485. };
  21486. RowRenderer.prototype.forEachCellComp = function (callback) {
  21487. this.forEachRowComp(function (key, rowComp) { return rowComp.forEachCellComp(callback); });
  21488. };
  21489. RowRenderer.prototype.forEachRowComp = function (callback) {
  21490. _.iterateObject(this.rowCompsByIndex, callback);
  21491. _.iterateObject(this.floatingTopRowComps, callback);
  21492. _.iterateObject(this.floatingBottomRowComps, callback);
  21493. };
  21494. RowRenderer.prototype.addRenderedRowListener = function (eventName, rowIndex, callback) {
  21495. var rowComp = this.rowCompsByIndex[rowIndex];
  21496. if (rowComp) {
  21497. rowComp.addEventListener(eventName, callback);
  21498. }
  21499. };
  21500. RowRenderer.prototype.flashCells = function (params) {
  21501. if (params === void 0) { params = {}; }
  21502. var flashDelay = params.flashDelay, fadeDelay = params.fadeDelay;
  21503. this.forEachCellCompFiltered(params.rowNodes, params.columns, function (cellComp) { return cellComp.flashCell({ flashDelay: flashDelay, fadeDelay: fadeDelay }); });
  21504. };
  21505. RowRenderer.prototype.refreshCells = function (params) {
  21506. if (params === void 0) { params = {}; }
  21507. var refreshCellParams = {
  21508. forceRefresh: params.force,
  21509. newData: false,
  21510. suppressFlash: params.suppressFlash
  21511. };
  21512. this.forEachCellCompFiltered(params.rowNodes, params.columns, function (cellComp) { return cellComp.refreshCell(refreshCellParams); });
  21513. };
  21514. RowRenderer.prototype.getCellRendererInstances = function (params) {
  21515. var res = [];
  21516. this.forEachCellCompFiltered(params.rowNodes, params.columns, function (cellComp) {
  21517. var cellRenderer = cellComp.getCellRenderer();
  21518. if (cellRenderer) {
  21519. res.push(cellRenderer);
  21520. }
  21521. });
  21522. return res;
  21523. };
  21524. RowRenderer.prototype.getCellEditorInstances = function (params) {
  21525. var res = [];
  21526. this.forEachCellCompFiltered(params.rowNodes, params.columns, function (cellComp) {
  21527. var cellEditor = cellComp.getCellEditor();
  21528. if (cellEditor) {
  21529. res.push(cellEditor);
  21530. }
  21531. });
  21532. return res;
  21533. };
  21534. RowRenderer.prototype.getEditingCells = function () {
  21535. var res = [];
  21536. this.forEachCellComp(function (cellComp) {
  21537. if (cellComp.isEditing()) {
  21538. var cellPosition = cellComp.getCellPosition();
  21539. res.push(cellPosition);
  21540. }
  21541. });
  21542. return res;
  21543. };
  21544. // calls the callback for each cellComp that match the provided rowNodes and columns. eg if one row node
  21545. // and two columns provided, that identifies 4 cells, so callback gets called 4 times, once for each cell.
  21546. RowRenderer.prototype.forEachCellCompFiltered = function (rowNodes, columns, callback) {
  21547. var _this = this;
  21548. var rowIdsMap;
  21549. if (_.exists(rowNodes)) {
  21550. rowIdsMap = {
  21551. top: {},
  21552. bottom: {},
  21553. normal: {}
  21554. };
  21555. rowNodes.forEach(function (rowNode) {
  21556. if (rowNode.rowPinned === Constants.PINNED_TOP) {
  21557. rowIdsMap.top[rowNode.id] = true;
  21558. }
  21559. else if (rowNode.rowPinned === Constants.PINNED_BOTTOM) {
  21560. rowIdsMap.bottom[rowNode.id] = true;
  21561. }
  21562. else {
  21563. rowIdsMap.normal[rowNode.id] = true;
  21564. }
  21565. });
  21566. }
  21567. var colIdsMap;
  21568. if (_.exists(columns)) {
  21569. colIdsMap = {};
  21570. columns.forEach(function (colKey) {
  21571. var column = _this.columnController.getGridColumn(colKey);
  21572. if (_.exists(column)) {
  21573. colIdsMap[column.getId()] = true;
  21574. }
  21575. });
  21576. }
  21577. var processRow = function (rowComp) {
  21578. var rowNode = rowComp.getRowNode();
  21579. var id = rowNode.id;
  21580. var floating = rowNode.rowPinned;
  21581. // skip this row if it is missing from the provided list
  21582. if (_.exists(rowIdsMap)) {
  21583. if (floating === Constants.PINNED_BOTTOM) {
  21584. if (!rowIdsMap.bottom[id]) {
  21585. return;
  21586. }
  21587. }
  21588. else if (floating === Constants.PINNED_TOP) {
  21589. if (!rowIdsMap.top[id]) {
  21590. return;
  21591. }
  21592. }
  21593. else {
  21594. if (!rowIdsMap.normal[id]) {
  21595. return;
  21596. }
  21597. }
  21598. }
  21599. rowComp.forEachCellComp(function (cellComp) {
  21600. var colId = cellComp.getColumn().getId();
  21601. var excludeColFromRefresh = colIdsMap && !colIdsMap[colId];
  21602. if (excludeColFromRefresh) {
  21603. return;
  21604. }
  21605. callback(cellComp);
  21606. });
  21607. };
  21608. _.iterateObject(this.rowCompsByIndex, function (index, rowComp) {
  21609. processRow(rowComp);
  21610. });
  21611. if (this.floatingTopRowComps) {
  21612. this.floatingTopRowComps.forEach(processRow);
  21613. }
  21614. if (this.floatingBottomRowComps) {
  21615. this.floatingBottomRowComps.forEach(processRow);
  21616. }
  21617. };
  21618. RowRenderer.prototype.destroy = function () {
  21619. var rowIndexesToRemove = Object.keys(this.rowCompsByIndex);
  21620. this.removeRowComps(rowIndexesToRemove);
  21621. _super.prototype.destroy.call(this);
  21622. };
  21623. RowRenderer.prototype.binRowComps = function (recycleRows) {
  21624. var _this = this;
  21625. var rowsToRecycle = {};
  21626. var indexesToRemove;
  21627. if (recycleRows) {
  21628. indexesToRemove = [];
  21629. _.iterateObject(this.rowCompsByIndex, function (index, rowComp) {
  21630. var rowNode = rowComp.getRowNode();
  21631. if (_.exists(rowNode.id)) {
  21632. rowsToRecycle[rowNode.id] = rowComp;
  21633. delete _this.rowCompsByIndex[index];
  21634. }
  21635. else {
  21636. indexesToRemove.push(index);
  21637. }
  21638. });
  21639. }
  21640. else {
  21641. indexesToRemove = Object.keys(this.rowCompsByIndex);
  21642. }
  21643. this.removeRowComps(indexesToRemove);
  21644. return rowsToRecycle;
  21645. };
  21646. // takes array of row indexes
  21647. RowRenderer.prototype.removeRowComps = function (rowsToRemove) {
  21648. var _this = this;
  21649. // if no fromIndex then set to -1, which will refresh everything
  21650. // let realFromIndex = -1;
  21651. rowsToRemove.forEach(function (indexToRemove) {
  21652. var renderedRow = _this.rowCompsByIndex[indexToRemove];
  21653. renderedRow.destroy();
  21654. delete _this.rowCompsByIndex[indexToRemove];
  21655. });
  21656. };
  21657. // gets called when rows don't change, but viewport does, so after:
  21658. // 1) height of grid body changes, ie number of displayed rows has changed
  21659. // 2) grid scrolled to new position
  21660. // 3) ensure index visible (which is a scroll)
  21661. RowRenderer.prototype.redrawAfterScroll = function () {
  21662. this.getLockOnRefresh();
  21663. this.redraw(null, false, true);
  21664. this.releaseLockOnRefresh();
  21665. };
  21666. RowRenderer.prototype.removeRowCompsNotToDraw = function (indexesToDraw) {
  21667. // for speedy lookup, dump into map
  21668. var indexesToDrawMap = {};
  21669. indexesToDraw.forEach(function (index) { return (indexesToDrawMap[index] = true); });
  21670. var existingIndexes = Object.keys(this.rowCompsByIndex);
  21671. var indexesNotToDraw = existingIndexes.filter(function (index) { return !indexesToDrawMap[index]; });
  21672. this.removeRowComps(indexesNotToDraw);
  21673. };
  21674. RowRenderer.prototype.calculateIndexesToDraw = function (rowsToRecycle) {
  21675. var _this = this;
  21676. // all in all indexes in the viewport
  21677. var indexesToDraw = _.createArrayOfNumbers(this.firstRenderedRow, this.lastRenderedRow);
  21678. var checkRowToDraw = function (indexStr, rowComp) {
  21679. var index = Number(indexStr);
  21680. if (index < _this.firstRenderedRow || index > _this.lastRenderedRow) {
  21681. if (_this.doNotUnVirtualiseRow(rowComp)) {
  21682. indexesToDraw.push(index);
  21683. }
  21684. }
  21685. };
  21686. // if we are redrawing due to scrolling change, then old rows are in this.rowCompsByIndex
  21687. _.iterateObject(this.rowCompsByIndex, checkRowToDraw);
  21688. // if we are redrawing due to model update, then old rows are in rowsToRecycle
  21689. _.iterateObject(rowsToRecycle, checkRowToDraw);
  21690. indexesToDraw.sort(function (a, b) { return a - b; });
  21691. return indexesToDraw;
  21692. };
  21693. RowRenderer.prototype.redraw = function (rowsToRecycle, animate, afterScroll) {
  21694. var _this = this;
  21695. if (animate === void 0) { animate = false; }
  21696. if (afterScroll === void 0) { afterScroll = false; }
  21697. this.maxDivHeightScaler.updateOffset();
  21698. this.workOutFirstAndLastRowsToRender();
  21699. // the row can already exist and be in the following:
  21700. // rowsToRecycle -> if model change, then the index may be different, however row may
  21701. // exist here from previous time (mapped by id).
  21702. // this.rowCompsByIndex -> if just a scroll, then this will contain what is currently in the viewport
  21703. // this is all the indexes we want, including those that already exist, so this method
  21704. // will end up going through each index and drawing only if the row doesn't already exist
  21705. var indexesToDraw = this.calculateIndexesToDraw(rowsToRecycle);
  21706. this.removeRowCompsNotToDraw(indexesToDraw);
  21707. // never animate when doing print layout - as we want to get things ready to print as quickly as possible,
  21708. // otherwise we risk the printer printing a row that's half faded (half way through fading in)
  21709. if (this.printLayout) {
  21710. animate = false;
  21711. }
  21712. // add in new rows
  21713. var nextVmTurnFunctions = [];
  21714. var rowComps = [];
  21715. indexesToDraw.forEach(function (rowIndex) {
  21716. var rowComp = _this.createOrUpdateRowComp(rowIndex, rowsToRecycle, animate, afterScroll);
  21717. if (_.exists(rowComp)) {
  21718. rowComps.push(rowComp);
  21719. _.pushAll(nextVmTurnFunctions, rowComp.getAndClearNextVMTurnFunctions());
  21720. }
  21721. });
  21722. this.flushContainers(rowComps);
  21723. _.executeNextVMTurn(nextVmTurnFunctions);
  21724. var useAnimationFrame = afterScroll && !this.gridOptionsWrapper.isSuppressAnimationFrame() && !this.printLayout;
  21725. if (useAnimationFrame) {
  21726. this.beans.taskQueue.addDestroyTask(this.destroyRowComps.bind(this, rowsToRecycle, animate));
  21727. }
  21728. else {
  21729. this.destroyRowComps(rowsToRecycle, animate);
  21730. }
  21731. this.checkAngularCompile();
  21732. this.gridPanel.updateRowCount();
  21733. };
  21734. RowRenderer.prototype.flushContainers = function (rowComps) {
  21735. _.iterateObject(this.rowContainers, function (key, rowContainerComp) {
  21736. if (rowContainerComp) {
  21737. rowContainerComp.flushRowTemplates();
  21738. }
  21739. });
  21740. rowComps.forEach(function (rowComp) { return rowComp.afterFlush(); });
  21741. };
  21742. RowRenderer.prototype.onDisplayedColumnsChanged = function () {
  21743. var pinningLeft = this.columnController.isPinningLeft();
  21744. var pinningRight = this.columnController.isPinningRight();
  21745. var atLeastOneChanged = this.pinningLeft !== pinningLeft || pinningRight !== this.pinningRight;
  21746. if (atLeastOneChanged) {
  21747. this.pinningLeft = pinningLeft;
  21748. this.pinningRight = pinningRight;
  21749. if (this.embedFullWidthRows) {
  21750. this.redrawFullWidthEmbeddedRows();
  21751. }
  21752. }
  21753. };
  21754. // when embedding, what gets showed in each section depends on what is pinned. eg if embedding group expand / collapse,
  21755. // then it should go into the pinned left area if pinning left, or the center area if not pinning.
  21756. RowRenderer.prototype.redrawFullWidthEmbeddedRows = function () {
  21757. // if either of the pinned panels has shown / hidden, then need to redraw the fullWidth bits when
  21758. // embedded, as what appears in each section depends on whether we are pinned or not
  21759. var rowsToRemove = [];
  21760. _.iterateObject(this.rowCompsByIndex, function (id, rowComp) {
  21761. if (rowComp.isFullWidth()) {
  21762. var rowIndex = rowComp.getRowNode().rowIndex;
  21763. rowsToRemove.push(rowIndex.toString());
  21764. }
  21765. });
  21766. this.refreshFloatingRowComps();
  21767. this.removeRowComps(rowsToRemove);
  21768. this.redrawAfterScroll();
  21769. };
  21770. RowRenderer.prototype.refreshFullWidthRows = function () {
  21771. var rowsToRemove = [];
  21772. _.iterateObject(this.rowCompsByIndex, function (id, rowComp) {
  21773. if (rowComp.isFullWidth()) {
  21774. var fullWidthRowsRefreshed = rowComp.refreshFullWidth();
  21775. if (!fullWidthRowsRefreshed) {
  21776. var rowIndex = rowComp.getRowNode().rowIndex;
  21777. rowsToRemove.push(rowIndex.toString());
  21778. }
  21779. }
  21780. });
  21781. this.removeRowComps(rowsToRemove);
  21782. this.redrawAfterScroll();
  21783. };
  21784. RowRenderer.prototype.createOrUpdateRowComp = function (rowIndex, rowsToRecycle, animate, afterScroll) {
  21785. var rowNode;
  21786. var rowComp = this.rowCompsByIndex[rowIndex];
  21787. // if no row comp, see if we can get it from the previous rowComps
  21788. if (!rowComp) {
  21789. rowNode = this.paginationProxy.getRow(rowIndex);
  21790. if (_.exists(rowNode) && _.exists(rowsToRecycle) && rowsToRecycle[rowNode.id] && rowNode.alreadyRendered) {
  21791. rowComp = rowsToRecycle[rowNode.id];
  21792. rowsToRecycle[rowNode.id] = null;
  21793. }
  21794. }
  21795. var creatingNewRowComp = !rowComp;
  21796. if (creatingNewRowComp) {
  21797. // create a new one
  21798. if (!rowNode) {
  21799. rowNode = this.paginationProxy.getRow(rowIndex);
  21800. }
  21801. if (_.exists(rowNode)) {
  21802. rowComp = this.createRowComp(rowNode, animate, afterScroll);
  21803. }
  21804. else {
  21805. // this should never happen - if somehow we are trying to create
  21806. // a row for a rowNode that does not exist.
  21807. return;
  21808. }
  21809. }
  21810. else {
  21811. // ensure row comp is in right position in DOM
  21812. rowComp.ensureDomOrder();
  21813. }
  21814. if (rowNode) {
  21815. // set node as 'alreadyRendered' to ensure we only recycle rowComps that have been rendered, this ensures
  21816. // we don't reuse rowComps that have been removed and then re-added in the same batch transaction.
  21817. rowNode.alreadyRendered = true;
  21818. }
  21819. this.rowCompsByIndex[rowIndex] = rowComp;
  21820. return rowComp;
  21821. };
  21822. RowRenderer.prototype.destroyRowComps = function (rowCompsMap, animate) {
  21823. var delayedFuncs = [];
  21824. _.iterateObject(rowCompsMap, function (nodeId, rowComp) {
  21825. // if row was used, then it's null
  21826. if (!rowComp) {
  21827. return;
  21828. }
  21829. rowComp.destroy(animate);
  21830. _.pushAll(delayedFuncs, rowComp.getAndClearDelayedDestroyFunctions());
  21831. });
  21832. _.executeInAWhile(delayedFuncs);
  21833. };
  21834. RowRenderer.prototype.checkAngularCompile = function () {
  21835. var _this = this;
  21836. // if we are doing angular compiling, then do digest the scope here
  21837. if (this.gridOptionsWrapper.isAngularCompileRows()) {
  21838. // we do it in a timeout, in case we are already in an apply
  21839. window.setTimeout(function () {
  21840. _this.$scope.$apply();
  21841. }, 0);
  21842. }
  21843. };
  21844. RowRenderer.prototype.workOutFirstAndLastRowsToRender = function () {
  21845. var _this = this;
  21846. var newFirst;
  21847. var newLast;
  21848. if (!this.paginationProxy.isRowsToRender()) {
  21849. newFirst = 0;
  21850. newLast = -1; // setting to -1 means nothing in range
  21851. }
  21852. else if (this.printLayout) {
  21853. newFirst = this.paginationProxy.getPageFirstRow();
  21854. newLast = this.paginationProxy.getPageLastRow();
  21855. }
  21856. else {
  21857. var paginationOffset = this.paginationProxy.getPixelOffset();
  21858. var maxDivHeightScaler = this.maxDivHeightScaler.getOffset();
  21859. var bodyVRange = this.gridPanel.getVScrollPosition();
  21860. var bodyTopPixel = bodyVRange.top;
  21861. var bodyBottomPixel = bodyVRange.bottom;
  21862. var bufferPixels = this.gridOptionsWrapper.getRowBufferInPixels();
  21863. var firstPixel = bodyTopPixel + paginationOffset + maxDivHeightScaler - bufferPixels;
  21864. var lastPixel = bodyBottomPixel + paginationOffset + maxDivHeightScaler + bufferPixels;
  21865. this.ensureAllRowsInRangeHaveHeightsCalculated(firstPixel, lastPixel);
  21866. var firstRowIndex = this.paginationProxy.getRowIndexAtPixel(firstPixel);
  21867. var lastRowIndex = this.paginationProxy.getRowIndexAtPixel(lastPixel);
  21868. var pageFirstRow = this.paginationProxy.getPageFirstRow();
  21869. var pageLastRow = this.paginationProxy.getPageLastRow();
  21870. // adjust, in case buffer extended actual size
  21871. if (firstRowIndex < pageFirstRow) {
  21872. firstRowIndex = pageFirstRow;
  21873. }
  21874. if (lastRowIndex > pageLastRow) {
  21875. lastRowIndex = pageLastRow;
  21876. }
  21877. newFirst = firstRowIndex;
  21878. newLast = lastRowIndex;
  21879. }
  21880. // sometimes user doesn't set CSS right and ends up with grid with no height and grid ends up
  21881. // trying to render all the rows, eg 10,000+ rows. this will kill the browser. so instead of
  21882. // killing the browser, we limit the number of rows. just in case some use case we didn't think
  21883. // of, we also have a property to not do this operation.
  21884. var rowLayoutNormal = this.gridOptionsWrapper.getDomLayout() === Constants.DOM_LAYOUT_NORMAL;
  21885. var suppressRowCountRestriction = this.gridOptionsWrapper.isSuppressMaxRenderedRowRestriction();
  21886. var rowBufferMaxSize = Math.max(this.gridOptionsWrapper.getRowBuffer(), 500);
  21887. if (rowLayoutNormal && !suppressRowCountRestriction) {
  21888. if (newLast - newFirst > rowBufferMaxSize) {
  21889. newLast = newFirst + rowBufferMaxSize;
  21890. }
  21891. }
  21892. var firstDiffers = newFirst !== this.firstRenderedRow;
  21893. var lastDiffers = newLast !== this.lastRenderedRow;
  21894. if (firstDiffers || lastDiffers) {
  21895. this.firstRenderedRow = newFirst;
  21896. this.lastRenderedRow = newLast;
  21897. var event_1 = {
  21898. type: Events.EVENT_VIEWPORT_CHANGED,
  21899. firstRow: newFirst,
  21900. lastRow: newLast,
  21901. api: this.gridApi,
  21902. columnApi: this.columnApi
  21903. };
  21904. this.eventService.dispatchEvent(event_1);
  21905. }
  21906. // only dispatch firstDataRendered if we have actually rendered some data
  21907. if (this.paginationProxy.isRowsToRender()) {
  21908. var event_2 = {
  21909. type: Events.EVENT_FIRST_DATA_RENDERED,
  21910. firstRow: newFirst,
  21911. lastRow: newLast,
  21912. api: this.gridApi,
  21913. columnApi: this.columnApi
  21914. };
  21915. // added a small delay here because in some scenarios this can be fired
  21916. // before the grid is actually rendered, causing component creation
  21917. // on EVENT_FIRST_DATA_RENDERED to fail.
  21918. window.setTimeout(function () { return _this.eventService.dispatchEventOnce(event_2); }, 50);
  21919. }
  21920. };
  21921. RowRenderer.prototype.ensureAllRowsInRangeHaveHeightsCalculated = function (topPixel, bottomPixel) {
  21922. // ensureRowHeightsVisible only works with CSRM, as it's the only row model that allows lazy row height calcs.
  21923. // all the other row models just hard code so the method just returns back false
  21924. var rowHeightsChanged = this.paginationProxy.ensureRowHeightsValid(topPixel, bottomPixel, -1, -1);
  21925. if (rowHeightsChanged) {
  21926. // if row heights have changed, we need to resize the containers the rows sit it
  21927. this.sizeContainerToPageHeight();
  21928. // we also need to update heightScaler as this has dependency of row container height
  21929. this.maxDivHeightScaler.updateOffset();
  21930. }
  21931. };
  21932. RowRenderer.prototype.getFirstVirtualRenderedRow = function () {
  21933. return this.firstRenderedRow;
  21934. };
  21935. RowRenderer.prototype.getLastVirtualRenderedRow = function () {
  21936. return this.lastRenderedRow;
  21937. };
  21938. // check that none of the rows to remove are editing or focused as:
  21939. // a) if editing, we want to keep them, otherwise the user will loose the context of the edit,
  21940. // eg user starts editing, enters some text, then scrolls down and then up, next time row rendered
  21941. // the edit is reset - so we want to keep it rendered.
  21942. // b) if focused, we want ot keep keyboard focus, so if user ctrl+c, it goes to clipboard,
  21943. // otherwise the user can range select and drag (with focus cell going out of the viewport)
  21944. // and then ctrl+c, nothing will happen if cell is removed from dom.
  21945. // c) if detail record of master detail, as users complained that the context of detail rows
  21946. // was getting lost when detail row out of view. eg user expands to show detail row,
  21947. // then manipulates the detail panel (eg sorts the detail grid), then context is lost
  21948. // after detail panel is scrolled out of / into view.
  21949. RowRenderer.prototype.doNotUnVirtualiseRow = function (rowComp) {
  21950. var REMOVE_ROW = false;
  21951. var KEEP_ROW = true;
  21952. var rowNode = rowComp.getRowNode();
  21953. var rowHasFocus = this.focusController.isRowNodeFocused(rowNode);
  21954. var rowIsEditing = rowComp.isEditing();
  21955. var rowIsDetail = rowNode.detail;
  21956. var mightWantToKeepRow = rowHasFocus || rowIsEditing || rowIsDetail;
  21957. // if we deffo don't want to keep it,
  21958. if (!mightWantToKeepRow) {
  21959. return REMOVE_ROW;
  21960. }
  21961. // editing row, only remove if it is no longer rendered, eg filtered out or new data set.
  21962. // the reason we want to keep is if user is scrolling up and down, we don't want to loose
  21963. // the context of the editing in process.
  21964. var rowNodePresent = this.paginationProxy.isRowPresent(rowNode);
  21965. return rowNodePresent ? KEEP_ROW : REMOVE_ROW;
  21966. };
  21967. RowRenderer.prototype.createRowComp = function (rowNode, animate, afterScroll) {
  21968. var suppressAnimationFrame = this.gridOptionsWrapper.isSuppressAnimationFrame();
  21969. // we don't use animations frames for printing, so the user can put the grid into print mode
  21970. // and immediately print - otherwise the user would have to wait for the rows to draw in the background
  21971. // (via the animation frames) which is awkward to do from code.
  21972. // we only do the animation frames after scrolling, as this is where we want the smooth user experience.
  21973. // having animation frames for other times makes the grid look 'jumpy'.
  21974. var useAnimationFrameForCreate = afterScroll && !suppressAnimationFrame && !this.printLayout;
  21975. var rowComp = new RowComp(this.$scope, this.rowContainers.body, this.rowContainers.pinnedLeft, this.rowContainers.pinnedRight, this.rowContainers.fullWidth, rowNode, this.beans, animate, useAnimationFrameForCreate, this.printLayout, this.embedFullWidthRows);
  21976. rowComp.init();
  21977. return rowComp;
  21978. };
  21979. RowRenderer.prototype.getRenderedNodes = function () {
  21980. var renderedRows = this.rowCompsByIndex;
  21981. return Object.keys(renderedRows).map(function (key) { return renderedRows[key].getRowNode(); });
  21982. };
  21983. // we use index for rows, but column object for columns, as the next column (by index) might not
  21984. // be visible (header grouping) so it's not reliable, so using the column object instead.
  21985. RowRenderer.prototype.navigateToNextCell = function (event, key, currentCell, allowUserOverride) {
  21986. // we keep searching for a next cell until we find one. this is how the group rows get skipped
  21987. var nextCell = currentCell;
  21988. var hitEdgeOfGrid = false;
  21989. while (nextCell && (nextCell === currentCell || !this.isValidNavigateCell(nextCell))) {
  21990. // if the current cell is spanning across multiple columns, we need to move
  21991. // our current position to be the last cell on the right before finding the
  21992. // the next target.
  21993. if (this.gridOptionsWrapper.isEnableRtl()) {
  21994. if (key === Constants.KEY_LEFT) {
  21995. nextCell = this.getLastCellOfColSpan(nextCell);
  21996. }
  21997. }
  21998. else if (key === Constants.KEY_RIGHT) {
  21999. nextCell = this.getLastCellOfColSpan(nextCell);
  22000. }
  22001. nextCell = this.cellNavigationService.getNextCellToFocus(key, nextCell);
  22002. // eg if going down, and nextCell=undefined, means we are gone past the last row
  22003. hitEdgeOfGrid = _.missing(nextCell);
  22004. }
  22005. if (hitEdgeOfGrid && event.keyCode === Constants.KEY_UP) {
  22006. nextCell = {
  22007. rowIndex: -1,
  22008. rowPinned: null,
  22009. column: currentCell.column
  22010. };
  22011. }
  22012. // allow user to override what cell to go to next. when doing normal cell navigation (with keys)
  22013. // we allow this, however if processing 'enter after edit' we don't allow override
  22014. if (allowUserOverride) {
  22015. var userFunc = this.gridOptionsWrapper.getNavigateToNextCellFunc();
  22016. if (_.exists(userFunc)) {
  22017. var params = {
  22018. key: key,
  22019. previousCellPosition: currentCell,
  22020. nextCellPosition: nextCell ? nextCell : null,
  22021. event: event
  22022. };
  22023. var userCell = userFunc(params);
  22024. if (_.exists(userCell)) {
  22025. if (userCell.floating) {
  22026. _.doOnce(function () { console.warn("ag-Grid: tabToNextCellFunc return type should have attributes: rowIndex, rowPinned, column. However you had 'floating', maybe you meant 'rowPinned'?"); }, 'no floating in userCell');
  22027. userCell.rowPinned = userCell.floating;
  22028. }
  22029. nextCell = {
  22030. rowPinned: userCell.rowPinned,
  22031. rowIndex: userCell.rowIndex,
  22032. column: userCell.column
  22033. };
  22034. }
  22035. else {
  22036. nextCell = null;
  22037. }
  22038. }
  22039. }
  22040. // no next cell means we have reached a grid boundary, eg left, right, top or bottom of grid
  22041. if (!nextCell) {
  22042. return;
  22043. }
  22044. if (nextCell.rowIndex < 0) {
  22045. var headerLen = this.beans.headerNavigationService.getHeaderRowCount();
  22046. this.focusController.focusHeaderPosition({
  22047. headerRowIndex: headerLen + (nextCell.rowIndex), column: currentCell.column
  22048. });
  22049. return;
  22050. }
  22051. // in case we have col spanning we get the cellComp and use it to
  22052. // get the position. This was we always focus the first cell inside
  22053. // the spanning.
  22054. this.ensureCellVisible(nextCell); // ensureCellVisible first, to make sure nextCell is rendered
  22055. var cellComp = this.getComponentForCell(nextCell);
  22056. // not guaranteed to have a cellComp when using the SSRM as blocks are loading.
  22057. if (!cellComp) {
  22058. return;
  22059. }
  22060. nextCell = cellComp.getCellPosition();
  22061. // we call this again, as nextCell can be different to it's previous value due to Column Spanning
  22062. // (ie if cursor moving from right to left, and cell is spanning columns, then nextCell was the
  22063. // last column in the group, however now it's the first column in the group). if we didn't do
  22064. // ensureCellVisible again, then we could only be showing the last portion (last column) of the
  22065. // merged cells.
  22066. this.ensureCellVisible(nextCell);
  22067. this.focusController.setFocusedCell(nextCell.rowIndex, nextCell.column, nextCell.rowPinned, true);
  22068. if (this.rangeController) {
  22069. this.rangeController.setRangeToCell(nextCell);
  22070. }
  22071. };
  22072. RowRenderer.prototype.isValidNavigateCell = function (cell) {
  22073. var rowNode = this.rowPositionUtils.getRowNode(cell);
  22074. // we do not allow focusing on detail rows and full width rows
  22075. if (rowNode.detail || rowNode.isFullWidthCell()) {
  22076. return false;
  22077. }
  22078. // if not a group, then we have a valid row, so quit the search
  22079. if (!rowNode.group) {
  22080. return true;
  22081. }
  22082. // full width rows cannot be focused, so if it's a group and using full width rows,
  22083. // we need to skip over the row
  22084. var pivotMode = this.columnController.isPivotMode();
  22085. var usingFullWidthRows = this.gridOptionsWrapper.isGroupUseEntireRow(pivotMode);
  22086. if (!usingFullWidthRows) {
  22087. return true;
  22088. }
  22089. return false;
  22090. };
  22091. RowRenderer.prototype.getLastCellOfColSpan = function (cell) {
  22092. var cellComp = this.getComponentForCell(cell);
  22093. if (!cellComp) {
  22094. return cell;
  22095. }
  22096. var colSpanningList = cellComp.getColSpanningList();
  22097. if (colSpanningList.length === 1) {
  22098. return cell;
  22099. }
  22100. return {
  22101. rowIndex: cell.rowIndex,
  22102. column: _.last(colSpanningList),
  22103. rowPinned: cell.rowPinned
  22104. };
  22105. };
  22106. RowRenderer.prototype.ensureCellVisible = function (gridCell) {
  22107. // this scrolls the row into view
  22108. if (_.missing(gridCell.rowPinned)) {
  22109. this.gridPanel.ensureIndexVisible(gridCell.rowIndex);
  22110. }
  22111. if (!gridCell.column.isPinned()) {
  22112. this.gridPanel.ensureColumnVisible(gridCell.column);
  22113. }
  22114. // need to nudge the scrolls for the floating items. otherwise when we set focus on a non-visible
  22115. // floating cell, the scrolls get out of sync
  22116. this.gridPanel.horizontallyScrollHeaderCenterAndFloatingCenter();
  22117. // need to flush frames, to make sure the correct cells are rendered
  22118. this.animationFrameService.flushAllFrames();
  22119. };
  22120. RowRenderer.prototype.startEditingCell = function (gridCell, keyPress, charPress) {
  22121. var cell = this.getComponentForCell(gridCell);
  22122. if (cell) {
  22123. cell.startRowOrCellEdit(keyPress, charPress);
  22124. }
  22125. };
  22126. RowRenderer.prototype.getComponentForCell = function (cellPosition) {
  22127. var rowComponent;
  22128. switch (cellPosition.rowPinned) {
  22129. case Constants.PINNED_TOP:
  22130. rowComponent = this.floatingTopRowComps[cellPosition.rowIndex];
  22131. break;
  22132. case Constants.PINNED_BOTTOM:
  22133. rowComponent = this.floatingBottomRowComps[cellPosition.rowIndex];
  22134. break;
  22135. default:
  22136. rowComponent = this.rowCompsByIndex[cellPosition.rowIndex];
  22137. break;
  22138. }
  22139. if (!rowComponent) {
  22140. return null;
  22141. }
  22142. var cellComponent = rowComponent.getRenderedCellForColumn(cellPosition.column);
  22143. return cellComponent;
  22144. };
  22145. RowRenderer.prototype.getRowNode = function (gridRow) {
  22146. switch (gridRow.rowPinned) {
  22147. case Constants.PINNED_TOP:
  22148. return this.pinnedRowModel.getPinnedTopRowData()[gridRow.rowIndex];
  22149. case Constants.PINNED_BOTTOM:
  22150. return this.pinnedRowModel.getPinnedBottomRowData()[gridRow.rowIndex];
  22151. default:
  22152. return this.rowModel.getRow(gridRow.rowIndex);
  22153. }
  22154. };
  22155. RowRenderer.prototype.onTabKeyDown = function (previousRenderedCell, keyboardEvent) {
  22156. var backwards = keyboardEvent.shiftKey;
  22157. var success = this.moveToCellAfter(previousRenderedCell, backwards);
  22158. if (success) {
  22159. keyboardEvent.preventDefault();
  22160. }
  22161. else if (keyboardEvent.shiftKey) {
  22162. var cellPosition = previousRenderedCell.getCellPosition();
  22163. if (cellPosition.rowIndex === 0) {
  22164. keyboardEvent.preventDefault();
  22165. this.focusController.focusHeaderPosition({
  22166. headerRowIndex: this.beans.headerNavigationService.getHeaderRowCount() - 1,
  22167. column: _.last(this.columnController.getAllDisplayedColumns())
  22168. });
  22169. }
  22170. }
  22171. };
  22172. RowRenderer.prototype.tabToNextCell = function (backwards) {
  22173. var focusedCell = this.focusController.getFocusedCell();
  22174. // if no focus, then cannot navigate
  22175. if (_.missing(focusedCell)) {
  22176. return false;
  22177. }
  22178. var renderedCell = this.getComponentForCell(focusedCell);
  22179. // if cell is not rendered, means user has scrolled away from the cell
  22180. if (_.missing(renderedCell)) {
  22181. return false;
  22182. }
  22183. var result = this.moveToCellAfter(renderedCell, backwards);
  22184. return result;
  22185. };
  22186. RowRenderer.prototype.moveToCellAfter = function (previousRenderedCell, backwards) {
  22187. var editing = previousRenderedCell.isEditing();
  22188. var res;
  22189. if (editing) {
  22190. if (this.gridOptionsWrapper.isFullRowEdit()) {
  22191. res = this.moveToNextEditingRow(previousRenderedCell, backwards);
  22192. }
  22193. else {
  22194. res = this.moveToNextEditingCell(previousRenderedCell, backwards);
  22195. }
  22196. }
  22197. else {
  22198. res = this.moveToNextCellNotEditing(previousRenderedCell, backwards);
  22199. }
  22200. return res;
  22201. };
  22202. RowRenderer.prototype.moveToNextEditingCell = function (previousRenderedCell, backwards) {
  22203. var gridCell = previousRenderedCell.getCellPosition();
  22204. // need to do this before getting next cell to edit, in case the next cell
  22205. // has editable function (eg colDef.editable=func() ) and it depends on the
  22206. // result of this cell, so need to save updates from the first edit, in case
  22207. // the value is referenced in the function.
  22208. previousRenderedCell.stopEditing();
  22209. // find the next cell to start editing
  22210. var nextRenderedCell = this.findNextCellToFocusOn(gridCell, backwards, true);
  22211. var foundCell = _.exists(nextRenderedCell);
  22212. // only prevent default if we found a cell. so if user is on last cell and hits tab, then we default
  22213. // to the normal tabbing so user can exit the grid.
  22214. if (foundCell) {
  22215. nextRenderedCell.startEditingIfEnabled(null, null, true);
  22216. nextRenderedCell.focusCell(false);
  22217. }
  22218. return foundCell;
  22219. };
  22220. RowRenderer.prototype.moveToNextEditingRow = function (previousRenderedCell, backwards) {
  22221. var gridCell = previousRenderedCell.getCellPosition();
  22222. // find the next cell to start editing
  22223. var nextRenderedCell = this.findNextCellToFocusOn(gridCell, backwards, true);
  22224. var foundCell = _.exists(nextRenderedCell);
  22225. // only prevent default if we found a cell. so if user is on last cell and hits tab, then we default
  22226. // to the normal tabbing so user can exit the grid.
  22227. if (foundCell) {
  22228. this.moveEditToNextCellOrRow(previousRenderedCell, nextRenderedCell);
  22229. }
  22230. return foundCell;
  22231. };
  22232. RowRenderer.prototype.moveToNextCellNotEditing = function (previousRenderedCell, backwards) {
  22233. var gridCell = previousRenderedCell.getCellPosition();
  22234. // find the next cell to start editing
  22235. var nextRenderedCell = this.findNextCellToFocusOn(gridCell, backwards, false);
  22236. var foundCell = _.exists(nextRenderedCell);
  22237. // only prevent default if we found a cell. so if user is on last cell and hits tab, then we default
  22238. // to the normal tabbing so user can exit the grid.
  22239. if (foundCell) {
  22240. nextRenderedCell.focusCell(true);
  22241. }
  22242. return foundCell;
  22243. };
  22244. RowRenderer.prototype.moveEditToNextCellOrRow = function (previousRenderedCell, nextRenderedCell) {
  22245. var pGridCell = previousRenderedCell.getCellPosition();
  22246. var nGridCell = nextRenderedCell.getCellPosition();
  22247. var rowsMatch = pGridCell.rowIndex === nGridCell.rowIndex && pGridCell.rowPinned === nGridCell.rowPinned;
  22248. if (rowsMatch) {
  22249. // same row, so we don't start / stop editing, we just move the focus along
  22250. previousRenderedCell.setFocusOutOnEditor();
  22251. nextRenderedCell.setFocusInOnEditor();
  22252. }
  22253. else {
  22254. var pRow = previousRenderedCell.getRenderedRow();
  22255. var nRow = nextRenderedCell.getRenderedRow();
  22256. previousRenderedCell.setFocusOutOnEditor();
  22257. pRow.stopEditing();
  22258. nRow.startRowEditing();
  22259. nextRenderedCell.setFocusInOnEditor();
  22260. }
  22261. nextRenderedCell.focusCell();
  22262. };
  22263. // called by the cell, when tab is pressed while editing.
  22264. // @return: RenderedCell when navigation successful, otherwise null
  22265. RowRenderer.prototype.findNextCellToFocusOn = function (gridCell, backwards, startEditing) {
  22266. var nextCell = gridCell;
  22267. while (true) {
  22268. if (!backwards) {
  22269. nextCell = this.getLastCellOfColSpan(nextCell);
  22270. }
  22271. nextCell = this.cellNavigationService.getNextTabbedCell(nextCell, backwards);
  22272. // allow user to override what cell to go to next
  22273. var userFunc = this.gridOptionsWrapper.getTabToNextCellFunc();
  22274. if (_.exists(userFunc)) {
  22275. var params = {
  22276. backwards: backwards,
  22277. editing: startEditing,
  22278. previousCellPosition: gridCell,
  22279. nextCellPosition: nextCell ? nextCell : null
  22280. };
  22281. var userCell = userFunc(params);
  22282. if (_.exists(userCell)) {
  22283. if (userCell.floating) {
  22284. _.doOnce(function () { console.warn("ag-Grid: tabToNextCellFunc return type should have attributes: rowIndex, rowPinned, column. However you had 'floating', maybe you meant 'rowPinned'?"); }, 'no floating in userCell');
  22285. userCell.rowPinned = userCell.floating;
  22286. }
  22287. nextCell = {
  22288. rowIndex: userCell.rowIndex,
  22289. column: userCell.column,
  22290. rowPinned: userCell.rowPinned
  22291. };
  22292. }
  22293. else {
  22294. nextCell = null;
  22295. }
  22296. }
  22297. // if no 'next cell', means we have got to last cell of grid, so nothing to move to,
  22298. // so bottom right cell going forwards, or top left going backwards
  22299. if (!nextCell) {
  22300. return null;
  22301. }
  22302. // if editing, but cell not editable, skip cell. we do this before we do all of
  22303. // the 'ensure index visible' and 'flush all frames', otherwise if we are skipping
  22304. // a bunch of cells (eg 10 rows) then all the work on ensuring cell visible is useless
  22305. // (except for the last one) which causes grid to stall for a while.
  22306. if (startEditing) {
  22307. var rowNode = this.lookupRowNodeForCell(nextCell);
  22308. var cellIsEditable = nextCell.column.isCellEditable(rowNode);
  22309. if (!cellIsEditable) {
  22310. continue;
  22311. }
  22312. }
  22313. // this scrolls the row into view
  22314. var cellIsNotFloating = _.missing(nextCell.rowPinned);
  22315. if (cellIsNotFloating) {
  22316. this.gridPanel.ensureIndexVisible(nextCell.rowIndex);
  22317. }
  22318. // pinned columns don't scroll, so no need to ensure index visible
  22319. if (!nextCell.column.isPinned()) {
  22320. this.gridPanel.ensureColumnVisible(nextCell.column);
  22321. }
  22322. // need to nudge the scrolls for the floating items. otherwise when we set focus on a non-visible
  22323. // floating cell, the scrolls get out of sync
  22324. this.gridPanel.horizontallyScrollHeaderCenterAndFloatingCenter();
  22325. // get the grid panel to flush all animation frames - otherwise the call below to get the cellComp
  22326. // could fail, if we just scrolled the grid (to make a cell visible) and the rendering hasn't finished.
  22327. this.animationFrameService.flushAllFrames();
  22328. // we have to call this after ensureColumnVisible - otherwise it could be a virtual column
  22329. // or row that is not currently in view, hence the renderedCell would not exist
  22330. var nextCellComp = this.getComponentForCell(nextCell);
  22331. // if next cell is fullWidth row, then no rendered cell,
  22332. // as fullWidth rows have no cells, so we skip it
  22333. if (_.missing(nextCellComp)) {
  22334. continue;
  22335. }
  22336. if (nextCellComp.isSuppressNavigable()) {
  22337. continue;
  22338. }
  22339. // by default, when we click a cell, it gets selected into a range, so to keep keyboard navigation
  22340. // consistent, we set into range here also.
  22341. if (this.rangeController) {
  22342. this.rangeController.setRangeToCell(nextCell);
  22343. }
  22344. // we successfully tabbed onto a grid cell, so return true
  22345. return nextCellComp;
  22346. }
  22347. };
  22348. RowRenderer.prototype.lookupRowNodeForCell = function (cell) {
  22349. if (cell.rowPinned === Constants.PINNED_TOP) {
  22350. return this.pinnedRowModel.getPinnedTopRow(cell.rowIndex);
  22351. }
  22352. if (cell.rowPinned === Constants.PINNED_BOTTOM) {
  22353. return this.pinnedRowModel.getPinnedBottomRow(cell.rowIndex);
  22354. }
  22355. return this.paginationProxy.getRow(cell.rowIndex);
  22356. };
  22357. __decorate$H([
  22358. Autowired("paginationProxy")
  22359. ], RowRenderer.prototype, "paginationProxy", void 0);
  22360. __decorate$H([
  22361. Autowired("columnController")
  22362. ], RowRenderer.prototype, "columnController", void 0);
  22363. __decorate$H([
  22364. Autowired("gridOptionsWrapper")
  22365. ], RowRenderer.prototype, "gridOptionsWrapper", void 0);
  22366. __decorate$H([
  22367. Autowired("$scope")
  22368. ], RowRenderer.prototype, "$scope", void 0);
  22369. __decorate$H([
  22370. Autowired("pinnedRowModel")
  22371. ], RowRenderer.prototype, "pinnedRowModel", void 0);
  22372. __decorate$H([
  22373. Autowired("rowModel")
  22374. ], RowRenderer.prototype, "rowModel", void 0);
  22375. __decorate$H([
  22376. Autowired("loggerFactory")
  22377. ], RowRenderer.prototype, "loggerFactory", void 0);
  22378. __decorate$H([
  22379. Autowired("focusController")
  22380. ], RowRenderer.prototype, "focusController", void 0);
  22381. __decorate$H([
  22382. Autowired("cellNavigationService")
  22383. ], RowRenderer.prototype, "cellNavigationService", void 0);
  22384. __decorate$H([
  22385. Autowired("columnApi")
  22386. ], RowRenderer.prototype, "columnApi", void 0);
  22387. __decorate$H([
  22388. Autowired("gridApi")
  22389. ], RowRenderer.prototype, "gridApi", void 0);
  22390. __decorate$H([
  22391. Autowired("beans")
  22392. ], RowRenderer.prototype, "beans", void 0);
  22393. __decorate$H([
  22394. Autowired("maxDivHeightScaler")
  22395. ], RowRenderer.prototype, "maxDivHeightScaler", void 0);
  22396. __decorate$H([
  22397. Autowired("animationFrameService")
  22398. ], RowRenderer.prototype, "animationFrameService", void 0);
  22399. __decorate$H([
  22400. Autowired("rowPositionUtils")
  22401. ], RowRenderer.prototype, "rowPositionUtils", void 0);
  22402. __decorate$H([
  22403. Optional("rangeController")
  22404. ], RowRenderer.prototype, "rangeController", void 0);
  22405. __decorate$H([
  22406. __param$5(0, Qualifier("loggerFactory"))
  22407. ], RowRenderer.prototype, "agWire", null);
  22408. RowRenderer = __decorate$H([
  22409. Bean("rowRenderer")
  22410. ], RowRenderer);
  22411. return RowRenderer;
  22412. }(BeanStub));
  22413. /**
  22414. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  22415. * @version v23.2.1
  22416. * @link http://www.ag-grid.com/
  22417. * @license MIT
  22418. */
  22419. var CssClassApplier = /** @class */ (function () {
  22420. function CssClassApplier() {
  22421. }
  22422. CssClassApplier.addHeaderClassesFromColDef = function (abstractColDef, eHeaderCell, gridOptionsWrapper, column, columnGroup) {
  22423. if (_.missing(abstractColDef)) {
  22424. return;
  22425. }
  22426. this.addColumnClassesFromCollDef(abstractColDef.headerClass, abstractColDef, eHeaderCell, gridOptionsWrapper, column, columnGroup);
  22427. };
  22428. CssClassApplier.addToolPanelClassesFromColDef = function (abstractColDef, eHeaderCell, gridOptionsWrapper, column, columnGroup) {
  22429. if (_.missing(abstractColDef)) {
  22430. return;
  22431. }
  22432. this.addColumnClassesFromCollDef(abstractColDef.toolPanelClass, abstractColDef, eHeaderCell, gridOptionsWrapper, column, columnGroup);
  22433. };
  22434. CssClassApplier.addColumnClassesFromCollDef = function (classesOrFunc, abstractColDef, eHeaderCell, gridOptionsWrapper, column, columnGroup) {
  22435. if (_.missing(classesOrFunc)) {
  22436. return;
  22437. }
  22438. var classToUse;
  22439. if (typeof classesOrFunc === 'function') {
  22440. var params = {
  22441. // bad naming, as colDef here can be a group or a column,
  22442. // however most people won't appreciate the difference,
  22443. // so keeping it as colDef to avoid confusion.
  22444. colDef: abstractColDef,
  22445. column: column,
  22446. columnGroup: columnGroup,
  22447. context: gridOptionsWrapper.getContext(),
  22448. api: gridOptionsWrapper.getApi()
  22449. };
  22450. var headerClassFunc = classesOrFunc;
  22451. classToUse = headerClassFunc(params);
  22452. }
  22453. else {
  22454. classToUse = classesOrFunc;
  22455. }
  22456. if (typeof classToUse === 'string') {
  22457. _.addCssClass(eHeaderCell, classToUse);
  22458. }
  22459. else if (Array.isArray(classToUse)) {
  22460. classToUse.forEach(function (cssClassItem) {
  22461. _.addCssClass(eHeaderCell, cssClassItem);
  22462. });
  22463. }
  22464. };
  22465. return CssClassApplier;
  22466. }());
  22467. /**
  22468. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  22469. * @version v23.2.1
  22470. * @link http://www.ag-grid.com/
  22471. * @license MIT
  22472. */
  22473. var __extends$M = (undefined && undefined.__extends) || (function () {
  22474. var extendStatics = function (d, b) {
  22475. extendStatics = Object.setPrototypeOf ||
  22476. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  22477. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  22478. return extendStatics(d, b);
  22479. };
  22480. return function (d, b) {
  22481. extendStatics(d, b);
  22482. function __() { this.constructor = d; }
  22483. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  22484. };
  22485. })();
  22486. var __decorate$I = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  22487. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  22488. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  22489. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  22490. return c > 3 && r && Object.defineProperty(target, key, r), r;
  22491. };
  22492. var HoverFeature = /** @class */ (function (_super) {
  22493. __extends$M(HoverFeature, _super);
  22494. function HoverFeature(columns, element) {
  22495. var _this = _super.call(this) || this;
  22496. _this.columns = columns;
  22497. _this.element = element;
  22498. return _this;
  22499. }
  22500. HoverFeature.prototype.postConstruct = function () {
  22501. this.addMouseHoverListeners();
  22502. };
  22503. HoverFeature.prototype.addMouseHoverListeners = function () {
  22504. this.addManagedListener(this.element, 'mouseout', this.onMouseOut.bind(this));
  22505. this.addManagedListener(this.element, 'mouseover', this.onMouseOver.bind(this));
  22506. };
  22507. HoverFeature.prototype.onMouseOut = function () {
  22508. this.columnHoverService.clearMouseOver();
  22509. };
  22510. HoverFeature.prototype.onMouseOver = function () {
  22511. this.columnHoverService.setMouseOver(this.columns);
  22512. };
  22513. __decorate$I([
  22514. Autowired('columnHoverService')
  22515. ], HoverFeature.prototype, "columnHoverService", void 0);
  22516. __decorate$I([
  22517. PostConstruct
  22518. ], HoverFeature.prototype, "postConstruct", null);
  22519. return HoverFeature;
  22520. }(BeanStub));
  22521. /**
  22522. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  22523. * @version v23.2.1
  22524. * @link http://www.ag-grid.com/
  22525. * @license MIT
  22526. */
  22527. var __extends$N = (undefined && undefined.__extends) || (function () {
  22528. var extendStatics = function (d, b) {
  22529. extendStatics = Object.setPrototypeOf ||
  22530. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  22531. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  22532. return extendStatics(d, b);
  22533. };
  22534. return function (d, b) {
  22535. extendStatics(d, b);
  22536. function __() { this.constructor = d; }
  22537. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  22538. };
  22539. })();
  22540. var __decorate$J = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  22541. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  22542. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  22543. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  22544. return c > 3 && r && Object.defineProperty(target, key, r), r;
  22545. };
  22546. var SetLeftFeature = /** @class */ (function (_super) {
  22547. __extends$N(SetLeftFeature, _super);
  22548. function SetLeftFeature(columnOrGroup, eCell, beans, colsSpanning) {
  22549. var _this = _super.call(this) || this;
  22550. _this.columnOrGroup = columnOrGroup;
  22551. _this.eCell = eCell;
  22552. _this.ariaEl = _this.eCell.querySelector('[role=columnheader]') || _this.eCell;
  22553. _this.colsSpanning = colsSpanning;
  22554. _this.beans = beans;
  22555. _this.printLayout = beans.gridOptionsWrapper.getDomLayout() === Constants.DOM_LAYOUT_PRINT;
  22556. return _this;
  22557. }
  22558. SetLeftFeature.prototype.setColsSpanning = function (colsSpanning) {
  22559. this.colsSpanning = colsSpanning;
  22560. this.onLeftChanged();
  22561. };
  22562. SetLeftFeature.prototype.getColumnOrGroup = function () {
  22563. if (this.beans.gridOptionsWrapper.isEnableRtl() && this.colsSpanning) {
  22564. return _.last(this.colsSpanning);
  22565. }
  22566. return this.columnOrGroup;
  22567. };
  22568. SetLeftFeature.prototype.postConstruct = function () {
  22569. this.addManagedListener(this.columnOrGroup, Column.EVENT_LEFT_CHANGED, this.onLeftChanged.bind(this));
  22570. this.setLeftFirstTime();
  22571. };
  22572. SetLeftFeature.prototype.setLeftFirstTime = function () {
  22573. var suppressMoveAnimation = this.beans.gridOptionsWrapper.isSuppressColumnMoveAnimation();
  22574. var oldLeftExists = _.exists(this.columnOrGroup.getOldLeft());
  22575. var animateColumnMove = this.beans.columnAnimationService.isActive() && oldLeftExists && !suppressMoveAnimation;
  22576. if (animateColumnMove) {
  22577. this.animateInLeft();
  22578. }
  22579. else {
  22580. this.onLeftChanged();
  22581. }
  22582. };
  22583. SetLeftFeature.prototype.animateInLeft = function () {
  22584. var _this = this;
  22585. var left = this.getColumnOrGroup().getLeft();
  22586. var oldLeft = this.getColumnOrGroup().getOldLeft();
  22587. this.setLeft(oldLeft);
  22588. // we must keep track of the left we want to set to, as this would otherwise lead to a race
  22589. // condition, if the user changed the left value many times in one VM turn, then we want to make
  22590. // make sure the actualLeft we set in the timeout below (in the next VM turn) is the correct left
  22591. // position. eg if user changes column position twice, then setLeft() below executes twice in next
  22592. // VM turn, but only one (the correct one) should get applied.
  22593. this.actualLeft = left;
  22594. this.beans.columnAnimationService.executeNextVMTurn(function () {
  22595. // test this left value is the latest one to be applied, and if not, do nothing
  22596. if (_this.actualLeft === left) {
  22597. _this.setLeft(left);
  22598. }
  22599. });
  22600. };
  22601. SetLeftFeature.prototype.onLeftChanged = function () {
  22602. var colOrGroup = this.getColumnOrGroup();
  22603. var left = colOrGroup.getLeft();
  22604. this.actualLeft = this.modifyLeftForPrintLayout(colOrGroup, left);
  22605. this.setLeft(this.actualLeft);
  22606. };
  22607. SetLeftFeature.prototype.modifyLeftForPrintLayout = function (colOrGroup, leftPosition) {
  22608. if (!this.printLayout) {
  22609. return leftPosition;
  22610. }
  22611. if (colOrGroup.getPinned() === Constants.PINNED_LEFT) {
  22612. return leftPosition;
  22613. }
  22614. if (colOrGroup.getPinned() === Constants.PINNED_RIGHT) {
  22615. var leftWidth_1 = this.beans.columnController.getPinnedLeftContainerWidth();
  22616. var bodyWidth = this.beans.columnController.getBodyContainerWidth();
  22617. return leftWidth_1 + bodyWidth + leftPosition;
  22618. }
  22619. // is in body
  22620. var leftWidth = this.beans.columnController.getPinnedLeftContainerWidth();
  22621. return leftWidth + leftPosition;
  22622. };
  22623. SetLeftFeature.prototype.setLeft = function (value) {
  22624. // if the value is null, then that means the column is no longer
  22625. // displayed. there is logic in the rendering to fade these columns
  22626. // out, so we don't try and change their left positions.
  22627. if (_.exists(value)) {
  22628. this.eCell.style.left = value + "px";
  22629. }
  22630. if (this.columnOrGroup instanceof Column) {
  22631. var colIndex = this.beans.columnController.getAllDisplayedColumns().indexOf(this.columnOrGroup);
  22632. this.ariaEl.setAttribute('aria-colindex', (colIndex + 1).toString());
  22633. }
  22634. else {
  22635. this.ariaEl.removeAttribute('aria-colindex');
  22636. }
  22637. };
  22638. __decorate$J([
  22639. PostConstruct
  22640. ], SetLeftFeature.prototype, "postConstruct", null);
  22641. return SetLeftFeature;
  22642. }(BeanStub));
  22643. /**
  22644. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  22645. * @version v23.2.1
  22646. * @link http://www.ag-grid.com/
  22647. * @license MIT
  22648. */
  22649. var __extends$O = (undefined && undefined.__extends) || (function () {
  22650. var extendStatics = function (d, b) {
  22651. extendStatics = Object.setPrototypeOf ||
  22652. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  22653. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  22654. return extendStatics(d, b);
  22655. };
  22656. return function (d, b) {
  22657. extendStatics(d, b);
  22658. function __() { this.constructor = d; }
  22659. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  22660. };
  22661. })();
  22662. var __decorate$K = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  22663. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  22664. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  22665. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  22666. return c > 3 && r && Object.defineProperty(target, key, r), r;
  22667. };
  22668. var SelectAllFeature = /** @class */ (function (_super) {
  22669. __extends$O(SelectAllFeature, _super);
  22670. function SelectAllFeature(cbSelectAll, column) {
  22671. var _this = _super.call(this) || this;
  22672. _this.cbSelectAllVisible = false;
  22673. _this.processingEventFromCheckbox = false;
  22674. _this.cbSelectAll = cbSelectAll;
  22675. _this.column = column;
  22676. var colDef = column.getColDef();
  22677. _this.filteredOnly = colDef ? !!colDef.headerCheckboxSelectionFilteredOnly : false;
  22678. return _this;
  22679. }
  22680. SelectAllFeature.prototype.postConstruct = function () {
  22681. this.showOrHideSelectAll();
  22682. this.addManagedListener(this.eventService, Events.EVENT_DISPLAYED_COLUMNS_CHANGED, this.showOrHideSelectAll.bind(this));
  22683. this.addManagedListener(this.eventService, Events.EVENT_SELECTION_CHANGED, this.onSelectionChanged.bind(this));
  22684. this.addManagedListener(this.eventService, Events.EVENT_MODEL_UPDATED, this.onModelChanged.bind(this));
  22685. this.addManagedListener(this.cbSelectAll, AgCheckbox.EVENT_CHANGED, this.onCbSelectAll.bind(this));
  22686. };
  22687. SelectAllFeature.prototype.showOrHideSelectAll = function () {
  22688. this.cbSelectAllVisible = this.isCheckboxSelection();
  22689. this.cbSelectAll.setDisplayed(this.cbSelectAllVisible);
  22690. if (this.cbSelectAllVisible) {
  22691. // in case user is trying this feature with the wrong model type
  22692. this.checkRightRowModelType();
  22693. // make sure checkbox is showing the right state
  22694. this.updateStateOfCheckbox();
  22695. }
  22696. };
  22697. SelectAllFeature.prototype.onModelChanged = function () {
  22698. if (!this.cbSelectAllVisible) {
  22699. return;
  22700. }
  22701. this.updateStateOfCheckbox();
  22702. };
  22703. SelectAllFeature.prototype.onSelectionChanged = function () {
  22704. if (!this.cbSelectAllVisible) {
  22705. return;
  22706. }
  22707. this.updateStateOfCheckbox();
  22708. };
  22709. SelectAllFeature.prototype.getNextCheckboxState = function (selectionCount) {
  22710. // if no rows, always have it unselected
  22711. if (selectionCount.selected === 0 && selectionCount.notSelected === 0) {
  22712. return false;
  22713. }
  22714. // if mix of selected and unselected, this is the tri-state
  22715. if (selectionCount.selected > 0 && selectionCount.notSelected > 0) {
  22716. return null;
  22717. }
  22718. // only selected
  22719. if (selectionCount.selected > 0) {
  22720. return true;
  22721. }
  22722. // nothing selected
  22723. return false;
  22724. };
  22725. SelectAllFeature.prototype.updateStateOfCheckbox = function () {
  22726. if (this.processingEventFromCheckbox) {
  22727. return;
  22728. }
  22729. this.processingEventFromCheckbox = true;
  22730. var selectionCount = this.getSelectionCount();
  22731. var allSelected = this.getNextCheckboxState(selectionCount);
  22732. this.cbSelectAll.setValue(allSelected);
  22733. this.processingEventFromCheckbox = false;
  22734. };
  22735. SelectAllFeature.prototype.getSelectionCount = function () {
  22736. var _this = this;
  22737. var selectedCount = 0;
  22738. var notSelectedCount = 0;
  22739. var callback = function (node) {
  22740. if (_this.gridOptionsWrapper.isGroupSelectsChildren() && node.group) {
  22741. return;
  22742. }
  22743. if (node.isSelected()) {
  22744. selectedCount++;
  22745. }
  22746. else if (!node.selectable) ;
  22747. else {
  22748. notSelectedCount++;
  22749. }
  22750. };
  22751. if (this.filteredOnly) {
  22752. this.gridApi.forEachNodeAfterFilter(callback);
  22753. }
  22754. else {
  22755. this.gridApi.forEachNode(callback);
  22756. }
  22757. return {
  22758. notSelected: notSelectedCount,
  22759. selected: selectedCount
  22760. };
  22761. };
  22762. SelectAllFeature.prototype.checkRightRowModelType = function () {
  22763. var rowModelType = this.rowModel.getType();
  22764. var rowModelMatches = rowModelType === Constants.ROW_MODEL_TYPE_CLIENT_SIDE;
  22765. if (!rowModelMatches) {
  22766. console.warn("ag-Grid: selectAllCheckbox is only available if using normal row model, you are using " + rowModelType);
  22767. }
  22768. };
  22769. SelectAllFeature.prototype.onCbSelectAll = function () {
  22770. if (this.processingEventFromCheckbox) {
  22771. return;
  22772. }
  22773. if (!this.cbSelectAllVisible) {
  22774. return;
  22775. }
  22776. var value = this.cbSelectAll.getValue();
  22777. if (value) {
  22778. this.selectionController.selectAllRowNodes(this.filteredOnly);
  22779. }
  22780. else {
  22781. this.selectionController.deselectAllRowNodes(this.filteredOnly);
  22782. }
  22783. };
  22784. SelectAllFeature.prototype.isCheckboxSelection = function () {
  22785. var result = this.column.getColDef().headerCheckboxSelection;
  22786. if (typeof result === 'function') {
  22787. var func = result;
  22788. result = func({
  22789. column: this.column,
  22790. colDef: this.column.getColDef(),
  22791. columnApi: this.columnApi,
  22792. api: this.gridApi
  22793. });
  22794. }
  22795. if (result) {
  22796. if (this.gridOptionsWrapper.isRowModelServerSide()) {
  22797. console.warn('headerCheckboxSelection is not supported for Server Side Row Model');
  22798. return false;
  22799. }
  22800. if (this.gridOptionsWrapper.isRowModelInfinite()) {
  22801. console.warn('headerCheckboxSelection is not supported for Infinite Row Model');
  22802. return false;
  22803. }
  22804. if (this.gridOptionsWrapper.isRowModelViewport()) {
  22805. console.warn('headerCheckboxSelection is not supported for Viewport Row Model');
  22806. return false;
  22807. }
  22808. // otherwise the row model is compatible, so return true
  22809. return true;
  22810. }
  22811. return false;
  22812. };
  22813. __decorate$K([
  22814. Autowired('gridApi')
  22815. ], SelectAllFeature.prototype, "gridApi", void 0);
  22816. __decorate$K([
  22817. Autowired('columnApi')
  22818. ], SelectAllFeature.prototype, "columnApi", void 0);
  22819. __decorate$K([
  22820. Autowired('rowModel')
  22821. ], SelectAllFeature.prototype, "rowModel", void 0);
  22822. __decorate$K([
  22823. Autowired('selectionController')
  22824. ], SelectAllFeature.prototype, "selectionController", void 0);
  22825. __decorate$K([
  22826. Autowired('gridOptionsWrapper')
  22827. ], SelectAllFeature.prototype, "gridOptionsWrapper", void 0);
  22828. __decorate$K([
  22829. PostConstruct
  22830. ], SelectAllFeature.prototype, "postConstruct", null);
  22831. return SelectAllFeature;
  22832. }(BeanStub));
  22833. /**
  22834. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  22835. * @version v23.2.1
  22836. * @link http://www.ag-grid.com/
  22837. * @license MIT
  22838. */
  22839. var __extends$P = (undefined && undefined.__extends) || (function () {
  22840. var extendStatics = function (d, b) {
  22841. extendStatics = Object.setPrototypeOf ||
  22842. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  22843. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  22844. return extendStatics(d, b);
  22845. };
  22846. return function (d, b) {
  22847. extendStatics(d, b);
  22848. function __() { this.constructor = d; }
  22849. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  22850. };
  22851. })();
  22852. var __decorate$L = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  22853. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  22854. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  22855. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  22856. return c > 3 && r && Object.defineProperty(target, key, r), r;
  22857. };
  22858. /**
  22859. * This provides logic to override the default browser focus logic.
  22860. *
  22861. * When the component gets focus, it uses the grid logic to find out what should be focused,
  22862. * and then focuses that instead.
  22863. *
  22864. * This is how we ensure when user tabs into the relevant section, we focus the correct item.
  22865. * For example GridCore extends ManagedFocusComponent, and it ensures when it receives focus
  22866. * that focus goes to the first cell of the first header row.
  22867. */
  22868. var ManagedFocusComponent = /** @class */ (function (_super) {
  22869. __extends$P(ManagedFocusComponent, _super);
  22870. function ManagedFocusComponent() {
  22871. var _this = _super !== null && _super.apply(this, arguments) || this;
  22872. _this.skipTabGuardFocus = false;
  22873. return _this;
  22874. }
  22875. ManagedFocusComponent.prototype.postConstruct = function () {
  22876. var focusableElement = this.getFocusableElement();
  22877. if (!focusableElement) {
  22878. return;
  22879. }
  22880. this.wireFocusManagement();
  22881. };
  22882. ManagedFocusComponent.prototype.wireFocusManagement = function () {
  22883. var _this = this;
  22884. var focusableElement = this.getFocusableElement();
  22885. _.addCssClass(focusableElement, ManagedFocusComponent.FOCUS_MANAGED_CLASS);
  22886. if (this.isFocusableContainer()) {
  22887. this.topTabGuard = this.createTabGuard('top');
  22888. this.bottomTabGuard = this.createTabGuard('bottom');
  22889. this.addTabGuards();
  22890. this.activateTabGuards();
  22891. this.forEachTabGuard(function (tabGuards) {
  22892. _this.addManagedListener(tabGuards, 'focus', _this.onFocus.bind(_this));
  22893. });
  22894. }
  22895. if (this.onTabKeyDown || this.handleKeyDown) {
  22896. this.addKeyDownListeners(focusableElement);
  22897. }
  22898. this.addManagedListener(focusableElement, 'focusin', this.onFocusIn.bind(this));
  22899. this.addManagedListener(focusableElement, 'focusout', this.onFocusOut.bind(this));
  22900. };
  22901. /*
  22902. * Override this method to return true if this component will contain multiple focus-managed
  22903. * elements within. When set to true, this component will add tabGuards that will be responsible
  22904. * for receiving focus from outside and focusing an internal element using the focusInnerElementMethod
  22905. */
  22906. ManagedFocusComponent.prototype.isFocusableContainer = function () {
  22907. return false;
  22908. };
  22909. /*
  22910. * Override this method if focusing the default element requires special logic.
  22911. */
  22912. ManagedFocusComponent.prototype.focusInnerElement = function (fromBottom) {
  22913. var focusable = this.focusController.findFocusableElements(this.getFocusableElement(), '.ag-tab-guard, :not([tabindex="-1"])');
  22914. if (!focusable.length) {
  22915. return;
  22916. }
  22917. focusable[fromBottom ? focusable.length - 1 : 0].focus();
  22918. };
  22919. ManagedFocusComponent.prototype.onFocusIn = function (e) {
  22920. if (!this.isFocusableContainer()) {
  22921. return;
  22922. }
  22923. this.deactivateTabGuards();
  22924. };
  22925. ManagedFocusComponent.prototype.onFocusOut = function (e) {
  22926. if (!this.isFocusableContainer()) {
  22927. return;
  22928. }
  22929. var focusEl = this.getFocusableElement();
  22930. if (!focusEl.contains(e.relatedTarget)) {
  22931. this.activateTabGuards();
  22932. }
  22933. };
  22934. ManagedFocusComponent.prototype.forceFocusOutOfContainer = function () {
  22935. this.activateTabGuards();
  22936. this.skipTabGuardFocus = true;
  22937. this.bottomTabGuard.focus();
  22938. };
  22939. ManagedFocusComponent.prototype.appendChild = function (newChild, container) {
  22940. if (!this.isFocusableContainer()) {
  22941. _super.prototype.appendChild.call(this, newChild, container);
  22942. }
  22943. else {
  22944. if (!_.isNodeOrElement(newChild)) {
  22945. newChild = newChild.getGui();
  22946. }
  22947. var bottomTabGuard = this.bottomTabGuard;
  22948. if (bottomTabGuard) {
  22949. bottomTabGuard.insertAdjacentElement('beforebegin', newChild);
  22950. }
  22951. else {
  22952. _super.prototype.appendChild.call(this, newChild, container);
  22953. }
  22954. }
  22955. };
  22956. ManagedFocusComponent.prototype.createTabGuard = function (side) {
  22957. var tabGuard = document.createElement('div');
  22958. tabGuard.classList.add('ag-tab-guard');
  22959. tabGuard.classList.add("ag-tab-guard-" + side);
  22960. return tabGuard;
  22961. };
  22962. ManagedFocusComponent.prototype.addTabGuards = function () {
  22963. var focusableEl = this.getFocusableElement();
  22964. focusableEl.insertAdjacentElement('afterbegin', this.topTabGuard);
  22965. focusableEl.insertAdjacentElement('beforeend', this.bottomTabGuard);
  22966. };
  22967. ManagedFocusComponent.prototype.forEachTabGuard = function (callback) {
  22968. [this.topTabGuard, this.bottomTabGuard].forEach(callback);
  22969. };
  22970. ManagedFocusComponent.prototype.addKeyDownListeners = function (eGui) {
  22971. var _this = this;
  22972. this.addManagedListener(eGui, 'keydown', function (e) {
  22973. if (e.defaultPrevented) {
  22974. return;
  22975. }
  22976. if (e.keyCode === Constants.KEY_TAB && _this.onTabKeyDown) {
  22977. _this.onTabKeyDown(e);
  22978. }
  22979. else if (_this.handleKeyDown) {
  22980. _this.handleKeyDown(e);
  22981. }
  22982. });
  22983. };
  22984. ManagedFocusComponent.prototype.onFocus = function (e) {
  22985. if (!this.isFocusableContainer()) {
  22986. return;
  22987. }
  22988. if (this.skipTabGuardFocus) {
  22989. this.skipTabGuardFocus = false;
  22990. return;
  22991. }
  22992. this.focusInnerElement(e.target === this.bottomTabGuard);
  22993. };
  22994. ManagedFocusComponent.prototype.activateTabGuards = function () {
  22995. this.forEachTabGuard(function (tabGuard) { return tabGuard.setAttribute('tabIndex', '0'); });
  22996. };
  22997. ManagedFocusComponent.prototype.deactivateTabGuards = function () {
  22998. this.forEachTabGuard(function (tabGuards) { return tabGuards.removeAttribute('tabindex'); });
  22999. };
  23000. ManagedFocusComponent.FOCUS_MANAGED_CLASS = 'ag-focus-managed';
  23001. __decorate$L([
  23002. Autowired('focusController')
  23003. ], ManagedFocusComponent.prototype, "focusController", void 0);
  23004. __decorate$L([
  23005. PostConstruct
  23006. ], ManagedFocusComponent.prototype, "postConstruct", null);
  23007. return ManagedFocusComponent;
  23008. }(Component));
  23009. /**
  23010. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  23011. * @version v23.2.1
  23012. * @link http://www.ag-grid.com/
  23013. * @license MIT
  23014. */
  23015. var __extends$Q = (undefined && undefined.__extends) || (function () {
  23016. var extendStatics = function (d, b) {
  23017. extendStatics = Object.setPrototypeOf ||
  23018. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  23019. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  23020. return extendStatics(d, b);
  23021. };
  23022. return function (d, b) {
  23023. extendStatics(d, b);
  23024. function __() { this.constructor = d; }
  23025. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  23026. };
  23027. })();
  23028. var AbstractHeaderWrapper = /** @class */ (function (_super) {
  23029. __extends$Q(AbstractHeaderWrapper, _super);
  23030. function AbstractHeaderWrapper() {
  23031. return _super !== null && _super.apply(this, arguments) || this;
  23032. }
  23033. AbstractHeaderWrapper.prototype.getColumn = function () {
  23034. return this.column;
  23035. };
  23036. AbstractHeaderWrapper.prototype.getPinned = function () {
  23037. return this.pinned;
  23038. };
  23039. return AbstractHeaderWrapper;
  23040. }(ManagedFocusComponent));
  23041. /**
  23042. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  23043. * @version v23.2.1
  23044. * @link http://www.ag-grid.com/
  23045. * @license MIT
  23046. */
  23047. var __extends$R = (undefined && undefined.__extends) || (function () {
  23048. var extendStatics = function (d, b) {
  23049. extendStatics = Object.setPrototypeOf ||
  23050. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  23051. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  23052. return extendStatics(d, b);
  23053. };
  23054. return function (d, b) {
  23055. extendStatics(d, b);
  23056. function __() { this.constructor = d; }
  23057. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  23058. };
  23059. })();
  23060. var __decorate$M = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  23061. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  23062. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  23063. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  23064. return c > 3 && r && Object.defineProperty(target, key, r), r;
  23065. };
  23066. var HeaderWrapperComp = /** @class */ (function (_super) {
  23067. __extends$R(HeaderWrapperComp, _super);
  23068. function HeaderWrapperComp(column, dragSourceDropTarget, pinned) {
  23069. var _this = _super.call(this, HeaderWrapperComp.TEMPLATE) || this;
  23070. _this.column = column;
  23071. _this.dragSourceDropTarget = dragSourceDropTarget;
  23072. _this.pinned = pinned;
  23073. return _this;
  23074. }
  23075. HeaderWrapperComp.prototype.postConstruct = function () {
  23076. _super.prototype.postConstruct.call(this);
  23077. var colDef = this.getComponentHolder();
  23078. var displayName = this.columnController.getDisplayNameForColumn(this.column, 'header', true);
  23079. var enableSorting = colDef.sortable;
  23080. var enableMenu = this.menuEnabled = this.menuFactory.isMenuEnabled(this.column) && !colDef.suppressMenu;
  23081. this.appendHeaderComp(displayName, enableSorting, enableMenu);
  23082. this.setupWidth();
  23083. this.setupMovingCss();
  23084. this.setupTooltip();
  23085. this.setupResize();
  23086. this.setupMenuClass();
  23087. this.setupSortableClass(enableSorting);
  23088. this.addColumnHoverListener();
  23089. this.addDisplayMenuListeners();
  23090. this.cbSelectAll.setInputAriaLabel('Toggle Selection of All Rows');
  23091. this.createManagedBean(new HoverFeature([this.column], this.getGui()));
  23092. this.addManagedListener(this.column, Column.EVENT_FILTER_ACTIVE_CHANGED, this.onFilterChanged.bind(this));
  23093. this.onFilterChanged();
  23094. this.createManagedBean(new SelectAllFeature(this.cbSelectAll, this.column));
  23095. var setLeftFeature = new SetLeftFeature(this.column, this.getGui(), this.beans);
  23096. this.createManagedBean(setLeftFeature);
  23097. this.addAttributes();
  23098. CssClassApplier.addHeaderClassesFromColDef(colDef, this.getGui(), this.gridOptionsWrapper, this.column, null);
  23099. };
  23100. HeaderWrapperComp.prototype.addDisplayMenuListeners = function () {
  23101. var mouseListener = this.onMouseOverOut.bind(this);
  23102. this.addGuiEventListener('mouseenter', mouseListener);
  23103. this.addGuiEventListener('mouseleave', mouseListener);
  23104. };
  23105. HeaderWrapperComp.prototype.onMouseOverOut = function (e) {
  23106. if (this.headerComp && this.headerComp.setActiveParent) {
  23107. this.headerComp.setActiveParent(e.type === 'mouseenter');
  23108. }
  23109. };
  23110. HeaderWrapperComp.prototype.onFocusIn = function (e) {
  23111. if (!this.getGui().contains(e.relatedTarget)) {
  23112. var headerRow = this.getParentComponent();
  23113. this.focusController.setFocusedHeader(headerRow.getRowIndex(), this.getColumn());
  23114. }
  23115. if (this.headerComp && this.headerComp.setActiveParent) {
  23116. this.headerComp.setActiveParent(true);
  23117. }
  23118. };
  23119. HeaderWrapperComp.prototype.onFocusOut = function (e) {
  23120. if (!this.headerComp ||
  23121. !this.headerComp.setActiveParent ||
  23122. this.getGui().contains(e.relatedTarget)) {
  23123. return;
  23124. }
  23125. this.headerComp.setActiveParent(false);
  23126. };
  23127. HeaderWrapperComp.prototype.handleKeyDown = function (e) {
  23128. var headerComp = this.headerComp;
  23129. if (!headerComp) {
  23130. return;
  23131. }
  23132. if (e.keyCode === Constants.KEY_SPACE) {
  23133. var checkbox = this.cbSelectAll;
  23134. if (checkbox.isDisplayed() && !checkbox.getGui().contains(document.activeElement)) {
  23135. checkbox.setValue(!checkbox.getValue());
  23136. }
  23137. }
  23138. if (e.keyCode === Constants.KEY_ENTER) {
  23139. if (e.ctrlKey || e.metaKey) {
  23140. if (this.menuEnabled && headerComp.showMenu) {
  23141. e.preventDefault();
  23142. headerComp.showMenu();
  23143. }
  23144. }
  23145. else if (this.sortable) {
  23146. var multiSort = e.shiftKey;
  23147. this.sortController.progressSort(this.column, multiSort, "uiColumnSorted");
  23148. }
  23149. }
  23150. };
  23151. HeaderWrapperComp.prototype.getComponentHolder = function () {
  23152. return this.column.getColDef();
  23153. };
  23154. HeaderWrapperComp.prototype.addColumnHoverListener = function () {
  23155. this.addManagedListener(this.eventService, Events.EVENT_COLUMN_HOVER_CHANGED, this.onColumnHover.bind(this));
  23156. this.onColumnHover();
  23157. };
  23158. HeaderWrapperComp.prototype.onColumnHover = function () {
  23159. var isHovered = this.columnHoverService.isHovered(this.column);
  23160. _.addOrRemoveCssClass(this.getGui(), 'ag-column-hover', isHovered);
  23161. };
  23162. HeaderWrapperComp.prototype.setupSortableClass = function (enableSorting) {
  23163. if (!enableSorting) {
  23164. return;
  23165. }
  23166. var element = this.getGui();
  23167. _.addCssClass(element, 'ag-header-cell-sortable');
  23168. this.sortable = true;
  23169. };
  23170. HeaderWrapperComp.prototype.onFilterChanged = function () {
  23171. var filterPresent = this.column.isFilterActive();
  23172. _.addOrRemoveCssClass(this.getGui(), 'ag-header-cell-filtered', filterPresent);
  23173. };
  23174. HeaderWrapperComp.prototype.appendHeaderComp = function (displayName, enableSorting, enableMenu) {
  23175. var _this = this;
  23176. var params = {
  23177. column: this.column,
  23178. displayName: displayName,
  23179. enableSorting: enableSorting,
  23180. enableMenu: enableMenu,
  23181. showColumnMenu: function (source) {
  23182. _this.gridApi.showColumnMenuAfterButtonClick(_this.column, source);
  23183. },
  23184. progressSort: function (multiSort) {
  23185. _this.sortController.progressSort(_this.column, !!multiSort, "uiColumnSorted");
  23186. },
  23187. setSort: function (sort, multiSort) {
  23188. _this.sortController.setSortForColumn(_this.column, sort, !!multiSort, "uiColumnSorted");
  23189. },
  23190. api: this.gridApi,
  23191. columnApi: this.columnApi,
  23192. context: this.gridOptionsWrapper.getContext()
  23193. };
  23194. var callback = this.afterHeaderCompCreated.bind(this, displayName);
  23195. this.userComponentFactory.newHeaderComponent(params).then(callback);
  23196. };
  23197. HeaderWrapperComp.prototype.afterHeaderCompCreated = function (displayName, headerComp) {
  23198. var _this = this;
  23199. this.getGui().appendChild(headerComp.getGui());
  23200. this.addDestroyFunc(function () {
  23201. _this.getContext().destroyBean(headerComp);
  23202. });
  23203. this.setupMove(headerComp.getGui(), displayName);
  23204. this.headerComp = headerComp;
  23205. };
  23206. HeaderWrapperComp.prototype.onColumnMovingChanged = function () {
  23207. // this function adds or removes the moving css, based on if the col is moving.
  23208. // this is what makes the header go dark when it is been moved (gives impression to
  23209. // user that the column was picked up).
  23210. if (this.column.isMoving()) {
  23211. _.addCssClass(this.getGui(), 'ag-header-cell-moving');
  23212. }
  23213. else {
  23214. _.removeCssClass(this.getGui(), 'ag-header-cell-moving');
  23215. }
  23216. };
  23217. HeaderWrapperComp.prototype.setupMove = function (eHeaderCellLabel, displayName) {
  23218. var _this = this;
  23219. var colDef = this.column.getColDef();
  23220. var suppressMove = this.gridOptionsWrapper.isSuppressMovableColumns()
  23221. || this.getComponentHolder().suppressMovable
  23222. || colDef.lockPosition;
  23223. if (suppressMove &&
  23224. !colDef.enableRowGroup &&
  23225. !colDef.enablePivot) {
  23226. return;
  23227. }
  23228. if (eHeaderCellLabel) {
  23229. var dragSource_1 = {
  23230. type: exports.DragSourceType.HeaderCell,
  23231. eElement: eHeaderCellLabel,
  23232. defaultIconName: DragAndDropService.ICON_HIDE,
  23233. getDragItem: function () { return _this.createDragItem(); },
  23234. dragItemName: displayName,
  23235. dragSourceDropTarget: this.dragSourceDropTarget,
  23236. onDragStarted: function () { return !suppressMove && _this.column.setMoving(true, "uiColumnMoved"); },
  23237. onDragStopped: function () { return !suppressMove && _this.column.setMoving(false, "uiColumnMoved"); }
  23238. };
  23239. this.dragAndDropService.addDragSource(dragSource_1, true);
  23240. this.addDestroyFunc(function () { return _this.dragAndDropService.removeDragSource(dragSource_1); });
  23241. }
  23242. };
  23243. HeaderWrapperComp.prototype.createDragItem = function () {
  23244. var visibleState = {};
  23245. visibleState[this.column.getId()] = this.column.isVisible();
  23246. return {
  23247. columns: [this.column],
  23248. visibleState: visibleState
  23249. };
  23250. };
  23251. HeaderWrapperComp.prototype.setupResize = function () {
  23252. var _this = this;
  23253. var colDef = this.getComponentHolder();
  23254. // if no eResize in template, do nothing
  23255. if (!this.eResize) {
  23256. return;
  23257. }
  23258. if (!this.column.isResizable()) {
  23259. _.removeFromParent(this.eResize);
  23260. return;
  23261. }
  23262. var finishedWithResizeFunc = this.horizontalResizeService.addResizeBar({
  23263. eResizeBar: this.eResize,
  23264. onResizeStart: this.onResizeStart.bind(this),
  23265. onResizing: this.onResizing.bind(this, false),
  23266. onResizeEnd: this.onResizing.bind(this, true)
  23267. });
  23268. this.addDestroyFunc(finishedWithResizeFunc);
  23269. var weWantAutoSize = !this.gridOptionsWrapper.isSuppressAutoSize() && !colDef.suppressAutoSize;
  23270. var skipHeaderOnAutoSize = this.gridOptionsWrapper.isSkipHeaderOnAutoSize();
  23271. if (weWantAutoSize) {
  23272. this.addManagedListener(this.eResize, 'dblclick', function () {
  23273. _this.columnController.autoSizeColumn(_this.column, skipHeaderOnAutoSize, "uiColumnResized");
  23274. });
  23275. var touchListener = new TouchListener(this.eResize);
  23276. this.addManagedListener(touchListener, TouchListener.EVENT_DOUBLE_TAP, function () {
  23277. _this.columnController.autoSizeColumn(_this.column, skipHeaderOnAutoSize, "uiColumnResized");
  23278. });
  23279. this.addDestroyFunc(touchListener.destroy.bind(touchListener));
  23280. }
  23281. };
  23282. HeaderWrapperComp.prototype.onResizing = function (finished, resizeAmount) {
  23283. var resizeAmountNormalised = this.normaliseResizeAmount(resizeAmount);
  23284. var columnWidths = [{ key: this.column, newWidth: this.resizeStartWidth + resizeAmountNormalised }];
  23285. this.columnController.setColumnWidths(columnWidths, this.resizeWithShiftKey, finished, "uiColumnDragged");
  23286. if (finished) {
  23287. _.removeCssClass(this.getGui(), 'ag-column-resizing');
  23288. }
  23289. };
  23290. HeaderWrapperComp.prototype.onResizeStart = function (shiftKey) {
  23291. this.resizeStartWidth = this.column.getActualWidth();
  23292. this.resizeWithShiftKey = shiftKey;
  23293. _.addCssClass(this.getGui(), 'ag-column-resizing');
  23294. };
  23295. HeaderWrapperComp.prototype.getTooltipText = function () {
  23296. var colDef = this.getComponentHolder();
  23297. return colDef.headerTooltip;
  23298. };
  23299. HeaderWrapperComp.prototype.setupTooltip = function () {
  23300. var tooltipText = this.getTooltipText();
  23301. // add tooltip if exists
  23302. if (tooltipText == null) {
  23303. return;
  23304. }
  23305. if (this.gridOptionsWrapper.isEnableBrowserTooltips()) {
  23306. this.getGui().setAttribute('title', tooltipText);
  23307. }
  23308. else {
  23309. this.createManagedBean(new TooltipFeature(this, 'header'));
  23310. }
  23311. };
  23312. HeaderWrapperComp.prototype.setupMovingCss = function () {
  23313. this.addManagedListener(this.column, Column.EVENT_MOVING_CHANGED, this.onColumnMovingChanged.bind(this));
  23314. this.onColumnMovingChanged();
  23315. };
  23316. HeaderWrapperComp.prototype.addAttributes = function () {
  23317. this.getGui().setAttribute("col-id", this.column.getColId());
  23318. };
  23319. HeaderWrapperComp.prototype.setupWidth = function () {
  23320. this.addManagedListener(this.column, Column.EVENT_WIDTH_CHANGED, this.onColumnWidthChanged.bind(this));
  23321. this.onColumnWidthChanged();
  23322. };
  23323. HeaderWrapperComp.prototype.setupMenuClass = function () {
  23324. this.addManagedListener(this.column, Column.EVENT_MENU_VISIBLE_CHANGED, this.onMenuVisible.bind(this));
  23325. this.onColumnWidthChanged();
  23326. };
  23327. HeaderWrapperComp.prototype.onMenuVisible = function () {
  23328. this.addOrRemoveCssClass('ag-column-menu-visible', this.column.isMenuVisible());
  23329. };
  23330. HeaderWrapperComp.prototype.onColumnWidthChanged = function () {
  23331. this.getGui().style.width = this.column.getActualWidth() + 'px';
  23332. };
  23333. // optionally inverts the drag, depending on pinned and RTL
  23334. // note - this method is duplicated in RenderedHeaderGroupCell - should refactor out?
  23335. HeaderWrapperComp.prototype.normaliseResizeAmount = function (dragChange) {
  23336. var result = dragChange;
  23337. if (this.gridOptionsWrapper.isEnableRtl()) {
  23338. // for RTL, dragging left makes the col bigger, except when pinning left
  23339. if (this.pinned !== Constants.PINNED_LEFT) {
  23340. result *= -1;
  23341. }
  23342. }
  23343. else {
  23344. // for LTR (ie normal), dragging left makes the col smaller, except when pinning right
  23345. if (this.pinned === Constants.PINNED_RIGHT) {
  23346. result *= -1;
  23347. }
  23348. }
  23349. return result;
  23350. };
  23351. HeaderWrapperComp.TEMPLATE = "<div class=\"ag-header-cell\" role=\"presentation\" unselectable=\"on\" tabindex=\"-1\">\n <div ref=\"eResize\" class=\"ag-header-cell-resize\" role=\"presentation\"></div>\n <ag-checkbox ref=\"cbSelectAll\" class=\"ag-header-select-all\" role=\"presentation\"></ag-checkbox>\n </div>";
  23352. __decorate$M([
  23353. Autowired('gridOptionsWrapper')
  23354. ], HeaderWrapperComp.prototype, "gridOptionsWrapper", void 0);
  23355. __decorate$M([
  23356. Autowired('dragAndDropService')
  23357. ], HeaderWrapperComp.prototype, "dragAndDropService", void 0);
  23358. __decorate$M([
  23359. Autowired('columnController')
  23360. ], HeaderWrapperComp.prototype, "columnController", void 0);
  23361. __decorate$M([
  23362. Autowired('horizontalResizeService')
  23363. ], HeaderWrapperComp.prototype, "horizontalResizeService", void 0);
  23364. __decorate$M([
  23365. Autowired('menuFactory')
  23366. ], HeaderWrapperComp.prototype, "menuFactory", void 0);
  23367. __decorate$M([
  23368. Autowired('gridApi')
  23369. ], HeaderWrapperComp.prototype, "gridApi", void 0);
  23370. __decorate$M([
  23371. Autowired('columnApi')
  23372. ], HeaderWrapperComp.prototype, "columnApi", void 0);
  23373. __decorate$M([
  23374. Autowired('sortController')
  23375. ], HeaderWrapperComp.prototype, "sortController", void 0);
  23376. __decorate$M([
  23377. Autowired('userComponentFactory')
  23378. ], HeaderWrapperComp.prototype, "userComponentFactory", void 0);
  23379. __decorate$M([
  23380. Autowired('columnHoverService')
  23381. ], HeaderWrapperComp.prototype, "columnHoverService", void 0);
  23382. __decorate$M([
  23383. Autowired('beans')
  23384. ], HeaderWrapperComp.prototype, "beans", void 0);
  23385. __decorate$M([
  23386. RefSelector('eResize')
  23387. ], HeaderWrapperComp.prototype, "eResize", void 0);
  23388. __decorate$M([
  23389. RefSelector('cbSelectAll')
  23390. ], HeaderWrapperComp.prototype, "cbSelectAll", void 0);
  23391. return HeaderWrapperComp;
  23392. }(AbstractHeaderWrapper));
  23393. /**
  23394. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  23395. * @version v23.2.1
  23396. * @link http://www.ag-grid.com/
  23397. * @license MIT
  23398. */
  23399. var __extends$S = (undefined && undefined.__extends) || (function () {
  23400. var extendStatics = function (d, b) {
  23401. extendStatics = Object.setPrototypeOf ||
  23402. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  23403. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  23404. return extendStatics(d, b);
  23405. };
  23406. return function (d, b) {
  23407. extendStatics(d, b);
  23408. function __() { this.constructor = d; }
  23409. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  23410. };
  23411. })();
  23412. var __decorate$N = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  23413. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  23414. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  23415. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  23416. return c > 3 && r && Object.defineProperty(target, key, r), r;
  23417. };
  23418. var HeaderGroupWrapperComp = /** @class */ (function (_super) {
  23419. __extends$S(HeaderGroupWrapperComp, _super);
  23420. function HeaderGroupWrapperComp(columnGroup, dragSourceDropTarget, pinned) {
  23421. var _this = _super.call(this, HeaderGroupWrapperComp.TEMPLATE) || this;
  23422. // the children can change, we keep destroy functions related to listening to the children here
  23423. _this.removeChildListenersFuncs = [];
  23424. _this.column = columnGroup;
  23425. _this.dragSourceDropTarget = dragSourceDropTarget;
  23426. _this.pinned = pinned;
  23427. return _this;
  23428. }
  23429. HeaderGroupWrapperComp.prototype.postConstruct = function () {
  23430. _super.prototype.postConstruct.call(this);
  23431. CssClassApplier.addHeaderClassesFromColDef(this.getComponentHolder(), this.getGui(), this.gridOptionsWrapper, null, this.column);
  23432. var displayName = this.columnController.getDisplayNameForColumnGroup(this.column, 'header');
  23433. this.appendHeaderGroupComp(displayName);
  23434. this.setupResize();
  23435. this.addClasses();
  23436. this.setupWidth();
  23437. this.addAttributes();
  23438. this.setupMovingCss();
  23439. this.setupTooltip();
  23440. this.createManagedBean(new HoverFeature(this.column.getOriginalColumnGroup().getLeafColumns(), this.getGui()));
  23441. this.createManagedBean(new SetLeftFeature(this.column, this.getGui(), this.beans));
  23442. };
  23443. HeaderGroupWrapperComp.prototype.onFocusIn = function (e) {
  23444. if (!this.getGui().contains(e.relatedTarget)) {
  23445. var headerRow = this.getParentComponent();
  23446. this.beans.focusController.setFocusedHeader(headerRow.getRowIndex(), this.getColumn());
  23447. }
  23448. };
  23449. HeaderGroupWrapperComp.prototype.handleKeyDown = function (e) {
  23450. var activeEl = document.activeElement;
  23451. var eGui = this.getGui();
  23452. var wrapperHasFocus = activeEl === eGui;
  23453. switch (e.keyCode) {
  23454. case Constants.KEY_ENTER:
  23455. if (wrapperHasFocus) {
  23456. var column = this.getColumn();
  23457. var expandable = column.isExpandable();
  23458. if (expandable) {
  23459. var newExpandedValue = !column.isExpanded();
  23460. this.columnController.setColumnGroupOpened(column.getOriginalColumnGroup(), newExpandedValue, "uiColumnExpanded");
  23461. }
  23462. }
  23463. }
  23464. };
  23465. HeaderGroupWrapperComp.prototype.setupMovingCss = function () {
  23466. var _this = this;
  23467. var originalColumnGroup = this.column.getOriginalColumnGroup();
  23468. var leafColumns = originalColumnGroup.getLeafColumns();
  23469. leafColumns.forEach(function (col) {
  23470. _this.addManagedListener(col, Column.EVENT_MOVING_CHANGED, _this.onColumnMovingChanged.bind(_this));
  23471. });
  23472. this.onColumnMovingChanged();
  23473. };
  23474. HeaderGroupWrapperComp.prototype.getComponentHolder = function () {
  23475. return this.column.getColGroupDef();
  23476. };
  23477. HeaderGroupWrapperComp.prototype.getTooltipText = function () {
  23478. var colGroupDef = this.getComponentHolder();
  23479. return colGroupDef && colGroupDef.headerTooltip;
  23480. };
  23481. HeaderGroupWrapperComp.prototype.setupTooltip = function () {
  23482. var tooltipText = this.getTooltipText();
  23483. if (tooltipText == null) {
  23484. return;
  23485. }
  23486. if (this.gridOptionsWrapper.isEnableBrowserTooltips()) {
  23487. this.getGui().setAttribute('title', tooltipText);
  23488. }
  23489. else {
  23490. this.createManagedBean(new TooltipFeature(this, 'headerGroup'));
  23491. }
  23492. };
  23493. HeaderGroupWrapperComp.prototype.onColumnMovingChanged = function () {
  23494. // this function adds or removes the moving css, based on if the col is moving.
  23495. // this is what makes the header go dark when it is been moved (gives impression to
  23496. // user that the column was picked up).
  23497. _.addOrRemoveCssClass(this.getGui(), 'ag-header-cell-moving', this.column.isMoving());
  23498. };
  23499. HeaderGroupWrapperComp.prototype.addAttributes = function () {
  23500. this.getGui().setAttribute("col-id", this.column.getUniqueId());
  23501. };
  23502. HeaderGroupWrapperComp.prototype.appendHeaderGroupComp = function (displayName) {
  23503. var _this = this;
  23504. var params = {
  23505. displayName: displayName,
  23506. columnGroup: this.column,
  23507. setExpanded: function (expanded) {
  23508. _this.columnController.setColumnGroupOpened(_this.column.getOriginalColumnGroup(), expanded, "gridInitializing");
  23509. },
  23510. api: this.gridApi,
  23511. columnApi: this.columnApi,
  23512. context: this.gridOptionsWrapper.getContext()
  23513. };
  23514. if (!displayName) {
  23515. var columnGroup = this.column;
  23516. var leafCols = columnGroup.getLeafColumns();
  23517. // find the top most column group that represents the same columns. so if we are dragging a group, we also
  23518. // want to visually show the parent groups dragging for the same column set. for example imaging 5 levels
  23519. // of grouping, with each group only containing the next group, and the last group containing three columns,
  23520. // then when you move any group (even the lowest level group) you are in-fact moving all the groups, as all
  23521. // the groups represent the same column set.
  23522. while (columnGroup.getParent() && columnGroup.getParent().getLeafColumns().length === leafCols.length) {
  23523. columnGroup = columnGroup.getParent();
  23524. }
  23525. var colGroupDef = columnGroup.getColGroupDef();
  23526. if (colGroupDef) {
  23527. displayName = colGroupDef.headerName;
  23528. }
  23529. if (!displayName) {
  23530. displayName = leafCols ? this.columnController.getDisplayNameForColumn(leafCols[0], 'header', true) : '';
  23531. }
  23532. }
  23533. var callback = this.afterHeaderCompCreated.bind(this, displayName);
  23534. this.userComponentFactory.newHeaderGroupComponent(params).then(callback);
  23535. };
  23536. HeaderGroupWrapperComp.prototype.afterHeaderCompCreated = function (displayName, headerGroupComp) {
  23537. var _this = this;
  23538. this.getGui().appendChild(headerGroupComp.getGui());
  23539. this.addDestroyFunc(function () {
  23540. _this.getContext().destroyBean(headerGroupComp);
  23541. });
  23542. this.setupMove(headerGroupComp.getGui(), displayName);
  23543. };
  23544. HeaderGroupWrapperComp.prototype.addClasses = function () {
  23545. // having different classes below allows the style to not have a bottom border
  23546. // on the group header, if no group is specified
  23547. // columnGroup.getColGroupDef
  23548. var style = this.column.isPadding() ? 'no' : 'with';
  23549. this.addCssClass("ag-header-group-cell-" + style + "-group");
  23550. };
  23551. HeaderGroupWrapperComp.prototype.setupMove = function (eHeaderGroup, displayName) {
  23552. var _this = this;
  23553. if (!eHeaderGroup) {
  23554. return;
  23555. }
  23556. if (this.isSuppressMoving()) {
  23557. return;
  23558. }
  23559. var allLeafColumns = this.column.getOriginalColumnGroup().getLeafColumns();
  23560. var dragSource = {
  23561. type: exports.DragSourceType.HeaderCell,
  23562. eElement: eHeaderGroup,
  23563. defaultIconName: DragAndDropService.ICON_HIDE,
  23564. dragItemName: displayName,
  23565. // we add in the original group leaf columns, so we move both visible and non-visible items
  23566. getDragItem: this.getDragItemForGroup.bind(this),
  23567. dragSourceDropTarget: this.dragSourceDropTarget,
  23568. onDragStarted: function () { return allLeafColumns.forEach(function (col) { return col.setMoving(true, "uiColumnDragged"); }); },
  23569. onDragStopped: function () { return allLeafColumns.forEach(function (col) { return col.setMoving(false, "uiColumnDragged"); }); }
  23570. };
  23571. this.dragAndDropService.addDragSource(dragSource, true);
  23572. this.addDestroyFunc(function () { return _this.dragAndDropService.removeDragSource(dragSource); });
  23573. };
  23574. // when moving the columns, we want to move all the columns (contained within the DragItem) in this group in one go,
  23575. // and in the order they are currently in the screen.
  23576. HeaderGroupWrapperComp.prototype.getDragItemForGroup = function () {
  23577. var allColumnsOriginalOrder = this.column.getOriginalColumnGroup().getLeafColumns();
  23578. // capture visible state, used when re-entering grid to dictate which columns should be visible
  23579. var visibleState = {};
  23580. allColumnsOriginalOrder.forEach(function (column) { return visibleState[column.getId()] = column.isVisible(); });
  23581. var allColumnsCurrentOrder = [];
  23582. this.columnController.getAllDisplayedColumns().forEach(function (column) {
  23583. if (allColumnsOriginalOrder.indexOf(column) >= 0) {
  23584. allColumnsCurrentOrder.push(column);
  23585. _.removeFromArray(allColumnsOriginalOrder, column);
  23586. }
  23587. });
  23588. // we are left with non-visible columns, stick these in at the end
  23589. allColumnsOriginalOrder.forEach(function (column) { return allColumnsCurrentOrder.push(column); });
  23590. // create and return dragItem
  23591. return {
  23592. columns: allColumnsCurrentOrder,
  23593. visibleState: visibleState
  23594. };
  23595. };
  23596. HeaderGroupWrapperComp.prototype.isSuppressMoving = function () {
  23597. // if any child is fixed, then don't allow moving
  23598. var childSuppressesMoving = false;
  23599. this.column.getLeafColumns().forEach(function (column) {
  23600. if (column.getColDef().suppressMovable || column.getColDef().lockPosition) {
  23601. childSuppressesMoving = true;
  23602. }
  23603. });
  23604. var result = childSuppressesMoving || this.gridOptionsWrapper.isSuppressMovableColumns();
  23605. return result;
  23606. };
  23607. HeaderGroupWrapperComp.prototype.setupWidth = function () {
  23608. // we need to listen to changes in child columns, as they impact our width
  23609. this.addListenersToChildrenColumns();
  23610. // the children belonging to this group can change, so we need to add and remove listeners as they change
  23611. this.addManagedListener(this.column, ColumnGroup.EVENT_DISPLAYED_CHILDREN_CHANGED, this.onDisplayedChildrenChanged.bind(this));
  23612. this.onWidthChanged();
  23613. // the child listeners are not tied to this components life-cycle, as children can get added and removed
  23614. // to the group - hence they are on a different life-cycle. so we must make sure the existing children
  23615. // listeners are removed when we finally get destroyed
  23616. this.addDestroyFunc(this.removeListenersOnChildrenColumns.bind(this));
  23617. };
  23618. HeaderGroupWrapperComp.prototype.onDisplayedChildrenChanged = function () {
  23619. this.addListenersToChildrenColumns();
  23620. this.onWidthChanged();
  23621. };
  23622. HeaderGroupWrapperComp.prototype.addListenersToChildrenColumns = function () {
  23623. var _this = this;
  23624. // first destroy any old listeners
  23625. this.removeListenersOnChildrenColumns();
  23626. // now add new listeners to the new set of children
  23627. var widthChangedListener = this.onWidthChanged.bind(this);
  23628. this.column.getLeafColumns().forEach(function (column) {
  23629. column.addEventListener(Column.EVENT_WIDTH_CHANGED, widthChangedListener);
  23630. column.addEventListener(Column.EVENT_VISIBLE_CHANGED, widthChangedListener);
  23631. _this.removeChildListenersFuncs.push(function () {
  23632. column.removeEventListener(Column.EVENT_WIDTH_CHANGED, widthChangedListener);
  23633. column.removeEventListener(Column.EVENT_VISIBLE_CHANGED, widthChangedListener);
  23634. });
  23635. });
  23636. };
  23637. HeaderGroupWrapperComp.prototype.removeListenersOnChildrenColumns = function () {
  23638. this.removeChildListenersFuncs.forEach(function (func) { return func(); });
  23639. this.removeChildListenersFuncs = [];
  23640. };
  23641. HeaderGroupWrapperComp.prototype.onWidthChanged = function () {
  23642. this.getGui().style.width = this.column.getActualWidth() + 'px';
  23643. };
  23644. HeaderGroupWrapperComp.prototype.setupResize = function () {
  23645. var _this = this;
  23646. this.eHeaderCellResize = this.getRefElement('agResize');
  23647. if (!this.column.isResizable()) {
  23648. _.removeFromParent(this.eHeaderCellResize);
  23649. return;
  23650. }
  23651. var finishedWithResizeFunc = this.horizontalResizeService.addResizeBar({
  23652. eResizeBar: this.eHeaderCellResize,
  23653. onResizeStart: this.onResizeStart.bind(this),
  23654. onResizing: this.onResizing.bind(this, false),
  23655. onResizeEnd: this.onResizing.bind(this, true)
  23656. });
  23657. this.addDestroyFunc(finishedWithResizeFunc);
  23658. if (!this.gridOptionsWrapper.isSuppressAutoSize()) {
  23659. var skipHeaderOnAutoSize_1 = this.gridOptionsWrapper.isSkipHeaderOnAutoSize();
  23660. this.eHeaderCellResize.addEventListener('dblclick', function (event) {
  23661. // get list of all the column keys we are responsible for
  23662. var keys = [];
  23663. _this.column.getDisplayedLeafColumns().forEach(function (column) {
  23664. // not all cols in the group may be participating with auto-resize
  23665. if (!column.getColDef().suppressAutoSize) {
  23666. keys.push(column.getColId());
  23667. }
  23668. });
  23669. if (keys.length > 0) {
  23670. _this.columnController.autoSizeColumns(keys, skipHeaderOnAutoSize_1, "uiColumnResized");
  23671. }
  23672. });
  23673. }
  23674. };
  23675. HeaderGroupWrapperComp.prototype.onResizeStart = function (shiftKey) {
  23676. var _this = this;
  23677. var leafCols = this.column.getDisplayedLeafColumns();
  23678. this.resizeCols = leafCols.filter(function (col) { return col.isResizable(); });
  23679. this.resizeStartWidth = 0;
  23680. this.resizeCols.forEach(function (col) { return _this.resizeStartWidth += col.getActualWidth(); });
  23681. this.resizeRatios = [];
  23682. this.resizeCols.forEach(function (col) { return _this.resizeRatios.push(col.getActualWidth() / _this.resizeStartWidth); });
  23683. var takeFromGroup = null;
  23684. if (shiftKey) {
  23685. takeFromGroup = this.columnController.getDisplayedGroupAfter(this.column);
  23686. }
  23687. if (takeFromGroup) {
  23688. var takeFromLeafCols = takeFromGroup.getDisplayedLeafColumns();
  23689. this.resizeTakeFromCols = takeFromLeafCols.filter(function (col) { return col.isResizable(); });
  23690. this.resizeTakeFromStartWidth = 0;
  23691. this.resizeTakeFromCols.forEach(function (col) { return _this.resizeTakeFromStartWidth += col.getActualWidth(); });
  23692. this.resizeTakeFromRatios = [];
  23693. this.resizeTakeFromCols.forEach(function (col) { return _this.resizeTakeFromRatios.push(col.getActualWidth() / _this.resizeTakeFromStartWidth); });
  23694. }
  23695. else {
  23696. this.resizeTakeFromCols = null;
  23697. this.resizeTakeFromStartWidth = null;
  23698. this.resizeTakeFromRatios = null;
  23699. }
  23700. _.addCssClass(this.getGui(), 'ag-column-resizing');
  23701. };
  23702. HeaderGroupWrapperComp.prototype.onResizing = function (finished, resizeAmount) {
  23703. var resizeSets = [];
  23704. var resizeAmountNormalised = this.normaliseDragChange(resizeAmount);
  23705. resizeSets.push({
  23706. columns: this.resizeCols,
  23707. ratios: this.resizeRatios,
  23708. width: this.resizeStartWidth + resizeAmountNormalised
  23709. });
  23710. if (this.resizeTakeFromCols) {
  23711. resizeSets.push({
  23712. columns: this.resizeTakeFromCols,
  23713. ratios: this.resizeTakeFromRatios,
  23714. width: this.resizeTakeFromStartWidth - resizeAmountNormalised
  23715. });
  23716. }
  23717. this.columnController.resizeColumnSets(resizeSets, finished, 'uiColumnDragged');
  23718. if (finished) {
  23719. _.removeCssClass(this.getGui(), 'ag-column-resizing');
  23720. }
  23721. };
  23722. // optionally inverts the drag, depending on pinned and RTL
  23723. // note - this method is duplicated in RenderedHeaderCell - should refactor out?
  23724. HeaderGroupWrapperComp.prototype.normaliseDragChange = function (dragChange) {
  23725. var result = dragChange;
  23726. if (this.gridOptionsWrapper.isEnableRtl()) {
  23727. // for RTL, dragging left makes the col bigger, except when pinning left
  23728. if (this.pinned !== Constants.PINNED_LEFT) {
  23729. result *= -1;
  23730. }
  23731. }
  23732. else if (this.pinned === Constants.PINNED_RIGHT) {
  23733. // for LTR (ie normal), dragging left makes the col smaller, except when pinning right
  23734. result *= -1;
  23735. }
  23736. return result;
  23737. };
  23738. HeaderGroupWrapperComp.TEMPLATE = "<div class=\"ag-header-group-cell\" role=\"presentation\" tabindex=\"-1\">\n <div ref=\"agResize\" class=\"ag-header-cell-resize\" role=\"presentation\"></div>\n </div>";
  23739. __decorate$N([
  23740. Autowired('gridOptionsWrapper')
  23741. ], HeaderGroupWrapperComp.prototype, "gridOptionsWrapper", void 0);
  23742. __decorate$N([
  23743. Autowired('columnController')
  23744. ], HeaderGroupWrapperComp.prototype, "columnController", void 0);
  23745. __decorate$N([
  23746. Autowired('horizontalResizeService')
  23747. ], HeaderGroupWrapperComp.prototype, "horizontalResizeService", void 0);
  23748. __decorate$N([
  23749. Autowired('dragAndDropService')
  23750. ], HeaderGroupWrapperComp.prototype, "dragAndDropService", void 0);
  23751. __decorate$N([
  23752. Autowired('userComponentFactory')
  23753. ], HeaderGroupWrapperComp.prototype, "userComponentFactory", void 0);
  23754. __decorate$N([
  23755. Autowired('beans')
  23756. ], HeaderGroupWrapperComp.prototype, "beans", void 0);
  23757. __decorate$N([
  23758. Autowired('gridApi')
  23759. ], HeaderGroupWrapperComp.prototype, "gridApi", void 0);
  23760. __decorate$N([
  23761. Autowired('columnApi')
  23762. ], HeaderGroupWrapperComp.prototype, "columnApi", void 0);
  23763. return HeaderGroupWrapperComp;
  23764. }(AbstractHeaderWrapper));
  23765. /**
  23766. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  23767. * @version v23.2.1
  23768. * @link http://www.ag-grid.com/
  23769. * @license MIT
  23770. */
  23771. var __extends$T = (undefined && undefined.__extends) || (function () {
  23772. var extendStatics = function (d, b) {
  23773. extendStatics = Object.setPrototypeOf ||
  23774. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  23775. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  23776. return extendStatics(d, b);
  23777. };
  23778. return function (d, b) {
  23779. extendStatics(d, b);
  23780. function __() { this.constructor = d; }
  23781. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  23782. };
  23783. })();
  23784. var __decorate$O = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  23785. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  23786. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  23787. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  23788. return c > 3 && r && Object.defineProperty(target, key, r), r;
  23789. };
  23790. // optional floating filter for user provided filters - instead of providing a floating filter,
  23791. // they can provide a getModelAsString() method on the filter instead. this class just displays
  23792. // the string returned from getModelAsString()
  23793. var ReadOnlyFloatingFilter = /** @class */ (function (_super) {
  23794. __extends$T(ReadOnlyFloatingFilter, _super);
  23795. function ReadOnlyFloatingFilter() {
  23796. return _super.call(this, /* html */ "\n <div class=\"ag-floating-filter-input\" role=\"presentation\">\n <ag-input-text-field ref=\"eFloatingFilterText\"></ag-input-text-field>\n </div>") || this;
  23797. }
  23798. // this is a user component, and IComponent has "public destroy()" as part of the interface.
  23799. // so we need to override destroy() just to make the method public.
  23800. ReadOnlyFloatingFilter.prototype.destroy = function () {
  23801. _super.prototype.destroy.call(this);
  23802. };
  23803. ReadOnlyFloatingFilter.prototype.init = function (params) {
  23804. this.params = params;
  23805. var displayName = this.columnController.getDisplayNameForColumn(params.column, 'header', true);
  23806. this.eFloatingFilterText
  23807. .setDisabled(true)
  23808. .setInputAriaLabel(displayName + " Filter Input");
  23809. };
  23810. ReadOnlyFloatingFilter.prototype.onParentModelChanged = function (parentModel) {
  23811. var _this = this;
  23812. if (!parentModel) {
  23813. this.eFloatingFilterText.setValue('');
  23814. return;
  23815. }
  23816. this.params.parentFilterInstance(function (filterInstance) {
  23817. // getModelAsString should be present, as we check this
  23818. // in floatingFilterWrapper
  23819. if (filterInstance.getModelAsString) {
  23820. var modelAsString = filterInstance.getModelAsString(parentModel);
  23821. _this.eFloatingFilterText.setValue(modelAsString);
  23822. }
  23823. });
  23824. };
  23825. __decorate$O([
  23826. RefSelector('eFloatingFilterText')
  23827. ], ReadOnlyFloatingFilter.prototype, "eFloatingFilterText", void 0);
  23828. __decorate$O([
  23829. Autowired('columnController')
  23830. ], ReadOnlyFloatingFilter.prototype, "columnController", void 0);
  23831. return ReadOnlyFloatingFilter;
  23832. }(Component));
  23833. /**
  23834. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  23835. * @version v23.2.1
  23836. * @link http://www.ag-grid.com/
  23837. * @license MIT
  23838. */
  23839. var __extends$U = (undefined && undefined.__extends) || (function () {
  23840. var extendStatics = function (d, b) {
  23841. extendStatics = Object.setPrototypeOf ||
  23842. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  23843. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  23844. return extendStatics(d, b);
  23845. };
  23846. return function (d, b) {
  23847. extendStatics(d, b);
  23848. function __() { this.constructor = d; }
  23849. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  23850. };
  23851. })();
  23852. var __decorate$P = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  23853. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  23854. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  23855. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  23856. return c > 3 && r && Object.defineProperty(target, key, r), r;
  23857. };
  23858. var FloatingFilterWrapper = /** @class */ (function (_super) {
  23859. __extends$U(FloatingFilterWrapper, _super);
  23860. function FloatingFilterWrapper(column, pinned) {
  23861. var _this = _super.call(this, FloatingFilterWrapper.TEMPLATE) || this;
  23862. _this.column = column;
  23863. _this.pinned = pinned;
  23864. return _this;
  23865. }
  23866. FloatingFilterWrapper.prototype.postConstruct = function () {
  23867. _super.prototype.postConstruct.call(this);
  23868. this.setupFloatingFilter();
  23869. this.setupWidth();
  23870. this.setupLeftPositioning();
  23871. this.setupColumnHover();
  23872. this.createManagedBean(new HoverFeature([this.column], this.getGui()));
  23873. this.addManagedListener(this.eButtonShowMainFilter, 'click', this.showParentFilter.bind(this));
  23874. };
  23875. FloatingFilterWrapper.prototype.onTabKeyDown = function (e) {
  23876. var activeEl = document.activeElement;
  23877. var eGui = this.getGui();
  23878. var wrapperHasFocus = activeEl === eGui;
  23879. if (wrapperHasFocus) {
  23880. return;
  23881. }
  23882. e.preventDefault();
  23883. var nextFocusableEl = this.focusController.findNextFocusableElement(eGui, null, e.shiftKey);
  23884. if (nextFocusableEl) {
  23885. nextFocusableEl.focus();
  23886. }
  23887. else {
  23888. eGui.focus();
  23889. }
  23890. };
  23891. FloatingFilterWrapper.prototype.handleKeyDown = function (e) {
  23892. var activeEl = document.activeElement;
  23893. var eGui = this.getGui();
  23894. var wrapperHasFocus = activeEl === eGui;
  23895. switch (e.keyCode) {
  23896. case Constants.KEY_UP:
  23897. case Constants.KEY_DOWN:
  23898. if (!wrapperHasFocus) {
  23899. e.preventDefault();
  23900. }
  23901. case Constants.KEY_LEFT:
  23902. case Constants.KEY_RIGHT:
  23903. if (wrapperHasFocus) {
  23904. return;
  23905. }
  23906. e.stopPropagation();
  23907. case Constants.KEY_ENTER:
  23908. if (wrapperHasFocus) {
  23909. if (this.focusController.focusFirstFocusableElement(eGui)) {
  23910. e.preventDefault();
  23911. }
  23912. }
  23913. break;
  23914. case Constants.KEY_ESCAPE:
  23915. if (!wrapperHasFocus) {
  23916. this.getGui().focus();
  23917. }
  23918. }
  23919. };
  23920. FloatingFilterWrapper.prototype.onFocusIn = function (e) {
  23921. var eGui = this.getGui();
  23922. if (!eGui.contains(e.relatedTarget)) {
  23923. var headerRow = this.getParentComponent();
  23924. this.beans.focusController.setFocusedHeader(headerRow.getRowIndex(), this.getColumn());
  23925. }
  23926. };
  23927. FloatingFilterWrapper.prototype.setupFloatingFilter = function () {
  23928. var _this = this;
  23929. var colDef = this.column.getColDef();
  23930. if (colDef.filter && colDef.floatingFilter) {
  23931. this.floatingFilterCompPromise = this.getFloatingFilterInstance();
  23932. if (this.floatingFilterCompPromise) {
  23933. this.floatingFilterCompPromise.then(function (compInstance) {
  23934. if (compInstance) {
  23935. _this.setupWithFloatingFilter(compInstance);
  23936. _this.setupSyncWithFilter();
  23937. }
  23938. else {
  23939. _this.setupEmpty();
  23940. }
  23941. });
  23942. }
  23943. else {
  23944. this.setupEmpty();
  23945. }
  23946. }
  23947. else {
  23948. this.setupEmpty();
  23949. }
  23950. };
  23951. FloatingFilterWrapper.prototype.setupLeftPositioning = function () {
  23952. var setLeftFeature = new SetLeftFeature(this.column, this.getGui(), this.beans);
  23953. this.createManagedBean(setLeftFeature);
  23954. };
  23955. FloatingFilterWrapper.prototype.setupSyncWithFilter = function () {
  23956. var _this = this;
  23957. var syncWithFilter = function (filterChangedEvent) {
  23958. var parentModel = _this.getFilterComponent().resolveNow(null, function (filter) { return filter.getModel(); });
  23959. _this.onParentModelChanged(parentModel, filterChangedEvent);
  23960. };
  23961. this.addManagedListener(this.column, Column.EVENT_FILTER_CHANGED, syncWithFilter);
  23962. if (this.filterManager.isFilterActive(this.column)) {
  23963. syncWithFilter(null);
  23964. }
  23965. };
  23966. // linked to event listener in template
  23967. FloatingFilterWrapper.prototype.showParentFilter = function () {
  23968. this.menuFactory.showMenuAfterButtonClick(this.column, this.eButtonShowMainFilter, 'filterMenuTab', ['filterMenuTab']);
  23969. };
  23970. FloatingFilterWrapper.prototype.setupColumnHover = function () {
  23971. this.addManagedListener(this.eventService, Events.EVENT_COLUMN_HOVER_CHANGED, this.onColumnHover.bind(this));
  23972. this.onColumnHover();
  23973. };
  23974. FloatingFilterWrapper.prototype.onColumnHover = function () {
  23975. addOrRemoveCssClass(this.getGui(), 'ag-column-hover', this.columnHoverService.isHovered(this.column));
  23976. };
  23977. FloatingFilterWrapper.prototype.setupWidth = function () {
  23978. this.addManagedListener(this.column, Column.EVENT_WIDTH_CHANGED, this.onColumnWidthChanged.bind(this));
  23979. this.onColumnWidthChanged();
  23980. };
  23981. FloatingFilterWrapper.prototype.onColumnWidthChanged = function () {
  23982. this.getGui().style.width = this.column.getActualWidth() + "px";
  23983. };
  23984. FloatingFilterWrapper.prototype.setupWithFloatingFilter = function (floatingFilterComp) {
  23985. var _this = this;
  23986. var disposeFunc = function () {
  23987. _this.getContext().destroyBean(floatingFilterComp);
  23988. };
  23989. if (!this.isAlive()) {
  23990. disposeFunc();
  23991. return;
  23992. }
  23993. this.addDestroyFunc(disposeFunc);
  23994. var floatingFilterCompUi = floatingFilterComp.getGui();
  23995. addOrRemoveCssClass(this.eFloatingFilterBody, 'ag-floating-filter-body', !this.suppressFilterButton);
  23996. addOrRemoveCssClass(this.eFloatingFilterBody, 'ag-floating-filter-full-body', this.suppressFilterButton);
  23997. setDisplayed(this.eButtonWrapper, !this.suppressFilterButton);
  23998. var eIcon = createIconNoSpan('filter', this.gridOptionsWrapper, this.column);
  23999. this.eButtonShowMainFilter.appendChild(eIcon);
  24000. this.eFloatingFilterBody.appendChild(floatingFilterCompUi);
  24001. if (floatingFilterComp.afterGuiAttached) {
  24002. floatingFilterComp.afterGuiAttached();
  24003. }
  24004. };
  24005. FloatingFilterWrapper.prototype.parentFilterInstance = function (callback) {
  24006. this.getFilterComponent().then(callback);
  24007. };
  24008. FloatingFilterWrapper.prototype.getFilterComponent = function () {
  24009. return this.filterManager.getFilterComponent(this.column, 'NO_UI');
  24010. };
  24011. FloatingFilterWrapper.prototype.getFloatingFilterInstance = function () {
  24012. var colDef = this.column.getColDef();
  24013. var defaultFloatingFilterType;
  24014. if (typeof colDef.filter === 'string') {
  24015. // will be undefined if not in the map
  24016. defaultFloatingFilterType = FloatingFilterWrapper.filterToFloatingFilterNames[colDef.filter];
  24017. }
  24018. else if (colDef.filterFramework) ;
  24019. else if (colDef.filter === true) {
  24020. var setFilterModuleLoaded = ModuleRegistry.isRegistered(exports.ModuleNames.SetFilterModule);
  24021. defaultFloatingFilterType = setFilterModuleLoaded ? 'agSetColumnFloatingFilter' : 'agTextColumnFloatingFilter';
  24022. }
  24023. var filterParams = this.filterManager.createFilterParams(this.column, this.column.getColDef());
  24024. var finalFilterParams = this.userComponentFactory.createFinalParams(colDef, 'filter', filterParams);
  24025. var params = {
  24026. api: this.gridApi,
  24027. column: this.column,
  24028. filterParams: finalFilterParams,
  24029. currentParentModel: this.currentParentModel.bind(this),
  24030. parentFilterInstance: this.parentFilterInstance.bind(this),
  24031. onFloatingFilterChanged: this.onFloatingFilterChanged.bind(this),
  24032. suppressFilterButton: false // This one might be overridden from the colDef
  24033. };
  24034. // this is unusual - we need a params value OUTSIDE the component the params are for.
  24035. // the params are for the floating filter component, but this property is actually for the wrapper.
  24036. this.suppressFilterButton = colDef.floatingFilterComponentParams ? !!colDef.floatingFilterComponentParams.suppressFilterButton : false;
  24037. var promise = this.userComponentFactory.newFloatingFilterComponent(colDef, params, defaultFloatingFilterType);
  24038. if (!promise) {
  24039. var filterComponent = this.getFilterComponentPrototype(colDef);
  24040. var getModelAsStringExists = filterComponent && filterComponent.prototype && filterComponent.prototype.getModelAsString;
  24041. if (getModelAsStringExists) {
  24042. var compInstance = this.userComponentFactory.createUserComponentFromConcreteClass(ReadOnlyFloatingFilter, params);
  24043. promise = Promise.resolve(compInstance);
  24044. }
  24045. }
  24046. return promise;
  24047. };
  24048. FloatingFilterWrapper.prototype.createDynamicParams = function () {
  24049. return {
  24050. column: this.column,
  24051. colDef: this.column.getColDef(),
  24052. api: this.gridApi,
  24053. columnApi: this.columnApi
  24054. };
  24055. };
  24056. FloatingFilterWrapper.prototype.getFilterComponentPrototype = function (colDef) {
  24057. var resolvedComponent = this.userComponentFactory.lookupComponentClassDef(colDef, 'filter', this.createDynamicParams());
  24058. return resolvedComponent ? resolvedComponent.component : null;
  24059. };
  24060. FloatingFilterWrapper.prototype.setupEmpty = function () {
  24061. setDisplayed(this.eButtonWrapper, false);
  24062. };
  24063. FloatingFilterWrapper.prototype.currentParentModel = function () {
  24064. return this.getFilterComponent().resolveNow(null, function (filter) { return filter.getModel(); });
  24065. };
  24066. FloatingFilterWrapper.prototype.onParentModelChanged = function (model, filterChangedEvent) {
  24067. if (!this.floatingFilterCompPromise) {
  24068. return;
  24069. }
  24070. this.floatingFilterCompPromise.then(function (comp) { return comp.onParentModelChanged(model, filterChangedEvent); });
  24071. };
  24072. FloatingFilterWrapper.prototype.onFloatingFilterChanged = function () {
  24073. console.warn('ag-Grid: since version 21.x, how floating filters are implemented has changed. ' +
  24074. 'Instead of calling params.onFloatingFilterChanged(), get a reference to the main filter via ' +
  24075. 'params.parentFilterInstance() and then set a value on the parent filter directly.');
  24076. };
  24077. FloatingFilterWrapper.filterToFloatingFilterNames = {
  24078. set: 'agSetColumnFloatingFilter',
  24079. agSetColumnFilter: 'agSetColumnFloatingFilter',
  24080. number: 'agNumberColumnFloatingFilter',
  24081. agNumberColumnFilter: 'agNumberColumnFloatingFilter',
  24082. date: 'agDateColumnFloatingFilter',
  24083. agDateColumnFilter: 'agDateColumnFloatingFilter',
  24084. text: 'agTextColumnFloatingFilter',
  24085. agTextColumnFilter: 'agTextColumnFloatingFilter'
  24086. };
  24087. FloatingFilterWrapper.TEMPLATE = "<div class=\"ag-header-cell\" role=\"presentation\" tabindex=\"-1\">\n <div ref=\"eFloatingFilterBody\" role=\"columnheader\"></div>\n <div class=\"ag-floating-filter-button\" ref=\"eButtonWrapper\" role=\"presentation\">\n <button type=\"button\" aria-label=\"Open Filter Menu\" class=\"ag-floating-filter-button-button\" ref=\"eButtonShowMainFilter\" tabindex=\"-1\"></button>\n </div>\n </div>";
  24088. __decorate$P([
  24089. Autowired('columnHoverService')
  24090. ], FloatingFilterWrapper.prototype, "columnHoverService", void 0);
  24091. __decorate$P([
  24092. Autowired('gridOptionsWrapper')
  24093. ], FloatingFilterWrapper.prototype, "gridOptionsWrapper", void 0);
  24094. __decorate$P([
  24095. Autowired('userComponentFactory')
  24096. ], FloatingFilterWrapper.prototype, "userComponentFactory", void 0);
  24097. __decorate$P([
  24098. Autowired('gridApi')
  24099. ], FloatingFilterWrapper.prototype, "gridApi", void 0);
  24100. __decorate$P([
  24101. Autowired('columnApi')
  24102. ], FloatingFilterWrapper.prototype, "columnApi", void 0);
  24103. __decorate$P([
  24104. Autowired('filterManager')
  24105. ], FloatingFilterWrapper.prototype, "filterManager", void 0);
  24106. __decorate$P([
  24107. Autowired('menuFactory')
  24108. ], FloatingFilterWrapper.prototype, "menuFactory", void 0);
  24109. __decorate$P([
  24110. Autowired('beans')
  24111. ], FloatingFilterWrapper.prototype, "beans", void 0);
  24112. __decorate$P([
  24113. RefSelector('eFloatingFilterBody')
  24114. ], FloatingFilterWrapper.prototype, "eFloatingFilterBody", void 0);
  24115. __decorate$P([
  24116. RefSelector('eButtonWrapper')
  24117. ], FloatingFilterWrapper.prototype, "eButtonWrapper", void 0);
  24118. __decorate$P([
  24119. RefSelector('eButtonShowMainFilter')
  24120. ], FloatingFilterWrapper.prototype, "eButtonShowMainFilter", void 0);
  24121. return FloatingFilterWrapper;
  24122. }(AbstractHeaderWrapper));
  24123. /**
  24124. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  24125. * @version v23.2.1
  24126. * @link http://www.ag-grid.com/
  24127. * @license MIT
  24128. */
  24129. var __extends$V = (undefined && undefined.__extends) || (function () {
  24130. var extendStatics = function (d, b) {
  24131. extendStatics = Object.setPrototypeOf ||
  24132. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  24133. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  24134. return extendStatics(d, b);
  24135. };
  24136. return function (d, b) {
  24137. extendStatics(d, b);
  24138. function __() { this.constructor = d; }
  24139. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  24140. };
  24141. })();
  24142. var __decorate$Q = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  24143. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  24144. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  24145. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  24146. return c > 3 && r && Object.defineProperty(target, key, r), r;
  24147. };
  24148. var HeaderRowType;
  24149. (function (HeaderRowType) {
  24150. HeaderRowType[HeaderRowType["COLUMN_GROUP"] = 0] = "COLUMN_GROUP";
  24151. HeaderRowType[HeaderRowType["COLUMN"] = 1] = "COLUMN";
  24152. HeaderRowType[HeaderRowType["FLOATING_FILTER"] = 2] = "FLOATING_FILTER";
  24153. })(HeaderRowType || (HeaderRowType = {}));
  24154. var HeaderRowComp = /** @class */ (function (_super) {
  24155. __extends$V(HeaderRowComp, _super);
  24156. function HeaderRowComp(dept, type, pinned, dropTarget) {
  24157. var _this = _super.call(this, /* html */ "<div class=\"ag-header-row\" role=\"row\" />") || this;
  24158. _this.headerComps = {};
  24159. _this.dept = dept;
  24160. _this.type = type;
  24161. _this.pinned = pinned;
  24162. _this.dropTarget = dropTarget;
  24163. var niceClassName = HeaderRowType[type].toLowerCase().replace(/_/g, '-');
  24164. _this.addCssClass("ag-header-row-" + niceClassName);
  24165. if (isBrowserSafari()) {
  24166. // fix for a Safari rendering bug that caused the header to flicker above chart panels
  24167. // as you move the mouse over the header
  24168. _this.getGui().style.transform = 'translateZ(0)';
  24169. }
  24170. return _this;
  24171. }
  24172. HeaderRowComp.prototype.forEachHeaderElement = function (callback) {
  24173. var _this = this;
  24174. Object.keys(this.headerComps).forEach(function (key) {
  24175. callback(_this.headerComps[key]);
  24176. });
  24177. };
  24178. HeaderRowComp.prototype.setRowIndex = function (idx) {
  24179. this.rowIndex = idx;
  24180. this.getGui().setAttribute('aria-rowindex', (idx + 1).toString());
  24181. };
  24182. HeaderRowComp.prototype.getRowIndex = function () {
  24183. return this.rowIndex;
  24184. };
  24185. HeaderRowComp.prototype.getType = function () {
  24186. return this.type;
  24187. };
  24188. HeaderRowComp.prototype.destroyAllChildComponents = function () {
  24189. var idsOfAllChildren = Object.keys(this.headerComps);
  24190. this.destroyChildComponents(idsOfAllChildren);
  24191. };
  24192. HeaderRowComp.prototype.destroyChildComponents = function (idsToDestroy, keepFocused) {
  24193. var _this = this;
  24194. idsToDestroy.forEach(function (id) {
  24195. var childHeaderWrapper = _this.headerComps[id];
  24196. if (keepFocused &&
  24197. !childHeaderWrapper.getColumn().isMoving() &&
  24198. _this.focusController.isHeaderWrapperFocused(childHeaderWrapper)) {
  24199. return;
  24200. }
  24201. _this.getGui().removeChild(childHeaderWrapper.getGui());
  24202. _this.destroyBean(childHeaderWrapper);
  24203. delete _this.headerComps[id];
  24204. });
  24205. };
  24206. HeaderRowComp.prototype.onRowHeightChanged = function () {
  24207. var headerRowCount = this.columnController.getHeaderRowCount();
  24208. var sizes = [];
  24209. var numberOfFloating = 0;
  24210. var groupHeight;
  24211. var headerHeight;
  24212. if (this.columnController.isPivotMode()) {
  24213. groupHeight = this.gridOptionsWrapper.getPivotGroupHeaderHeight();
  24214. headerHeight = this.gridOptionsWrapper.getPivotHeaderHeight();
  24215. }
  24216. else {
  24217. if (this.columnController.hasFloatingFilters()) {
  24218. headerRowCount++;
  24219. numberOfFloating = 1;
  24220. }
  24221. groupHeight = this.gridOptionsWrapper.getGroupHeaderHeight();
  24222. headerHeight = this.gridOptionsWrapper.getHeaderHeight();
  24223. }
  24224. var numberOfNonGroups = 1 + numberOfFloating;
  24225. var numberOfGroups = headerRowCount - numberOfNonGroups;
  24226. for (var i = 0; i < numberOfGroups; i++) {
  24227. sizes.push(groupHeight);
  24228. }
  24229. sizes.push(headerHeight);
  24230. for (var i = 0; i < numberOfFloating; i++) {
  24231. sizes.push(this.gridOptionsWrapper.getFloatingFiltersHeight());
  24232. }
  24233. var rowHeight = 0;
  24234. for (var i = 0; i < this.dept; i++) {
  24235. rowHeight += sizes[i];
  24236. }
  24237. this.getGui().style.top = rowHeight + 'px';
  24238. this.getGui().style.height = sizes[this.dept] + 'px';
  24239. };
  24240. //noinspection JSUnusedLocalSymbols
  24241. HeaderRowComp.prototype.init = function () {
  24242. this.onRowHeightChanged();
  24243. this.onVirtualColumnsChanged();
  24244. this.setWidth();
  24245. this.addManagedListener(this.gridOptionsWrapper, GridOptionsWrapper.PROP_HEADER_HEIGHT, this.onRowHeightChanged.bind(this));
  24246. this.addManagedListener(this.gridOptionsWrapper, GridOptionsWrapper.PROP_PIVOT_HEADER_HEIGHT, this.onRowHeightChanged.bind(this));
  24247. this.addManagedListener(this.gridOptionsWrapper, GridOptionsWrapper.PROP_GROUP_HEADER_HEIGHT, this.onRowHeightChanged.bind(this));
  24248. this.addManagedListener(this.gridOptionsWrapper, GridOptionsWrapper.PROP_PIVOT_GROUP_HEADER_HEIGHT, this.onRowHeightChanged.bind(this));
  24249. this.addManagedListener(this.gridOptionsWrapper, GridOptionsWrapper.PROP_FLOATING_FILTERS_HEIGHT, this.onRowHeightChanged.bind(this));
  24250. this.addManagedListener(this.eventService, Events.EVENT_VIRTUAL_COLUMNS_CHANGED, this.onVirtualColumnsChanged.bind(this));
  24251. this.addManagedListener(this.eventService, Events.EVENT_DISPLAYED_COLUMNS_CHANGED, this.onDisplayedColumnsChanged.bind(this));
  24252. this.addManagedListener(this.eventService, Events.EVENT_COLUMN_RESIZED, this.onColumnResized.bind(this));
  24253. this.addManagedListener(this.eventService, Events.EVENT_GRID_COLUMNS_CHANGED, this.onGridColumnsChanged.bind(this));
  24254. };
  24255. HeaderRowComp.prototype.onColumnResized = function () {
  24256. this.setWidth();
  24257. };
  24258. HeaderRowComp.prototype.setWidth = function () {
  24259. var width = this.getWidthForRow();
  24260. this.getGui().style.width = width + 'px';
  24261. };
  24262. HeaderRowComp.prototype.getWidthForRow = function () {
  24263. var printLayout = this.gridOptionsWrapper.getDomLayout() === Constants.DOM_LAYOUT_PRINT;
  24264. if (printLayout) {
  24265. var centerRow = missing(this.pinned);
  24266. if (centerRow) {
  24267. return this.columnController.getContainerWidth(Constants.PINNED_RIGHT)
  24268. + this.columnController.getContainerWidth(Constants.PINNED_LEFT)
  24269. + this.columnController.getContainerWidth(null);
  24270. }
  24271. return 0;
  24272. }
  24273. // if not printing, just return the width as normal
  24274. return this.columnController.getContainerWidth(this.pinned);
  24275. };
  24276. HeaderRowComp.prototype.onGridColumnsChanged = function () {
  24277. this.removeAndDestroyAllChildComponents();
  24278. };
  24279. HeaderRowComp.prototype.removeAndDestroyAllChildComponents = function () {
  24280. var idsOfAllChildren = Object.keys(this.headerComps);
  24281. this.destroyChildComponents(idsOfAllChildren);
  24282. };
  24283. HeaderRowComp.prototype.onDisplayedColumnsChanged = function () {
  24284. this.onVirtualColumnsChanged();
  24285. this.setWidth();
  24286. };
  24287. HeaderRowComp.prototype.getItemsAtDepth = function () {
  24288. var _this = this;
  24289. var printLayout = this.gridOptionsWrapper.getDomLayout() === Constants.DOM_LAYOUT_PRINT;
  24290. if (printLayout) {
  24291. // for print layout, we add all columns into the center
  24292. var centerContainer = missing(this.pinned);
  24293. if (centerContainer) {
  24294. var result_1 = [];
  24295. [Constants.PINNED_LEFT, null, Constants.PINNED_RIGHT].forEach(function (pinned) {
  24296. var items = _this.columnController.getVirtualHeaderGroupRow(pinned, _this.type == HeaderRowType.FLOATING_FILTER ?
  24297. _this.dept - 1 :
  24298. _this.dept);
  24299. result_1 = result_1.concat(items);
  24300. });
  24301. return result_1;
  24302. }
  24303. return [];
  24304. }
  24305. // when in normal layout, we add the columns for that container only
  24306. return this.columnController.getVirtualHeaderGroupRow(this.pinned, this.type == HeaderRowType.FLOATING_FILTER ?
  24307. this.dept - 1 :
  24308. this.dept);
  24309. };
  24310. HeaderRowComp.prototype.onVirtualColumnsChanged = function () {
  24311. var _this = this;
  24312. var currentChildIds = Object.keys(this.headerComps);
  24313. var correctChildIds = [];
  24314. var itemsAtDepth = this.getItemsAtDepth();
  24315. itemsAtDepth.forEach(function (child) {
  24316. // skip groups that have no displayed children. this can happen when the group is broken,
  24317. // and this section happens to have nothing to display for the open / closed state.
  24318. // (a broken group is one that is split, ie columns in the group have a non-group column
  24319. // in between them)
  24320. if (child.isEmptyGroup()) {
  24321. return;
  24322. }
  24323. var idOfChild = child.getUniqueId();
  24324. var eParentContainer = _this.getGui();
  24325. // if we already have this cell rendered, do nothing
  24326. var colAlreadyInDom = currentChildIds.indexOf(idOfChild) >= 0;
  24327. var headerComp;
  24328. var eHeaderCompGui;
  24329. if (colAlreadyInDom) {
  24330. removeFromArray(currentChildIds, idOfChild);
  24331. }
  24332. else {
  24333. headerComp = _this.createHeaderComp(child);
  24334. _this.headerComps[idOfChild] = headerComp;
  24335. eHeaderCompGui = headerComp.getGui();
  24336. eParentContainer.appendChild(eHeaderCompGui);
  24337. }
  24338. correctChildIds.push(idOfChild);
  24339. });
  24340. // at this point, anything left in currentChildIds is an element that is no longer in the viewport
  24341. this.destroyChildComponents(currentChildIds, true);
  24342. var ensureDomOrder = this.gridOptionsWrapper.isEnsureDomOrder();
  24343. if (ensureDomOrder) {
  24344. var correctChildOrder = correctChildIds.map(function (id) { return _this.headerComps[id].getGui(); });
  24345. setDomChildOrder(this.getGui(), correctChildOrder);
  24346. }
  24347. };
  24348. HeaderRowComp.prototype.createHeaderComp = function (columnGroupChild) {
  24349. var result;
  24350. switch (this.type) {
  24351. case HeaderRowType.COLUMN:
  24352. result = new HeaderWrapperComp(columnGroupChild, this.dropTarget, this.pinned);
  24353. break;
  24354. case HeaderRowType.COLUMN_GROUP:
  24355. result = new HeaderGroupWrapperComp(columnGroupChild, this.dropTarget, this.pinned);
  24356. break;
  24357. case HeaderRowType.FLOATING_FILTER:
  24358. result = new FloatingFilterWrapper(columnGroupChild, this.pinned);
  24359. break;
  24360. }
  24361. this.createBean(result);
  24362. result.setParentComponent(this);
  24363. return result;
  24364. };
  24365. HeaderRowComp.prototype.getHeaderComps = function () {
  24366. return this.headerComps;
  24367. };
  24368. __decorate$Q([
  24369. Autowired('gridOptionsWrapper')
  24370. ], HeaderRowComp.prototype, "gridOptionsWrapper", void 0);
  24371. __decorate$Q([
  24372. Autowired('columnController')
  24373. ], HeaderRowComp.prototype, "columnController", void 0);
  24374. __decorate$Q([
  24375. Autowired('focusController')
  24376. ], HeaderRowComp.prototype, "focusController", void 0);
  24377. __decorate$Q([
  24378. PreDestroy
  24379. ], HeaderRowComp.prototype, "destroyAllChildComponents", null);
  24380. __decorate$Q([
  24381. PostConstruct
  24382. ], HeaderRowComp.prototype, "init", null);
  24383. return HeaderRowComp;
  24384. }(Component));
  24385. /**
  24386. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  24387. * @version v23.2.1
  24388. * @link http://www.ag-grid.com/
  24389. * @license MIT
  24390. */
  24391. var __decorate$R = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  24392. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  24393. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  24394. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  24395. return c > 3 && r && Object.defineProperty(target, key, r), r;
  24396. };
  24397. var MoveColumnController = /** @class */ (function () {
  24398. function MoveColumnController(pinned, eContainer) {
  24399. this.needToMoveLeft = false;
  24400. this.needToMoveRight = false;
  24401. this.pinned = pinned;
  24402. this.eContainer = eContainer;
  24403. this.centerContainer = !_.exists(pinned);
  24404. }
  24405. MoveColumnController.prototype.registerGridComp = function (gridPanel) {
  24406. this.gridPanel = gridPanel;
  24407. };
  24408. MoveColumnController.prototype.init = function () {
  24409. this.logger = this.loggerFactory.create('MoveColumnController');
  24410. };
  24411. MoveColumnController.prototype.getIconName = function () {
  24412. return this.pinned ? DragAndDropService.ICON_PINNED : DragAndDropService.ICON_MOVE;
  24413. };
  24414. MoveColumnController.prototype.onDragEnter = function (draggingEvent) {
  24415. // we do dummy drag, so make sure column appears in the right location when first placed
  24416. var columns = draggingEvent.dragItem.columns;
  24417. var dragCameFromToolPanel = draggingEvent.dragSource.type === exports.DragSourceType.ToolPanel;
  24418. if (dragCameFromToolPanel) {
  24419. // the if statement doesn't work if drag leaves grid, then enters again
  24420. this.setColumnsVisible(columns, true, "uiColumnDragged");
  24421. }
  24422. else {
  24423. // restore previous state of visible columns upon re-entering. this means if the user drags
  24424. // a group out, and then drags the group back in, only columns that were originally visible
  24425. // will be visible again. otherwise a group with three columns (but only two visible) could
  24426. // be dragged out, then when it's dragged in again, all three are visible. this stops that.
  24427. var visibleState_1 = draggingEvent.dragItem.visibleState;
  24428. var visibleColumns = columns.filter(function (column) { return visibleState_1[column.getId()]; });
  24429. this.setColumnsVisible(visibleColumns, true, "uiColumnDragged");
  24430. }
  24431. this.setColumnsPinned(columns, this.pinned, "uiColumnDragged");
  24432. this.onDragging(draggingEvent, true);
  24433. };
  24434. MoveColumnController.prototype.onDragLeave = function (draggingEvent) {
  24435. var hideColumnOnExit = !this.gridOptionsWrapper.isSuppressDragLeaveHidesColumns() && !draggingEvent.fromNudge;
  24436. if (hideColumnOnExit) {
  24437. var dragItem = draggingEvent.dragSource.getDragItem();
  24438. var columns = dragItem.columns;
  24439. this.setColumnsVisible(columns, false, "uiColumnDragged");
  24440. }
  24441. this.ensureIntervalCleared();
  24442. };
  24443. MoveColumnController.prototype.setColumnsVisible = function (columns, visible, source) {
  24444. if (source === void 0) { source = "api"; }
  24445. if (columns) {
  24446. var allowedCols = columns.filter(function (c) { return !c.getColDef().lockVisible; });
  24447. this.columnController.setColumnsVisible(allowedCols, visible, source);
  24448. }
  24449. };
  24450. MoveColumnController.prototype.setColumnsPinned = function (columns, pinned, source) {
  24451. if (source === void 0) { source = "api"; }
  24452. if (columns) {
  24453. var allowedCols = columns.filter(function (c) { return !c.getColDef().lockPinned; });
  24454. this.columnController.setColumnsPinned(allowedCols, pinned, source);
  24455. }
  24456. };
  24457. MoveColumnController.prototype.onDragStop = function () {
  24458. this.ensureIntervalCleared();
  24459. };
  24460. MoveColumnController.prototype.normaliseX = function (x) {
  24461. // flip the coordinate if doing RTL
  24462. if (this.gridOptionsWrapper.isEnableRtl()) {
  24463. var clientWidth = this.eContainer.clientWidth;
  24464. x = clientWidth - x;
  24465. }
  24466. // adjust for scroll only if centre container (the pinned containers don't scroll)
  24467. if (this.centerContainer) {
  24468. x += this.gridPanel.getCenterViewportScrollLeft();
  24469. }
  24470. return x;
  24471. };
  24472. MoveColumnController.prototype.checkCenterForScrolling = function (xAdjustedForScroll) {
  24473. if (this.centerContainer) {
  24474. // scroll if the mouse has gone outside the grid (or just outside the scrollable part if pinning)
  24475. // putting in 50 buffer, so even if user gets to edge of grid, a scroll will happen
  24476. var firstVisiblePixel = this.gridPanel.getCenterViewportScrollLeft();
  24477. var lastVisiblePixel = firstVisiblePixel + this.gridPanel.getCenterWidth();
  24478. if (this.gridOptionsWrapper.isEnableRtl()) {
  24479. this.needToMoveRight = xAdjustedForScroll < (firstVisiblePixel + 50);
  24480. this.needToMoveLeft = xAdjustedForScroll > (lastVisiblePixel - 50);
  24481. }
  24482. else {
  24483. this.needToMoveLeft = xAdjustedForScroll < (firstVisiblePixel + 50);
  24484. this.needToMoveRight = xAdjustedForScroll > (lastVisiblePixel - 50);
  24485. }
  24486. if (this.needToMoveLeft || this.needToMoveRight) {
  24487. this.ensureIntervalStarted();
  24488. }
  24489. else {
  24490. this.ensureIntervalCleared();
  24491. }
  24492. }
  24493. };
  24494. MoveColumnController.prototype.onDragging = function (draggingEvent, fromEnter) {
  24495. var _this = this;
  24496. if (fromEnter === void 0) { fromEnter = false; }
  24497. this.lastDraggingEvent = draggingEvent;
  24498. // if moving up or down (ie not left or right) then do nothing
  24499. if (_.missing(draggingEvent.hDirection)) {
  24500. return;
  24501. }
  24502. var mouseXNormalised = this.normaliseX(draggingEvent.x);
  24503. // if the user is dragging into the panel, ie coming from the side panel into the main grid,
  24504. // we don't want to scroll the grid this time, it would appear like the table is jumping
  24505. // each time a column is dragged in.
  24506. if (!fromEnter) {
  24507. this.checkCenterForScrolling(mouseXNormalised);
  24508. }
  24509. var hDirectionNormalised = this.normaliseDirection(draggingEvent.hDirection);
  24510. var dragSourceType = draggingEvent.dragSource.type;
  24511. var columnsToMove = draggingEvent.dragSource.getDragItem().columns;
  24512. columnsToMove = columnsToMove.filter(function (col) {
  24513. if (col.getColDef().lockPinned) {
  24514. // if locked return true only if both col and container are same pin type.
  24515. // double equals (==) here on purpose so that null==undefined is true (for not pinned options)
  24516. return col.getPinned() == _this.pinned;
  24517. }
  24518. else {
  24519. // if not pin locked, then always allowed to be in this container
  24520. return true;
  24521. }
  24522. });
  24523. this.attemptMoveColumns(dragSourceType, columnsToMove, hDirectionNormalised, mouseXNormalised, fromEnter);
  24524. };
  24525. MoveColumnController.prototype.normaliseDirection = function (hDirection) {
  24526. if (this.gridOptionsWrapper.isEnableRtl()) {
  24527. switch (hDirection) {
  24528. case exports.HorizontalDirection.Left: return exports.HorizontalDirection.Right;
  24529. case exports.HorizontalDirection.Right: return exports.HorizontalDirection.Left;
  24530. default: console.error("ag-Grid: Unknown direction " + hDirection);
  24531. }
  24532. }
  24533. else {
  24534. return hDirection;
  24535. }
  24536. };
  24537. // returns the index of the first column in the list ONLY if the cols are all beside
  24538. // each other. if the cols are not beside each other, then returns null
  24539. MoveColumnController.prototype.calculateOldIndex = function (movingCols) {
  24540. var gridCols = this.columnController.getAllGridColumns();
  24541. var indexes = _.sortNumerically(movingCols.map(function (col) { return gridCols.indexOf(col); }));
  24542. var firstIndex = indexes[0];
  24543. var lastIndex = _.last(indexes);
  24544. var spread = lastIndex - firstIndex;
  24545. var gapsExist = spread !== indexes.length - 1;
  24546. return gapsExist ? null : firstIndex;
  24547. };
  24548. MoveColumnController.prototype.attemptMoveColumns = function (dragSourceType, allMovingColumns, hDirection, mouseX, fromEnter) {
  24549. var draggingLeft = hDirection === exports.HorizontalDirection.Left;
  24550. var draggingRight = hDirection === exports.HorizontalDirection.Right;
  24551. var validMoves = this.calculateValidMoves(allMovingColumns, draggingRight, mouseX);
  24552. // if cols are not adjacent, then this returns null. when moving, we constrain the direction of the move
  24553. // (ie left or right) to the mouse direction. however
  24554. var oldIndex = this.calculateOldIndex(allMovingColumns);
  24555. if (validMoves.length === 0) {
  24556. return;
  24557. }
  24558. var firstValidMove = validMoves[0];
  24559. // the two check below stop an error when the user grabs a group my a middle column, then
  24560. // it is possible the mouse pointer is to the right of a column while been dragged left.
  24561. // so we need to make sure that the mouse pointer is actually left of the left most column
  24562. // if moving left, and right of the right most column if moving right
  24563. // we check 'fromEnter' below so we move the column to the new spot if the mouse is coming from
  24564. // outside the grid, eg if the column is moving from side panel, mouse is moving left, then we should
  24565. // place the column to the RHS even if the mouse is moving left and the column is already on
  24566. // the LHS. otherwise we stick to the rule described above.
  24567. var constrainDirection = oldIndex !== null && !fromEnter;
  24568. // don't consider 'fromEnter' when dragging header cells, otherwise group can jump to opposite direction of drag
  24569. if (dragSourceType == exports.DragSourceType.HeaderCell) {
  24570. constrainDirection = oldIndex !== null;
  24571. }
  24572. if (constrainDirection) {
  24573. // only allow left drag if this column is moving left
  24574. if (draggingLeft && firstValidMove >= oldIndex) {
  24575. return;
  24576. }
  24577. // only allow right drag if this column is moving right
  24578. if (draggingRight && firstValidMove <= oldIndex) {
  24579. return;
  24580. }
  24581. }
  24582. for (var i = 0; i < validMoves.length; i++) {
  24583. var move = validMoves[i];
  24584. if (!this.columnController.doesMovePassRules(allMovingColumns, move)) {
  24585. continue;
  24586. }
  24587. this.columnController.moveColumns(allMovingColumns, move, "uiColumnDragged");
  24588. // important to return here, so once we do the first valid move, we don't try do any more
  24589. return;
  24590. }
  24591. };
  24592. MoveColumnController.prototype.calculateValidMoves = function (movingCols, draggingRight, mouseX) {
  24593. var isMoveBlocked = this.gridOptionsWrapper.isSuppressMovableColumns() || movingCols.some(function (col) { return col.getColDef().suppressMovable; });
  24594. if (isMoveBlocked) {
  24595. return [];
  24596. }
  24597. // this is the list of cols on the screen, so it's these we use when comparing the x mouse position
  24598. var allDisplayedCols = this.columnController.getDisplayedColumns(this.pinned);
  24599. // but this list is the list of all cols, when we move a col it's the index within this list that gets used,
  24600. // so the result we return has to be and index location for this list
  24601. var allGridCols = this.columnController.getAllGridColumns();
  24602. var movingDisplayedCols = allDisplayedCols.filter(function (col) { return _.includes(movingCols, col); });
  24603. var otherDisplayedCols = allDisplayedCols.filter(function (col) { return !_.includes(movingCols, col); });
  24604. var otherGridCols = allGridCols.filter(function (col) { return !_.includes(movingCols, col); });
  24605. // work out how many DISPLAYED columns fit before the 'x' position. this gives us the displayIndex.
  24606. // for example, if cols are a,b,c,d and we find a,b fit before 'x', then we want to place the moving
  24607. // col between b and c (so that it is under the mouse position).
  24608. var displayIndex = 0;
  24609. var availableWidth = mouseX;
  24610. // if we are dragging right, then the columns will be to the left of the mouse, so we also want to
  24611. // include the width of the moving columns
  24612. if (draggingRight) {
  24613. var widthOfMovingDisplayedCols_1 = 0;
  24614. movingDisplayedCols.forEach(function (col) { return widthOfMovingDisplayedCols_1 += col.getActualWidth(); });
  24615. availableWidth -= widthOfMovingDisplayedCols_1;
  24616. }
  24617. if (availableWidth > 0) {
  24618. // now count how many of the displayed columns will fit to the left
  24619. for (var i = 0; i < otherDisplayedCols.length; i++) {
  24620. var col = otherDisplayedCols[i];
  24621. availableWidth -= col.getActualWidth();
  24622. if (availableWidth < 0) {
  24623. break;
  24624. }
  24625. displayIndex++;
  24626. }
  24627. // trial and error, if going right, we adjust by one, i didn't manage to quantify why, but it works
  24628. if (draggingRight) {
  24629. displayIndex++;
  24630. }
  24631. }
  24632. // the display index is with respect to all the showing columns, however when we move, it's with
  24633. // respect to all grid columns, so we need to translate from display index to grid index
  24634. var firstValidMove;
  24635. if (displayIndex > 0) {
  24636. var leftColumn = otherDisplayedCols[displayIndex - 1];
  24637. firstValidMove = otherGridCols.indexOf(leftColumn) + 1;
  24638. }
  24639. else {
  24640. firstValidMove = otherGridCols.indexOf(otherDisplayedCols[0]);
  24641. if (firstValidMove === -1) {
  24642. firstValidMove = 0;
  24643. }
  24644. }
  24645. var validMoves = [firstValidMove];
  24646. // add in other valid moves due to hidden columns and married children. for example, a particular
  24647. // move might break a group that has married children (so move isn't valid), however there could
  24648. // be hidden columns (not displayed) that we could jump over to make the move valid. because
  24649. // they are hidden, user doesn't see any different, however it allows moves that would otherwise
  24650. // not work. for example imagine a group with 9 columns and all columns are hidden except the
  24651. // middle one (so 4 hidden to left, 4 hidden to right), then when moving 'firstValidMove' will
  24652. // be relative to the not-shown column, however we need to consider the move jumping over all the
  24653. // hidden children. if we didn't do this, then if the group just described was at the end (RHS) of the
  24654. // grid, there would be no way to put a column after it (as the grid would only consider beside the
  24655. // visible column, which would fail valid move rules).
  24656. if (draggingRight) {
  24657. // if dragging right, then we add all the additional moves to the right. so in other words
  24658. // if the next move is not valid, find the next move to the right that is valid.
  24659. var pointer = firstValidMove + 1;
  24660. var lastIndex = allGridCols.length - 1;
  24661. while (pointer <= lastIndex) {
  24662. validMoves.push(pointer);
  24663. pointer++;
  24664. }
  24665. }
  24666. else {
  24667. // if dragging left we do the reverse of dragging right, we add in all the valid moves to the
  24668. // left. however we also have to consider moves to the right for all hidden columns first.
  24669. // (this logic is hard to reason with, it was worked out with trial and error,
  24670. // move observation rather than science).
  24671. // add moves to the right
  24672. var pointer = firstValidMove;
  24673. var lastIndex = allGridCols.length - 1;
  24674. var displacedCol = allGridCols[pointer];
  24675. while (pointer <= lastIndex && this.isColumnHidden(allDisplayedCols, displacedCol)) {
  24676. pointer++;
  24677. validMoves.push(pointer);
  24678. displacedCol = allGridCols[pointer];
  24679. }
  24680. // add moves to the left
  24681. pointer = firstValidMove - 1;
  24682. var firstDisplayIndex = 0;
  24683. while (pointer >= firstDisplayIndex) {
  24684. validMoves.push(pointer);
  24685. pointer--;
  24686. }
  24687. }
  24688. return validMoves;
  24689. };
  24690. // isHidden takes into account visible=false and group=closed, ie it is not displayed
  24691. MoveColumnController.prototype.isColumnHidden = function (displayedColumns, col) {
  24692. return displayedColumns.indexOf(col) < 0;
  24693. };
  24694. MoveColumnController.prototype.ensureIntervalStarted = function () {
  24695. if (!this.movingIntervalId) {
  24696. this.intervalCount = 0;
  24697. this.failedMoveAttempts = 0;
  24698. this.movingIntervalId = window.setInterval(this.moveInterval.bind(this), 100);
  24699. if (this.needToMoveLeft) {
  24700. this.dragAndDropService.setGhostIcon(DragAndDropService.ICON_LEFT, true);
  24701. }
  24702. else {
  24703. this.dragAndDropService.setGhostIcon(DragAndDropService.ICON_RIGHT, true);
  24704. }
  24705. }
  24706. };
  24707. MoveColumnController.prototype.ensureIntervalCleared = function () {
  24708. if (this.moveInterval) {
  24709. window.clearInterval(this.movingIntervalId);
  24710. this.movingIntervalId = null;
  24711. this.dragAndDropService.setGhostIcon(DragAndDropService.ICON_MOVE);
  24712. }
  24713. };
  24714. MoveColumnController.prototype.moveInterval = function () {
  24715. // the amounts we move get bigger at each interval, so the speed accelerates, starting a bit slow
  24716. // and getting faster. this is to give smoother user experience. we max at 100px to limit the speed.
  24717. var pixelsToMove;
  24718. this.intervalCount++;
  24719. pixelsToMove = 10 + (this.intervalCount * 5);
  24720. if (pixelsToMove > 100) {
  24721. pixelsToMove = 100;
  24722. }
  24723. var pixelsMoved;
  24724. if (this.needToMoveLeft) {
  24725. pixelsMoved = this.gridPanel.scrollHorizontally(-pixelsToMove);
  24726. }
  24727. else if (this.needToMoveRight) {
  24728. pixelsMoved = this.gridPanel.scrollHorizontally(pixelsToMove);
  24729. }
  24730. if (pixelsMoved !== 0) {
  24731. this.onDragging(this.lastDraggingEvent);
  24732. this.failedMoveAttempts = 0;
  24733. }
  24734. else {
  24735. // we count the failed move attempts. if we fail to move 7 times, then we pin the column.
  24736. // this is how we achieve pining by dragging the column to the edge of the grid.
  24737. this.failedMoveAttempts++;
  24738. var columns = this.lastDraggingEvent.dragItem.columns;
  24739. var columnsThatCanPin = columns.filter(function (c) { return !c.getColDef().lockPinned; });
  24740. if (columnsThatCanPin.length > 0) {
  24741. this.dragAndDropService.setGhostIcon(DragAndDropService.ICON_PINNED);
  24742. if (this.failedMoveAttempts > 7) {
  24743. var pinType = this.needToMoveLeft ? Constants.PINNED_LEFT : Constants.PINNED_RIGHT;
  24744. this.setColumnsPinned(columnsThatCanPin, pinType, "uiColumnDragged");
  24745. this.dragAndDropService.nudge();
  24746. }
  24747. }
  24748. }
  24749. };
  24750. __decorate$R([
  24751. Autowired('loggerFactory')
  24752. ], MoveColumnController.prototype, "loggerFactory", void 0);
  24753. __decorate$R([
  24754. Autowired('columnController')
  24755. ], MoveColumnController.prototype, "columnController", void 0);
  24756. __decorate$R([
  24757. Autowired('dragAndDropService')
  24758. ], MoveColumnController.prototype, "dragAndDropService", void 0);
  24759. __decorate$R([
  24760. Autowired('gridOptionsWrapper')
  24761. ], MoveColumnController.prototype, "gridOptionsWrapper", void 0);
  24762. __decorate$R([
  24763. PostConstruct
  24764. ], MoveColumnController.prototype, "init", null);
  24765. return MoveColumnController;
  24766. }());
  24767. /**
  24768. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  24769. * @version v23.2.1
  24770. * @link http://www.ag-grid.com/
  24771. * @license MIT
  24772. */
  24773. var __decorate$S = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  24774. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  24775. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  24776. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  24777. return c > 3 && r && Object.defineProperty(target, key, r), r;
  24778. };
  24779. var BodyDropPivotTarget = /** @class */ (function () {
  24780. function BodyDropPivotTarget(pinned) {
  24781. this.columnsToAggregate = [];
  24782. this.columnsToGroup = [];
  24783. this.columnsToPivot = [];
  24784. this.pinned = pinned;
  24785. }
  24786. /** Callback for when drag enters */
  24787. BodyDropPivotTarget.prototype.onDragEnter = function (draggingEvent) {
  24788. var _this = this;
  24789. this.clearColumnsList();
  24790. // in pivot mode, we don't accept any drops if functions are read only
  24791. if (this.gridOptionsWrapper.isFunctionsReadOnly()) {
  24792. return;
  24793. }
  24794. var dragColumns = draggingEvent.dragItem.columns;
  24795. dragColumns.forEach(function (column) {
  24796. // we don't allow adding secondary columns
  24797. if (!column.isPrimary()) {
  24798. return;
  24799. }
  24800. if (column.isAnyFunctionActive()) {
  24801. return;
  24802. }
  24803. if (column.isAllowValue()) {
  24804. _this.columnsToAggregate.push(column);
  24805. }
  24806. else if (column.isAllowRowGroup()) {
  24807. _this.columnsToGroup.push(column);
  24808. }
  24809. else if (column.isAllowRowGroup()) {
  24810. _this.columnsToPivot.push(column);
  24811. }
  24812. });
  24813. };
  24814. BodyDropPivotTarget.prototype.getIconName = function () {
  24815. var totalColumns = this.columnsToAggregate.length + this.columnsToGroup.length + this.columnsToPivot.length;
  24816. if (totalColumns > 0) {
  24817. return this.pinned ? DragAndDropService.ICON_PINNED : DragAndDropService.ICON_MOVE;
  24818. }
  24819. else {
  24820. return null;
  24821. }
  24822. };
  24823. /** Callback for when drag leaves */
  24824. BodyDropPivotTarget.prototype.onDragLeave = function (draggingEvent) {
  24825. // if we are taking columns out of the center, then we remove them from the report
  24826. this.clearColumnsList();
  24827. };
  24828. BodyDropPivotTarget.prototype.clearColumnsList = function () {
  24829. this.columnsToAggregate.length = 0;
  24830. this.columnsToGroup.length = 0;
  24831. this.columnsToPivot.length = 0;
  24832. };
  24833. /** Callback for when dragging */
  24834. BodyDropPivotTarget.prototype.onDragging = function (draggingEvent) {
  24835. };
  24836. /** Callback for when drag stops */
  24837. BodyDropPivotTarget.prototype.onDragStop = function (draggingEvent) {
  24838. if (this.columnsToAggregate.length > 0) {
  24839. this.columnController.addValueColumns(this.columnsToAggregate, "toolPanelDragAndDrop");
  24840. }
  24841. if (this.columnsToGroup.length > 0) {
  24842. this.columnController.addRowGroupColumns(this.columnsToGroup, "toolPanelDragAndDrop");
  24843. }
  24844. if (this.columnsToPivot.length > 0) {
  24845. this.columnController.addPivotColumns(this.columnsToPivot, "toolPanelDragAndDrop");
  24846. }
  24847. };
  24848. __decorate$S([
  24849. Autowired('columnController')
  24850. ], BodyDropPivotTarget.prototype, "columnController", void 0);
  24851. __decorate$S([
  24852. Autowired('gridOptionsWrapper')
  24853. ], BodyDropPivotTarget.prototype, "gridOptionsWrapper", void 0);
  24854. return BodyDropPivotTarget;
  24855. }());
  24856. /**
  24857. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  24858. * @version v23.2.1
  24859. * @link http://www.ag-grid.com/
  24860. * @license MIT
  24861. */
  24862. var __extends$W = (undefined && undefined.__extends) || (function () {
  24863. var extendStatics = function (d, b) {
  24864. extendStatics = Object.setPrototypeOf ||
  24865. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  24866. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  24867. return extendStatics(d, b);
  24868. };
  24869. return function (d, b) {
  24870. extendStatics(d, b);
  24871. function __() { this.constructor = d; }
  24872. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  24873. };
  24874. })();
  24875. var __decorate$T = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  24876. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  24877. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  24878. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  24879. return c > 3 && r && Object.defineProperty(target, key, r), r;
  24880. };
  24881. var DropType;
  24882. (function (DropType) {
  24883. DropType[DropType["ColumnMove"] = 0] = "ColumnMove";
  24884. DropType[DropType["Pivot"] = 1] = "Pivot";
  24885. })(DropType || (DropType = {}));
  24886. var BodyDropTarget = /** @class */ (function (_super) {
  24887. __extends$W(BodyDropTarget, _super);
  24888. function BodyDropTarget(pinned, eContainer) {
  24889. var _this = _super.call(this) || this;
  24890. _this.dropListeners = {};
  24891. _this.pinned = pinned;
  24892. _this.eContainer = eContainer;
  24893. return _this;
  24894. }
  24895. BodyDropTarget.prototype.registerGridComp = function (gridPanel) {
  24896. this.gridPanel = gridPanel;
  24897. this.moveColumnController.registerGridComp(gridPanel);
  24898. switch (this.pinned) {
  24899. case Constants.PINNED_LEFT:
  24900. this.eSecondaryContainers = this.gridPanel.getDropTargetLeftContainers();
  24901. break;
  24902. case Constants.PINNED_RIGHT:
  24903. this.eSecondaryContainers = this.gridPanel.getDropTargetRightContainers();
  24904. break;
  24905. default:
  24906. this.eSecondaryContainers = this.gridPanel.getDropTargetBodyContainers();
  24907. break;
  24908. }
  24909. };
  24910. BodyDropTarget.prototype.isInterestedIn = function (type) {
  24911. return type === exports.DragSourceType.HeaderCell ||
  24912. (type === exports.DragSourceType.ToolPanel && this.gridOptionsWrapper.isAllowDragFromColumnsToolPanel());
  24913. };
  24914. BodyDropTarget.prototype.getSecondaryContainers = function () {
  24915. return this.eSecondaryContainers;
  24916. };
  24917. BodyDropTarget.prototype.getContainer = function () {
  24918. return this.eContainer;
  24919. };
  24920. BodyDropTarget.prototype.init = function () {
  24921. this.moveColumnController = this.createBean(new MoveColumnController(this.pinned, this.eContainer));
  24922. var bodyDropPivotTarget = new BodyDropPivotTarget(this.pinned);
  24923. this.createBean(bodyDropPivotTarget);
  24924. this.dropListeners[DropType.ColumnMove] = this.moveColumnController;
  24925. this.dropListeners[DropType.Pivot] = bodyDropPivotTarget;
  24926. this.dragAndDropService.addDropTarget(this);
  24927. };
  24928. BodyDropTarget.prototype.getIconName = function () {
  24929. return this.currentDropListener.getIconName();
  24930. };
  24931. // we want to use the bodyPivotTarget if the user is dragging columns in from the toolPanel
  24932. // and we are in pivot mode, as it has to logic to set pivot/value/group on the columns when
  24933. // dropped into the grid's body.
  24934. BodyDropTarget.prototype.getDropType = function (draggingEvent) {
  24935. if (this.columnController.isPivotMode()) {
  24936. // in pivot mode, then if moving a column (ie didn't come from toolpanel) then it's
  24937. // a standard column move, however if it came from the toolpanel, then we are introducing
  24938. // dimensions or values to the grid
  24939. if (draggingEvent.dragSource.type === exports.DragSourceType.ToolPanel) {
  24940. return DropType.Pivot;
  24941. }
  24942. return DropType.ColumnMove;
  24943. }
  24944. // it's a column, and not pivot mode, so always moving
  24945. return DropType.ColumnMove;
  24946. };
  24947. BodyDropTarget.prototype.onDragEnter = function (draggingEvent) {
  24948. // we pick the drop listener depending on whether we are in pivot mode are not. if we are
  24949. // in pivot mode, then dropping cols changes the row group, pivot, value stats. otherwise
  24950. // we change visibility state and position.
  24951. // if (this.columnController.isPivotMode()) {
  24952. var dropType = this.getDropType(draggingEvent);
  24953. this.currentDropListener = this.dropListeners[dropType];
  24954. this.currentDropListener.onDragEnter(draggingEvent);
  24955. };
  24956. BodyDropTarget.prototype.onDragLeave = function (params) {
  24957. this.currentDropListener.onDragLeave(params);
  24958. };
  24959. BodyDropTarget.prototype.onDragging = function (params) {
  24960. this.currentDropListener.onDragging(params);
  24961. };
  24962. BodyDropTarget.prototype.onDragStop = function (params) {
  24963. this.currentDropListener.onDragStop(params);
  24964. };
  24965. __decorate$T([
  24966. Autowired('dragAndDropService')
  24967. ], BodyDropTarget.prototype, "dragAndDropService", void 0);
  24968. __decorate$T([
  24969. Autowired('columnController')
  24970. ], BodyDropTarget.prototype, "columnController", void 0);
  24971. __decorate$T([
  24972. Autowired('gridOptionsWrapper')
  24973. ], BodyDropTarget.prototype, "gridOptionsWrapper", void 0);
  24974. __decorate$T([
  24975. PostConstruct
  24976. ], BodyDropTarget.prototype, "init", null);
  24977. return BodyDropTarget;
  24978. }(BeanStub));
  24979. /**
  24980. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  24981. * @version v23.2.1
  24982. * @link http://www.ag-grid.com/
  24983. * @license MIT
  24984. */
  24985. var __extends$X = (undefined && undefined.__extends) || (function () {
  24986. var extendStatics = function (d, b) {
  24987. extendStatics = Object.setPrototypeOf ||
  24988. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  24989. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  24990. return extendStatics(d, b);
  24991. };
  24992. return function (d, b) {
  24993. extendStatics(d, b);
  24994. function __() { this.constructor = d; }
  24995. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  24996. };
  24997. })();
  24998. var __decorate$U = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  24999. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  25000. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  25001. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  25002. return c > 3 && r && Object.defineProperty(target, key, r), r;
  25003. };
  25004. var HeaderContainer = /** @class */ (function (_super) {
  25005. __extends$X(HeaderContainer, _super);
  25006. function HeaderContainer(eContainer, eViewport, pinned) {
  25007. var _this = _super.call(this) || this;
  25008. _this.headerRowComps = [];
  25009. _this.eContainer = eContainer;
  25010. _this.pinned = pinned;
  25011. _this.eViewport = eViewport;
  25012. return _this;
  25013. }
  25014. HeaderContainer.prototype.forEachHeaderElement = function (callback) {
  25015. this.headerRowComps.forEach(function (headerRowComp) { return headerRowComp.forEachHeaderElement(callback); });
  25016. };
  25017. HeaderContainer.prototype.init = function () {
  25018. this.scrollWidth = this.gridOptionsWrapper.getScrollbarWidth();
  25019. // if value changes, then if not pivoting, we at least need to change the label eg from sum() to avg(),
  25020. // if pivoting, then the columns have changed
  25021. this.addManagedListener(this.eventService, Events.EVENT_COLUMN_VALUE_CHANGED, this.onColumnValueChanged.bind(this)),
  25022. this.addManagedListener(this.eventService, Events.EVENT_COLUMN_ROW_GROUP_CHANGED, this.onColumnRowGroupChanged.bind(this)),
  25023. this.addManagedListener(this.eventService, Events.EVENT_GRID_COLUMNS_CHANGED, this.onGridColumnsChanged.bind(this)),
  25024. this.addManagedListener(this.eventService, Events.EVENT_SCROLL_VISIBILITY_CHANGED, this.onScrollVisibilityChanged.bind(this)),
  25025. this.addManagedListener(this.eventService, Events.EVENT_COLUMN_RESIZED, this.onColumnResized.bind(this)),
  25026. this.addManagedListener(this.eventService, Events.EVENT_DISPLAYED_COLUMNS_CHANGED, this.onDisplayedColumnsChanged.bind(this));
  25027. };
  25028. // if row group changes, that means we may need to add aggFuncs to the column headers,
  25029. // if the grid goes from no aggregation (ie no grouping) to grouping
  25030. HeaderContainer.prototype.onColumnRowGroupChanged = function () {
  25031. this.onGridColumnsChanged();
  25032. };
  25033. // if the agg func of a column changes, then we may need to update the agg func in columns header
  25034. HeaderContainer.prototype.onColumnValueChanged = function () {
  25035. this.onGridColumnsChanged();
  25036. };
  25037. HeaderContainer.prototype.onColumnResized = function () {
  25038. this.setWidthOfPinnedContainer();
  25039. };
  25040. HeaderContainer.prototype.onDisplayedColumnsChanged = function () {
  25041. this.setWidthOfPinnedContainer();
  25042. };
  25043. HeaderContainer.prototype.onScrollVisibilityChanged = function () {
  25044. this.setWidthOfPinnedContainer();
  25045. };
  25046. HeaderContainer.prototype.setWidthOfPinnedContainer = function () {
  25047. var pinningLeft = this.pinned === Constants.PINNED_LEFT;
  25048. var pinningRight = this.pinned === Constants.PINNED_RIGHT;
  25049. var controller = this.columnController;
  25050. var isRtl = this.gridOptionsWrapper.isEnableRtl();
  25051. if (pinningLeft || pinningRight) {
  25052. // size to fit all columns
  25053. var width = controller[pinningLeft ? 'getPinnedLeftContainerWidth' : 'getPinnedRightContainerWidth']();
  25054. // if there is a scroll showing (and taking up space, so Windows, and not iOS)
  25055. // in the body, then we add extra space to keep header aligned with the body,
  25056. // as body width fits the cols and the scrollbar
  25057. var addPaddingForScrollbar = this.scrollVisibleService.isVerticalScrollShowing() && ((isRtl && pinningLeft) || (!isRtl && pinningRight));
  25058. if (addPaddingForScrollbar) {
  25059. width += this.scrollWidth;
  25060. }
  25061. setFixedWidth(this.eContainer, width);
  25062. }
  25063. };
  25064. HeaderContainer.prototype.getRowComps = function () {
  25065. return this.headerRowComps;
  25066. };
  25067. // grid cols have changed - this also means the number of rows in the header can have
  25068. // changed. so we remove all the old rows and insert new ones for a complete refresh
  25069. HeaderContainer.prototype.onGridColumnsChanged = function () {
  25070. this.removeAndCreateAllRowComps();
  25071. };
  25072. HeaderContainer.prototype.removeAndCreateAllRowComps = function () {
  25073. this.removeHeaderRowComps();
  25074. this.createHeaderRowComps();
  25075. };
  25076. // we expose this for gridOptions.api.refreshHeader() to call
  25077. HeaderContainer.prototype.refresh = function () {
  25078. this.removeAndCreateAllRowComps();
  25079. };
  25080. HeaderContainer.prototype.setupDragAndDrop = function (gridComp) {
  25081. var dropContainer = this.eViewport ? this.eViewport : this.eContainer;
  25082. var bodyDropTarget = new BodyDropTarget(this.pinned, dropContainer);
  25083. this.createManagedBean(bodyDropTarget);
  25084. bodyDropTarget.registerGridComp(gridComp);
  25085. };
  25086. HeaderContainer.prototype.removeHeaderRowComps = function () {
  25087. var _this = this;
  25088. this.headerRowComps.forEach(function (headerRowComp) { return _this.destroyBean(headerRowComp); });
  25089. this.headerRowComps.length = 0;
  25090. clearElement(this.eContainer);
  25091. };
  25092. HeaderContainer.prototype.createHeaderRowComps = function () {
  25093. // if we are displaying header groups, then we have many rows here.
  25094. // go through each row of the header, one by one.
  25095. var rowCount = this.columnController.getHeaderRowCount();
  25096. for (var dept = 0; dept < rowCount; dept++) {
  25097. var groupRow = dept !== (rowCount - 1);
  25098. var type = groupRow ? HeaderRowType.COLUMN_GROUP : HeaderRowType.COLUMN;
  25099. var headerRowComp = new HeaderRowComp(dept, type, this.pinned, this.dropTarget);
  25100. this.createBean(headerRowComp);
  25101. this.headerRowComps.push(headerRowComp);
  25102. headerRowComp.setRowIndex(this.headerRowComps.length - 1);
  25103. this.eContainer.appendChild(headerRowComp.getGui());
  25104. }
  25105. if (!this.columnController.isPivotMode() && this.columnController.hasFloatingFilters()) {
  25106. var headerRowComp = new HeaderRowComp(rowCount, HeaderRowType.FLOATING_FILTER, this.pinned, this.dropTarget);
  25107. this.createBean(headerRowComp);
  25108. this.headerRowComps.push(headerRowComp);
  25109. headerRowComp.setRowIndex(this.headerRowComps.length - 1);
  25110. this.eContainer.appendChild(headerRowComp.getGui());
  25111. }
  25112. };
  25113. __decorate$U([
  25114. Autowired('gridOptionsWrapper')
  25115. ], HeaderContainer.prototype, "gridOptionsWrapper", void 0);
  25116. __decorate$U([
  25117. Autowired('columnController')
  25118. ], HeaderContainer.prototype, "columnController", void 0);
  25119. __decorate$U([
  25120. Autowired('scrollVisibleService')
  25121. ], HeaderContainer.prototype, "scrollVisibleService", void 0);
  25122. __decorate$U([
  25123. PostConstruct
  25124. ], HeaderContainer.prototype, "init", null);
  25125. __decorate$U([
  25126. PreDestroy
  25127. ], HeaderContainer.prototype, "removeHeaderRowComps", null);
  25128. return HeaderContainer;
  25129. }(BeanStub));
  25130. /**
  25131. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  25132. * @version v23.2.1
  25133. * @link http://www.ag-grid.com/
  25134. * @license MIT
  25135. */
  25136. var __extends$Y = (undefined && undefined.__extends) || (function () {
  25137. var extendStatics = function (d, b) {
  25138. extendStatics = Object.setPrototypeOf ||
  25139. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  25140. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  25141. return extendStatics(d, b);
  25142. };
  25143. return function (d, b) {
  25144. extendStatics(d, b);
  25145. function __() { this.constructor = d; }
  25146. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  25147. };
  25148. })();
  25149. var __decorate$V = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  25150. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  25151. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  25152. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  25153. return c > 3 && r && Object.defineProperty(target, key, r), r;
  25154. };
  25155. (function (HeaderNavigationDirection) {
  25156. HeaderNavigationDirection[HeaderNavigationDirection["UP"] = 0] = "UP";
  25157. HeaderNavigationDirection[HeaderNavigationDirection["DOWN"] = 1] = "DOWN";
  25158. HeaderNavigationDirection[HeaderNavigationDirection["LEFT"] = 2] = "LEFT";
  25159. HeaderNavigationDirection[HeaderNavigationDirection["RIGHT"] = 3] = "RIGHT";
  25160. })(exports.HeaderNavigationDirection || (exports.HeaderNavigationDirection = {}));
  25161. var HeaderNavigationService = /** @class */ (function (_super) {
  25162. __extends$Y(HeaderNavigationService, _super);
  25163. function HeaderNavigationService() {
  25164. return _super !== null && _super.apply(this, arguments) || this;
  25165. }
  25166. HeaderNavigationService.prototype.registerGridComp = function (gridPanel) {
  25167. this.gridPanel = gridPanel;
  25168. };
  25169. HeaderNavigationService.prototype.registerHeaderRoot = function (headerRoot) {
  25170. this.headerRoot = headerRoot;
  25171. };
  25172. HeaderNavigationService.prototype.getHeaderRowCount = function () {
  25173. var headerContainers = this.headerRoot.getHeaderContainers();
  25174. return headerContainers.size === 0 ? 0 : this.getHeaderContainer().getRowComps().length;
  25175. };
  25176. HeaderNavigationService.prototype.getHeaderRowType = function (idx) {
  25177. if (this.getHeaderRowCount()) {
  25178. return this.getHeaderContainer().getRowComps()[idx].getType();
  25179. }
  25180. };
  25181. HeaderNavigationService.prototype.getHeaderContainer = function (position) {
  25182. if (position === void 0) { position = 'center'; }
  25183. if (position === null) {
  25184. position = 'center';
  25185. }
  25186. return this.headerRoot.getHeaderContainers().get(position);
  25187. };
  25188. /*
  25189. * This method navigates grid header vertically
  25190. * @return {boolean} true to preventDefault on the event that caused this navigation.
  25191. */
  25192. HeaderNavigationService.prototype.navigateVertically = function (direction, fromHeader) {
  25193. if (!fromHeader) {
  25194. fromHeader = this.focusController.getFocusedHeader();
  25195. }
  25196. if (!fromHeader) {
  25197. return false;
  25198. }
  25199. var headerRowIndex = fromHeader.headerRowIndex, column = fromHeader.column;
  25200. var rowLen = this.getHeaderRowCount();
  25201. var isUp = direction === exports.HeaderNavigationDirection.UP;
  25202. var nextRow = isUp ? headerRowIndex - 1 : headerRowIndex + 1;
  25203. if (nextRow < 0) {
  25204. return false;
  25205. }
  25206. if (nextRow >= rowLen) {
  25207. // focusGridView returns false when the grid has no cells rendered.
  25208. return this.focusController.focusGridView();
  25209. }
  25210. var currentRowType = this.getHeaderRowType(headerRowIndex);
  25211. var nextFocusColumn;
  25212. if (currentRowType === HeaderRowType.COLUMN_GROUP) {
  25213. var currentColumn = column;
  25214. nextFocusColumn = isUp ? column.getParent() : currentColumn.getDisplayedChildren()[0];
  25215. }
  25216. else if (currentRowType === HeaderRowType.FLOATING_FILTER) {
  25217. nextFocusColumn = column;
  25218. }
  25219. else {
  25220. var currentColumn = column;
  25221. nextFocusColumn = isUp ? currentColumn.getParent() : currentColumn;
  25222. }
  25223. if (!nextFocusColumn) {
  25224. return false;
  25225. }
  25226. this.focusController.focusHeaderPosition({
  25227. headerRowIndex: nextRow,
  25228. column: nextFocusColumn
  25229. });
  25230. return true;
  25231. };
  25232. /*
  25233. * This method navigates grid header horizontally
  25234. * @return {boolean} true to preventDefault on the event that caused this navigation.
  25235. */
  25236. HeaderNavigationService.prototype.navigateHorizontally = function (direction, fromTab) {
  25237. var focusedHeader = this.focusController.getFocusedHeader();
  25238. var isLeft = direction === exports.HeaderNavigationDirection.LEFT;
  25239. var isRtl = this.gridOptionsWrapper.isEnableRtl();
  25240. var nextHeader;
  25241. var normalisedDirection;
  25242. // either navigating to the left or isRtl (cannot be both)
  25243. if (isLeft !== isRtl) {
  25244. normalisedDirection = 'Before';
  25245. nextHeader = this.headerPositionUtils.findHeader(focusedHeader, normalisedDirection);
  25246. }
  25247. else {
  25248. normalisedDirection = 'After';
  25249. nextHeader = this.headerPositionUtils.findHeader(focusedHeader, normalisedDirection);
  25250. }
  25251. if (nextHeader) {
  25252. this.focusController.focusHeaderPosition(nextHeader, normalisedDirection);
  25253. return true;
  25254. }
  25255. if (!fromTab) {
  25256. return true;
  25257. }
  25258. return this.focusNextHeaderRow(focusedHeader, normalisedDirection);
  25259. };
  25260. HeaderNavigationService.prototype.focusNextHeaderRow = function (focusedHeader, direction) {
  25261. var currentIndex = focusedHeader.headerRowIndex;
  25262. var nextPosition;
  25263. var nextRowIndex;
  25264. if (direction === 'Before') {
  25265. if (currentIndex === 0) {
  25266. return false;
  25267. }
  25268. nextRowIndex = currentIndex - 1;
  25269. nextPosition = this.headerPositionUtils.findColAtEdgeForHeaderRow(nextRowIndex, 'end');
  25270. }
  25271. else {
  25272. nextRowIndex = currentIndex + 1;
  25273. nextPosition = this.headerPositionUtils.findColAtEdgeForHeaderRow(nextRowIndex, 'start');
  25274. }
  25275. if (nextPosition) {
  25276. if (nextPosition.headerRowIndex === -1) {
  25277. return this.focusController.focusGridView(nextPosition.column);
  25278. }
  25279. return this.focusController.focusHeaderPosition(nextPosition, direction);
  25280. }
  25281. return false;
  25282. };
  25283. HeaderNavigationService.prototype.scrollToColumn = function (column, direction) {
  25284. if (direction === void 0) { direction = 'After'; }
  25285. if (column.getPinned()) {
  25286. return;
  25287. }
  25288. var columnToScrollTo;
  25289. if (column instanceof ColumnGroup) {
  25290. var columns = column.getDisplayedLeafColumns();
  25291. columnToScrollTo = direction === 'Before' ? _.last(columns) : columns[0];
  25292. }
  25293. else {
  25294. columnToScrollTo = column;
  25295. }
  25296. this.gridPanel.ensureColumnVisible(columnToScrollTo);
  25297. // need to nudge the scrolls for the floating items. otherwise when we set focus on a non-visible
  25298. // floating cell, the scrolls get out of sync
  25299. this.gridPanel.horizontallyScrollHeaderCenterAndFloatingCenter();
  25300. // need to flush frames, to make sure the correct cells are rendered
  25301. this.animationFrameService.flushAllFrames();
  25302. };
  25303. __decorate$V([
  25304. Autowired('gridOptionsWrapper')
  25305. ], HeaderNavigationService.prototype, "gridOptionsWrapper", void 0);
  25306. __decorate$V([
  25307. Autowired('focusController')
  25308. ], HeaderNavigationService.prototype, "focusController", void 0);
  25309. __decorate$V([
  25310. Autowired('headerPositionUtils')
  25311. ], HeaderNavigationService.prototype, "headerPositionUtils", void 0);
  25312. __decorate$V([
  25313. Autowired('animationFrameService')
  25314. ], HeaderNavigationService.prototype, "animationFrameService", void 0);
  25315. HeaderNavigationService = __decorate$V([
  25316. Bean('headerNavigationService')
  25317. ], HeaderNavigationService);
  25318. return HeaderNavigationService;
  25319. }(BeanStub));
  25320. /**
  25321. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  25322. * @version v23.2.1
  25323. * @link http://www.ag-grid.com/
  25324. * @license MIT
  25325. */
  25326. var __extends$Z = (undefined && undefined.__extends) || (function () {
  25327. var extendStatics = function (d, b) {
  25328. extendStatics = Object.setPrototypeOf ||
  25329. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  25330. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  25331. return extendStatics(d, b);
  25332. };
  25333. return function (d, b) {
  25334. extendStatics(d, b);
  25335. function __() { this.constructor = d; }
  25336. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  25337. };
  25338. })();
  25339. var __decorate$W = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  25340. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  25341. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  25342. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  25343. return c > 3 && r && Object.defineProperty(target, key, r), r;
  25344. };
  25345. var HeaderRootComp = /** @class */ (function (_super) {
  25346. __extends$Z(HeaderRootComp, _super);
  25347. function HeaderRootComp() {
  25348. var _this = _super.call(this, HeaderRootComp.TEMPLATE) || this;
  25349. _this.headerContainers = new Map();
  25350. return _this;
  25351. }
  25352. HeaderRootComp.prototype.postConstruct = function () {
  25353. var _this = this;
  25354. _super.prototype.postConstruct.call(this);
  25355. this.printLayout = this.gridOptionsWrapper.getDomLayout() === Constants.DOM_LAYOUT_PRINT;
  25356. this.gridApi.registerHeaderRootComp(this);
  25357. this.autoWidthCalculator.registerHeaderRootComp(this);
  25358. this.registerHeaderContainer(new HeaderContainer(this.eHeaderContainer, this.eHeaderViewport, null), 'center');
  25359. this.registerHeaderContainer(new HeaderContainer(this.ePinnedLeftHeader, null, Constants.PINNED_LEFT), 'left');
  25360. this.registerHeaderContainer(new HeaderContainer(this.ePinnedRightHeader, null, Constants.PINNED_RIGHT), 'right');
  25361. this.headerContainers.forEach(function (container) { return _this.createManagedBean(container); });
  25362. this.headerNavigationService.registerHeaderRoot(this);
  25363. // shotgun way to get labels to change, eg from sum(amount) to avg(amount)
  25364. this.addManagedListener(this.eventService, Events.EVENT_COLUMN_VALUE_CHANGED, this.refreshHeader.bind(this));
  25365. this.addManagedListener(this.gridOptionsWrapper, GridOptionsWrapper.PROP_DOM_LAYOUT, this.onDomLayoutChanged.bind(this));
  25366. // for setting ag-pivot-on / ag-pivot-off CSS classes
  25367. this.addManagedListener(this.eventService, Events.EVENT_COLUMN_PIVOT_MODE_CHANGED, this.onPivotModeChanged.bind(this));
  25368. this.onPivotModeChanged();
  25369. this.addPreventHeaderScroll();
  25370. if (this.columnController.isReady()) {
  25371. this.refreshHeader();
  25372. }
  25373. };
  25374. HeaderRootComp.prototype.registerGridComp = function (gridPanel) {
  25375. this.gridPanel = gridPanel;
  25376. this.headerContainers.forEach(function (c) { return c.setupDragAndDrop(gridPanel); });
  25377. };
  25378. HeaderRootComp.prototype.registerHeaderContainer = function (headerContainer, type) {
  25379. this.headerContainers.set(type, headerContainer);
  25380. };
  25381. HeaderRootComp.prototype.onTabKeyDown = function (e) {
  25382. var isRtl = this.gridOptionsWrapper.isEnableRtl();
  25383. var direction = e.shiftKey !== isRtl
  25384. ? exports.HeaderNavigationDirection.LEFT
  25385. : exports.HeaderNavigationDirection.RIGHT;
  25386. if (this.headerNavigationService.navigateHorizontally(direction, true) ||
  25387. this.focusController.focusNextGridCoreContainer(e.shiftKey)) {
  25388. e.preventDefault();
  25389. }
  25390. };
  25391. HeaderRootComp.prototype.handleKeyDown = function (e) {
  25392. var direction;
  25393. switch (e.keyCode) {
  25394. case Constants.KEY_LEFT:
  25395. direction = exports.HeaderNavigationDirection.LEFT;
  25396. case Constants.KEY_RIGHT:
  25397. if (!_.exists(direction)) {
  25398. direction = exports.HeaderNavigationDirection.RIGHT;
  25399. }
  25400. this.headerNavigationService.navigateHorizontally(direction);
  25401. break;
  25402. case Constants.KEY_UP:
  25403. direction = exports.HeaderNavigationDirection.UP;
  25404. case Constants.KEY_DOWN:
  25405. if (!_.exists(direction)) {
  25406. direction = exports.HeaderNavigationDirection.DOWN;
  25407. }
  25408. if (this.headerNavigationService.navigateVertically(direction)) {
  25409. e.preventDefault();
  25410. }
  25411. break;
  25412. default:
  25413. return;
  25414. }
  25415. };
  25416. HeaderRootComp.prototype.onFocusOut = function (e) {
  25417. var relatedTarget = e.relatedTarget;
  25418. var eGui = this.getGui();
  25419. if (!relatedTarget && eGui.contains(document.activeElement)) {
  25420. return;
  25421. }
  25422. if (!eGui.contains(relatedTarget)) {
  25423. this.focusController.clearFocusedHeader();
  25424. }
  25425. };
  25426. HeaderRootComp.prototype.onDomLayoutChanged = function () {
  25427. var newValue = this.gridOptionsWrapper.getDomLayout() === Constants.DOM_LAYOUT_PRINT;
  25428. if (this.printLayout !== newValue) {
  25429. this.printLayout = newValue;
  25430. this.refreshHeader();
  25431. }
  25432. };
  25433. HeaderRootComp.prototype.setHorizontalScroll = function (offset) {
  25434. this.eHeaderContainer.style.transform = "translateX(" + offset + "px)";
  25435. };
  25436. HeaderRootComp.prototype.forEachHeaderElement = function (callback) {
  25437. this.headerContainers.forEach(function (childContainer) { return childContainer.forEachHeaderElement(callback); });
  25438. };
  25439. HeaderRootComp.prototype.refreshHeader = function () {
  25440. this.headerContainers.forEach(function (container) { return container.refresh(); });
  25441. };
  25442. HeaderRootComp.prototype.onPivotModeChanged = function () {
  25443. var pivotMode = this.columnController.isPivotMode();
  25444. addOrRemoveCssClass(this.getGui(), 'ag-pivot-on', pivotMode);
  25445. addOrRemoveCssClass(this.getGui(), 'ag-pivot-off', !pivotMode);
  25446. };
  25447. HeaderRootComp.prototype.setHeight = function (height) {
  25448. // one extra pixel is needed here to account for the
  25449. // height of the border
  25450. var px = height + 1 + "px";
  25451. this.getGui().style.height = px;
  25452. this.getGui().style.minHeight = px;
  25453. };
  25454. // if the user is in floating filter and hits tab a few times, the header can
  25455. // end up scrolling to show items off the screen, leaving the grid and header
  25456. // and the grid columns no longer in sync.
  25457. HeaderRootComp.prototype.addPreventHeaderScroll = function () {
  25458. var _this = this;
  25459. this.addManagedListener(this.eHeaderViewport, 'scroll', function () {
  25460. // if the header scrolls, the header will be out of sync. so we reset the
  25461. // header scroll, and then scroll the body, which will in turn set the offset
  25462. // on the header, giving the impression that the header scrolled as expected.
  25463. var scrollLeft = _this.eHeaderViewport.scrollLeft;
  25464. if (scrollLeft !== 0) {
  25465. _this.gridPanel.scrollHorizontally(scrollLeft);
  25466. _this.eHeaderViewport.scrollLeft = 0;
  25467. }
  25468. });
  25469. };
  25470. HeaderRootComp.prototype.getHeaderContainers = function () {
  25471. return this.headerContainers;
  25472. };
  25473. HeaderRootComp.prototype.setHeaderContainerWidth = function (width) {
  25474. this.eHeaderContainer.style.width = width + "px";
  25475. };
  25476. HeaderRootComp.prototype.setLeftVisible = function (visible) {
  25477. setDisplayed(this.ePinnedLeftHeader, visible);
  25478. };
  25479. HeaderRootComp.prototype.setRightVisible = function (visible) {
  25480. setDisplayed(this.ePinnedRightHeader, visible);
  25481. };
  25482. HeaderRootComp.TEMPLATE = "<div class=\"ag-header\" role=\"presentation\">\n <div class=\"ag-pinned-left-header\" ref=\"ePinnedLeftHeader\" role=\"presentation\"></div>\n <div class=\"ag-header-viewport\" ref=\"eHeaderViewport\" role=\"presentation\">\n <div class=\"ag-header-container\" ref=\"eHeaderContainer\" role=\"rowgroup\"></div>\n </div>\n <div class=\"ag-pinned-right-header\" ref=\"ePinnedRightHeader\" role=\"presentation\"></div>\n </div>";
  25483. __decorate$W([
  25484. RefSelector('ePinnedLeftHeader')
  25485. ], HeaderRootComp.prototype, "ePinnedLeftHeader", void 0);
  25486. __decorate$W([
  25487. RefSelector('ePinnedRightHeader')
  25488. ], HeaderRootComp.prototype, "ePinnedRightHeader", void 0);
  25489. __decorate$W([
  25490. RefSelector('eHeaderContainer')
  25491. ], HeaderRootComp.prototype, "eHeaderContainer", void 0);
  25492. __decorate$W([
  25493. RefSelector('eHeaderViewport')
  25494. ], HeaderRootComp.prototype, "eHeaderViewport", void 0);
  25495. __decorate$W([
  25496. Autowired('gridOptionsWrapper')
  25497. ], HeaderRootComp.prototype, "gridOptionsWrapper", void 0);
  25498. __decorate$W([
  25499. Autowired('columnController')
  25500. ], HeaderRootComp.prototype, "columnController", void 0);
  25501. __decorate$W([
  25502. Autowired('gridApi')
  25503. ], HeaderRootComp.prototype, "gridApi", void 0);
  25504. __decorate$W([
  25505. Autowired('autoWidthCalculator')
  25506. ], HeaderRootComp.prototype, "autoWidthCalculator", void 0);
  25507. __decorate$W([
  25508. Autowired('headerNavigationService')
  25509. ], HeaderRootComp.prototype, "headerNavigationService", void 0);
  25510. return HeaderRootComp;
  25511. }(ManagedFocusComponent));
  25512. /**
  25513. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  25514. * @version v23.2.1
  25515. * @link http://www.ag-grid.com/
  25516. * @license MIT
  25517. */
  25518. var __extends$_ = (undefined && undefined.__extends) || (function () {
  25519. var extendStatics = function (d, b) {
  25520. extendStatics = Object.setPrototypeOf ||
  25521. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  25522. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  25523. return extendStatics(d, b);
  25524. };
  25525. return function (d, b) {
  25526. extendStatics(d, b);
  25527. function __() { this.constructor = d; }
  25528. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  25529. };
  25530. })();
  25531. var __decorate$X = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  25532. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  25533. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  25534. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  25535. return c > 3 && r && Object.defineProperty(target, key, r), r;
  25536. };
  25537. var FilterManager = /** @class */ (function (_super) {
  25538. __extends$_(FilterManager, _super);
  25539. function FilterManager() {
  25540. var _this = _super !== null && _super.apply(this, arguments) || this;
  25541. _this.allFilters = new Map();
  25542. _this.quickFilter = null;
  25543. _this.quickFilterParts = null;
  25544. // this is true when the grid is processing the filter change. this is used by the cell comps, so that they
  25545. // don't flash when data changes due to filter changes. there is no need to flash when filter changes as the
  25546. // user is in control, so doesn't make sense to show flashing changes. for example, go to main demo where
  25547. // this feature is turned off (hack code to always return false for isSuppressFlashingCellsBecauseFiltering(), put in)
  25548. // 100,000 rows and group by country. then do some filtering. all the cells flash, which is silly.
  25549. _this.processingFilterChange = false;
  25550. return _this;
  25551. }
  25552. FilterManager_1 = FilterManager;
  25553. FilterManager.prototype.init = function () {
  25554. this.addManagedListener(this.eventService, Events.EVENT_ROW_DATA_CHANGED, this.onNewRowsLoaded.bind(this));
  25555. this.addManagedListener(this.eventService, Events.EVENT_NEW_COLUMNS_LOADED, this.onNewColumnsLoaded.bind(this));
  25556. this.quickFilter = this.parseQuickFilter(this.gridOptionsWrapper.getQuickFilterText());
  25557. this.setQuickFilterParts();
  25558. this.allowShowChangeAfterFilter = this.gridOptionsWrapper.isAllowShowChangeAfterFilter();
  25559. // check this here, in case there is a filter from the start
  25560. this.checkExternalFilter();
  25561. };
  25562. FilterManager.prototype.setQuickFilterParts = function () {
  25563. this.quickFilterParts = this.quickFilter ? this.quickFilter.split(' ') : null;
  25564. };
  25565. FilterManager.prototype.setFilterModel = function (model) {
  25566. var _this = this;
  25567. var allPromises = [];
  25568. if (model) {
  25569. // mark the filters as we set them, so any active filters left over we stop
  25570. var modelKeys_1 = convertToSet(Object.keys(model));
  25571. this.allFilters.forEach(function (filterWrapper, colId) {
  25572. var newModel = model[colId];
  25573. allPromises.push(_this.setModelOnFilterWrapper(filterWrapper.filterPromise, newModel));
  25574. modelKeys_1.delete(colId);
  25575. });
  25576. // at this point, processedFields contains data for which we don't have a filter working yet
  25577. modelKeys_1.forEach(function (colId) {
  25578. var column = _this.columnController.getPrimaryColumn(colId);
  25579. if (!column) {
  25580. console.warn('Warning ag-grid setFilterModel - no column found for colId ' + colId);
  25581. return;
  25582. }
  25583. var filterWrapper = _this.getOrCreateFilterWrapper(column, 'NO_UI');
  25584. allPromises.push(_this.setModelOnFilterWrapper(filterWrapper.filterPromise, model[colId]));
  25585. });
  25586. }
  25587. else {
  25588. this.allFilters.forEach(function (filterWrapper) {
  25589. allPromises.push(_this.setModelOnFilterWrapper(filterWrapper.filterPromise, null));
  25590. });
  25591. }
  25592. Promise.all(allPromises).then(function () { return _this.onFilterChanged(); });
  25593. };
  25594. FilterManager.prototype.setModelOnFilterWrapper = function (filterPromise, newModel) {
  25595. return new Promise(function (resolve) {
  25596. filterPromise.then(function (filter) {
  25597. if (typeof filter.setModel !== 'function') {
  25598. console.warn('Warning ag-grid - filter missing setModel method, which is needed for setFilterModel');
  25599. resolve();
  25600. }
  25601. var promise = filter.setModel(newModel);
  25602. if (promise == null) {
  25603. resolve();
  25604. }
  25605. else {
  25606. promise.then(function () { return resolve(); });
  25607. }
  25608. });
  25609. });
  25610. };
  25611. FilterManager.prototype.getFilterModel = function () {
  25612. var result = {};
  25613. this.allFilters.forEach(function (filterWrapper, key) {
  25614. // because user can provide filters, we provide useful error checking and messages
  25615. var filterPromise = filterWrapper.filterPromise;
  25616. var filter = filterPromise.resolveNow(null, function (filter) { return filter; });
  25617. if (filter == null) {
  25618. return null;
  25619. }
  25620. if (typeof filter.getModel !== 'function') {
  25621. console.warn('Warning ag-grid - filter API missing getModel method, which is needed for getFilterModel');
  25622. return;
  25623. }
  25624. var model = filter.getModel();
  25625. if (exists(model)) {
  25626. result[key] = model;
  25627. }
  25628. });
  25629. return result;
  25630. };
  25631. // returns true if any advanced filter (ie not quick filter) active
  25632. FilterManager.prototype.isAdvancedFilterPresent = function () {
  25633. return this.advancedFilterPresent;
  25634. };
  25635. // called by:
  25636. // 1) onFilterChanged()
  25637. // 2) onNewRowsLoaded()
  25638. FilterManager.prototype.setAdvancedFilterPresent = function () {
  25639. var atLeastOneActive = false;
  25640. this.allFilters.forEach(function (filterWrapper) {
  25641. if (atLeastOneActive) {
  25642. return;
  25643. } // no need to check any more
  25644. if (filterWrapper.filterPromise.resolveNow(false, function (filter) { return filter.isFilterActive(); })) {
  25645. atLeastOneActive = true;
  25646. }
  25647. });
  25648. this.advancedFilterPresent = atLeastOneActive;
  25649. };
  25650. FilterManager.prototype.updateFilterFlagInColumns = function (source, additionalEventAttributes) {
  25651. this.allFilters.forEach(function (filterWrapper) {
  25652. var isFilterActive = filterWrapper.filterPromise.resolveNow(false, function (filter) { return filter.isFilterActive(); });
  25653. filterWrapper.column.setFilterActive(isFilterActive, source, additionalEventAttributes);
  25654. });
  25655. };
  25656. // returns true if quickFilter or advancedFilter
  25657. FilterManager.prototype.isAnyFilterPresent = function () {
  25658. return this.isQuickFilterPresent() || this.advancedFilterPresent || this.externalFilterPresent;
  25659. };
  25660. FilterManager.prototype.doesFilterPass = function (node, filterToSkip) {
  25661. var data = node.data;
  25662. var filterPasses = true;
  25663. this.allFilters.forEach(function (filterWrapper) {
  25664. // if a filter has already failed, no need to run any more
  25665. if (!filterPasses) {
  25666. return;
  25667. }
  25668. // if no filter, always pass
  25669. if (filterWrapper == null) {
  25670. return;
  25671. }
  25672. var filter = filterWrapper.filterPromise.resolveNow(undefined, function (filter) { return filter; });
  25673. if (filter == null || filter === filterToSkip || !filter.isFilterActive()) {
  25674. return;
  25675. }
  25676. if (!filter.doesFilterPass) { // because users can do custom filters, give nice error message
  25677. throw new Error('Filter is missing method doesFilterPass');
  25678. }
  25679. filterPasses = filter.doesFilterPass({ node: node, data: data });
  25680. });
  25681. return filterPasses;
  25682. };
  25683. FilterManager.prototype.parseQuickFilter = function (newFilter) {
  25684. if (!exists(newFilter)) {
  25685. return null;
  25686. }
  25687. if (!this.gridOptionsWrapper.isRowModelDefault()) {
  25688. console.warn('ag-grid: quick filtering only works with the Client-Side Row Model');
  25689. return null;
  25690. }
  25691. return newFilter.toUpperCase();
  25692. };
  25693. FilterManager.prototype.setQuickFilter = function (newFilter) {
  25694. var parsedFilter = this.parseQuickFilter(newFilter);
  25695. if (this.quickFilter !== parsedFilter) {
  25696. this.quickFilter = parsedFilter;
  25697. this.setQuickFilterParts();
  25698. this.onFilterChanged();
  25699. }
  25700. };
  25701. FilterManager.prototype.checkExternalFilter = function () {
  25702. this.externalFilterPresent = this.gridOptionsWrapper.isExternalFilterPresent();
  25703. };
  25704. FilterManager.prototype.onFilterChanged = function (filterInstance, additionalEventAttributes) {
  25705. this.setAdvancedFilterPresent();
  25706. this.updateFilterFlagInColumns('filterChanged', additionalEventAttributes);
  25707. this.checkExternalFilter();
  25708. this.allFilters.forEach(function (filterWrapper) {
  25709. filterWrapper.filterPromise.then(function (filter) {
  25710. if (filter !== filterInstance && filter.onAnyFilterChanged) {
  25711. filter.onAnyFilterChanged();
  25712. }
  25713. });
  25714. });
  25715. var filterChangedEvent = {
  25716. type: Events.EVENT_FILTER_CHANGED,
  25717. api: this.gridApi,
  25718. columnApi: this.columnApi
  25719. };
  25720. if (additionalEventAttributes) {
  25721. mergeDeep(filterChangedEvent, additionalEventAttributes);
  25722. }
  25723. // because internal events are not async in ag-grid, when the dispatchEvent
  25724. // method comes back, we know all listeners have finished executing.
  25725. this.processingFilterChange = true;
  25726. this.eventService.dispatchEvent(filterChangedEvent);
  25727. this.processingFilterChange = false;
  25728. };
  25729. FilterManager.prototype.isSuppressFlashingCellsBecauseFiltering = function () {
  25730. // if user has elected to always flash cell changes, then always return false, otherwise we suppress flashing
  25731. // changes when filtering
  25732. return !this.allowShowChangeAfterFilter && this.processingFilterChange;
  25733. };
  25734. FilterManager.prototype.isQuickFilterPresent = function () {
  25735. return this.quickFilter !== null;
  25736. };
  25737. FilterManager.prototype.doesRowPassOtherFilters = function (filterToSkip, node) {
  25738. return this.doesRowPassFilter(node, filterToSkip);
  25739. };
  25740. FilterManager.prototype.doesRowPassQuickFilterNoCache = function (node, filterPart) {
  25741. var _this = this;
  25742. var columns = this.columnController.getAllColumnsForQuickFilter();
  25743. return some(columns, function (column) {
  25744. var part = _this.getQuickFilterTextForColumn(column, node);
  25745. return exists(part) && part.indexOf(filterPart) >= 0;
  25746. });
  25747. };
  25748. FilterManager.prototype.doesRowPassQuickFilterCache = function (node, filterPart) {
  25749. if (!node.quickFilterAggregateText) {
  25750. this.aggregateRowForQuickFilter(node);
  25751. }
  25752. return node.quickFilterAggregateText.indexOf(filterPart) >= 0;
  25753. };
  25754. FilterManager.prototype.doesRowPassQuickFilter = function (node) {
  25755. var _this = this;
  25756. var usingCache = this.gridOptionsWrapper.isCacheQuickFilter();
  25757. // each part must pass, if any fails, then the whole filter fails
  25758. return every(this.quickFilterParts, function (part) {
  25759. return usingCache ? _this.doesRowPassQuickFilterCache(node, part) : _this.doesRowPassQuickFilterNoCache(node, part);
  25760. });
  25761. };
  25762. FilterManager.prototype.doesRowPassFilter = function (node, filterToSkip) {
  25763. // the row must pass ALL of the filters, so if any of them fail,
  25764. // we return true. that means if a row passes the quick filter,
  25765. // but fails the column filter, it fails overall
  25766. // first up, check quick filter
  25767. if (this.isQuickFilterPresent() && !this.doesRowPassQuickFilter(node)) {
  25768. return false;
  25769. }
  25770. // secondly, give the client a chance to reject this row
  25771. if (this.externalFilterPresent && !this.gridOptionsWrapper.doesExternalFilterPass(node)) {
  25772. return false;
  25773. }
  25774. // lastly, check our internal advanced filter
  25775. if (this.advancedFilterPresent && !this.doesFilterPass(node, filterToSkip)) {
  25776. return false;
  25777. }
  25778. // got this far, all filters pass
  25779. return true;
  25780. };
  25781. FilterManager.prototype.getQuickFilterTextForColumn = function (column, node) {
  25782. var value = this.valueService.getValue(column, node, true);
  25783. var colDef = column.getColDef();
  25784. if (colDef.getQuickFilterText) {
  25785. var params = {
  25786. value: value,
  25787. node: node,
  25788. data: node.data,
  25789. column: column,
  25790. colDef: colDef,
  25791. context: this.gridOptionsWrapper.getContext()
  25792. };
  25793. value = colDef.getQuickFilterText(params);
  25794. }
  25795. return exists(value) ? value.toString().toUpperCase() : null;
  25796. };
  25797. FilterManager.prototype.aggregateRowForQuickFilter = function (node) {
  25798. var _this = this;
  25799. var stringParts = [];
  25800. var columns = this.columnController.getAllColumnsForQuickFilter();
  25801. forEach(columns, function (column) {
  25802. var part = _this.getQuickFilterTextForColumn(column, node);
  25803. if (exists(part)) {
  25804. stringParts.push(part);
  25805. }
  25806. });
  25807. node.quickFilterAggregateText = stringParts.join(FilterManager_1.QUICK_FILTER_SEPARATOR);
  25808. };
  25809. FilterManager.prototype.onNewRowsLoaded = function (source) {
  25810. this.allFilters.forEach(function (filterWrapper) {
  25811. filterWrapper.filterPromise.then(function (filter) {
  25812. if (filter.onNewRowsLoaded) {
  25813. filter.onNewRowsLoaded();
  25814. }
  25815. });
  25816. });
  25817. this.updateFilterFlagInColumns(source);
  25818. this.setAdvancedFilterPresent();
  25819. };
  25820. FilterManager.prototype.createValueGetter = function (column) {
  25821. var _this = this;
  25822. return function (node) { return _this.valueService.getValue(column, node, true); };
  25823. };
  25824. FilterManager.prototype.getFilterComponent = function (column, source) {
  25825. return this.getOrCreateFilterWrapper(column, source).filterPromise;
  25826. };
  25827. FilterManager.prototype.isFilterActive = function (column) {
  25828. var filterWrapper = this.cachedFilter(column);
  25829. return filterWrapper && filterWrapper.filterPromise.resolveNow(false, function (filter) { return filter.isFilterActive(); });
  25830. };
  25831. FilterManager.prototype.getOrCreateFilterWrapper = function (column, source) {
  25832. var filterWrapper = this.cachedFilter(column);
  25833. if (!filterWrapper) {
  25834. filterWrapper = this.createFilterWrapper(column, source);
  25835. this.allFilters.set(column.getColId(), filterWrapper);
  25836. }
  25837. else if (source !== 'NO_UI') {
  25838. this.putIntoGui(filterWrapper, source);
  25839. }
  25840. return filterWrapper;
  25841. };
  25842. FilterManager.prototype.cachedFilter = function (column) {
  25843. return this.allFilters.get(column.getColId());
  25844. };
  25845. FilterManager.prototype.createFilterInstance = function (column, $scope) {
  25846. var _this = this;
  25847. var defaultFilter = ModuleRegistry.isRegistered(exports.ModuleNames.SetFilterModule) ? 'agSetColumnFilter' : 'agTextColumnFilter';
  25848. var sanitisedColDef = cloneObject(column.getColDef());
  25849. var filterInstance;
  25850. var params = this.createFilterParams(column, sanitisedColDef, $scope);
  25851. params.filterModifiedCallback = function () {
  25852. var event = {
  25853. type: Events.EVENT_FILTER_MODIFIED,
  25854. api: _this.gridApi,
  25855. columnApi: _this.columnApi,
  25856. column: column,
  25857. filterInstance: filterInstance
  25858. };
  25859. _this.eventService.dispatchEvent(event);
  25860. };
  25861. // we modify params in a callback as we need the filter instance, and this isn't available
  25862. // when creating the params above
  25863. var modifyParamsCallback = function (params, filterInstance) { return assign(params, {
  25864. doesRowPassOtherFilter: function (node) { return _this.doesRowPassOtherFilters(filterInstance, node); },
  25865. filterChangedCallback: function (additionalEventAttributes) {
  25866. return _this.onFilterChanged(filterInstance, additionalEventAttributes);
  25867. }
  25868. }); };
  25869. var res = this.userComponentFactory.newFilterComponent(sanitisedColDef, params, defaultFilter, modifyParamsCallback);
  25870. if (res) {
  25871. res.then(function (r) { return filterInstance = r; });
  25872. }
  25873. return res;
  25874. };
  25875. FilterManager.prototype.createFilterParams = function (column, colDef, $scope) {
  25876. if ($scope === void 0) { $scope = null; }
  25877. var params = {
  25878. api: this.gridOptionsWrapper.getApi(),
  25879. column: column,
  25880. colDef: colDef,
  25881. rowModel: this.rowModel,
  25882. filterChangedCallback: null,
  25883. filterModifiedCallback: null,
  25884. valueGetter: this.createValueGetter(column),
  25885. context: this.gridOptionsWrapper.getContext(),
  25886. doesRowPassOtherFilter: null
  25887. };
  25888. // hack in scope if using AngularJS
  25889. if ($scope) {
  25890. params.$scope = $scope;
  25891. }
  25892. return params;
  25893. };
  25894. FilterManager.prototype.createFilterWrapper = function (column, source) {
  25895. var filterWrapper = {
  25896. column: column,
  25897. filterPromise: null,
  25898. scope: null,
  25899. compiledElement: null,
  25900. guiPromise: Promise.resolve(null)
  25901. };
  25902. filterWrapper.scope = this.gridOptionsWrapper.isAngularCompileFilters() ? this.$scope.$new() : null;
  25903. filterWrapper.filterPromise = this.createFilterInstance(column, filterWrapper.scope);
  25904. if (filterWrapper.filterPromise) {
  25905. this.putIntoGui(filterWrapper, source);
  25906. }
  25907. return filterWrapper;
  25908. };
  25909. FilterManager.prototype.putIntoGui = function (filterWrapper, source) {
  25910. var _this = this;
  25911. var eFilterGui = document.createElement('div');
  25912. eFilterGui.className = 'ag-filter';
  25913. filterWrapper.guiPromise = new Promise(function (resolve) {
  25914. filterWrapper.filterPromise.then(function (filter) {
  25915. var guiFromFilter = filter.getGui();
  25916. if (!exists(guiFromFilter)) {
  25917. console.warn("getGui method from filter returned " + guiFromFilter + ", it should be a DOM element or an HTML template string.");
  25918. }
  25919. // for backwards compatibility with Angular 1 - we
  25920. // used to allow providing back HTML from getGui().
  25921. // once we move away from supporting Angular 1
  25922. // directly, we can change this.
  25923. if (typeof guiFromFilter === 'string') {
  25924. guiFromFilter = loadTemplate(guiFromFilter);
  25925. }
  25926. eFilterGui.appendChild(guiFromFilter);
  25927. if (filterWrapper.scope) {
  25928. var compiledElement = _this.$compile(eFilterGui)(filterWrapper.scope);
  25929. filterWrapper.compiledElement = compiledElement;
  25930. window.setTimeout(function () { return filterWrapper.scope.$apply(); }, 0);
  25931. }
  25932. resolve(eFilterGui);
  25933. _this.eventService.dispatchEvent({
  25934. type: Events.EVENT_FILTER_OPENED,
  25935. column: filterWrapper.column,
  25936. source: source,
  25937. eGui: eFilterGui,
  25938. api: _this.gridApi,
  25939. columnApi: _this.columnApi
  25940. });
  25941. });
  25942. });
  25943. };
  25944. FilterManager.prototype.onNewColumnsLoaded = function () {
  25945. var _this = this;
  25946. var atLeastOneFilterGone = false;
  25947. this.allFilters.forEach(function (filterWrapper) {
  25948. var oldColumn = !_this.columnController.getPrimaryColumn(filterWrapper.column);
  25949. if (oldColumn) {
  25950. atLeastOneFilterGone = true;
  25951. _this.disposeFilterWrapper(filterWrapper, 'filterDestroyed');
  25952. }
  25953. });
  25954. if (atLeastOneFilterGone) {
  25955. this.onFilterChanged();
  25956. }
  25957. };
  25958. // destroys the filter, so it not longer takes part
  25959. FilterManager.prototype.destroyFilter = function (column, source) {
  25960. if (source === void 0) { source = 'api'; }
  25961. var filterWrapper = this.allFilters.get(column.getColId());
  25962. if (filterWrapper) {
  25963. this.disposeFilterWrapper(filterWrapper, source);
  25964. this.onFilterChanged();
  25965. }
  25966. };
  25967. FilterManager.prototype.disposeFilterWrapper = function (filterWrapper, source) {
  25968. var _this = this;
  25969. filterWrapper.filterPromise.then(function (filter) {
  25970. filter.setModel(null);
  25971. _this.getContext().destroyBean(filter);
  25972. filterWrapper.column.setFilterActive(false, source);
  25973. if (filterWrapper.scope) {
  25974. if (filterWrapper.compiledElement) {
  25975. filterWrapper.compiledElement.remove();
  25976. }
  25977. filterWrapper.scope.$destroy();
  25978. }
  25979. _this.allFilters.delete(filterWrapper.column.getColId());
  25980. });
  25981. };
  25982. FilterManager.prototype.destroy = function () {
  25983. var _this = this;
  25984. _super.prototype.destroy.call(this);
  25985. this.allFilters.forEach(function (filterWrapper) { return _this.disposeFilterWrapper(filterWrapper, 'filterDestroyed'); });
  25986. };
  25987. var FilterManager_1;
  25988. FilterManager.QUICK_FILTER_SEPARATOR = '\n';
  25989. __decorate$X([
  25990. Autowired('$compile')
  25991. ], FilterManager.prototype, "$compile", void 0);
  25992. __decorate$X([
  25993. Autowired('$scope')
  25994. ], FilterManager.prototype, "$scope", void 0);
  25995. __decorate$X([
  25996. Autowired('gridOptionsWrapper')
  25997. ], FilterManager.prototype, "gridOptionsWrapper", void 0);
  25998. __decorate$X([
  25999. Autowired('valueService')
  26000. ], FilterManager.prototype, "valueService", void 0);
  26001. __decorate$X([
  26002. Autowired('columnController')
  26003. ], FilterManager.prototype, "columnController", void 0);
  26004. __decorate$X([
  26005. Autowired('rowModel')
  26006. ], FilterManager.prototype, "rowModel", void 0);
  26007. __decorate$X([
  26008. Autowired('columnApi')
  26009. ], FilterManager.prototype, "columnApi", void 0);
  26010. __decorate$X([
  26011. Autowired('gridApi')
  26012. ], FilterManager.prototype, "gridApi", void 0);
  26013. __decorate$X([
  26014. Autowired('userComponentFactory')
  26015. ], FilterManager.prototype, "userComponentFactory", void 0);
  26016. __decorate$X([
  26017. PostConstruct
  26018. ], FilterManager.prototype, "init", null);
  26019. __decorate$X([
  26020. PreDestroy
  26021. ], FilterManager.prototype, "destroy", null);
  26022. FilterManager = FilterManager_1 = __decorate$X([
  26023. Bean('filterManager')
  26024. ], FilterManager);
  26025. return FilterManager;
  26026. }(BeanStub));
  26027. /**
  26028. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  26029. * @version v23.2.1
  26030. * @link http://www.ag-grid.com/
  26031. * @license MIT
  26032. */
  26033. var __extends$$ = (undefined && undefined.__extends) || (function () {
  26034. var extendStatics = function (d, b) {
  26035. extendStatics = Object.setPrototypeOf ||
  26036. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  26037. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  26038. return extendStatics(d, b);
  26039. };
  26040. return function (d, b) {
  26041. extendStatics(d, b);
  26042. function __() { this.constructor = d; }
  26043. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  26044. };
  26045. })();
  26046. var __decorate$Y = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  26047. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  26048. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  26049. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  26050. return c > 3 && r && Object.defineProperty(target, key, r), r;
  26051. };
  26052. var ValueService = /** @class */ (function (_super) {
  26053. __extends$$(ValueService, _super);
  26054. function ValueService() {
  26055. var _this = _super !== null && _super.apply(this, arguments) || this;
  26056. _this.initialised = false;
  26057. return _this;
  26058. }
  26059. ValueService.prototype.init = function () {
  26060. this.cellExpressions = this.gridOptionsWrapper.isEnableCellExpressions();
  26061. this.initialised = true;
  26062. };
  26063. ValueService.prototype.getValue = function (column, rowNode, forFilter, ignoreAggData) {
  26064. if (forFilter === void 0) { forFilter = false; }
  26065. if (ignoreAggData === void 0) { ignoreAggData = false; }
  26066. // hack - the grid is getting refreshed before this bean gets initialised, race condition.
  26067. // really should have a way so they get initialised in the right order???
  26068. if (!this.initialised) {
  26069. this.init();
  26070. }
  26071. if (!rowNode) {
  26072. return;
  26073. }
  26074. // pull these out to make code below easier to read
  26075. var colDef = column.getColDef();
  26076. var field = colDef.field;
  26077. var colId = column.getId();
  26078. var data = rowNode.data;
  26079. var result;
  26080. // if there is a value getter, this gets precedence over a field
  26081. var groupDataExists = rowNode.groupData && rowNode.groupData[colId] !== undefined;
  26082. var aggDataExists = !ignoreAggData && rowNode.aggData && rowNode.aggData[colId] !== undefined;
  26083. if (forFilter && colDef.filterValueGetter) {
  26084. result = this.executeFilterValueGetter(colDef.filterValueGetter, data, column, rowNode);
  26085. }
  26086. else if (this.gridOptionsWrapper.isTreeData() && aggDataExists) {
  26087. result = rowNode.aggData[colId];
  26088. }
  26089. else if (this.gridOptionsWrapper.isTreeData() && colDef.valueGetter) {
  26090. result = this.executeValueGetter(colDef.valueGetter, data, column, rowNode);
  26091. }
  26092. else if (this.gridOptionsWrapper.isTreeData() && (field && data)) {
  26093. result = _.getValueUsingField(data, field, column.isFieldContainsDots());
  26094. }
  26095. else if (groupDataExists) {
  26096. result = rowNode.groupData[colId];
  26097. }
  26098. else if (aggDataExists) {
  26099. result = rowNode.aggData[colId];
  26100. }
  26101. else if (colDef.valueGetter) {
  26102. result = this.executeValueGetter(colDef.valueGetter, data, column, rowNode);
  26103. }
  26104. else if (field && data) {
  26105. result = _.getValueUsingField(data, field, column.isFieldContainsDots());
  26106. }
  26107. // the result could be an expression itself, if we are allowing cell values to be expressions
  26108. if (this.cellExpressions && (typeof result === 'string') && result.indexOf('=') === 0) {
  26109. var cellValueGetter = result.substring(1);
  26110. result = this.executeValueGetter(cellValueGetter, data, column, rowNode);
  26111. }
  26112. return result;
  26113. };
  26114. ValueService.prototype.setValue = function (rowNode, colKey, newValue, eventSource) {
  26115. var column = this.columnController.getPrimaryColumn(colKey);
  26116. if (!rowNode || !column) {
  26117. return;
  26118. }
  26119. // this will only happen if user is trying to paste into a group row, which doesn't make sense
  26120. // the user should not be trying to paste into group rows
  26121. if (_.missing(rowNode.data)) {
  26122. rowNode.data = {};
  26123. }
  26124. // for backwards compatibility we are also retrieving the newValueHandler as well as the valueSetter
  26125. var _a = column.getColDef(), field = _a.field, newValueHandler = _a.newValueHandler, valueSetter = _a.valueSetter;
  26126. // need either a field or a newValueHandler for this to work
  26127. if (_.missing(field) && _.missing(newValueHandler) && _.missing(valueSetter)) {
  26128. // we don't tell user about newValueHandler, as that is deprecated
  26129. console.warn("ag-Grid: you need either field or valueSetter set on colDef for editing to work");
  26130. return;
  26131. }
  26132. var params = {
  26133. node: rowNode,
  26134. data: rowNode.data,
  26135. oldValue: this.getValue(column, rowNode),
  26136. newValue: newValue,
  26137. colDef: column.getColDef(),
  26138. column: column,
  26139. api: this.gridOptionsWrapper.getApi(),
  26140. columnApi: this.gridOptionsWrapper.getColumnApi(),
  26141. context: this.gridOptionsWrapper.getContext()
  26142. };
  26143. params.newValue = newValue;
  26144. var valueWasDifferent;
  26145. if (newValueHandler && _.exists(newValueHandler)) {
  26146. valueWasDifferent = newValueHandler(params);
  26147. }
  26148. else if (_.exists(valueSetter)) {
  26149. valueWasDifferent = this.expressionService.evaluate(valueSetter, params);
  26150. }
  26151. else {
  26152. valueWasDifferent = this.setValueUsingField(rowNode.data, field, newValue, column.isFieldContainsDots());
  26153. }
  26154. // in case user forgot to return something (possible if they are not using TypeScript
  26155. // and just forgot, or using an old newValueHandler we didn't always expect a return
  26156. // value here), we default the return value to true, so we always refresh.
  26157. if (valueWasDifferent === undefined) {
  26158. valueWasDifferent = true;
  26159. }
  26160. // if no change to the value, then no need to do the updating, or notifying via events.
  26161. // otherwise the user could be tabbing around the grid, and cellValueChange would get called
  26162. // all the time.
  26163. if (!valueWasDifferent) {
  26164. return;
  26165. }
  26166. // reset quick filter on this row
  26167. rowNode.resetQuickFilterAggregateText();
  26168. this.valueCache.onDataChanged();
  26169. params.newValue = this.getValue(column, rowNode);
  26170. var onCellValueChanged = column.getColDef().onCellValueChanged;
  26171. if (typeof onCellValueChanged === 'function') {
  26172. // to make callback async, do in a timeout
  26173. setTimeout(function () { return onCellValueChanged(params); }, 0);
  26174. }
  26175. var event = {
  26176. type: Events.EVENT_CELL_VALUE_CHANGED,
  26177. event: null,
  26178. rowIndex: rowNode.rowIndex,
  26179. rowPinned: rowNode.rowPinned,
  26180. column: params.column,
  26181. api: params.api,
  26182. colDef: params.colDef,
  26183. columnApi: params.columnApi,
  26184. context: params.context,
  26185. data: rowNode.data,
  26186. node: rowNode,
  26187. oldValue: params.oldValue,
  26188. newValue: params.newValue,
  26189. value: params.newValue,
  26190. source: eventSource
  26191. };
  26192. this.eventService.dispatchEvent(event);
  26193. };
  26194. ValueService.prototype.setValueUsingField = function (data, field, newValue, isFieldContainsDots) {
  26195. if (!field) {
  26196. return false;
  26197. }
  26198. // if no '.', then it's not a deep value
  26199. var valuesAreSame = false;
  26200. if (!isFieldContainsDots) {
  26201. data[field] = newValue;
  26202. }
  26203. else {
  26204. // otherwise it is a deep value, so need to dig for it
  26205. var fieldPieces = field.split('.');
  26206. var currentObject = data;
  26207. while (fieldPieces.length > 0 && currentObject) {
  26208. var fieldPiece = fieldPieces.shift();
  26209. if (fieldPieces.length === 0) {
  26210. currentObject[fieldPiece] = newValue;
  26211. }
  26212. else {
  26213. currentObject = currentObject[fieldPiece];
  26214. }
  26215. }
  26216. }
  26217. return !valuesAreSame;
  26218. };
  26219. ValueService.prototype.executeFilterValueGetter = function (valueGetter, data, column, rowNode) {
  26220. var params = {
  26221. data: data,
  26222. node: rowNode,
  26223. column: column,
  26224. colDef: column.getColDef(),
  26225. api: this.gridOptionsWrapper.getApi(),
  26226. columnApi: this.gridOptionsWrapper.getColumnApi(),
  26227. context: this.gridOptionsWrapper.getContext(),
  26228. getValue: this.getValueCallback.bind(this, rowNode)
  26229. };
  26230. return this.expressionService.evaluate(valueGetter, params);
  26231. };
  26232. ValueService.prototype.executeValueGetter = function (valueGetter, data, column, rowNode) {
  26233. var colId = column.getId();
  26234. // if inside the same turn, just return back the value we got last time
  26235. var valueFromCache = this.valueCache.getValue(rowNode, colId);
  26236. if (valueFromCache !== undefined) {
  26237. return valueFromCache;
  26238. }
  26239. var params = {
  26240. data: data,
  26241. node: rowNode,
  26242. column: column,
  26243. colDef: column.getColDef(),
  26244. api: this.gridOptionsWrapper.getApi(),
  26245. columnApi: this.gridOptionsWrapper.getColumnApi(),
  26246. context: this.gridOptionsWrapper.getContext(),
  26247. getValue: this.getValueCallback.bind(this, rowNode)
  26248. };
  26249. var result = this.expressionService.evaluate(valueGetter, params);
  26250. // if a turn is active, store the value in case the grid asks for it again
  26251. this.valueCache.setValue(rowNode, colId, result);
  26252. return result;
  26253. };
  26254. ValueService.prototype.getValueCallback = function (node, field) {
  26255. var otherColumn = this.columnController.getPrimaryColumn(field);
  26256. if (otherColumn) {
  26257. return this.getValue(otherColumn, node);
  26258. }
  26259. return null;
  26260. };
  26261. // used by row grouping and pivot, to get key for a row. col can be a pivot col or a row grouping col
  26262. ValueService.prototype.getKeyForNode = function (col, rowNode) {
  26263. var value = this.getValue(col, rowNode);
  26264. var keyCreator = col.getColDef().keyCreator;
  26265. var result = keyCreator ? keyCreator({ value: value }) : value;
  26266. // if already a string, or missing, just return it
  26267. if (typeof result === 'string' || result == null) {
  26268. return result;
  26269. }
  26270. result = String(result);
  26271. if (result === '[object Object]') {
  26272. _.doOnce(function () {
  26273. console.warn('ag-Grid: a column you are grouping or pivoting by has objects as values. If you want to group by complex objects then either a) use a colDef.keyCreator (se ag-Grid docs) or b) to toString() on the object to return a key');
  26274. }, 'getKeyForNode - warn about [object,object]');
  26275. }
  26276. return result;
  26277. };
  26278. __decorate$Y([
  26279. Autowired('gridOptionsWrapper')
  26280. ], ValueService.prototype, "gridOptionsWrapper", void 0);
  26281. __decorate$Y([
  26282. Autowired('expressionService')
  26283. ], ValueService.prototype, "expressionService", void 0);
  26284. __decorate$Y([
  26285. Autowired('columnController')
  26286. ], ValueService.prototype, "columnController", void 0);
  26287. __decorate$Y([
  26288. Autowired('valueCache')
  26289. ], ValueService.prototype, "valueCache", void 0);
  26290. __decorate$Y([
  26291. PostConstruct
  26292. ], ValueService.prototype, "init", null);
  26293. ValueService = __decorate$Y([
  26294. Bean('valueService')
  26295. ], ValueService);
  26296. return ValueService;
  26297. }(BeanStub));
  26298. /**
  26299. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  26300. * @version v23.2.1
  26301. * @link http://www.ag-grid.com/
  26302. * @license MIT
  26303. */
  26304. var __decorate$Z = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  26305. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  26306. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  26307. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  26308. return c > 3 && r && Object.defineProperty(target, key, r), r;
  26309. };
  26310. /**
  26311. * There are many instances of this component covering each of the areas a row can be entered
  26312. * eg body, pinned left, fullWidth. The component differs from others in that it's given the
  26313. * elements, there is no template. All of the elements are part of the GridPanel.
  26314. */
  26315. var RowContainerComponent = /** @class */ (function () {
  26316. function RowContainerComponent(params) {
  26317. this.childCount = 0;
  26318. this.rowTemplatesToAdd = [];
  26319. this.afterGuiAttachedCallbacks = [];
  26320. // this is to cater for a 'strange behaviour' where when a panel is made visible, it is firing a scroll
  26321. // event which we want to ignore. see gridPanel.onAnyBodyScroll()
  26322. this.lastMadeVisibleTime = 0;
  26323. this.eContainer = params.eContainer;
  26324. this.eViewport = params.eViewport;
  26325. if (params.eWrapper) {
  26326. this.eWrapper = params.eWrapper;
  26327. }
  26328. this.hideWhenNoChildren = params.hideWhenNoChildren;
  26329. }
  26330. RowContainerComponent.prototype.setVerticalScrollPosition = function (verticalScrollPosition) {
  26331. this.scrollTop = verticalScrollPosition;
  26332. };
  26333. RowContainerComponent.prototype.postConstruct = function () {
  26334. this.checkDomOrder();
  26335. this.checkVisibility();
  26336. this.gridOptionsWrapper.addEventListener(GridOptionsWrapper.PROP_DOM_LAYOUT, this.checkDomOrder.bind(this));
  26337. };
  26338. RowContainerComponent.prototype.checkDomOrder = function () {
  26339. this.domOrder = this.gridOptionsWrapper.isEnsureDomOrder();
  26340. };
  26341. RowContainerComponent.prototype.getRowElement = function (compId) {
  26342. return this.eContainer.querySelector("[comp-id=\"" + compId + "\"]");
  26343. };
  26344. RowContainerComponent.prototype.setHeight = function (height) {
  26345. if (height == null) {
  26346. this.eContainer.style.height = '';
  26347. return;
  26348. }
  26349. this.eContainer.style.height = height + "px";
  26350. if (this.eWrapper) {
  26351. this.eWrapper.style.height = height + "px";
  26352. }
  26353. };
  26354. RowContainerComponent.prototype.flushRowTemplates = function () {
  26355. // if doing dom order, then rowTemplates will be empty,
  26356. // or if no rows added since last time also empty.
  26357. if (this.rowTemplatesToAdd.length !== 0) {
  26358. var htmlToAdd = this.rowTemplatesToAdd.join('');
  26359. _.appendHtml(this.eContainer, htmlToAdd);
  26360. this.rowTemplatesToAdd.length = 0;
  26361. }
  26362. // this only empty if no rows since last time, as when
  26363. // doing dom order, we still have callbacks to process
  26364. this.afterGuiAttachedCallbacks.forEach(function (func) { return func(); });
  26365. this.afterGuiAttachedCallbacks.length = 0;
  26366. this.lastPlacedElement = null;
  26367. };
  26368. RowContainerComponent.prototype.appendRowTemplate = function (rowTemplate, callback) {
  26369. if (this.domOrder) {
  26370. this.lastPlacedElement = _.insertTemplateWithDomOrder(this.eContainer, rowTemplate, this.lastPlacedElement);
  26371. }
  26372. else {
  26373. this.rowTemplatesToAdd.push(rowTemplate);
  26374. }
  26375. this.afterGuiAttachedCallbacks.push(callback);
  26376. // it is important we put items in in order, so that when we open a row group,
  26377. // the new rows are inserted after the opened group, but before the rows below.
  26378. // that way, the rows below are over the new rows (as dom renders last in dom over
  26379. // items previous in dom), otherwise the child rows would cover the row below and
  26380. // that meant the user doesn't see the rows below slide away.
  26381. this.childCount++;
  26382. this.checkVisibility();
  26383. };
  26384. RowContainerComponent.prototype.ensureDomOrder = function (eRow) {
  26385. if (this.domOrder) {
  26386. _.ensureDomOrder(this.eContainer, eRow, this.lastPlacedElement);
  26387. this.lastPlacedElement = eRow;
  26388. }
  26389. };
  26390. RowContainerComponent.prototype.removeRowElement = function (eRow) {
  26391. this.eContainer.removeChild(eRow);
  26392. this.childCount--;
  26393. this.checkVisibility();
  26394. };
  26395. RowContainerComponent.prototype.checkVisibility = function () {
  26396. if (!this.hideWhenNoChildren) {
  26397. return;
  26398. }
  26399. var eGui = this.eViewport ? this.eViewport : this.eContainer;
  26400. var visible = this.childCount > 0;
  26401. if (this.visible !== visible) {
  26402. this.visible = visible;
  26403. this.lastMadeVisibleTime = new Date().getTime();
  26404. _.setDisplayed(eGui, visible);
  26405. // if we are showing the viewport, then the scroll is always zero,
  26406. // so we need to align with the other sections (ie if this is full
  26407. // width container, and first time showing a full width row, we need to
  26408. // scroll it so full width rows are show in right place alongside the
  26409. // body rows). without this, there was an issue with 'loading rows' for
  26410. // server side row model, as loading rows are full width, and they were
  26411. // not getting displayed in the right location when rows were expanded.
  26412. if (visible && this.eViewport) {
  26413. this.eViewport.scrollTop = this.scrollTop;
  26414. }
  26415. }
  26416. };
  26417. RowContainerComponent.prototype.isMadeVisibleRecently = function () {
  26418. var now = new Date().getTime();
  26419. var millisSinceVisible = now - this.lastMadeVisibleTime;
  26420. return millisSinceVisible < 500;
  26421. };
  26422. __decorate$Z([
  26423. Autowired('gridOptionsWrapper')
  26424. ], RowContainerComponent.prototype, "gridOptionsWrapper", void 0);
  26425. __decorate$Z([
  26426. PostConstruct
  26427. ], RowContainerComponent.prototype, "postConstruct", null);
  26428. return RowContainerComponent;
  26429. }());
  26430. /**
  26431. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  26432. * @version v23.2.1
  26433. * @link http://www.ag-grid.com/
  26434. * @license MIT
  26435. */
  26436. var __extends$10 = (undefined && undefined.__extends) || (function () {
  26437. var extendStatics = function (d, b) {
  26438. extendStatics = Object.setPrototypeOf ||
  26439. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  26440. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  26441. return extendStatics(d, b);
  26442. };
  26443. return function (d, b) {
  26444. extendStatics(d, b);
  26445. function __() { this.constructor = d; }
  26446. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  26447. };
  26448. })();
  26449. var __assign$3 = (undefined && undefined.__assign) || function () {
  26450. __assign$3 = Object.assign || function(t) {
  26451. for (var s, i = 1, n = arguments.length; i < n; i++) {
  26452. s = arguments[i];
  26453. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
  26454. t[p] = s[p];
  26455. }
  26456. return t;
  26457. };
  26458. return __assign$3.apply(this, arguments);
  26459. };
  26460. var __decorate$_ = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  26461. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  26462. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  26463. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  26464. return c > 3 && r && Object.defineProperty(target, key, r), r;
  26465. };
  26466. var __spreadArrays$4 = (undefined && undefined.__spreadArrays) || function () {
  26467. for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
  26468. for (var r = Array(s), k = 0, i = 0; i < il; i++)
  26469. for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
  26470. r[k] = a[j];
  26471. return r;
  26472. };
  26473. var RowDragFeature = /** @class */ (function (_super) {
  26474. __extends$10(RowDragFeature, _super);
  26475. function RowDragFeature(eContainer, gridPanel) {
  26476. var _this = _super.call(this) || this;
  26477. _this.isMultiRowDrag = false;
  26478. _this.isGridSorted = false;
  26479. _this.isGridFiltered = false;
  26480. _this.isRowGroupActive = false;
  26481. _this.eContainer = eContainer;
  26482. _this.gridPanel = gridPanel;
  26483. return _this;
  26484. }
  26485. RowDragFeature.prototype.postConstruct = function () {
  26486. if (this.gridOptionsWrapper.isRowModelDefault()) {
  26487. this.clientSideRowModel = this.rowModel;
  26488. }
  26489. this.addManagedListener(this.eventService, Events.EVENT_SORT_CHANGED, this.onSortChanged.bind(this));
  26490. this.addManagedListener(this.eventService, Events.EVENT_FILTER_CHANGED, this.onFilterChanged.bind(this));
  26491. this.addManagedListener(this.eventService, Events.EVENT_COLUMN_ROW_GROUP_CHANGED, this.onRowGroupChanged.bind(this));
  26492. this.onSortChanged();
  26493. this.onFilterChanged();
  26494. this.onRowGroupChanged();
  26495. };
  26496. RowDragFeature.prototype.onSortChanged = function () {
  26497. var sortModel = this.sortController.getSortModel();
  26498. this.isGridSorted = !_.missingOrEmpty(sortModel);
  26499. };
  26500. RowDragFeature.prototype.onFilterChanged = function () {
  26501. this.isGridFiltered = this.filterManager.isAnyFilterPresent();
  26502. };
  26503. RowDragFeature.prototype.onRowGroupChanged = function () {
  26504. var rowGroups = this.columnController.getRowGroupColumns();
  26505. this.isRowGroupActive = !_.missingOrEmpty(rowGroups);
  26506. };
  26507. RowDragFeature.prototype.getContainer = function () {
  26508. return this.eContainer;
  26509. };
  26510. RowDragFeature.prototype.isInterestedIn = function (type) {
  26511. return type === exports.DragSourceType.RowDrag;
  26512. };
  26513. RowDragFeature.prototype.getIconName = function () {
  26514. var managedDrag = this.gridOptionsWrapper.isRowDragManaged();
  26515. if (managedDrag && this.shouldPreventRowMove()) {
  26516. return DragAndDropService.ICON_NOT_ALLOWED;
  26517. }
  26518. return DragAndDropService.ICON_MOVE;
  26519. };
  26520. RowDragFeature.prototype.shouldPreventRowMove = function () {
  26521. return this.isGridSorted || this.isGridFiltered || this.isRowGroupActive;
  26522. };
  26523. RowDragFeature.prototype.getRowNodes = function (draggingEvent) {
  26524. if (!this.isFromThisGrid(draggingEvent)) {
  26525. return draggingEvent.dragItem.rowNodes;
  26526. }
  26527. var enableMultiRowDragging = this.gridOptionsWrapper.isEnableMultiRowDragging();
  26528. var selectedNodes = this.selectionController.getSelectedNodes();
  26529. var currentNode = draggingEvent.dragItem.rowNode;
  26530. if (enableMultiRowDragging && selectedNodes.indexOf(currentNode) !== -1) {
  26531. this.isMultiRowDrag = true;
  26532. return __spreadArrays$4(selectedNodes);
  26533. }
  26534. this.isMultiRowDrag = false;
  26535. return [currentNode];
  26536. };
  26537. RowDragFeature.prototype.onDragEnter = function (draggingEvent) {
  26538. // when entering, we fire the enter event, then in onEnterOrDragging,
  26539. // we also fire the move event. so we get both events when entering.
  26540. this.dispatchGridEvent(Events.EVENT_ROW_DRAG_ENTER, draggingEvent);
  26541. this.getRowNodes(draggingEvent).forEach(function (rowNode) {
  26542. rowNode.setDragging(true);
  26543. });
  26544. this.onEnterOrDragging(draggingEvent);
  26545. };
  26546. RowDragFeature.prototype.onDragging = function (draggingEvent) {
  26547. this.onEnterOrDragging(draggingEvent);
  26548. };
  26549. RowDragFeature.prototype.isFromThisGrid = function (draggingEvent) {
  26550. return this.gridPanel.getGui().contains(draggingEvent.dragSource.eElement);
  26551. };
  26552. RowDragFeature.prototype.isDropZoneWithinThisGrid = function (draggingEvent) {
  26553. var gridGui = this.gridPanel.getGui();
  26554. var dropZoneTarget = draggingEvent.dropZoneTarget;
  26555. return !gridGui.contains(dropZoneTarget);
  26556. };
  26557. RowDragFeature.prototype.onEnterOrDragging = function (draggingEvent) {
  26558. // this event is fired for enter and move
  26559. this.dispatchGridEvent(Events.EVENT_ROW_DRAG_MOVE, draggingEvent);
  26560. this.lastDraggingEvent = draggingEvent;
  26561. var pixel = this.mouseEventService.getNormalisedPosition(draggingEvent).y;
  26562. var managedDrag = this.gridOptionsWrapper.isRowDragManaged();
  26563. if (managedDrag) {
  26564. this.doManagedDrag(draggingEvent, pixel);
  26565. }
  26566. this.checkCenterForScrolling(pixel);
  26567. };
  26568. RowDragFeature.prototype.doManagedDrag = function (draggingEvent, pixel) {
  26569. var _this = this;
  26570. var rowNodes;
  26571. var isFromThisGrid = this.isFromThisGrid(draggingEvent);
  26572. if (isFromThisGrid) {
  26573. rowNodes = [draggingEvent.dragItem.rowNode];
  26574. if (this.isMultiRowDrag) {
  26575. rowNodes = __spreadArrays$4(this.selectionController.getSelectedNodes()).sort(function (a, b) { return _this.getRowIndexNumber(a) - _this.getRowIndexNumber(b); });
  26576. }
  26577. draggingEvent.dragItem.rowNodes = rowNodes;
  26578. }
  26579. else {
  26580. rowNodes = draggingEvent.dragItem.rowNodes;
  26581. }
  26582. var managedDrag = this.gridOptionsWrapper.isRowDragManaged();
  26583. if (managedDrag && this.shouldPreventRowMove()) {
  26584. return;
  26585. }
  26586. if (this.gridOptionsWrapper.isSuppressMoveWhenRowDragging() || !isFromThisGrid) {
  26587. if (!this.isDropZoneWithinThisGrid(draggingEvent)) {
  26588. this.clientSideRowModel.highlightRowAtPixel(rowNodes[0], pixel);
  26589. }
  26590. }
  26591. else {
  26592. this.moveRows(rowNodes, pixel);
  26593. }
  26594. };
  26595. RowDragFeature.prototype.getRowIndexNumber = function (rowNode) {
  26596. return parseInt(last(rowNode.getRowIndexString().split('-')), 10);
  26597. };
  26598. RowDragFeature.prototype.moveRowAndClearHighlight = function (draggingEvent) {
  26599. var _this = this;
  26600. var lastHighlightedRowNode = this.clientSideRowModel.getLastHighlightedRowNode();
  26601. var isBelow = lastHighlightedRowNode && lastHighlightedRowNode.highlighted === 'below';
  26602. var pixel = this.mouseEventService.getNormalisedPosition(draggingEvent).y;
  26603. var rowNodes = draggingEvent.dragItem.rowNodes;
  26604. var increment = isBelow ? 1 : 0;
  26605. if (this.isFromThisGrid(draggingEvent)) {
  26606. rowNodes.forEach(function (rowNode) {
  26607. if (rowNode.rowTop < pixel) {
  26608. increment -= 1;
  26609. }
  26610. });
  26611. this.moveRows(rowNodes, pixel, increment);
  26612. }
  26613. else {
  26614. var getRowNodeId_1 = this.gridOptionsWrapper.getRowNodeIdFunc();
  26615. var addIndex = this.clientSideRowModel.getRowIndexAtPixel(pixel) + 1;
  26616. if (this.clientSideRowModel.getHighlightPosition(pixel) === 'above') {
  26617. addIndex--;
  26618. }
  26619. this.clientSideRowModel.updateRowData({
  26620. add: rowNodes
  26621. .map(function (node) { return node.data; })
  26622. .filter(function (data) { return !_this.clientSideRowModel.getRowNode(getRowNodeId_1 ? getRowNodeId_1(data) : data.id); }),
  26623. addIndex: addIndex
  26624. });
  26625. }
  26626. this.clearRowHighlight();
  26627. };
  26628. RowDragFeature.prototype.clearRowHighlight = function () {
  26629. this.clientSideRowModel.highlightRowAtPixel(null);
  26630. };
  26631. RowDragFeature.prototype.moveRows = function (rowNodes, pixel, increment) {
  26632. if (increment === void 0) { increment = 0; }
  26633. var rowWasMoved = this.clientSideRowModel.ensureRowsAtPixel(rowNodes, pixel, increment);
  26634. if (rowWasMoved) {
  26635. this.focusController.clearFocusedCell();
  26636. if (this.rangeController) {
  26637. this.rangeController.removeAllCellRanges();
  26638. }
  26639. }
  26640. };
  26641. RowDragFeature.prototype.checkCenterForScrolling = function (pixel) {
  26642. // scroll if the mouse is within 50px of the grid edge
  26643. var pixelRange = this.gridPanel.getVScrollPosition();
  26644. // console.log(`pixelRange = (${pixelRange.top}, ${pixelRange.bottom})`);
  26645. this.needToMoveUp = pixel < (pixelRange.top + 50);
  26646. this.needToMoveDown = pixel > (pixelRange.bottom - 50);
  26647. // console.log(`needToMoveUp = ${this.needToMoveUp} = pixel < (pixelRange.top + 50) = ${pixel} < (${pixelRange.top} + 50)`);
  26648. // console.log(`needToMoveDown = ${this.needToMoveDown} = pixel < (pixelRange.top + 50) = ${pixel} < (${pixelRange.top} + 50)`);
  26649. if (this.needToMoveUp || this.needToMoveDown) {
  26650. this.ensureIntervalStarted();
  26651. }
  26652. else {
  26653. this.ensureIntervalCleared();
  26654. }
  26655. };
  26656. RowDragFeature.prototype.ensureIntervalStarted = function () {
  26657. if (this.movingIntervalId) {
  26658. return;
  26659. }
  26660. this.intervalCount = 0;
  26661. this.movingIntervalId = window.setInterval(this.moveInterval.bind(this), 100);
  26662. };
  26663. RowDragFeature.prototype.ensureIntervalCleared = function () {
  26664. if (!this.moveInterval) {
  26665. return;
  26666. }
  26667. window.clearInterval(this.movingIntervalId);
  26668. this.movingIntervalId = null;
  26669. };
  26670. RowDragFeature.prototype.moveInterval = function () {
  26671. // the amounts we move get bigger at each interval, so the speed accelerates, starting a bit slow
  26672. // and getting faster. this is to give smoother user experience. we max at 100px to limit the speed.
  26673. var pixelsToMove;
  26674. this.intervalCount++;
  26675. pixelsToMove = 10 + (this.intervalCount * 5);
  26676. if (pixelsToMove > 100) {
  26677. pixelsToMove = 100;
  26678. }
  26679. var pixelsMoved;
  26680. if (this.needToMoveDown) {
  26681. pixelsMoved = this.gridPanel.scrollVertically(pixelsToMove);
  26682. }
  26683. else if (this.needToMoveUp) {
  26684. pixelsMoved = this.gridPanel.scrollVertically(-pixelsToMove);
  26685. }
  26686. if (pixelsMoved !== 0) {
  26687. this.onDragging(this.lastDraggingEvent);
  26688. }
  26689. };
  26690. RowDragFeature.prototype.addRowDropZone = function (params) {
  26691. var _this = this;
  26692. if (!params.getContainer()) {
  26693. _.doOnce(function () { return console.warn('ag-Grid: addRowDropZone - A container target needs to be provided'); }, 'add-drop-zone-empty-target');
  26694. return;
  26695. }
  26696. if (this.dragAndDropService.findExternalZone(params)) {
  26697. console.warn('ag-Grid: addRowDropZone - target already exists in the list of DropZones. Use `removeRowDropZone` before adding it again.');
  26698. return;
  26699. }
  26700. var processedParams = {
  26701. getContainer: params.getContainer
  26702. };
  26703. if (params.fromGrid) {
  26704. params.fromGrid = undefined;
  26705. processedParams = params;
  26706. }
  26707. else {
  26708. if (params.onDragEnter) {
  26709. processedParams.onDragEnter = function (e) {
  26710. params.onDragEnter(_this.draggingToRowDragEvent(Events.EVENT_ROW_DRAG_ENTER, e));
  26711. };
  26712. }
  26713. if (params.onDragLeave) {
  26714. processedParams.onDragLeave = function (e) {
  26715. params.onDragLeave(_this.draggingToRowDragEvent(Events.EVENT_ROW_DRAG_LEAVE, e));
  26716. };
  26717. }
  26718. if (params.onDragging) {
  26719. processedParams.onDragging = function (e) {
  26720. params.onDragging(_this.draggingToRowDragEvent(Events.EVENT_ROW_DRAG_MOVE, e));
  26721. };
  26722. }
  26723. if (params.onDragStop) {
  26724. processedParams.onDragStop = function (e) {
  26725. params.onDragStop(_this.draggingToRowDragEvent(Events.EVENT_ROW_DRAG_END, e));
  26726. };
  26727. }
  26728. }
  26729. this.dragAndDropService.addDropTarget(__assign$3({ isInterestedIn: function (type) { return type === exports.DragSourceType.RowDrag; }, getIconName: function () { return DragAndDropService.ICON_MOVE; }, external: true }, processedParams));
  26730. };
  26731. RowDragFeature.prototype.getRowDropZone = function (events) {
  26732. var _this = this;
  26733. var getContainer = this.getContainer.bind(this);
  26734. var onDragEnter = this.onDragEnter.bind(this);
  26735. var onDragLeave = this.onDragLeave.bind(this);
  26736. var onDragging = this.onDragging.bind(this);
  26737. var onDragStop = this.onDragStop.bind(this);
  26738. if (!events) {
  26739. return { getContainer: getContainer, onDragEnter: onDragEnter, onDragLeave: onDragLeave, onDragging: onDragging, onDragStop: onDragStop, fromGrid: true };
  26740. }
  26741. return {
  26742. getContainer: getContainer,
  26743. onDragEnter: events.onDragEnter
  26744. ? (function (e) {
  26745. onDragEnter(e);
  26746. events.onDragEnter(_this.draggingToRowDragEvent(Events.EVENT_ROW_DRAG_ENTER, e));
  26747. })
  26748. : onDragEnter,
  26749. onDragLeave: events.onDragLeave
  26750. ? (function (e) {
  26751. onDragLeave(e);
  26752. events.onDragLeave(_this.draggingToRowDragEvent(Events.EVENT_ROW_DRAG_LEAVE, e));
  26753. })
  26754. : onDragLeave,
  26755. onDragging: events.onDragging
  26756. ? (function (e) {
  26757. onDragging(e);
  26758. events.onDragging(_this.draggingToRowDragEvent(Events.EVENT_ROW_DRAG_MOVE, e));
  26759. })
  26760. : onDragging,
  26761. onDragStop: events.onDragStop
  26762. ? (function (e) {
  26763. onDragStop(e);
  26764. events.onDragStop(_this.draggingToRowDragEvent(Events.EVENT_ROW_DRAG_END, e));
  26765. })
  26766. : onDragStop,
  26767. fromGrid: true
  26768. };
  26769. };
  26770. RowDragFeature.prototype.draggingToRowDragEvent = function (type, draggingEvent) {
  26771. var yNormalised = this.mouseEventService.getNormalisedPosition(draggingEvent).y;
  26772. var mouseIsPastLastRow = yNormalised > this.rowModel.getCurrentPageHeight();
  26773. var overIndex = -1;
  26774. var overNode = null;
  26775. if (!mouseIsPastLastRow) {
  26776. overIndex = this.rowModel.getRowIndexAtPixel(yNormalised);
  26777. overNode = this.rowModel.getRow(overIndex);
  26778. }
  26779. var vDirectionString;
  26780. switch (draggingEvent.vDirection) {
  26781. case exports.VerticalDirection.Down:
  26782. vDirectionString = 'down';
  26783. break;
  26784. case exports.VerticalDirection.Up:
  26785. vDirectionString = 'up';
  26786. break;
  26787. default:
  26788. vDirectionString = null;
  26789. break;
  26790. }
  26791. var event = {
  26792. type: type,
  26793. api: this.gridOptionsWrapper.getApi(),
  26794. columnApi: this.gridOptionsWrapper.getColumnApi(),
  26795. event: draggingEvent.event,
  26796. node: draggingEvent.dragItem.rowNode,
  26797. nodes: draggingEvent.dragItem.rowNodes,
  26798. overIndex: overIndex,
  26799. overNode: overNode,
  26800. y: yNormalised,
  26801. vDirection: vDirectionString
  26802. };
  26803. return event;
  26804. };
  26805. RowDragFeature.prototype.dispatchGridEvent = function (type, draggingEvent) {
  26806. var event = this.draggingToRowDragEvent(type, draggingEvent);
  26807. this.eventService.dispatchEvent(event);
  26808. };
  26809. RowDragFeature.prototype.onDragLeave = function (draggingEvent) {
  26810. this.dispatchGridEvent(Events.EVENT_ROW_DRAG_LEAVE, draggingEvent);
  26811. this.stopDragging(draggingEvent);
  26812. this.clearRowHighlight();
  26813. if (this.isFromThisGrid(draggingEvent)) {
  26814. this.isMultiRowDrag = false;
  26815. }
  26816. };
  26817. RowDragFeature.prototype.onDragStop = function (draggingEvent) {
  26818. this.dispatchGridEvent(Events.EVENT_ROW_DRAG_END, draggingEvent);
  26819. this.stopDragging(draggingEvent);
  26820. if (this.gridOptionsWrapper.isRowDragManaged() &&
  26821. (this.gridOptionsWrapper.isSuppressMoveWhenRowDragging() || !this.isFromThisGrid(draggingEvent)) &&
  26822. !this.isDropZoneWithinThisGrid(draggingEvent)) {
  26823. this.moveRowAndClearHighlight(draggingEvent);
  26824. }
  26825. };
  26826. RowDragFeature.prototype.stopDragging = function (draggingEvent) {
  26827. this.ensureIntervalCleared();
  26828. this.getRowNodes(draggingEvent).forEach(function (rowNode) {
  26829. rowNode.setDragging(false);
  26830. });
  26831. };
  26832. __decorate$_([
  26833. Autowired('dragAndDropService')
  26834. ], RowDragFeature.prototype, "dragAndDropService", void 0);
  26835. __decorate$_([
  26836. Autowired('rowModel')
  26837. ], RowDragFeature.prototype, "rowModel", void 0);
  26838. __decorate$_([
  26839. Autowired('columnController')
  26840. ], RowDragFeature.prototype, "columnController", void 0);
  26841. __decorate$_([
  26842. Autowired('focusController')
  26843. ], RowDragFeature.prototype, "focusController", void 0);
  26844. __decorate$_([
  26845. Autowired('sortController')
  26846. ], RowDragFeature.prototype, "sortController", void 0);
  26847. __decorate$_([
  26848. Autowired('filterManager')
  26849. ], RowDragFeature.prototype, "filterManager", void 0);
  26850. __decorate$_([
  26851. Autowired('gridOptionsWrapper')
  26852. ], RowDragFeature.prototype, "gridOptionsWrapper", void 0);
  26853. __decorate$_([
  26854. Autowired('selectionController')
  26855. ], RowDragFeature.prototype, "selectionController", void 0);
  26856. __decorate$_([
  26857. Optional('rangeController')
  26858. ], RowDragFeature.prototype, "rangeController", void 0);
  26859. __decorate$_([
  26860. Autowired('mouseEventService')
  26861. ], RowDragFeature.prototype, "mouseEventService", void 0);
  26862. __decorate$_([
  26863. PostConstruct
  26864. ], RowDragFeature.prototype, "postConstruct", null);
  26865. return RowDragFeature;
  26866. }(BeanStub));
  26867. /**
  26868. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  26869. * @version v23.2.1
  26870. * @link http://www.ag-grid.com/
  26871. * @license MIT
  26872. */
  26873. var __extends$11 = (undefined && undefined.__extends) || (function () {
  26874. var extendStatics = function (d, b) {
  26875. extendStatics = Object.setPrototypeOf ||
  26876. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  26877. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  26878. return extendStatics(d, b);
  26879. };
  26880. return function (d, b) {
  26881. extendStatics(d, b);
  26882. function __() { this.constructor = d; }
  26883. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  26884. };
  26885. })();
  26886. var __decorate$$ = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  26887. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  26888. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  26889. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  26890. return c > 3 && r && Object.defineProperty(target, key, r), r;
  26891. };
  26892. // in the html below, it is important that there are no white space between some of the divs, as if there is white space,
  26893. // it won't render correctly in safari, as safari renders white space as a gap
  26894. var GRID_PANEL_NORMAL_TEMPLATE = /* html */ "<div class=\"ag-root ag-unselectable\" role=\"grid\" unselectable=\"on\">\n <ag-header-root ref=\"headerRoot\" unselectable=\"on\"></ag-header-root>\n <div class=\"ag-floating-top\" ref=\"eTop\" role=\"presentation\" unselectable=\"on\">\n <div class=\"ag-pinned-left-floating-top\" ref=\"eLeftTop\" role=\"presentation\" unselectable=\"on\"></div>\n <div class=\"ag-floating-top-viewport\" ref=\"eTopViewport\" role=\"presentation\" unselectable=\"on\">\n <div class=\"ag-floating-top-container\" ref=\"eTopContainer\" role=\"presentation\" unselectable=\"on\"></div>\n </div>\n <div class=\"ag-pinned-right-floating-top\" ref=\"eRightTop\" role=\"presentation\" unselectable=\"on\"></div>\n <div class=\"ag-floating-top-full-width-container\" ref=\"eTopFullWidthContainer\" role=\"presentation\" unselectable=\"on\"></div>\n </div>\n <div class=\"ag-body-viewport\" ref=\"eBodyViewport\" role=\"presentation\">\n <div class=\"ag-pinned-left-cols-container\" ref=\"eLeftContainer\" role=\"presentation\" unselectable=\"on\"></div>\n <div class=\"ag-center-cols-clipper\" ref=\"eCenterColsClipper\" role=\"presentation\" unselectable=\"on\">\n <div class=\"ag-center-cols-viewport\" ref=\"eCenterViewport\" role=\"presentation\">\n <div class=\"ag-center-cols-container\" ref=\"eCenterContainer\" role=\"rowgroup\" unselectable=\"on\"></div>\n </div>\n </div>\n <div class=\"ag-pinned-right-cols-container\" ref=\"eRightContainer\" role=\"presentation\" unselectable=\"on\"></div>\n <div class=\"ag-full-width-container\" ref=\"eFullWidthContainer\" role=\"presentation\" unselectable=\"on\"></div>\n </div>\n <div class=\"ag-floating-bottom\" ref=\"eBottom\" role=\"presentation\" unselectable=\"on\">\n <div class=\"ag-pinned-left-floating-bottom\" ref=\"eLeftBottom\" role=\"presentation\" unselectable=\"on\"></div>\n <div class=\"ag-floating-bottom-viewport\" ref=\"eBottomViewport\" role=\"presentation\" unselectable=\"on\">\n <div class=\"ag-floating-bottom-container\" ref=\"eBottomContainer\" role=\"presentation\" unselectable=\"on\"></div>\n </div>\n <div class=\"ag-pinned-right-floating-bottom\" ref=\"eRightBottom\" role=\"presentation\" unselectable=\"on\"></div>\n <div class=\"ag-floating-bottom-full-width-container\" ref=\"eBottomFullWidthContainer\" role=\"presentation\" unselectable=\"on\"></div>\n </div>\n <div class=\"ag-body-horizontal-scroll\" ref=\"eHorizontalScrollBody\" aria-hidden=\"true\">\n <div class=\"ag-horizontal-left-spacer\" ref=\"eHorizontalLeftSpacer\"></div>\n <div class=\"ag-body-horizontal-scroll-viewport\" ref=\"eBodyHorizontalScrollViewport\">\n <div class=\"ag-body-horizontal-scroll-container\" ref=\"eBodyHorizontalScrollContainer\"></div>\n </div>\n <div class=\"ag-horizontal-right-spacer\" ref=\"eHorizontalRightSpacer\"></div>\n </div>\n <ag-overlay-wrapper ref=\"overlayWrapper\"></ag-overlay-wrapper>\n </div>";
  26895. var GridPanel = /** @class */ (function (_super) {
  26896. __extends$11(GridPanel, _super);
  26897. function GridPanel() {
  26898. var _this = _super.call(this, GRID_PANEL_NORMAL_TEMPLATE) || this;
  26899. _this.scrollLeft = -1;
  26900. _this.scrollTop = -1;
  26901. _this.resetLastHorizontalScrollElementDebounced = _.debounce(_this.resetLastHorizontalScrollElement.bind(_this), 500);
  26902. return _this;
  26903. }
  26904. GridPanel.prototype.getVScrollPosition = function () {
  26905. var result = {
  26906. top: this.eBodyViewport.scrollTop,
  26907. bottom: this.eBodyViewport.scrollTop + this.eBodyViewport.offsetHeight
  26908. };
  26909. return result;
  26910. };
  26911. GridPanel.prototype.getHScrollPosition = function () {
  26912. var result = {
  26913. left: this.eCenterViewport.scrollLeft,
  26914. right: this.eCenterViewport.scrollLeft + this.eCenterViewport.offsetWidth
  26915. };
  26916. return result;
  26917. };
  26918. GridPanel.prototype.onRowDataChanged = function () {
  26919. this.showOrHideOverlay();
  26920. };
  26921. GridPanel.prototype.showOrHideOverlay = function () {
  26922. var isEmpty = this.paginationProxy.isEmpty();
  26923. var isSuppressNoRowsOverlay = this.gridOptionsWrapper.isSuppressNoRowsOverlay();
  26924. var method = isEmpty && !isSuppressNoRowsOverlay ? 'showNoRowsOverlay' : 'hideOverlay';
  26925. this[method]();
  26926. };
  26927. GridPanel.prototype.onNewColumnsLoaded = function () {
  26928. // hide overlay if columns and rows exist, this can happen if columns are loaded after data.
  26929. // this problem exists before of the race condition between the services (column controller in this case)
  26930. // and the view (grid panel). if the model beans were all initialised first, and then the view beans second,
  26931. // this race condition would not happen.
  26932. if (this.beans.columnController.isReady() && !this.paginationProxy.isEmpty()) {
  26933. this.hideOverlay();
  26934. }
  26935. };
  26936. GridPanel.prototype.init = function () {
  26937. var _this = this;
  26938. this.scrollWidth = this.gridOptionsWrapper.getScrollbarWidth();
  26939. this.enableRtl = this.gridOptionsWrapper.isEnableRtl();
  26940. this.printLayout = this.gridOptionsWrapper.getDomLayout() === Constants.DOM_LAYOUT_PRINT;
  26941. // these elements have different CSS when layout changes
  26942. this.gridOptionsWrapper.addLayoutElement(this.getGui());
  26943. this.gridOptionsWrapper.addLayoutElement(this.eBodyViewport);
  26944. this.suppressScrollOnFloatingRow();
  26945. this.setupRowAnimationCssClass();
  26946. this.buildRowContainerComponents();
  26947. this.addEventListeners();
  26948. this.addDragListeners();
  26949. this.addScrollListener();
  26950. if (this.gridOptionsWrapper.isRowModelDefault() && !this.gridOptionsWrapper.getRowData()) {
  26951. this.showLoadingOverlay();
  26952. }
  26953. this.setCellTextSelection(this.gridOptionsWrapper.isEnableCellTextSelect());
  26954. this.setPinnedContainerSize();
  26955. this.setHeaderAndFloatingHeights();
  26956. this.disableBrowserDragging();
  26957. this.addMouseListeners();
  26958. this.addKeyboardEvents();
  26959. this.addBodyViewportListener();
  26960. this.addStopEditingWhenGridLosesFocus();
  26961. this.mockContextMenuForIPad();
  26962. this.addRowDragListener();
  26963. if (this.$scope) {
  26964. this.addAngularApplyCheck();
  26965. }
  26966. this.onDisplayedColumnsWidthChanged();
  26967. this.gridApi.registerGridComp(this);
  26968. this.alignedGridsService.registerGridComp(this);
  26969. this.headerRootComp.registerGridComp(this);
  26970. this.navigationService.registerGridComp(this);
  26971. this.headerNavigationService.registerGridComp(this);
  26972. this.heightScaler.registerGridComp(this);
  26973. this.autoHeightCalculator.registerGridComp(this);
  26974. this.columnAnimationService.registerGridComp(this);
  26975. this.autoWidthCalculator.registerGridComp(this);
  26976. this.paginationAutoPageSizeService.registerGridComp(this);
  26977. this.mouseEventService.registerGridComp(this);
  26978. this.beans.registerGridComp(this);
  26979. this.rowRenderer.registerGridComp(this);
  26980. if (this.rangeController) {
  26981. this.rangeController.registerGridComp(this);
  26982. }
  26983. [this.eCenterViewport, this.eBodyViewport].forEach(function (viewport) {
  26984. var unsubscribeFromResize = _this.resizeObserverService.observeResize(viewport, _this.onCenterViewportResized.bind(_this));
  26985. _this.addDestroyFunc(function () { return unsubscribeFromResize(); });
  26986. });
  26987. [this.eTop, this.eBodyViewport, this.eBottom].forEach(function (element) {
  26988. _this.addManagedListener(element, 'focusin', function () {
  26989. _.addCssClass(element, 'ag-has-focus');
  26990. });
  26991. _this.addManagedListener(element, 'focusout', function (e) {
  26992. if (!element.contains(e.relatedTarget)) {
  26993. _.removeCssClass(element, 'ag-has-focus');
  26994. }
  26995. });
  26996. });
  26997. };
  26998. GridPanel.prototype.onDomLayoutChanged = function () {
  26999. var newPrintLayout = this.gridOptionsWrapper.getDomLayout() === Constants.DOM_LAYOUT_PRINT;
  27000. if (this.printLayout !== newPrintLayout) {
  27001. this.printLayout = newPrintLayout;
  27002. this.setWidthsOfContainers();
  27003. // pinned containers are always hidden for print layout
  27004. this.setPinnedContainerSize();
  27005. }
  27006. };
  27007. GridPanel.prototype.onCenterViewportResized = function () {
  27008. if (_.isVisible(this.eCenterViewport)) {
  27009. this.checkViewportAndScrolls();
  27010. this.beans.columnController.refreshFlexedColumns(this.getCenterWidth());
  27011. }
  27012. else {
  27013. this.bodyHeight = 0;
  27014. }
  27015. };
  27016. // used by ColumnAnimationService
  27017. GridPanel.prototype.setColumnMovingCss = function (moving) {
  27018. this.addOrRemoveCssClass('ag-column-moving', moving);
  27019. };
  27020. GridPanel.prototype.setCellTextSelection = function (selectable) {
  27021. if (selectable === void 0) { selectable = false; }
  27022. [this.eTop, this.eBodyViewport, this.eBottom]
  27023. .forEach(function (ct) { return _.addOrRemoveCssClass(ct, 'ag-selectable', selectable); });
  27024. };
  27025. GridPanel.prototype.addRowDragListener = function () {
  27026. this.rowDragFeature = this.createManagedBean(new RowDragFeature(this.eBodyViewport, this));
  27027. this.dragAndDropService.addDropTarget(this.rowDragFeature);
  27028. };
  27029. GridPanel.prototype.getRowDragFeature = function () {
  27030. return this.rowDragFeature;
  27031. };
  27032. GridPanel.prototype.addStopEditingWhenGridLosesFocus = function () {
  27033. var _this = this;
  27034. if (!this.gridOptionsWrapper.isStopEditingWhenGridLosesFocus()) {
  27035. return;
  27036. }
  27037. var viewports = [this.eBodyViewport, this.eBottom, this.eTop];
  27038. var focusOutListener = function (event) {
  27039. // this is the element the focus is moving to
  27040. var elementWithFocus = event.relatedTarget;
  27041. if (_.getTabIndex(elementWithFocus) === null) {
  27042. _this.rowRenderer.stopEditing();
  27043. return;
  27044. }
  27045. var clickInsideGrid = viewports.some(function (viewport) { return viewport.contains(elementWithFocus); });
  27046. if (!clickInsideGrid) {
  27047. var popupService = _this.beans.popupService;
  27048. clickInsideGrid =
  27049. popupService.getActivePopups().some(function (popup) { return popup.contains(elementWithFocus); }) ||
  27050. popupService.isElementWithinCustomPopup(elementWithFocus);
  27051. }
  27052. if (!clickInsideGrid) {
  27053. _this.rowRenderer.stopEditing();
  27054. }
  27055. };
  27056. viewports.forEach(function (viewport) { return _this.addManagedListener(viewport, 'focusout', focusOutListener); });
  27057. };
  27058. GridPanel.prototype.addAngularApplyCheck = function () {
  27059. var _this = this;
  27060. // this makes sure if we queue up requests, we only execute oe
  27061. var applyTriggered = false;
  27062. var listener = function () {
  27063. // only need to do one apply at a time
  27064. if (applyTriggered) {
  27065. return;
  27066. }
  27067. applyTriggered = true; // mark 'need apply' to true
  27068. window.setTimeout(function () {
  27069. applyTriggered = false;
  27070. _this.$scope.$apply();
  27071. }, 0);
  27072. };
  27073. // these are the events we need to do an apply after - these are the ones that can end up
  27074. // with columns added or removed
  27075. this.addManagedListener(this.eventService, Events.EVENT_DISPLAYED_COLUMNS_CHANGED, listener);
  27076. this.addManagedListener(this.eventService, Events.EVENT_VIRTUAL_COLUMNS_CHANGED, listener);
  27077. };
  27078. // if we do not do this, then the user can select a pic in the grid (eg an image in a custom cell renderer)
  27079. // and then that will start the browser native drag n' drop, which messes up with our own drag and drop.
  27080. GridPanel.prototype.disableBrowserDragging = function () {
  27081. this.addGuiEventListener('dragstart', function (event) {
  27082. if (event.target instanceof HTMLImageElement) {
  27083. event.preventDefault();
  27084. return false;
  27085. }
  27086. });
  27087. };
  27088. GridPanel.prototype.addEventListeners = function () {
  27089. this.addManagedListener(this.eventService, Events.EVENT_DISPLAYED_COLUMNS_CHANGED, this.onDisplayedColumnsChanged.bind(this));
  27090. this.addManagedListener(this.eventService, Events.EVENT_DISPLAYED_COLUMNS_WIDTH_CHANGED, this.onDisplayedColumnsWidthChanged.bind(this));
  27091. this.addManagedListener(this.eventService, Events.EVENT_PINNED_ROW_DATA_CHANGED, this.setHeaderAndFloatingHeights.bind(this));
  27092. this.addManagedListener(this.eventService, Events.EVENT_ROW_DATA_CHANGED, this.onRowDataChanged.bind(this));
  27093. this.addManagedListener(this.eventService, Events.EVENT_ROW_DATA_UPDATED, this.onRowDataChanged.bind(this));
  27094. this.addManagedListener(this.eventService, Events.EVENT_NEW_COLUMNS_LOADED, this.onNewColumnsLoaded.bind(this));
  27095. this.addManagedListener(this.gridOptionsWrapper, GridOptionsWrapper.PROP_HEADER_HEIGHT, this.setHeaderAndFloatingHeights.bind(this));
  27096. this.addManagedListener(this.gridOptionsWrapper, GridOptionsWrapper.PROP_PIVOT_HEADER_HEIGHT, this.setHeaderAndFloatingHeights.bind(this));
  27097. this.addManagedListener(this.gridOptionsWrapper, GridOptionsWrapper.PROP_GROUP_HEADER_HEIGHT, this.setHeaderAndFloatingHeights.bind(this));
  27098. this.addManagedListener(this.gridOptionsWrapper, GridOptionsWrapper.PROP_PIVOT_GROUP_HEADER_HEIGHT, this.setHeaderAndFloatingHeights.bind(this));
  27099. this.addManagedListener(this.gridOptionsWrapper, GridOptionsWrapper.PROP_FLOATING_FILTERS_HEIGHT, this.setHeaderAndFloatingHeights.bind(this));
  27100. this.addManagedListener(this.gridOptionsWrapper, GridOptionsWrapper.PROP_DOM_LAYOUT, this.onDomLayoutChanged.bind(this));
  27101. };
  27102. GridPanel.prototype.addDragListeners = function () {
  27103. var _this = this;
  27104. if (!this.gridOptionsWrapper.isEnableRangeSelection() || // no range selection if no property
  27105. _.missing(this.rangeController) // no range selection if not enterprise version
  27106. ) {
  27107. return;
  27108. }
  27109. var containers = [
  27110. this.eLeftContainer,
  27111. this.eRightContainer,
  27112. this.eCenterContainer,
  27113. this.eTop,
  27114. this.eBottom
  27115. ];
  27116. containers.forEach(function (container) {
  27117. var params = {
  27118. eElement: container,
  27119. onDragStart: _this.rangeController.onDragStart.bind(_this.rangeController),
  27120. onDragStop: _this.rangeController.onDragStop.bind(_this.rangeController),
  27121. onDragging: _this.rangeController.onDragging.bind(_this.rangeController)
  27122. };
  27123. _this.dragService.addDragSource(params);
  27124. _this.addDestroyFunc(function () { return _this.dragService.removeDragSource(params); });
  27125. });
  27126. };
  27127. GridPanel.prototype.addMouseListeners = function () {
  27128. var _this = this;
  27129. var eventNames = ['click', 'mousedown', 'dblclick', 'contextmenu', 'mouseover', 'mouseout'];
  27130. eventNames.forEach(function (eventName) {
  27131. var listener = _this.processMouseEvent.bind(_this, eventName);
  27132. _this.eAllCellContainers.forEach(function (container) {
  27133. return _this.addManagedListener(container, eventName, listener);
  27134. });
  27135. });
  27136. };
  27137. GridPanel.prototype.addKeyboardEvents = function () {
  27138. var _this = this;
  27139. var eventNames = ['keydown', 'keypress'];
  27140. eventNames.forEach(function (eventName) {
  27141. var listener = _this.processKeyboardEvent.bind(_this, eventName);
  27142. _this.eAllCellContainers.forEach(function (container) {
  27143. _this.addManagedListener(container, eventName, listener);
  27144. });
  27145. });
  27146. };
  27147. GridPanel.prototype.addBodyViewportListener = function () {
  27148. var _this = this;
  27149. // we want to listen for clicks directly on the eBodyViewport, so the user has a way of showing
  27150. // the context menu if no rows or columns are displayed, or user simply clicks outside of a cell
  27151. var listener = function (mouseEvent) {
  27152. var target = _.getTarget(mouseEvent);
  27153. if (target === _this.eBodyViewport || target === _this.eCenterViewport) {
  27154. // show it
  27155. _this.onContextMenu(mouseEvent, null, null, null, null);
  27156. _this.preventDefaultOnContextMenu(mouseEvent);
  27157. }
  27158. };
  27159. this.addManagedListener(this.eBodyViewport, 'contextmenu', listener);
  27160. };
  27161. // + rangeController - used to know when to scroll when user is dragging outside the
  27162. // main viewport while doing a range selection
  27163. GridPanel.prototype.getBodyClientRect = function () {
  27164. if (!this.eBodyViewport) {
  27165. return;
  27166. }
  27167. return this.eBodyViewport.getBoundingClientRect();
  27168. };
  27169. GridPanel.prototype.getRowForEvent = function (event) {
  27170. var sourceElement = _.getTarget(event);
  27171. while (sourceElement) {
  27172. var renderedRow = this.gridOptionsWrapper.getDomData(sourceElement, RowComp.DOM_DATA_KEY_RENDERED_ROW);
  27173. if (renderedRow) {
  27174. return renderedRow;
  27175. }
  27176. sourceElement = sourceElement.parentElement;
  27177. }
  27178. return null;
  27179. };
  27180. GridPanel.prototype.processKeyboardEvent = function (eventName, keyboardEvent) {
  27181. var cellComp = _.getCellCompForEvent(this.gridOptionsWrapper, keyboardEvent);
  27182. if (!cellComp || keyboardEvent.defaultPrevented) {
  27183. return;
  27184. }
  27185. var rowNode = cellComp.getRenderedRow().getRowNode();
  27186. var column = cellComp.getColumn();
  27187. var editing = cellComp.isEditing();
  27188. var gridProcessingAllowed = !_.isUserSuppressingKeyboardEvent(this.gridOptionsWrapper, keyboardEvent, rowNode, column, editing);
  27189. if (gridProcessingAllowed) {
  27190. switch (eventName) {
  27191. case 'keydown':
  27192. // first see if it's a scroll key, page up / down, home / end etc
  27193. var wasScrollKey = !editing && this.navigationService.handlePageScrollingKey(keyboardEvent);
  27194. // if not a scroll key, then we pass onto cell
  27195. if (!wasScrollKey) {
  27196. cellComp.onKeyDown(keyboardEvent);
  27197. }
  27198. // perform clipboard and undo / redo operations
  27199. this.doGridOperations(keyboardEvent, cellComp);
  27200. break;
  27201. case 'keypress':
  27202. cellComp.onKeyPress(keyboardEvent);
  27203. break;
  27204. }
  27205. }
  27206. if (eventName === 'keydown') {
  27207. var cellKeyDownEvent = cellComp.createEvent(keyboardEvent, Events.EVENT_CELL_KEY_DOWN);
  27208. this.beans.eventService.dispatchEvent(cellKeyDownEvent);
  27209. }
  27210. if (eventName === 'keypress') {
  27211. var cellKeyPressEvent = cellComp.createEvent(keyboardEvent, Events.EVENT_CELL_KEY_PRESS);
  27212. this.beans.eventService.dispatchEvent(cellKeyPressEvent);
  27213. }
  27214. };
  27215. GridPanel.prototype.doGridOperations = function (keyboardEvent, cellComp) {
  27216. // check if ctrl or meta key pressed
  27217. if (!keyboardEvent.ctrlKey && !keyboardEvent.metaKey) {
  27218. return;
  27219. }
  27220. // if the cell the event came from is editing, then we do not
  27221. // want to do the default shortcut keys, otherwise the editor
  27222. // (eg a text field) would not be able to do the normal cut/copy/paste
  27223. if (cellComp.isEditing()) {
  27224. return;
  27225. }
  27226. // for copy / paste, we don't want to execute when the event
  27227. // was from a child grid (happens in master detail)
  27228. if (!this.mouseEventService.isEventFromThisGrid(keyboardEvent)) {
  27229. return;
  27230. }
  27231. switch (keyboardEvent.which) {
  27232. case Constants.KEY_A:
  27233. return this.onCtrlAndA(keyboardEvent);
  27234. case Constants.KEY_C:
  27235. return this.onCtrlAndC(keyboardEvent);
  27236. case Constants.KEY_V:
  27237. return this.onCtrlAndV();
  27238. case Constants.KEY_D:
  27239. return this.onCtrlAndD(keyboardEvent);
  27240. case Constants.KEY_Z:
  27241. return keyboardEvent.shiftKey ? this.undoRedoService.redo() : this.undoRedoService.undo();
  27242. case Constants.KEY_Y:
  27243. return this.undoRedoService.redo();
  27244. }
  27245. };
  27246. // gets called by rowRenderer when new data loaded, as it will want to scroll to the top
  27247. GridPanel.prototype.scrollToTop = function () {
  27248. this.eBodyViewport.scrollTop = 0;
  27249. };
  27250. GridPanel.prototype.processMouseEvent = function (eventName, mouseEvent) {
  27251. if (!this.mouseEventService.isEventFromThisGrid(mouseEvent) ||
  27252. _.isStopPropagationForAgGrid(mouseEvent)) {
  27253. return;
  27254. }
  27255. var rowComp = this.getRowForEvent(mouseEvent);
  27256. var cellComp = this.mouseEventService.getRenderedCellForEvent(mouseEvent);
  27257. if (eventName === "contextmenu") {
  27258. this.preventDefaultOnContextMenu(mouseEvent);
  27259. this.handleContextMenuMouseEvent(mouseEvent, null, rowComp, cellComp);
  27260. }
  27261. else {
  27262. if (cellComp) {
  27263. cellComp.onMouseEvent(eventName, mouseEvent);
  27264. }
  27265. if (rowComp) {
  27266. rowComp.onMouseEvent(eventName, mouseEvent);
  27267. }
  27268. }
  27269. };
  27270. GridPanel.prototype.mockContextMenuForIPad = function () {
  27271. var _this = this;
  27272. // we do NOT want this when not in iPad, otherwise we will be doing
  27273. if (!_.isIOSUserAgent()) {
  27274. return;
  27275. }
  27276. this.eAllCellContainers.forEach(function (container) {
  27277. var touchListener = new TouchListener(container);
  27278. var longTapListener = function (event) {
  27279. var rowComp = _this.getRowForEvent(event.touchEvent);
  27280. var cellComp = _this.mouseEventService.getRenderedCellForEvent(event.touchEvent);
  27281. _this.handleContextMenuMouseEvent(null, event.touchEvent, rowComp, cellComp);
  27282. };
  27283. _this.addManagedListener(touchListener, TouchListener.EVENT_LONG_TAP, longTapListener);
  27284. _this.addDestroyFunc(function () { return touchListener.destroy(); });
  27285. });
  27286. };
  27287. GridPanel.prototype.handleContextMenuMouseEvent = function (mouseEvent, touchEvent, rowComp, cellComp) {
  27288. var rowNode = rowComp ? rowComp.getRowNode() : null;
  27289. var column = cellComp ? cellComp.getColumn() : null;
  27290. var value = null;
  27291. if (column) {
  27292. var event_1 = mouseEvent ? mouseEvent : touchEvent;
  27293. cellComp.dispatchCellContextMenuEvent(event_1);
  27294. value = this.valueService.getValue(column, rowNode);
  27295. }
  27296. this.onContextMenu(mouseEvent, touchEvent, rowNode, column, value);
  27297. };
  27298. GridPanel.prototype.onContextMenu = function (mouseEvent, touchEvent, rowNode, column, value) {
  27299. // to allow us to debug in chrome, we ignore the event if ctrl is pressed.
  27300. // not everyone wants this, so first 'if' below allows to turn this hack off.
  27301. if (!this.gridOptionsWrapper.isAllowContextMenuWithControlKey()) {
  27302. // then do the check
  27303. if (mouseEvent && (mouseEvent.ctrlKey || mouseEvent.metaKey)) {
  27304. return;
  27305. }
  27306. }
  27307. if (this.contextMenuFactory && !this.gridOptionsWrapper.isSuppressContextMenu()) {
  27308. var eventOrTouch = mouseEvent ? mouseEvent : touchEvent.touches[0];
  27309. if (this.contextMenuFactory.showMenu(rowNode, column, value, eventOrTouch)) {
  27310. var event_2 = mouseEvent ? mouseEvent : touchEvent;
  27311. event_2.preventDefault();
  27312. }
  27313. }
  27314. };
  27315. GridPanel.prototype.preventDefaultOnContextMenu = function (mouseEvent) {
  27316. // if we don't do this, then middle click will never result in a 'click' event, as 'mousedown'
  27317. // will be consumed by the browser to mean 'scroll' (as you can scroll with the middle mouse
  27318. // button in the browser). so this property allows the user to receive middle button clicks if
  27319. // they want.
  27320. var gridOptionsWrapper = this.gridOptionsWrapper;
  27321. var which = mouseEvent.which;
  27322. if (gridOptionsWrapper.isPreventDefaultOnContextMenu() ||
  27323. (gridOptionsWrapper.isSuppressMiddleClickScrolls() && which === 2)) {
  27324. mouseEvent.preventDefault();
  27325. }
  27326. };
  27327. GridPanel.prototype.onCtrlAndA = function (event) {
  27328. var _a = this, beans = _a.beans, pinnedRowModel = _a.pinnedRowModel, paginationProxy = _a.paginationProxy, rangeController = _a.rangeController;
  27329. var PINNED_BOTTOM = Constants.PINNED_BOTTOM, PINNED_TOP = Constants.PINNED_TOP;
  27330. if (rangeController && paginationProxy.isRowsToRender()) {
  27331. var _b = [
  27332. pinnedRowModel.isEmpty(PINNED_TOP),
  27333. pinnedRowModel.isEmpty(PINNED_BOTTOM)
  27334. ], isEmptyPinnedTop = _b[0], isEmptyPinnedBottom = _b[1];
  27335. var floatingStart = isEmptyPinnedTop ? null : PINNED_TOP;
  27336. var floatingEnd = void 0;
  27337. var rowEnd = void 0;
  27338. if (isEmptyPinnedBottom) {
  27339. floatingEnd = null;
  27340. rowEnd = this.paginationProxy.getRowCount() - 1;
  27341. }
  27342. else {
  27343. floatingEnd = PINNED_BOTTOM;
  27344. rowEnd = pinnedRowModel.getPinnedBottomRowData().length - 1;
  27345. }
  27346. var allDisplayedColumns = beans.columnController.getAllDisplayedColumns();
  27347. if (_.missingOrEmpty(allDisplayedColumns)) {
  27348. return;
  27349. }
  27350. rangeController.setCellRange({
  27351. rowStartIndex: 0,
  27352. rowStartPinned: floatingStart,
  27353. rowEndIndex: rowEnd,
  27354. rowEndPinned: floatingEnd,
  27355. columnStart: allDisplayedColumns[0],
  27356. columnEnd: _.last(allDisplayedColumns)
  27357. });
  27358. }
  27359. event.preventDefault();
  27360. };
  27361. GridPanel.prototype.onCtrlAndC = function (event) {
  27362. if (!this.clipboardService || this.gridOptionsWrapper.isEnableCellTextSelection()) {
  27363. return;
  27364. }
  27365. this.clipboardService.copyToClipboard();
  27366. event.preventDefault();
  27367. };
  27368. GridPanel.prototype.onCtrlAndV = function () {
  27369. if (ModuleRegistry.isRegistered(exports.ModuleNames.ClipboardModule) && !this.gridOptionsWrapper.isSuppressClipboardPaste()) {
  27370. this.clipboardService.pasteFromClipboard();
  27371. }
  27372. };
  27373. GridPanel.prototype.onCtrlAndD = function (event) {
  27374. if (ModuleRegistry.isRegistered(exports.ModuleNames.ClipboardModule) && !this.gridOptionsWrapper.isSuppressClipboardPaste()) {
  27375. this.clipboardService.copyRangeDown();
  27376. }
  27377. event.preventDefault();
  27378. };
  27379. // Valid values for position are bottom, middle and top
  27380. // position should be {'top','middle','bottom', or undefined/null}.
  27381. // if undefined/null, then the grid will to the minimal amount of scrolling,
  27382. // eg if grid needs to scroll up, it scrolls until row is on top,
  27383. // if grid needs to scroll down, it scrolls until row is on bottom,
  27384. // if row is already in view, grid does not scroll
  27385. GridPanel.prototype.ensureIndexVisible = function (index, position) {
  27386. // if for print or auto height, everything is always visible
  27387. if (this.printLayout) {
  27388. return;
  27389. }
  27390. var rowCount = this.paginationProxy.getRowCount();
  27391. if (typeof index !== 'number' || index < 0 || index >= rowCount) {
  27392. console.warn('invalid row index for ensureIndexVisible: ' + index);
  27393. return;
  27394. }
  27395. this.paginationProxy.goToPageWithIndex(index);
  27396. var rowNode = this.paginationProxy.getRow(index);
  27397. var rowGotShiftedDuringOperation;
  27398. do {
  27399. var startingRowTop = rowNode.rowTop;
  27400. var startingRowHeight = rowNode.rowHeight;
  27401. var paginationOffset = this.paginationProxy.getPixelOffset();
  27402. var rowTopPixel = rowNode.rowTop - paginationOffset;
  27403. var rowBottomPixel = rowTopPixel + rowNode.rowHeight;
  27404. var scrollPosition = this.getVScrollPosition();
  27405. var heightOffset = this.heightScaler.getOffset();
  27406. var vScrollTop = scrollPosition.top + heightOffset;
  27407. var vScrollBottom = scrollPosition.bottom + heightOffset;
  27408. var viewportHeight = vScrollBottom - vScrollTop;
  27409. // work out the pixels for top, middle and bottom up front,
  27410. // make the if/else below easier to read
  27411. var pxTop = this.heightScaler.getScrollPositionForPixel(rowTopPixel);
  27412. var pxBottom = this.heightScaler.getScrollPositionForPixel(rowBottomPixel - viewportHeight);
  27413. // make sure if middle, the row is not outside the top of the grid
  27414. var pxMiddle = Math.min((pxTop + pxBottom) / 2, rowTopPixel);
  27415. var rowBelowViewport = vScrollTop > rowTopPixel;
  27416. var rowAboveViewport = vScrollBottom < rowBottomPixel;
  27417. var newScrollPosition = null;
  27418. if (position === 'top') {
  27419. newScrollPosition = pxTop;
  27420. }
  27421. else if (position === 'bottom') {
  27422. newScrollPosition = pxBottom;
  27423. }
  27424. else if (position === 'middle') {
  27425. newScrollPosition = pxMiddle;
  27426. }
  27427. else if (rowBelowViewport) {
  27428. // if row is before, scroll up with row at top
  27429. newScrollPosition = pxTop;
  27430. }
  27431. else if (rowAboveViewport) {
  27432. // if row is below, scroll down with row at bottom
  27433. newScrollPosition = pxBottom;
  27434. }
  27435. if (newScrollPosition !== null) {
  27436. this.eBodyViewport.scrollTop = newScrollPosition;
  27437. this.rowRenderer.redrawAfterScroll();
  27438. }
  27439. // the row can get shifted if during the rendering (during rowRenderer.redrawAfterScroll()),
  27440. // the height of a row changes due to lazy calculation of row heights when using
  27441. // colDef.autoHeight or gridOptions.getRowHeight.
  27442. // if row was shifted, then the position we scrolled to is incorrect.
  27443. rowGotShiftedDuringOperation = (startingRowTop !== rowNode.rowTop)
  27444. || (startingRowHeight !== rowNode.rowHeight);
  27445. } while (rowGotShiftedDuringOperation);
  27446. // so when we return back to user, the cells have rendered
  27447. this.animationFrameService.flushAllFrames();
  27448. };
  27449. // + moveColumnController
  27450. GridPanel.prototype.getCenterWidth = function () {
  27451. return this.eCenterViewport.clientWidth;
  27452. };
  27453. GridPanel.prototype.isVerticalScrollShowing = function () {
  27454. var isAlwaysShowVerticalScroll = this.gridOptionsWrapper.isAlwaysShowVerticalScroll();
  27455. _.addOrRemoveCssClass(this.eBodyViewport, 'ag-force-vertical-scroll', isAlwaysShowVerticalScroll);
  27456. return isAlwaysShowVerticalScroll || _.isVerticalScrollShowing(this.eBodyViewport);
  27457. };
  27458. GridPanel.prototype.isHorizontalScrollShowing = function () {
  27459. return _.isHorizontalScrollShowing(this.eCenterViewport);
  27460. };
  27461. // gets called every time the viewport size changes. we use this to check visibility of scrollbars
  27462. // in the grid panel, and also to check size and position of viewport for row and column virtualisation.
  27463. GridPanel.prototype.checkViewportAndScrolls = function () {
  27464. // results in updating anything that depends on scroll showing
  27465. this.updateScrollVisibleService();
  27466. // fires event if height changes, used by PaginationService, HeightScalerService, RowRenderer
  27467. this.checkBodyHeight();
  27468. // check for virtual columns for ColumnController
  27469. this.onHorizontalViewportChanged();
  27470. this.setPinnedContainerSize();
  27471. // this is to cater for AG-3274, where grid is removed from the dom and then inserted back in again.
  27472. // (which happens with some implementations of tabbing). this can result in horizontal scroll getting
  27473. // reset back to the left, however no scroll event is fired. so we need to get header to also scroll
  27474. // back to the left to be kept in sync.
  27475. // adding and removing the grid from the DOM both resets the scroll position and
  27476. // triggers a resize event, so notify listeners if the scroll position has changed
  27477. if (this.scrollLeft !== this.getCenterViewportScrollLeft()) {
  27478. this.onBodyHorizontalScroll(this.eCenterViewport);
  27479. }
  27480. };
  27481. GridPanel.prototype.updateScrollVisibleService = function () {
  27482. // because of column animation (which takes 200ms), we have to do this twice.
  27483. // eg if user removes cols anywhere except at the RHS, then the cols on the RHS
  27484. // will animate to the left to fill the gap. this animation means just after
  27485. // the cols are removed, the remaining cols are still in the original location
  27486. // at the start of the animation, so pre animation the H scrollbar is still needed,
  27487. // but post animation it is not.
  27488. this.updateScrollVisibleServiceImpl();
  27489. setTimeout(this.updateScrollVisibleServiceImpl.bind(this), 500);
  27490. };
  27491. GridPanel.prototype.updateScrollVisibleServiceImpl = function () {
  27492. var params = {
  27493. horizontalScrollShowing: false,
  27494. verticalScrollShowing: false
  27495. };
  27496. params.verticalScrollShowing = this.isVerticalScrollShowing();
  27497. params.horizontalScrollShowing = this.isHorizontalScrollShowing();
  27498. this.scrollVisibleService.setScrollsVisible(params);
  27499. this.setHorizontalScrollVisible(params.horizontalScrollShowing);
  27500. this.setVerticalScrollPaddingVisible(params.verticalScrollShowing);
  27501. };
  27502. GridPanel.prototype.setHorizontalScrollVisible = function (visible) {
  27503. var isSuppressHorizontalScroll = this.gridOptionsWrapper.isSuppressHorizontalScroll();
  27504. var scrollSize = visible ? (this.gridOptionsWrapper.getScrollbarWidth() || 0) : 0;
  27505. var scrollContainerSize = !isSuppressHorizontalScroll ? scrollSize : 0;
  27506. var addIEPadding = _.isBrowserIE() && visible;
  27507. this.eCenterViewport.style.height = "calc(100% + " + scrollSize + "px)";
  27508. _.setFixedHeight(this.eHorizontalScrollBody, scrollContainerSize);
  27509. // we have to add an extra pixel to the scroller viewport on IE because
  27510. // if the container has the same size as the scrollbar, the scroll button won't work
  27511. _.setFixedHeight(this.eBodyHorizontalScrollViewport, scrollContainerSize + (addIEPadding ? 1 : 0));
  27512. _.setFixedHeight(this.eBodyHorizontalScrollContainer, scrollContainerSize);
  27513. };
  27514. GridPanel.prototype.setVerticalScrollPaddingVisible = function (show) {
  27515. var scroller = show ? 'scroll' : 'hidden';
  27516. this.eTop.style.overflowY = this.eBottom.style.overflowY = scroller;
  27517. this.setFakeHScrollSpacerWidths();
  27518. };
  27519. GridPanel.prototype.updateRowCount = function () {
  27520. var headerCount = this.headerNavigationService.getHeaderRowCount();
  27521. var rowCount = this.paginationProxy.getRowCount();
  27522. var total = (headerCount + rowCount).toString();
  27523. this.getGui().setAttribute('aria-rowcount', total);
  27524. };
  27525. GridPanel.prototype.updateColumnCount = function () {
  27526. var columns = this.columnController.getAllDisplayedColumns();
  27527. this.getGui().setAttribute('aria-colcount', columns.length.toString());
  27528. };
  27529. GridPanel.prototype.ensureColumnVisible = function (key) {
  27530. var column = this.columnController.getGridColumn(key);
  27531. if (!column) {
  27532. return;
  27533. }
  27534. if (column.isPinned()) {
  27535. console.warn('calling ensureIndexVisible on a ' + column.getPinned() + ' pinned column doesn\'t make sense for column ' + column.getColId());
  27536. return;
  27537. }
  27538. if (!this.columnController.isColumnDisplayed(column)) {
  27539. console.warn('column is not currently visible');
  27540. return;
  27541. }
  27542. var colLeftPixel = column.getLeft();
  27543. var colRightPixel = colLeftPixel + column.getActualWidth();
  27544. var viewportWidth = this.eCenterViewport.clientWidth;
  27545. var scrollPosition = this.getCenterViewportScrollLeft();
  27546. var bodyWidth = this.columnController.getBodyContainerWidth();
  27547. var viewportLeftPixel;
  27548. var viewportRightPixel;
  27549. // the logic of working out left and right viewport px is both here and in the ColumnController,
  27550. // need to refactor it out to one place
  27551. if (this.enableRtl) {
  27552. viewportLeftPixel = bodyWidth - scrollPosition - viewportWidth;
  27553. viewportRightPixel = bodyWidth - scrollPosition;
  27554. }
  27555. else {
  27556. viewportLeftPixel = scrollPosition;
  27557. viewportRightPixel = viewportWidth + scrollPosition;
  27558. }
  27559. var viewportScrolledPastCol = viewportLeftPixel > colLeftPixel;
  27560. var viewportScrolledBeforeCol = viewportRightPixel < colRightPixel;
  27561. var colToSmallForViewport = viewportWidth < column.getActualWidth();
  27562. var alignColToLeft = viewportScrolledPastCol || colToSmallForViewport;
  27563. var alignColToRight = viewportScrolledBeforeCol;
  27564. var newScrollPosition = this.getCenterViewportScrollLeft();
  27565. if (alignColToLeft || alignColToRight) {
  27566. if (this.enableRtl) {
  27567. newScrollPosition = alignColToLeft ? (bodyWidth - viewportWidth - colLeftPixel) : (bodyWidth - colRightPixel);
  27568. }
  27569. else {
  27570. newScrollPosition = alignColToLeft ? colLeftPixel : (colRightPixel - viewportWidth);
  27571. }
  27572. this.setCenterViewportScrollLeft(newScrollPosition);
  27573. }
  27574. // this will happen anyway, as the move will cause a 'scroll' event on the body, however
  27575. // it is possible that the ensureColumnVisible method is called from within ag-Grid and
  27576. // the caller will need to have the columns rendered to continue, which will be before
  27577. // the event has been worked on (which is the case for cell navigation).
  27578. this.onHorizontalViewportChanged();
  27579. // so when we return back to user, the cells have rendered
  27580. this.animationFrameService.flushAllFrames();
  27581. };
  27582. GridPanel.prototype.showLoadingOverlay = function () {
  27583. if (!this.gridOptionsWrapper.isSuppressLoadingOverlay()) {
  27584. this.overlayWrapper.showLoadingOverlay();
  27585. }
  27586. };
  27587. GridPanel.prototype.showNoRowsOverlay = function () {
  27588. if (!this.gridOptionsWrapper.isSuppressNoRowsOverlay()) {
  27589. this.overlayWrapper.showNoRowsOverlay();
  27590. }
  27591. };
  27592. GridPanel.prototype.hideOverlay = function () {
  27593. this.overlayWrapper.hideOverlay();
  27594. };
  27595. // method will call itself if no available width. this covers if the grid
  27596. // isn't visible, but is just about to be visible.
  27597. GridPanel.prototype.sizeColumnsToFit = function (nextTimeout) {
  27598. var _this = this;
  27599. var availableWidth = this.eBodyViewport.clientWidth;
  27600. if (availableWidth > 0) {
  27601. this.columnController.sizeColumnsToFit(availableWidth, "sizeColumnsToFit");
  27602. return;
  27603. }
  27604. if (nextTimeout === undefined) {
  27605. window.setTimeout(function () {
  27606. _this.sizeColumnsToFit(100);
  27607. }, 0);
  27608. }
  27609. else if (nextTimeout === 100) {
  27610. window.setTimeout(function () {
  27611. _this.sizeColumnsToFit(500);
  27612. }, 100);
  27613. }
  27614. else if (nextTimeout === 500) {
  27615. window.setTimeout(function () {
  27616. _this.sizeColumnsToFit(-1);
  27617. }, 500);
  27618. }
  27619. else {
  27620. console.warn('ag-Grid: tried to call sizeColumnsToFit() but the grid is coming back with ' +
  27621. 'zero width, maybe the grid is not visible yet on the screen?');
  27622. }
  27623. };
  27624. // used by autoWidthCalculator and autoHeightCalculator
  27625. GridPanel.prototype.getCenterContainer = function () {
  27626. return this.eCenterContainer;
  27627. };
  27628. GridPanel.prototype.getDropTargetBodyContainers = function () {
  27629. return [this.eCenterViewport, this.eTopViewport, this.eBottomViewport];
  27630. };
  27631. GridPanel.prototype.getDropTargetLeftContainers = function () {
  27632. return [this.eLeftContainer, this.eLeftBottom, this.eLeftTop];
  27633. };
  27634. GridPanel.prototype.getDropTargetRightContainers = function () {
  27635. return [this.eRightContainer, this.eRightBottom, this.eRightTop];
  27636. };
  27637. GridPanel.prototype.buildRowContainerComponents = function () {
  27638. var _this = this;
  27639. this.eAllCellContainers = [
  27640. this.eLeftContainer, this.eRightContainer, this.eCenterContainer,
  27641. this.eTop, this.eBottom, this.eFullWidthContainer
  27642. ];
  27643. this.rowContainerComponents = {
  27644. body: new RowContainerComponent({
  27645. eContainer: this.eCenterContainer,
  27646. eWrapper: this.eCenterColsClipper,
  27647. eViewport: this.eBodyViewport
  27648. }),
  27649. fullWidth: new RowContainerComponent({
  27650. eContainer: this.eFullWidthContainer
  27651. }),
  27652. pinnedLeft: new RowContainerComponent({ eContainer: this.eLeftContainer }),
  27653. pinnedRight: new RowContainerComponent({ eContainer: this.eRightContainer }),
  27654. floatingTop: new RowContainerComponent({ eContainer: this.eTopContainer }),
  27655. floatingTopPinnedLeft: new RowContainerComponent({ eContainer: this.eLeftTop }),
  27656. floatingTopPinnedRight: new RowContainerComponent({ eContainer: this.eRightTop }),
  27657. floatingTopFullWidth: new RowContainerComponent({
  27658. eContainer: this.eTopFullWidthContainer,
  27659. hideWhenNoChildren: true
  27660. }),
  27661. floatingBottom: new RowContainerComponent({ eContainer: this.eBottomContainer }),
  27662. floatingBottomPinnedLeft: new RowContainerComponent({ eContainer: this.eLeftBottom }),
  27663. floatingBottomPinnedRight: new RowContainerComponent({ eContainer: this.eRightBottom }),
  27664. floatingBottomFullWidth: new RowContainerComponent({
  27665. eContainer: this.eBottomFullWidthContainer,
  27666. hideWhenNoChildren: true
  27667. }),
  27668. };
  27669. _.iterateObject(this.rowContainerComponents, function (key, container) {
  27670. if (container) {
  27671. _this.getContext().createBean(container);
  27672. }
  27673. });
  27674. };
  27675. GridPanel.prototype.setupRowAnimationCssClass = function () {
  27676. var _this = this;
  27677. var listener = function () {
  27678. // we don't want to use row animation if scaling, as rows jump strangely as you scroll,
  27679. // when scaling and doing row animation.
  27680. var animateRows = _this.gridOptionsWrapper.isAnimateRows() && !_this.heightScaler.isScaling();
  27681. _.addOrRemoveCssClass(_this.eBodyViewport, 'ag-row-animation', animateRows);
  27682. _.addOrRemoveCssClass(_this.eBodyViewport, 'ag-row-no-animation', !animateRows);
  27683. };
  27684. listener();
  27685. this.addManagedListener(this.eventService, Events.EVENT_HEIGHT_SCALE_CHANGED, listener);
  27686. };
  27687. // when editing a pinned row, if the cell is half outside the scrollable area, the browser can
  27688. // scroll the column into view. we do not want this, the pinned sections should never scroll.
  27689. // so we listen to scrolls on these containers and reset the scroll if we find one.
  27690. GridPanel.prototype.suppressScrollOnFloatingRow = function () {
  27691. var _this = this;
  27692. var resetTopScroll = function () { return _this.eTopViewport.scrollLeft = 0; };
  27693. var resetBottomScroll = function () { return _this.eTopViewport.scrollLeft = 0; };
  27694. this.addManagedListener(this.eTopViewport, 'scroll', resetTopScroll);
  27695. this.addManagedListener(this.eBottomViewport, 'scroll', resetBottomScroll);
  27696. };
  27697. GridPanel.prototype.getRowContainers = function () {
  27698. return this.rowContainerComponents;
  27699. };
  27700. GridPanel.prototype.getFloatingTopBottom = function () {
  27701. return [this.eTop, this.eBottom];
  27702. };
  27703. GridPanel.prototype.onDisplayedColumnsChanged = function () {
  27704. this.setPinnedContainerSize();
  27705. this.setHeaderAndFloatingHeights();
  27706. this.onHorizontalViewportChanged();
  27707. this.updateScrollVisibleService();
  27708. this.updateColumnCount();
  27709. };
  27710. GridPanel.prototype.onDisplayedColumnsWidthChanged = function () {
  27711. this.setWidthsOfContainers();
  27712. this.onHorizontalViewportChanged();
  27713. this.updateScrollVisibleService();
  27714. if (this.enableRtl) {
  27715. // because RTL is all backwards, a change in the width of the row
  27716. // can cause a change in the scroll position, without a scroll event,
  27717. // because the scroll position in RTL is a function that depends on
  27718. // the width. to be convinced of this, take out this line, enable RTL,
  27719. // scroll all the way to the left and then resize a column
  27720. this.horizontallyScrollHeaderCenterAndFloatingCenter();
  27721. }
  27722. };
  27723. GridPanel.prototype.setWidthsOfContainers = function () {
  27724. this.setCenterWidth();
  27725. this.setPinnedContainerSize();
  27726. };
  27727. GridPanel.prototype.setCenterWidth = function () {
  27728. var _a = this, headerRootComp = _a.headerRootComp, columnController = _a.columnController;
  27729. var width = columnController.getBodyContainerWidth();
  27730. if (this.printLayout) {
  27731. var pinnedContainerWidths = columnController.getPinnedLeftContainerWidth()
  27732. + columnController.getPinnedRightContainerWidth();
  27733. width += pinnedContainerWidths;
  27734. }
  27735. headerRootComp.setHeaderContainerWidth(width);
  27736. var widthPx = width + "px";
  27737. this.eCenterContainer.style.width = widthPx;
  27738. this.eBottomContainer.style.width = widthPx;
  27739. this.eTopContainer.style.width = widthPx;
  27740. if (!this.printLayout) {
  27741. this.eBodyHorizontalScrollContainer.style.width = widthPx;
  27742. }
  27743. };
  27744. GridPanel.prototype.setPinnedLeftWidth = function () {
  27745. var _this = this;
  27746. var oldPinning = this.pinningLeft;
  27747. var widthOfCols = this.columnController.getPinnedLeftContainerWidth();
  27748. var newPinning = this.pinningLeft = !this.printLayout && widthOfCols > 0;
  27749. var containers = [this.eLeftContainer, this.eLeftTop, this.eLeftBottom];
  27750. if (oldPinning !== newPinning) {
  27751. this.headerRootComp.setLeftVisible(newPinning);
  27752. }
  27753. containers.forEach(function (e) { return _.setDisplayed(e, _this.pinningLeft); });
  27754. if (newPinning) {
  27755. containers.forEach(function (ct) { return _.setFixedWidth(ct, widthOfCols); });
  27756. }
  27757. };
  27758. GridPanel.prototype.setPinnedRightWidth = function () {
  27759. var oldPinning = this.pinningRight;
  27760. var widthOfCols = this.columnController.getPinnedRightContainerWidth();
  27761. var newPinning = this.pinningRight = !this.printLayout && widthOfCols > 0;
  27762. var containers = [this.eRightContainer, this.eRightTop, this.eRightBottom];
  27763. if (oldPinning !== newPinning) {
  27764. this.headerRootComp.setRightVisible(newPinning);
  27765. }
  27766. containers.forEach(function (ct) { return _.setDisplayed(ct, newPinning); });
  27767. if (newPinning) {
  27768. containers.forEach(function (ct) { return _.setFixedWidth(ct, widthOfCols); });
  27769. }
  27770. };
  27771. GridPanel.prototype.setPinnedContainerSize = function () {
  27772. this.setPinnedLeftWidth();
  27773. this.setPinnedRightWidth();
  27774. this.setFakeHScrollSpacerWidths();
  27775. };
  27776. GridPanel.prototype.setFakeHScrollSpacerWidths = function () {
  27777. // we pad the right based on a) if cols are pinned to the right and
  27778. // b) if v scroll is showing on the right (normal position of scroll)
  27779. var rightSpacing = this.columnController.getPinnedRightContainerWidth();
  27780. var scrollOnRight = !this.enableRtl && this.isVerticalScrollShowing();
  27781. if (scrollOnRight) {
  27782. rightSpacing += this.scrollWidth;
  27783. }
  27784. _.setFixedWidth(this.eHorizontalRightSpacer, rightSpacing);
  27785. _.addOrRemoveCssClass(this.eHorizontalRightSpacer, 'ag-scroller-corner', rightSpacing <= this.scrollWidth);
  27786. // we pad the left based on a) if cols are pinned to the left and
  27787. // b) if v scroll is showing on the left (happens in LTR layout only)
  27788. var leftSpacing = this.columnController.getPinnedLeftContainerWidth();
  27789. var scrollOnLeft = this.enableRtl && this.isVerticalScrollShowing();
  27790. if (scrollOnLeft) {
  27791. leftSpacing += this.scrollWidth;
  27792. }
  27793. _.setFixedWidth(this.eHorizontalLeftSpacer, leftSpacing);
  27794. _.addOrRemoveCssClass(this.eHorizontalLeftSpacer, 'ag-scroller-corner', leftSpacing <= this.scrollWidth);
  27795. };
  27796. GridPanel.prototype.checkBodyHeight = function () {
  27797. var bodyHeight = this.eBodyViewport.clientHeight;
  27798. if (this.bodyHeight !== bodyHeight) {
  27799. this.bodyHeight = bodyHeight;
  27800. var event_3 = {
  27801. type: Events.EVENT_BODY_HEIGHT_CHANGED,
  27802. api: this.gridApi,
  27803. columnApi: this.columnApi
  27804. };
  27805. this.eventService.dispatchEvent(event_3);
  27806. }
  27807. };
  27808. GridPanel.prototype.setHeaderAndFloatingHeights = function () {
  27809. var _a = this, columnController = _a.columnController, gridOptionsWrapper = _a.gridOptionsWrapper, pinnedRowModel = _a.pinnedRowModel, eTop = _a.eTop, eBottom = _a.eBottom;
  27810. var numberOfFloating = 0;
  27811. var headerRowCount = columnController.getHeaderRowCount();
  27812. var totalHeaderHeight;
  27813. var groupHeight;
  27814. var headerHeight;
  27815. if (columnController.isPivotMode()) {
  27816. groupHeight = gridOptionsWrapper.getPivotGroupHeaderHeight();
  27817. headerHeight = gridOptionsWrapper.getPivotHeaderHeight();
  27818. }
  27819. else {
  27820. var hasFloatingFilters = columnController.hasFloatingFilters();
  27821. if (hasFloatingFilters) {
  27822. headerRowCount++;
  27823. numberOfFloating = 1;
  27824. }
  27825. groupHeight = gridOptionsWrapper.getGroupHeaderHeight();
  27826. headerHeight = gridOptionsWrapper.getHeaderHeight();
  27827. }
  27828. var numberOfNonGroups = 1 + numberOfFloating;
  27829. var numberOfGroups = headerRowCount - numberOfNonGroups;
  27830. totalHeaderHeight = numberOfFloating * gridOptionsWrapper.getFloatingFiltersHeight();
  27831. totalHeaderHeight += numberOfGroups * groupHeight;
  27832. totalHeaderHeight += headerHeight;
  27833. this.headerRootComp.setHeight(totalHeaderHeight);
  27834. var floatingTopHeight = pinnedRowModel.getPinnedTopTotalHeight();
  27835. if (floatingTopHeight) {
  27836. // adding 1px for cell bottom border
  27837. floatingTopHeight += 1;
  27838. }
  27839. var floatingBottomHeight = pinnedRowModel.getPinnedBottomTotalHeight();
  27840. if (floatingBottomHeight) {
  27841. // adding 1px for cell bottom border
  27842. floatingBottomHeight += 1;
  27843. }
  27844. var floatingTopHeightString = floatingTopHeight + "px";
  27845. var floatingBottomHeightString = floatingBottomHeight + "px";
  27846. eTop.style.minHeight = floatingTopHeightString;
  27847. eTop.style.height = floatingTopHeightString;
  27848. eTop.style.display = floatingTopHeight ? 'inherit' : 'none';
  27849. eBottom.style.minHeight = floatingBottomHeightString;
  27850. eBottom.style.height = floatingBottomHeightString;
  27851. eBottom.style.display = floatingBottomHeight ? 'inherit' : 'none';
  27852. this.checkBodyHeight();
  27853. };
  27854. GridPanel.prototype.getBodyHeight = function () {
  27855. return this.bodyHeight;
  27856. };
  27857. // called by scrollHorizontally method and alignedGridsService
  27858. GridPanel.prototype.setHorizontalScrollPosition = function (hScrollPosition) {
  27859. this.eCenterViewport.scrollLeft = hScrollPosition;
  27860. // we need to manually do the event handling (rather than wait for the event)
  27861. // for the alignedGridsService, as if we don't, the aligned grid service gets
  27862. // notified async, and then it's 'consuming' flag doesn't get used right, and
  27863. // we can end up with an infinite loop
  27864. this.doHorizontalScroll(hScrollPosition);
  27865. };
  27866. GridPanel.prototype.setVerticalScrollPosition = function (vScrollPosition) {
  27867. this.eBodyViewport.scrollTop = vScrollPosition;
  27868. };
  27869. // called by the headerRootComp and moveColumnController
  27870. GridPanel.prototype.scrollHorizontally = function (pixels) {
  27871. var oldScrollPosition = this.eCenterViewport.scrollLeft;
  27872. this.setHorizontalScrollPosition(oldScrollPosition + pixels);
  27873. return this.eCenterViewport.scrollLeft - oldScrollPosition;
  27874. };
  27875. // called by rowDragFeature
  27876. GridPanel.prototype.scrollVertically = function (pixels) {
  27877. var oldScrollPosition = this.eBodyViewport.scrollTop;
  27878. this.setVerticalScrollPosition(oldScrollPosition + pixels);
  27879. return this.eBodyViewport.scrollTop - oldScrollPosition;
  27880. };
  27881. GridPanel.prototype.addScrollListener = function () {
  27882. this.addManagedListener(this.eCenterViewport, 'scroll', this.onCenterViewportScroll.bind(this));
  27883. this.addManagedListener(this.eBodyHorizontalScrollViewport, 'scroll', this.onFakeHorizontalScroll.bind(this));
  27884. this.addManagedListener(this.eBodyViewport, 'scroll', this.onVerticalScroll.bind(this));
  27885. };
  27886. GridPanel.prototype.onVerticalScroll = function () {
  27887. var scrollTop = this.eBodyViewport.scrollTop;
  27888. this.animationFrameService.setScrollTop(scrollTop);
  27889. this.scrollTop = scrollTop;
  27890. this.redrawRowsAfterScroll();
  27891. };
  27892. GridPanel.prototype.isControllingScroll = function (eDiv) {
  27893. if (!this.lastHorizontalScrollElement) {
  27894. this.lastHorizontalScrollElement = eDiv;
  27895. return true;
  27896. }
  27897. return eDiv === this.lastHorizontalScrollElement;
  27898. };
  27899. GridPanel.prototype.onFakeHorizontalScroll = function () {
  27900. if (!this.isControllingScroll(this.eBodyHorizontalScrollViewport)) {
  27901. return;
  27902. }
  27903. this.onBodyHorizontalScroll(this.eBodyHorizontalScrollViewport);
  27904. };
  27905. GridPanel.prototype.onCenterViewportScroll = function () {
  27906. if (!this.isControllingScroll(this.eCenterViewport)) {
  27907. return;
  27908. }
  27909. this.onBodyHorizontalScroll(this.eCenterViewport);
  27910. };
  27911. GridPanel.prototype.onBodyHorizontalScroll = function (eSource) {
  27912. var _a = this.eCenterViewport, scrollWidth = _a.scrollWidth, clientWidth = _a.clientWidth;
  27913. // in chrome, fractions can be in the scroll left, eg 250.342234 - which messes up our 'scrollWentPastBounds'
  27914. // formula. so we floor it to allow the formula to work.
  27915. var scrollLeft = Math.floor(_.getScrollLeft(eSource, this.enableRtl));
  27916. // touch devices allow elastic scroll - which temporally scrolls the panel outside of the viewport
  27917. // (eg user uses touch to go to the left of the grid, but drags past the left, the rows will actually
  27918. // scroll past the left until the user releases the mouse). when this happens, we want ignore the scroll,
  27919. // as otherwise it was causing the rows and header to flicker.
  27920. // sometimes when scrolling, we got values that extended the maximum scroll allowed. we used to
  27921. // ignore these scrolls. problem is the max scroll position could be skipped (eg the previous scroll event
  27922. // could be 10px before the max position, and then current scroll event could be 20px after the max position).
  27923. // if we just ignored the last event, we would be setting the scroll to 10px before the max position, when in
  27924. // actual fact the user has exceeded the max scroll and thus scroll should be set to the max.
  27925. var minScroll = 0;
  27926. var maxScroll = scrollWidth - clientWidth;
  27927. if (scrollLeft < minScroll) {
  27928. scrollLeft = minScroll;
  27929. }
  27930. else if (scrollLeft > maxScroll) {
  27931. scrollLeft = maxScroll;
  27932. }
  27933. this.doHorizontalScroll(scrollLeft);
  27934. this.resetLastHorizontalScrollElementDebounced();
  27935. };
  27936. GridPanel.prototype.resetLastHorizontalScrollElement = function () {
  27937. this.lastHorizontalScrollElement = null;
  27938. };
  27939. GridPanel.prototype.doHorizontalScroll = function (scrollLeft) {
  27940. this.scrollLeft = scrollLeft;
  27941. var event = {
  27942. type: Events.EVENT_BODY_SCROLL,
  27943. api: this.gridApi,
  27944. columnApi: this.columnApi,
  27945. direction: 'horizontal',
  27946. left: this.scrollLeft,
  27947. top: this.scrollTop
  27948. };
  27949. this.eventService.dispatchEvent(event);
  27950. this.horizontallyScrollHeaderCenterAndFloatingCenter(scrollLeft);
  27951. this.onHorizontalViewportChanged();
  27952. };
  27953. GridPanel.prototype.redrawRowsAfterScroll = function () {
  27954. var event = {
  27955. type: Events.EVENT_BODY_SCROLL,
  27956. direction: 'vertical',
  27957. api: this.gridApi,
  27958. columnApi: this.columnApi,
  27959. left: this.scrollLeft,
  27960. top: this.scrollTop
  27961. };
  27962. this.eventService.dispatchEvent(event);
  27963. };
  27964. // this gets called whenever a change in the viewport, so we can inform column controller it has to work
  27965. // out the virtual columns again. gets called from following locations:
  27966. // + ensureColVisible, scroll, init, layoutChanged, displayedColumnsChanged, API (doLayout)
  27967. GridPanel.prototype.onHorizontalViewportChanged = function () {
  27968. var scrollWidth = this.eCenterViewport.clientWidth;
  27969. var scrollPosition = this.getCenterViewportScrollLeft();
  27970. this.columnController.setVirtualViewportPosition(scrollWidth, scrollPosition);
  27971. };
  27972. GridPanel.prototype.getCenterViewportScrollLeft = function () {
  27973. // we defer to a util, as how you calculated scrollLeft when doing RTL depends on the browser
  27974. return _.getScrollLeft(this.eCenterViewport, this.enableRtl);
  27975. };
  27976. GridPanel.prototype.setCenterViewportScrollLeft = function (value) {
  27977. // we defer to a util, as how you calculated scrollLeft when doing RTL depends on the browser
  27978. _.setScrollLeft(this.eCenterViewport, value, this.enableRtl);
  27979. };
  27980. GridPanel.prototype.horizontallyScrollHeaderCenterAndFloatingCenter = function (scrollLeft) {
  27981. if (scrollLeft === undefined) {
  27982. scrollLeft = this.getCenterViewportScrollLeft();
  27983. }
  27984. var offset = this.enableRtl ? scrollLeft : -scrollLeft;
  27985. var _a = this.eCenterViewport, clientWidth = _a.clientWidth, scrollWidth = _a.scrollWidth;
  27986. var scrollWentPastBounds = Math.abs(offset) + clientWidth > scrollWidth;
  27987. if (scrollWentPastBounds ||
  27988. (this.enableRtl && offset < 0) ||
  27989. (!this.enableRtl && offset > 0)) {
  27990. return;
  27991. }
  27992. this.headerRootComp.setHorizontalScroll(offset);
  27993. this.eBottomContainer.style.transform = "translateX(" + offset + "px)";
  27994. this.eTopContainer.style.transform = "translateX(" + offset + "px)";
  27995. var partner = this.lastHorizontalScrollElement === this.eCenterViewport ? this.eBodyHorizontalScrollViewport : this.eCenterViewport;
  27996. _.setScrollLeft(partner, scrollLeft, this.enableRtl);
  27997. };
  27998. // + rangeController
  27999. GridPanel.prototype.addScrollEventListener = function (listener) {
  28000. this.eBodyViewport.addEventListener('scroll', listener);
  28001. };
  28002. // + rangeController
  28003. GridPanel.prototype.removeScrollEventListener = function (listener) {
  28004. this.eBodyViewport.removeEventListener('scroll', listener);
  28005. };
  28006. __decorate$$([
  28007. Autowired('alignedGridsService')
  28008. ], GridPanel.prototype, "alignedGridsService", void 0);
  28009. __decorate$$([
  28010. Autowired('gridOptionsWrapper')
  28011. ], GridPanel.prototype, "gridOptionsWrapper", void 0);
  28012. __decorate$$([
  28013. Autowired('rowRenderer')
  28014. ], GridPanel.prototype, "rowRenderer", void 0);
  28015. __decorate$$([
  28016. Autowired('pinnedRowModel')
  28017. ], GridPanel.prototype, "pinnedRowModel", void 0);
  28018. __decorate$$([
  28019. Autowired('animationFrameService')
  28020. ], GridPanel.prototype, "animationFrameService", void 0);
  28021. __decorate$$([
  28022. Autowired('navigationService')
  28023. ], GridPanel.prototype, "navigationService", void 0);
  28024. __decorate$$([
  28025. Autowired('autoHeightCalculator')
  28026. ], GridPanel.prototype, "autoHeightCalculator", void 0);
  28027. __decorate$$([
  28028. Autowired('columnAnimationService')
  28029. ], GridPanel.prototype, "columnAnimationService", void 0);
  28030. __decorate$$([
  28031. Autowired('autoWidthCalculator')
  28032. ], GridPanel.prototype, "autoWidthCalculator", void 0);
  28033. __decorate$$([
  28034. Autowired('paginationAutoPageSizeService')
  28035. ], GridPanel.prototype, "paginationAutoPageSizeService", void 0);
  28036. __decorate$$([
  28037. Autowired('beans')
  28038. ], GridPanel.prototype, "beans", void 0);
  28039. __decorate$$([
  28040. Autowired('paginationProxy')
  28041. ], GridPanel.prototype, "paginationProxy", void 0);
  28042. __decorate$$([
  28043. Autowired('columnApi')
  28044. ], GridPanel.prototype, "columnApi", void 0);
  28045. __decorate$$([
  28046. Autowired('gridApi')
  28047. ], GridPanel.prototype, "gridApi", void 0);
  28048. __decorate$$([
  28049. Autowired('dragService')
  28050. ], GridPanel.prototype, "dragService", void 0);
  28051. __decorate$$([
  28052. Autowired('mouseEventService')
  28053. ], GridPanel.prototype, "mouseEventService", void 0);
  28054. __decorate$$([
  28055. Autowired('$scope')
  28056. ], GridPanel.prototype, "$scope", void 0);
  28057. __decorate$$([
  28058. Autowired('scrollVisibleService')
  28059. ], GridPanel.prototype, "scrollVisibleService", void 0);
  28060. __decorate$$([
  28061. Autowired('valueService')
  28062. ], GridPanel.prototype, "valueService", void 0);
  28063. __decorate$$([
  28064. Autowired('dragAndDropService')
  28065. ], GridPanel.prototype, "dragAndDropService", void 0);
  28066. __decorate$$([
  28067. Autowired('maxDivHeightScaler')
  28068. ], GridPanel.prototype, "heightScaler", void 0);
  28069. __decorate$$([
  28070. Autowired('resizeObserverService')
  28071. ], GridPanel.prototype, "resizeObserverService", void 0);
  28072. __decorate$$([
  28073. Autowired('undoRedoService')
  28074. ], GridPanel.prototype, "undoRedoService", void 0);
  28075. __decorate$$([
  28076. Autowired('columnController')
  28077. ], GridPanel.prototype, "columnController", void 0);
  28078. __decorate$$([
  28079. Autowired('headerNavigationService')
  28080. ], GridPanel.prototype, "headerNavigationService", void 0);
  28081. __decorate$$([
  28082. Optional('rangeController')
  28083. ], GridPanel.prototype, "rangeController", void 0);
  28084. __decorate$$([
  28085. Optional('contextMenuFactory')
  28086. ], GridPanel.prototype, "contextMenuFactory", void 0);
  28087. __decorate$$([
  28088. Optional('clipboardService')
  28089. ], GridPanel.prototype, "clipboardService", void 0);
  28090. __decorate$$([
  28091. RefSelector('eBodyViewport')
  28092. ], GridPanel.prototype, "eBodyViewport", void 0);
  28093. __decorate$$([
  28094. RefSelector('eCenterContainer')
  28095. ], GridPanel.prototype, "eCenterContainer", void 0);
  28096. __decorate$$([
  28097. RefSelector('eCenterViewport')
  28098. ], GridPanel.prototype, "eCenterViewport", void 0);
  28099. __decorate$$([
  28100. RefSelector('eLeftContainer')
  28101. ], GridPanel.prototype, "eLeftContainer", void 0);
  28102. __decorate$$([
  28103. RefSelector('eRightContainer')
  28104. ], GridPanel.prototype, "eRightContainer", void 0);
  28105. __decorate$$([
  28106. RefSelector('eCenterColsClipper')
  28107. ], GridPanel.prototype, "eCenterColsClipper", void 0);
  28108. __decorate$$([
  28109. RefSelector('eHorizontalScrollBody')
  28110. ], GridPanel.prototype, "eHorizontalScrollBody", void 0);
  28111. __decorate$$([
  28112. RefSelector('eHorizontalLeftSpacer')
  28113. ], GridPanel.prototype, "eHorizontalLeftSpacer", void 0);
  28114. __decorate$$([
  28115. RefSelector('eHorizontalRightSpacer')
  28116. ], GridPanel.prototype, "eHorizontalRightSpacer", void 0);
  28117. __decorate$$([
  28118. RefSelector('eBodyHorizontalScrollViewport')
  28119. ], GridPanel.prototype, "eBodyHorizontalScrollViewport", void 0);
  28120. __decorate$$([
  28121. RefSelector('eBodyHorizontalScrollContainer')
  28122. ], GridPanel.prototype, "eBodyHorizontalScrollContainer", void 0);
  28123. __decorate$$([
  28124. RefSelector('eFullWidthContainer')
  28125. ], GridPanel.prototype, "eFullWidthContainer", void 0);
  28126. __decorate$$([
  28127. RefSelector('eTop')
  28128. ], GridPanel.prototype, "eTop", void 0);
  28129. __decorate$$([
  28130. RefSelector('eLeftTop')
  28131. ], GridPanel.prototype, "eLeftTop", void 0);
  28132. __decorate$$([
  28133. RefSelector('eRightTop')
  28134. ], GridPanel.prototype, "eRightTop", void 0);
  28135. __decorate$$([
  28136. RefSelector('eTopContainer')
  28137. ], GridPanel.prototype, "eTopContainer", void 0);
  28138. __decorate$$([
  28139. RefSelector('eTopViewport')
  28140. ], GridPanel.prototype, "eTopViewport", void 0);
  28141. __decorate$$([
  28142. RefSelector('eTopFullWidthContainer')
  28143. ], GridPanel.prototype, "eTopFullWidthContainer", void 0);
  28144. __decorate$$([
  28145. RefSelector('eBottom')
  28146. ], GridPanel.prototype, "eBottom", void 0);
  28147. __decorate$$([
  28148. RefSelector('eLeftBottom')
  28149. ], GridPanel.prototype, "eLeftBottom", void 0);
  28150. __decorate$$([
  28151. RefSelector('eRightBottom')
  28152. ], GridPanel.prototype, "eRightBottom", void 0);
  28153. __decorate$$([
  28154. RefSelector('eBottomContainer')
  28155. ], GridPanel.prototype, "eBottomContainer", void 0);
  28156. __decorate$$([
  28157. RefSelector('eBottomViewport')
  28158. ], GridPanel.prototype, "eBottomViewport", void 0);
  28159. __decorate$$([
  28160. RefSelector('eBottomFullWidthContainer')
  28161. ], GridPanel.prototype, "eBottomFullWidthContainer", void 0);
  28162. __decorate$$([
  28163. RefSelector('headerRoot')
  28164. ], GridPanel.prototype, "headerRootComp", void 0);
  28165. __decorate$$([
  28166. RefSelector('overlayWrapper')
  28167. ], GridPanel.prototype, "overlayWrapper", void 0);
  28168. __decorate$$([
  28169. PostConstruct
  28170. ], GridPanel.prototype, "init", null);
  28171. return GridPanel;
  28172. }(Component));
  28173. /**
  28174. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  28175. * @version v23.2.1
  28176. * @link http://www.ag-grid.com/
  28177. * @license MIT
  28178. */
  28179. var __decorate$10 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  28180. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  28181. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  28182. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  28183. return c > 3 && r && Object.defineProperty(target, key, r), r;
  28184. };
  28185. var GridApi = /** @class */ (function () {
  28186. function GridApi() {
  28187. this.detailGridInfoMap = {};
  28188. this.destroyCalled = false;
  28189. }
  28190. GridApi.prototype.registerGridComp = function (gridPanel) {
  28191. this.gridPanel = gridPanel;
  28192. };
  28193. GridApi.prototype.registerGridCore = function (gridCore) {
  28194. this.gridCore = gridCore;
  28195. };
  28196. GridApi.prototype.registerHeaderRootComp = function (headerRootComp) {
  28197. this.headerRootComp = headerRootComp;
  28198. };
  28199. GridApi.prototype.init = function () {
  28200. switch (this.rowModel.getType()) {
  28201. case Constants.ROW_MODEL_TYPE_CLIENT_SIDE:
  28202. this.clientSideRowModel = this.rowModel;
  28203. break;
  28204. case Constants.ROW_MODEL_TYPE_INFINITE:
  28205. this.infiniteRowModel = this.rowModel;
  28206. break;
  28207. case Constants.ROW_MODEL_TYPE_SERVER_SIDE:
  28208. this.serverSideRowModel = this.rowModel;
  28209. break;
  28210. }
  28211. };
  28212. /** Used internally by grid. Not intended to be used by the client. Interface may change between releases. */
  28213. GridApi.prototype.__getAlignedGridService = function () {
  28214. return this.alignedGridsService;
  28215. };
  28216. GridApi.prototype.addDetailGridInfo = function (id, gridInfo) {
  28217. this.detailGridInfoMap[id] = gridInfo;
  28218. };
  28219. GridApi.prototype.removeDetailGridInfo = function (id) {
  28220. this.detailGridInfoMap[id] = undefined;
  28221. };
  28222. GridApi.prototype.getDetailGridInfo = function (id) {
  28223. return this.detailGridInfoMap[id];
  28224. };
  28225. GridApi.prototype.forEachDetailGridInfo = function (callback) {
  28226. var index = 0;
  28227. _.iterateObject(this.detailGridInfoMap, function (id, gridInfo) {
  28228. // check for undefined, as old references will still be lying around
  28229. if (_.exists(gridInfo)) {
  28230. callback(gridInfo, index);
  28231. index++;
  28232. }
  28233. });
  28234. };
  28235. GridApi.prototype.getDataAsCsv = function (params) {
  28236. if (ModuleRegistry.assertRegistered(exports.ModuleNames.CsvExportModule, 'api.getDataAsCsv')) {
  28237. return this.csvCreator.getDataAsCsv(params);
  28238. }
  28239. };
  28240. GridApi.prototype.exportDataAsCsv = function (params) {
  28241. if (ModuleRegistry.assertRegistered(exports.ModuleNames.CsvExportModule, 'api.exportDataAsCSv')) {
  28242. this.csvCreator.exportDataAsCsv(params);
  28243. }
  28244. };
  28245. GridApi.prototype.getDataAsExcel = function (params) {
  28246. if (ModuleRegistry.assertRegistered(exports.ModuleNames.ExcelExportModule, 'api.getDataAsExcel')) {
  28247. return this.excelCreator.getDataAsExcelXml(params);
  28248. }
  28249. };
  28250. GridApi.prototype.exportDataAsExcel = function (params) {
  28251. if (ModuleRegistry.assertRegistered(exports.ModuleNames.ExcelExportModule, 'api.exportDataAsExcel')) {
  28252. this.excelCreator.exportDataAsExcel(params);
  28253. }
  28254. };
  28255. /** @deprecated */
  28256. GridApi.prototype.setEnterpriseDatasource = function (datasource) {
  28257. console.warn("ag-grid: since version 18.x, api.setEnterpriseDatasource() should be replaced with api.setServerSideDatasource()");
  28258. this.setServerSideDatasource(datasource);
  28259. };
  28260. GridApi.prototype.setServerSideDatasource = function (datasource) {
  28261. if (this.gridOptionsWrapper.isRowModelServerSide()) {
  28262. // should really have an IEnterpriseRowModel interface, so we are not casting to any
  28263. this.rowModel.setDatasource(datasource);
  28264. }
  28265. else {
  28266. console.warn("ag-Grid: you can only use an enterprise datasource when gridOptions.rowModelType is '" + Constants.ROW_MODEL_TYPE_SERVER_SIDE + "'");
  28267. }
  28268. };
  28269. GridApi.prototype.setDatasource = function (datasource) {
  28270. if (this.gridOptionsWrapper.isRowModelInfinite()) {
  28271. this.rowModel.setDatasource(datasource);
  28272. }
  28273. else {
  28274. console.warn("ag-Grid: you can only use a datasource when gridOptions.rowModelType is '" + Constants.ROW_MODEL_TYPE_INFINITE + "'");
  28275. }
  28276. };
  28277. GridApi.prototype.setViewportDatasource = function (viewportDatasource) {
  28278. if (this.gridOptionsWrapper.isRowModelViewport()) {
  28279. // this is bad coding, because it's using an interface that's exposed in the enterprise.
  28280. // really we should create an interface in the core for viewportDatasource and let
  28281. // the enterprise implement it, rather than casting to 'any' here
  28282. this.rowModel.setViewportDatasource(viewportDatasource);
  28283. }
  28284. else {
  28285. console.warn("ag-Grid: you can only use a viewport datasource when gridOptions.rowModelType is '" + Constants.ROW_MODEL_TYPE_VIEWPORT + "'");
  28286. }
  28287. };
  28288. GridApi.prototype.setRowData = function (rowData) {
  28289. if (this.gridOptionsWrapper.isRowModelDefault()) {
  28290. if (this.gridOptionsWrapper.isImmutableData()) {
  28291. var res = this.immutableService.createTransactionForRowData(rowData);
  28292. if (!res) {
  28293. return;
  28294. }
  28295. var transaction = res[0], orderIdMap = res[1];
  28296. this.clientSideRowModel.updateRowData(transaction, orderIdMap);
  28297. // need to force updating of full width rows - note this wouldn't be necessary the full width cell comp listened
  28298. // to the data change event on the row node and refreshed itself.
  28299. this.rowRenderer.refreshFullWidthRows();
  28300. }
  28301. else {
  28302. this.selectionController.reset();
  28303. this.clientSideRowModel.setRowData(rowData);
  28304. }
  28305. }
  28306. else {
  28307. console.warn('cannot call setRowData unless using normal row model');
  28308. }
  28309. };
  28310. /** @deprecated */
  28311. GridApi.prototype.setFloatingTopRowData = function (rows) {
  28312. console.warn('ag-Grid: since v12, api.setFloatingTopRowData() is now api.setPinnedTopRowData()');
  28313. this.setPinnedTopRowData(rows);
  28314. };
  28315. /** @deprecated */
  28316. GridApi.prototype.setFloatingBottomRowData = function (rows) {
  28317. console.warn('ag-Grid: since v12, api.setFloatingBottomRowData() is now api.setPinnedBottomRowData()');
  28318. this.setPinnedBottomRowData(rows);
  28319. };
  28320. /** @deprecated */
  28321. GridApi.prototype.getFloatingTopRowCount = function () {
  28322. console.warn('ag-Grid: since v12, api.getFloatingTopRowCount() is now api.getPinnedTopRowCount()');
  28323. return this.getPinnedTopRowCount();
  28324. };
  28325. /** @deprecated */
  28326. GridApi.prototype.getFloatingBottomRowCount = function () {
  28327. console.warn('ag-Grid: since v12, api.getFloatingBottomRowCount() is now api.getPinnedBottomRowCount()');
  28328. return this.getPinnedBottomRowCount();
  28329. };
  28330. /** @deprecated */
  28331. GridApi.prototype.getFloatingTopRow = function (index) {
  28332. console.warn('ag-Grid: since v12, api.getFloatingTopRow() is now api.getPinnedTopRow()');
  28333. return this.getPinnedTopRow(index);
  28334. };
  28335. /** @deprecated */
  28336. GridApi.prototype.getFloatingBottomRow = function (index) {
  28337. console.warn('ag-Grid: since v12, api.getFloatingBottomRow() is now api.getPinnedBottomRow()');
  28338. return this.getPinnedBottomRow(index);
  28339. };
  28340. GridApi.prototype.setPinnedTopRowData = function (rows) {
  28341. this.pinnedRowModel.setPinnedTopRowData(rows);
  28342. };
  28343. GridApi.prototype.setPinnedBottomRowData = function (rows) {
  28344. this.pinnedRowModel.setPinnedBottomRowData(rows);
  28345. };
  28346. GridApi.prototype.getPinnedTopRowCount = function () {
  28347. return this.pinnedRowModel.getPinnedTopRowCount();
  28348. };
  28349. GridApi.prototype.getPinnedBottomRowCount = function () {
  28350. return this.pinnedRowModel.getPinnedBottomRowCount();
  28351. };
  28352. GridApi.prototype.getPinnedTopRow = function (index) {
  28353. return this.pinnedRowModel.getPinnedTopRow(index);
  28354. };
  28355. GridApi.prototype.getPinnedBottomRow = function (index) {
  28356. return this.pinnedRowModel.getPinnedBottomRow(index);
  28357. };
  28358. GridApi.prototype.setColumnDefs = function (colDefs, source) {
  28359. if (source === void 0) { source = "api"; }
  28360. this.columnController.setColumnDefs(colDefs, source);
  28361. };
  28362. GridApi.prototype.setAutoGroupColumnDef = function (colDef, source) {
  28363. this.gridOptionsWrapper.setProperty('autoGroupColumnDef', colDef, true);
  28364. };
  28365. GridApi.prototype.expireValueCache = function () {
  28366. this.valueCache.expire();
  28367. };
  28368. GridApi.prototype.getVerticalPixelRange = function () {
  28369. return this.gridPanel.getVScrollPosition();
  28370. };
  28371. GridApi.prototype.getHorizontalPixelRange = function () {
  28372. return this.gridPanel.getHScrollPosition();
  28373. };
  28374. GridApi.prototype.setAlwaysShowVerticalScroll = function (show) {
  28375. this.gridOptionsWrapper.setProperty('alwaysShowVerticalScroll', show);
  28376. };
  28377. GridApi.prototype.refreshToolPanel = function () {
  28378. this.gridCore.refreshSideBar();
  28379. };
  28380. GridApi.prototype.refreshCells = function (params) {
  28381. if (params === void 0) { params = {}; }
  28382. if (Array.isArray(params)) {
  28383. // the old version of refreshCells() took an array of rowNodes for the first argument
  28384. console.warn('since ag-Grid v11.1, refreshCells() now takes parameters, please see the documentation.');
  28385. return;
  28386. }
  28387. this.rowRenderer.refreshCells(params);
  28388. };
  28389. GridApi.prototype.flashCells = function (params) {
  28390. if (params === void 0) { params = {}; }
  28391. this.rowRenderer.flashCells(params);
  28392. };
  28393. GridApi.prototype.redrawRows = function (params) {
  28394. if (params === void 0) { params = {}; }
  28395. if (params && params.rowNodes) {
  28396. this.rowRenderer.redrawRows(params.rowNodes);
  28397. }
  28398. else {
  28399. this.rowRenderer.redrawAfterModelUpdate();
  28400. }
  28401. };
  28402. GridApi.prototype.timeFullRedraw = function (count) {
  28403. if (count === void 0) { count = 1; }
  28404. var iterationCount = 0;
  28405. var totalProcessing = 0;
  28406. var totalReflow = 0;
  28407. var that = this;
  28408. doOneIteration();
  28409. function doOneIteration() {
  28410. var start = (new Date()).getTime();
  28411. that.rowRenderer.redrawAfterModelUpdate();
  28412. var endProcessing = (new Date()).getTime();
  28413. window.setTimeout(function () {
  28414. var endReflow = (new Date()).getTime();
  28415. var durationProcessing = endProcessing - start;
  28416. var durationReflow = endReflow - endProcessing;
  28417. // tslint:disable-next-line
  28418. console.log('duration: processing = ' + durationProcessing + 'ms, reflow = ' + durationReflow + 'ms');
  28419. iterationCount++;
  28420. totalProcessing += durationProcessing;
  28421. totalReflow += durationReflow;
  28422. if (iterationCount < count) {
  28423. // wait for 1s between tests
  28424. window.setTimeout(doOneIteration, 1000);
  28425. }
  28426. else {
  28427. finish();
  28428. }
  28429. }, 0);
  28430. }
  28431. function finish() {
  28432. // tslint:disable-next-line
  28433. console.log('tests complete. iteration count = ' + iterationCount);
  28434. // tslint:disable-next-line
  28435. console.log('average processing = ' + (totalProcessing / iterationCount) + 'ms');
  28436. // tslint:disable-next-line
  28437. console.log('average reflow = ' + (totalReflow / iterationCount) + 'ms');
  28438. }
  28439. };
  28440. /** @deprecated */
  28441. GridApi.prototype.refreshView = function () {
  28442. console.warn('ag-Grid: since v11.1, refreshView() is deprecated, please call refreshCells() or redrawRows() instead');
  28443. this.redrawRows();
  28444. };
  28445. /** @deprecated */
  28446. GridApi.prototype.refreshRows = function (rowNodes) {
  28447. console.warn('since ag-Grid v11.1, refreshRows() is deprecated, please use refreshCells({rowNodes: rows}) or redrawRows({rowNodes: rows}) instead');
  28448. this.refreshCells({ rowNodes: rowNodes });
  28449. };
  28450. /** @deprecated */
  28451. GridApi.prototype.rowDataChanged = function (rows) {
  28452. console.warn('ag-Grid: rowDataChanged is deprecated, either call refreshView() to refresh everything, or call rowNode.setRowData(newData) to set value on a particular node');
  28453. this.redrawRows();
  28454. };
  28455. /** @deprecated */
  28456. GridApi.prototype.softRefreshView = function () {
  28457. console.error('ag-Grid: since v16, softRefreshView() is no longer supported. Please check the documentation on how to refresh.');
  28458. };
  28459. /** @deprecated */
  28460. GridApi.prototype.refreshGroupRows = function () {
  28461. console.warn('ag-Grid: since v11.1, refreshGroupRows() is no longer supported, call refreshCells() instead. ' +
  28462. 'Because refreshCells() now does dirty checking, it will only refresh cells that have changed, so it should ' +
  28463. 'not be necessary to only refresh the group rows.');
  28464. this.refreshCells();
  28465. };
  28466. GridApi.prototype.setFunctionsReadOnly = function (readOnly) {
  28467. this.gridOptionsWrapper.setProperty('functionsReadOnly', readOnly);
  28468. };
  28469. GridApi.prototype.refreshHeader = function () {
  28470. this.headerRootComp.refreshHeader();
  28471. this.gridPanel.setHeaderAndFloatingHeights();
  28472. };
  28473. GridApi.prototype.isAnyFilterPresent = function () {
  28474. return this.filterManager.isAnyFilterPresent();
  28475. };
  28476. /** @deprecated */
  28477. GridApi.prototype.isAdvancedFilterPresent = function () {
  28478. console.warn('ag-Grid: isAdvancedFilterPresent() is deprecated, please use isColumnFilterPresent()');
  28479. return this.isColumnFilterPresent();
  28480. };
  28481. GridApi.prototype.isColumnFilterPresent = function () {
  28482. return this.filterManager.isAdvancedFilterPresent();
  28483. };
  28484. GridApi.prototype.isQuickFilterPresent = function () {
  28485. return this.filterManager.isQuickFilterPresent();
  28486. };
  28487. GridApi.prototype.getModel = function () {
  28488. return this.rowModel;
  28489. };
  28490. GridApi.prototype.setRowNodeExpanded = function (rowNode, expanded) {
  28491. if (rowNode) {
  28492. rowNode.setExpanded(expanded);
  28493. }
  28494. };
  28495. GridApi.prototype.onGroupExpandedOrCollapsed = function (deprecated_refreshFromIndex) {
  28496. if (_.missing(this.clientSideRowModel)) {
  28497. console.warn('ag-Grid: cannot call onGroupExpandedOrCollapsed unless using normal row model');
  28498. }
  28499. if (_.exists(deprecated_refreshFromIndex)) {
  28500. console.warn('ag-Grid: api.onGroupExpandedOrCollapsed - refreshFromIndex parameter is no longer used, the grid will refresh all rows');
  28501. }
  28502. // we don't really want the user calling this if only one rowNode was expanded, instead they should be
  28503. // calling rowNode.setExpanded(boolean) - this way we do a 'keepRenderedRows=false' so that the whole
  28504. // grid gets refreshed again - otherwise the row with the rowNodes that were changed won't get updated,
  28505. // and thus the expand icon in the group cell won't get 'opened' or 'closed'.
  28506. this.clientSideRowModel.refreshModel({ step: Constants.STEP_MAP });
  28507. };
  28508. GridApi.prototype.refreshInMemoryRowModel = function (step) {
  28509. console.warn("ag-grid: since version 18.x, api.refreshInMemoryRowModel() should be replaced with api.refreshClientSideRowModel()");
  28510. this.refreshClientSideRowModel(step);
  28511. };
  28512. GridApi.prototype.refreshClientSideRowModel = function (step) {
  28513. if (_.missing(this.clientSideRowModel)) {
  28514. console.warn('cannot call refreshClientSideRowModel unless using normal row model');
  28515. }
  28516. var paramsStep = Constants.STEP_EVERYTHING;
  28517. var stepsMapped = {
  28518. group: Constants.STEP_EVERYTHING,
  28519. filter: Constants.STEP_FILTER,
  28520. map: Constants.STEP_MAP,
  28521. aggregate: Constants.STEP_AGGREGATE,
  28522. sort: Constants.STEP_SORT,
  28523. pivot: Constants.STEP_PIVOT
  28524. };
  28525. if (_.exists(step)) {
  28526. paramsStep = stepsMapped[step];
  28527. }
  28528. if (_.missing(paramsStep)) {
  28529. console.error("ag-Grid: invalid step " + step + ", available steps are " + Object.keys(stepsMapped).join(', '));
  28530. return;
  28531. }
  28532. var modelParams = {
  28533. step: paramsStep,
  28534. keepRenderedRows: true,
  28535. animate: true,
  28536. keepEditingRows: true
  28537. };
  28538. this.clientSideRowModel.refreshModel(modelParams);
  28539. };
  28540. GridApi.prototype.isAnimationFrameQueueEmpty = function () {
  28541. return this.animationFrameService.isQueueEmpty();
  28542. };
  28543. GridApi.prototype.getRowNode = function (id) {
  28544. return this.rowModel.getRowNode(id);
  28545. };
  28546. GridApi.prototype.getSizesForCurrentTheme = function () {
  28547. return {
  28548. rowHeight: this.gridOptionsWrapper.getRowHeightAsNumber(),
  28549. headerHeight: this.gridOptionsWrapper.getHeaderHeight()
  28550. };
  28551. };
  28552. GridApi.prototype.expandAll = function () {
  28553. if (_.missing(this.clientSideRowModel)) {
  28554. console.warn('ag-Grid: cannot call expandAll unless using normal row model');
  28555. return;
  28556. }
  28557. this.clientSideRowModel.expandOrCollapseAll(true);
  28558. };
  28559. GridApi.prototype.collapseAll = function () {
  28560. if (_.missing(this.clientSideRowModel)) {
  28561. console.warn('ag-Grid: cannot call collapseAll unless using normal row model');
  28562. return;
  28563. }
  28564. this.clientSideRowModel.expandOrCollapseAll(false);
  28565. };
  28566. GridApi.prototype.getToolPanelInstance = function (id) {
  28567. return this.gridCore.getToolPanelInstance(id);
  28568. };
  28569. GridApi.prototype.addVirtualRowListener = function (eventName, rowIndex, callback) {
  28570. if (typeof eventName !== 'string') {
  28571. console.warn('ag-Grid: addVirtualRowListener is deprecated, please use addRenderedRowListener.');
  28572. }
  28573. this.addRenderedRowListener(eventName, rowIndex, callback);
  28574. };
  28575. GridApi.prototype.addRenderedRowListener = function (eventName, rowIndex, callback) {
  28576. if (eventName === 'virtualRowSelected') {
  28577. console.warn("ag-Grid: event virtualRowSelected is deprecated, to register for individual row\n selection events, add a listener directly to the row node.");
  28578. }
  28579. this.rowRenderer.addRenderedRowListener(eventName, rowIndex, callback);
  28580. };
  28581. GridApi.prototype.setQuickFilter = function (newFilter) {
  28582. this.filterManager.setQuickFilter(newFilter);
  28583. };
  28584. GridApi.prototype.selectIndex = function (index, tryMulti, suppressEvents) {
  28585. console.warn('ag-Grid: do not use api for selection, call node.setSelected(value) instead');
  28586. if (suppressEvents) {
  28587. console.warn('ag-Grid: suppressEvents is no longer supported, stop listening for the event if you no longer want it');
  28588. }
  28589. this.selectionController.selectIndex(index, tryMulti);
  28590. };
  28591. GridApi.prototype.deselectIndex = function (index, suppressEvents) {
  28592. if (suppressEvents === void 0) { suppressEvents = false; }
  28593. console.warn('ag-Grid: do not use api for selection, call node.setSelected(value) instead');
  28594. if (suppressEvents) {
  28595. console.warn('ag-Grid: suppressEvents is no longer supported, stop listening for the event if you no longer want it');
  28596. }
  28597. this.selectionController.deselectIndex(index);
  28598. };
  28599. GridApi.prototype.selectNode = function (node, tryMulti, suppressEvents) {
  28600. if (tryMulti === void 0) { tryMulti = false; }
  28601. if (suppressEvents === void 0) { suppressEvents = false; }
  28602. console.warn('ag-Grid: API for selection is deprecated, call node.setSelected(value) instead');
  28603. if (suppressEvents) {
  28604. console.warn('ag-Grid: suppressEvents is no longer supported, stop listening for the event if you no longer want it');
  28605. }
  28606. node.setSelectedParams({ newValue: true, clearSelection: !tryMulti });
  28607. };
  28608. GridApi.prototype.deselectNode = function (node, suppressEvents) {
  28609. if (suppressEvents === void 0) { suppressEvents = false; }
  28610. console.warn('ag-Grid: API for selection is deprecated, call node.setSelected(value) instead');
  28611. if (suppressEvents) {
  28612. console.warn('ag-Grid: suppressEvents is no longer supported, stop listening for the event if you no longer want it');
  28613. }
  28614. node.setSelectedParams({ newValue: false });
  28615. };
  28616. GridApi.prototype.selectAll = function () {
  28617. this.selectionController.selectAllRowNodes();
  28618. };
  28619. GridApi.prototype.deselectAll = function () {
  28620. this.selectionController.deselectAllRowNodes();
  28621. };
  28622. GridApi.prototype.selectAllFiltered = function () {
  28623. this.selectionController.selectAllRowNodes(true);
  28624. };
  28625. GridApi.prototype.deselectAllFiltered = function () {
  28626. this.selectionController.deselectAllRowNodes(true);
  28627. };
  28628. GridApi.prototype.recomputeAggregates = function () {
  28629. if (_.missing(this.clientSideRowModel)) {
  28630. console.warn('cannot call recomputeAggregates unless using normal row model');
  28631. }
  28632. console.warn("recomputeAggregates is deprecated, please call api.refreshClientSideRowModel('aggregate') instead");
  28633. this.clientSideRowModel.refreshModel({ step: Constants.STEP_AGGREGATE });
  28634. };
  28635. GridApi.prototype.sizeColumnsToFit = function () {
  28636. this.gridPanel.sizeColumnsToFit();
  28637. };
  28638. GridApi.prototype.showLoadingOverlay = function () {
  28639. this.gridPanel.showLoadingOverlay();
  28640. };
  28641. GridApi.prototype.showNoRowsOverlay = function () {
  28642. this.gridPanel.showNoRowsOverlay();
  28643. };
  28644. GridApi.prototype.hideOverlay = function () {
  28645. this.gridPanel.hideOverlay();
  28646. };
  28647. GridApi.prototype.isNodeSelected = function (node) {
  28648. console.warn('ag-Grid: no need to call api.isNodeSelected(), just call node.isSelected() instead');
  28649. return node.isSelected();
  28650. };
  28651. GridApi.prototype.getSelectedNodesById = function () {
  28652. console.error('ag-Grid: since version 3.4, getSelectedNodesById no longer exists, use getSelectedNodes() instead');
  28653. return null;
  28654. };
  28655. GridApi.prototype.getSelectedNodes = function () {
  28656. return this.selectionController.getSelectedNodes();
  28657. };
  28658. GridApi.prototype.getSelectedRows = function () {
  28659. return this.selectionController.getSelectedRows();
  28660. };
  28661. GridApi.prototype.getBestCostNodeSelection = function () {
  28662. return this.selectionController.getBestCostNodeSelection();
  28663. };
  28664. GridApi.prototype.getRenderedNodes = function () {
  28665. return this.rowRenderer.getRenderedNodes();
  28666. };
  28667. GridApi.prototype.ensureColIndexVisible = function (index) {
  28668. console.warn('ag-Grid: ensureColIndexVisible(index) no longer supported, use ensureColumnVisible(colKey) instead.');
  28669. };
  28670. GridApi.prototype.ensureColumnVisible = function (key) {
  28671. this.gridPanel.ensureColumnVisible(key);
  28672. };
  28673. // Valid values for position are bottom, middle and top
  28674. GridApi.prototype.ensureIndexVisible = function (index, position) {
  28675. this.gridPanel.ensureIndexVisible(index, position);
  28676. };
  28677. // Valid values for position are bottom, middle and top
  28678. GridApi.prototype.ensureNodeVisible = function (comparator, position) {
  28679. this.gridCore.ensureNodeVisible(comparator, position);
  28680. };
  28681. GridApi.prototype.forEachLeafNode = function (callback) {
  28682. if (_.missing(this.clientSideRowModel)) {
  28683. console.warn('cannot call forEachNode unless using normal row model');
  28684. }
  28685. this.clientSideRowModel.forEachLeafNode(callback);
  28686. };
  28687. GridApi.prototype.forEachNode = function (callback) {
  28688. this.rowModel.forEachNode(callback);
  28689. };
  28690. GridApi.prototype.forEachNodeAfterFilter = function (callback) {
  28691. if (_.missing(this.clientSideRowModel)) {
  28692. console.warn('cannot call forEachNodeAfterFilter unless using normal row model');
  28693. }
  28694. this.clientSideRowModel.forEachNodeAfterFilter(callback);
  28695. };
  28696. GridApi.prototype.forEachNodeAfterFilterAndSort = function (callback) {
  28697. if (_.missing(this.clientSideRowModel)) {
  28698. console.warn('cannot call forEachNodeAfterFilterAndSort unless using normal row model');
  28699. }
  28700. this.clientSideRowModel.forEachNodeAfterFilterAndSort(callback);
  28701. };
  28702. GridApi.prototype.getFilterApiForColDef = function (colDef) {
  28703. console.warn('ag-grid API method getFilterApiForColDef deprecated, use getFilterInstance instead');
  28704. return this.getFilterInstance(colDef);
  28705. };
  28706. GridApi.prototype.getFilterInstance = function (key, callback) {
  28707. var column = this.columnController.getPrimaryColumn(key);
  28708. if (column) {
  28709. var filterPromise = this.filterManager.getFilterComponent(column, 'NO_UI');
  28710. var currentValue = filterPromise.resolveNow(null, function (filterComp) { return filterComp; });
  28711. if (callback) {
  28712. if (currentValue) {
  28713. setTimeout(callback, 0, currentValue);
  28714. }
  28715. else {
  28716. filterPromise.then(callback);
  28717. }
  28718. }
  28719. return currentValue;
  28720. }
  28721. };
  28722. GridApi.prototype.getFilterApi = function (key) {
  28723. console.warn('ag-Grid: getFilterApi is deprecated, use getFilterInstance instead');
  28724. return this.getFilterInstance(key);
  28725. };
  28726. GridApi.prototype.destroyFilter = function (key) {
  28727. var column = this.columnController.getPrimaryColumn(key);
  28728. if (column) {
  28729. return this.filterManager.destroyFilter(column, "filterDestroyed");
  28730. }
  28731. };
  28732. GridApi.prototype.getStatusPanel = function (key) {
  28733. if (this.statusBarService) {
  28734. return this.statusBarService.getStatusPanel(key);
  28735. }
  28736. };
  28737. GridApi.prototype.getColumnDef = function (key) {
  28738. var column = this.columnController.getPrimaryColumn(key);
  28739. if (column) {
  28740. return column.getColDef();
  28741. }
  28742. return null;
  28743. };
  28744. GridApi.prototype.onFilterChanged = function () {
  28745. this.filterManager.onFilterChanged();
  28746. };
  28747. GridApi.prototype.onSortChanged = function () {
  28748. this.sortController.onSortChanged();
  28749. };
  28750. GridApi.prototype.setSortModel = function (sortModel, source) {
  28751. if (source === void 0) { source = "api"; }
  28752. this.sortController.setSortModel(sortModel, source);
  28753. };
  28754. GridApi.prototype.getSortModel = function () {
  28755. return this.sortController.getSortModel();
  28756. };
  28757. GridApi.prototype.setFilterModel = function (model) {
  28758. this.filterManager.setFilterModel(model);
  28759. };
  28760. GridApi.prototype.getFilterModel = function () {
  28761. return this.filterManager.getFilterModel();
  28762. };
  28763. GridApi.prototype.getFocusedCell = function () {
  28764. return this.focusController.getFocusedCell();
  28765. };
  28766. GridApi.prototype.clearFocusedCell = function () {
  28767. return this.focusController.clearFocusedCell();
  28768. };
  28769. GridApi.prototype.setFocusedCell = function (rowIndex, colKey, floating) {
  28770. this.focusController.setFocusedCell(rowIndex, colKey, floating, true);
  28771. };
  28772. GridApi.prototype.setSuppressRowDrag = function (value) {
  28773. this.gridOptionsWrapper.setProperty(GridOptionsWrapper.PROP_SUPPRESS_ROW_DRAG, value);
  28774. };
  28775. GridApi.prototype.setSuppressMoveWhenRowDragging = function (value) {
  28776. this.gridOptionsWrapper.setProperty(GridOptionsWrapper.PROP_SUPPRESS_MOVE_WHEN_ROW_DRAG, value);
  28777. };
  28778. GridApi.prototype.setSuppressRowClickSelection = function (value) {
  28779. this.gridOptionsWrapper.setProperty(GridOptionsWrapper.PROP_SUPPRESS_ROW_CLICK_SELECTION, value);
  28780. };
  28781. GridApi.prototype.addRowDropZone = function (params) {
  28782. this.gridPanel.getRowDragFeature().addRowDropZone(params);
  28783. };
  28784. GridApi.prototype.removeRowDropZone = function (params) {
  28785. var activeDropTarget = this.dragAndDropService.findExternalZone(params);
  28786. if (activeDropTarget) {
  28787. this.dragAndDropService.removeDropTarget(activeDropTarget);
  28788. }
  28789. };
  28790. GridApi.prototype.getRowDropZoneParams = function (events) {
  28791. return this.gridPanel.getRowDragFeature().getRowDropZone(events);
  28792. };
  28793. GridApi.prototype.setHeaderHeight = function (headerHeight) {
  28794. this.gridOptionsWrapper.setProperty(GridOptionsWrapper.PROP_HEADER_HEIGHT, headerHeight);
  28795. this.doLayout();
  28796. };
  28797. GridApi.prototype.setGridAutoHeight = function (gridAutoHeight) {
  28798. console.warn('api.setGridAutoHeight(boolean) is deprecated, please use api.setDomLayout() instead');
  28799. this.setDomLayout(gridAutoHeight ? 'autoHeight' : 'normal');
  28800. };
  28801. GridApi.prototype.setDomLayout = function (domLayout) {
  28802. this.gridOptionsWrapper.setProperty(GridOptionsWrapper.PROP_DOM_LAYOUT, domLayout);
  28803. };
  28804. GridApi.prototype.setEnableCellTextSelection = function (selectable) {
  28805. this.gridPanel.setCellTextSelection(selectable);
  28806. };
  28807. GridApi.prototype.setGroupHeaderHeight = function (headerHeight) {
  28808. this.gridOptionsWrapper.setProperty(GridOptionsWrapper.PROP_GROUP_HEADER_HEIGHT, headerHeight);
  28809. this.doLayout();
  28810. };
  28811. GridApi.prototype.setFloatingFiltersHeight = function (headerHeight) {
  28812. this.gridOptionsWrapper.setProperty(GridOptionsWrapper.PROP_FLOATING_FILTERS_HEIGHT, headerHeight);
  28813. this.doLayout();
  28814. };
  28815. GridApi.prototype.setPivotGroupHeaderHeight = function (headerHeight) {
  28816. this.gridOptionsWrapper.setProperty(GridOptionsWrapper.PROP_PIVOT_GROUP_HEADER_HEIGHT, headerHeight);
  28817. this.doLayout();
  28818. };
  28819. GridApi.prototype.setPivotHeaderHeight = function (headerHeight) {
  28820. this.gridOptionsWrapper.setProperty(GridOptionsWrapper.PROP_PIVOT_HEADER_HEIGHT, headerHeight);
  28821. this.doLayout();
  28822. };
  28823. GridApi.prototype.isSideBarVisible = function () {
  28824. return this.gridCore.isSideBarVisible();
  28825. };
  28826. GridApi.prototype.setSideBarVisible = function (show) {
  28827. this.gridCore.setSideBarVisible(show);
  28828. };
  28829. GridApi.prototype.setSideBarPosition = function (position) {
  28830. this.gridCore.setSideBarPosition(position);
  28831. };
  28832. GridApi.prototype.showToolPanel = function (show) {
  28833. console.warn("ag-grid: from v19 api.showToolPanel has been deprecated in favour of api.setSideBarVisible");
  28834. this.setSideBarVisible(show);
  28835. };
  28836. GridApi.prototype.openToolPanel = function (key) {
  28837. this.gridCore.openToolPanel(key);
  28838. };
  28839. GridApi.prototype.closeToolPanel = function () {
  28840. this.gridCore.closeToolPanel();
  28841. };
  28842. GridApi.prototype.getOpenedToolPanel = function () {
  28843. return this.gridCore.getOpenedToolPanel();
  28844. };
  28845. GridApi.prototype.getSideBar = function () {
  28846. return this.gridCore.getSideBar();
  28847. };
  28848. GridApi.prototype.setSideBar = function (def) {
  28849. return this.gridCore.setSideBar(def);
  28850. };
  28851. GridApi.prototype.setSuppressClipboardPaste = function (value) {
  28852. this.gridOptionsWrapper.setProperty(GridOptionsWrapper.PROP_SUPPRESS_CLIPBOARD_PASTE, value);
  28853. };
  28854. GridApi.prototype.isToolPanelShowing = function () {
  28855. return this.gridCore.isToolPanelShowing();
  28856. };
  28857. GridApi.prototype.doLayout = function () {
  28858. this.gridPanel.checkViewportAndScrolls();
  28859. };
  28860. GridApi.prototype.resetRowHeights = function () {
  28861. if (_.exists(this.clientSideRowModel)) {
  28862. this.clientSideRowModel.resetRowHeights();
  28863. }
  28864. };
  28865. GridApi.prototype.setGroupRemoveSingleChildren = function (value) {
  28866. this.gridOptionsWrapper.setProperty(GridOptionsWrapper.PROP_GROUP_REMOVE_SINGLE_CHILDREN, value);
  28867. };
  28868. GridApi.prototype.setGroupRemoveLowestSingleChildren = function (value) {
  28869. this.gridOptionsWrapper.setProperty(GridOptionsWrapper.PROP_GROUP_REMOVE_LOWEST_SINGLE_CHILDREN, value);
  28870. };
  28871. GridApi.prototype.onRowHeightChanged = function () {
  28872. if (this.clientSideRowModel) {
  28873. this.clientSideRowModel.onRowHeightChanged();
  28874. }
  28875. else if (this.serverSideRowModel) {
  28876. this.serverSideRowModel.onRowHeightChanged();
  28877. }
  28878. };
  28879. GridApi.prototype.getValue = function (colKey, rowNode) {
  28880. var column = this.columnController.getPrimaryColumn(colKey);
  28881. if (_.missing(column)) {
  28882. column = this.columnController.getGridColumn(colKey);
  28883. }
  28884. if (_.missing(column)) {
  28885. return null;
  28886. }
  28887. return this.valueService.getValue(column, rowNode);
  28888. };
  28889. GridApi.prototype.addEventListener = function (eventType, listener) {
  28890. var async = this.gridOptionsWrapper.useAsyncEvents();
  28891. this.eventService.addEventListener(eventType, listener, async);
  28892. };
  28893. GridApi.prototype.addGlobalListener = function (listener) {
  28894. var async = this.gridOptionsWrapper.useAsyncEvents();
  28895. this.eventService.addGlobalListener(listener, async);
  28896. };
  28897. GridApi.prototype.removeEventListener = function (eventType, listener) {
  28898. var async = this.gridOptionsWrapper.useAsyncEvents();
  28899. this.eventService.removeEventListener(eventType, listener, async);
  28900. };
  28901. GridApi.prototype.removeGlobalListener = function (listener) {
  28902. var async = this.gridOptionsWrapper.useAsyncEvents();
  28903. this.eventService.removeGlobalListener(listener, async);
  28904. };
  28905. GridApi.prototype.dispatchEvent = function (event) {
  28906. this.eventService.dispatchEvent(event);
  28907. };
  28908. GridApi.prototype.destroy = function () {
  28909. // this is needed as GridAPI is a bean, and GridAPI.destroy() is called as part
  28910. // of context.destroy(). so we need to stop the infinite loop.
  28911. if (this.destroyCalled) {
  28912. return;
  28913. }
  28914. this.destroyCalled = true;
  28915. // destroy the UI first (as they use the services)
  28916. this.context.destroyBean(this.gridCore);
  28917. // destroy the services
  28918. this.context.destroy();
  28919. };
  28920. GridApi.prototype.resetQuickFilter = function () {
  28921. this.rowModel.forEachNode(function (node) { return node.quickFilterAggregateText = null; });
  28922. };
  28923. GridApi.prototype.getRangeSelections = function () {
  28924. console.warn("ag-Grid: in v20.1.x, api.getRangeSelections() is gone, please use getCellRanges() instead.\n We had to change how cell selections works a small bit to allow charting to integrate. The return type of\n getCellRanges() is a bit different, please check the ag-Grid documentation.");
  28925. return null;
  28926. };
  28927. GridApi.prototype.getCellRanges = function () {
  28928. if (this.rangeController) {
  28929. return this.rangeController.getCellRanges();
  28930. }
  28931. console.warn('ag-Grid: cell range selection is only available in ag-Grid Enterprise');
  28932. return null;
  28933. };
  28934. GridApi.prototype.camelCaseToHumanReadable = function (camelCase) {
  28935. return _.camelCaseToHumanText(camelCase);
  28936. };
  28937. GridApi.prototype.addRangeSelection = function (deprecatedNoLongerUsed) {
  28938. console.warn('ag-Grid: As of version 21.x, range selection changed slightly to allow charting integration. Please call api.addCellRange() instead of api.addRangeSelection()');
  28939. };
  28940. GridApi.prototype.addCellRange = function (params) {
  28941. if (!this.rangeController) {
  28942. console.warn('ag-Grid: cell range selection is only available in ag-Grid Enterprise');
  28943. }
  28944. this.rangeController.addCellRange(params);
  28945. };
  28946. GridApi.prototype.clearRangeSelection = function () {
  28947. if (!this.rangeController) {
  28948. console.warn('ag-Grid: cell range selection is only available in ag-Grid Enterprise');
  28949. }
  28950. this.rangeController.removeAllCellRanges();
  28951. };
  28952. GridApi.prototype.undoCellEditing = function () {
  28953. this.undoRedoService.undo();
  28954. };
  28955. GridApi.prototype.redoCellEditing = function () {
  28956. this.undoRedoService.redo();
  28957. };
  28958. GridApi.prototype.getChartModels = function () {
  28959. if (ModuleRegistry.assertRegistered(exports.ModuleNames.RangeSelectionModule, 'api.getChartModels') &&
  28960. ModuleRegistry.assertRegistered(exports.ModuleNames.GridChartsModule, 'api.getChartModels')) {
  28961. return this.chartService.getChartModels();
  28962. }
  28963. };
  28964. GridApi.prototype.createRangeChart = function (params) {
  28965. if (ModuleRegistry.assertRegistered(exports.ModuleNames.RangeSelectionModule, 'api.createRangeChart') &&
  28966. ModuleRegistry.assertRegistered(exports.ModuleNames.GridChartsModule, 'api.createRangeChart')) {
  28967. return this.chartService.createRangeChart(params);
  28968. }
  28969. };
  28970. GridApi.prototype.createPivotChart = function (params) {
  28971. if (ModuleRegistry.assertRegistered(exports.ModuleNames.RangeSelectionModule, 'api.createPivotChart') &&
  28972. ModuleRegistry.assertRegistered(exports.ModuleNames.GridChartsModule, 'api.createPivotChart')) {
  28973. return this.chartService.createPivotChart(params);
  28974. }
  28975. };
  28976. GridApi.prototype.copySelectedRowsToClipboard = function (includeHeader, columnKeys) {
  28977. if (!this.clipboardService) {
  28978. console.warn('ag-Grid: clipboard is only available in ag-Grid Enterprise');
  28979. }
  28980. this.clipboardService.copySelectedRowsToClipboard(includeHeader, columnKeys);
  28981. };
  28982. GridApi.prototype.copySelectedRangeToClipboard = function (includeHeader) {
  28983. if (!this.clipboardService) {
  28984. console.warn('ag-Grid: clipboard is only available in ag-Grid Enterprise');
  28985. }
  28986. this.clipboardService.copySelectedRangeToClipboard(includeHeader);
  28987. };
  28988. GridApi.prototype.copySelectedRangeDown = function () {
  28989. if (!this.clipboardService) {
  28990. console.warn('ag-Grid: clipboard is only available in ag-Grid Enterprise');
  28991. }
  28992. this.clipboardService.copyRangeDown();
  28993. };
  28994. GridApi.prototype.showColumnMenuAfterButtonClick = function (colKey, buttonElement) {
  28995. // use grid column so works with pivot mode
  28996. var column = this.columnController.getGridColumn(colKey);
  28997. this.menuFactory.showMenuAfterButtonClick(column, buttonElement);
  28998. };
  28999. GridApi.prototype.showColumnMenuAfterMouseClick = function (colKey, mouseEvent) {
  29000. // use grid column so works with pivot mode
  29001. var column = this.columnController.getGridColumn(colKey);
  29002. if (!column) {
  29003. column = this.columnController.getPrimaryColumn(colKey);
  29004. }
  29005. if (!column) {
  29006. console.error("ag-Grid: column '" + colKey + "' not found");
  29007. return;
  29008. }
  29009. this.menuFactory.showMenuAfterMouseEvent(column, mouseEvent);
  29010. };
  29011. GridApi.prototype.hidePopupMenu = function () {
  29012. // hide the context menu if in enterprise
  29013. if (this.contextMenuFactory) {
  29014. this.contextMenuFactory.hideActiveMenu();
  29015. }
  29016. // and hide the column menu always
  29017. this.menuFactory.hideActiveMenu();
  29018. };
  29019. GridApi.prototype.setPopupParent = function (ePopupParent) {
  29020. this.gridOptionsWrapper.setProperty(GridOptionsWrapper.PROP_POPUP_PARENT, ePopupParent);
  29021. };
  29022. GridApi.prototype.tabToNextCell = function () {
  29023. return this.rowRenderer.tabToNextCell(false);
  29024. };
  29025. GridApi.prototype.tabToPreviousCell = function () {
  29026. return this.rowRenderer.tabToNextCell(true);
  29027. };
  29028. GridApi.prototype.getCellRendererInstances = function (params) {
  29029. if (params === void 0) { params = {}; }
  29030. return this.rowRenderer.getCellRendererInstances(params);
  29031. };
  29032. GridApi.prototype.getCellEditorInstances = function (params) {
  29033. if (params === void 0) { params = {}; }
  29034. return this.rowRenderer.getCellEditorInstances(params);
  29035. };
  29036. GridApi.prototype.getEditingCells = function () {
  29037. return this.rowRenderer.getEditingCells();
  29038. };
  29039. GridApi.prototype.stopEditing = function (cancel) {
  29040. if (cancel === void 0) { cancel = false; }
  29041. this.rowRenderer.stopEditing(cancel);
  29042. };
  29043. GridApi.prototype.startEditingCell = function (params) {
  29044. var column = this.columnController.getGridColumn(params.colKey);
  29045. if (!column) {
  29046. console.warn("ag-Grid: no column found for " + params.colKey);
  29047. return;
  29048. }
  29049. var cellPosition = {
  29050. rowIndex: params.rowIndex,
  29051. rowPinned: params.rowPinned,
  29052. column: column
  29053. };
  29054. var notPinned = _.missing(params.rowPinned);
  29055. if (notPinned) {
  29056. this.gridPanel.ensureIndexVisible(params.rowIndex);
  29057. }
  29058. this.rowRenderer.startEditingCell(cellPosition, params.keyPress, params.charPress);
  29059. };
  29060. GridApi.prototype.addAggFunc = function (key, aggFunc) {
  29061. if (this.aggFuncService) {
  29062. this.aggFuncService.addAggFunc(key, aggFunc);
  29063. }
  29064. };
  29065. GridApi.prototype.addAggFuncs = function (aggFuncs) {
  29066. if (this.aggFuncService) {
  29067. this.aggFuncService.addAggFuncs(aggFuncs);
  29068. }
  29069. };
  29070. GridApi.prototype.clearAggFuncs = function () {
  29071. if (this.aggFuncService) {
  29072. this.aggFuncService.clear();
  29073. }
  29074. };
  29075. GridApi.prototype.applyTransaction = function (rowDataTransaction) {
  29076. var res = null;
  29077. if (this.clientSideRowModel) {
  29078. if (rowDataTransaction && rowDataTransaction.addIndex != null) {
  29079. var message_1 = 'ag-Grid: as of v23.1, transaction.addIndex is deprecated. If you want precision control of adding data, use immutableData instead';
  29080. _.doOnce(function () { return console.warn(message_1); }, 'transaction.addIndex deprecated');
  29081. }
  29082. res = this.clientSideRowModel.updateRowData(rowDataTransaction);
  29083. }
  29084. else if (this.infiniteRowModel) {
  29085. var message_2 = 'ag-Grid: as of v23.1, transactions for Infinite Row Model are deprecated. If you want to make updates to data in Infinite Row Models, then refresh the data.';
  29086. _.doOnce(function () { return console.warn(message_2); }, 'applyTransaction infiniteRowModel deprecated');
  29087. this.infiniteRowModel.updateRowData(rowDataTransaction);
  29088. }
  29089. else {
  29090. console.error('ag-Grid: updateRowData() only works with ClientSideRowModel and InfiniteRowModel.');
  29091. }
  29092. // refresh all the full width rows
  29093. this.rowRenderer.refreshFullWidthRows();
  29094. // do change detection for all present cells
  29095. if (!this.gridOptionsWrapper.isSuppressChangeDetection()) {
  29096. this.rowRenderer.refreshCells();
  29097. }
  29098. return res;
  29099. };
  29100. /** @deprecated */
  29101. GridApi.prototype.updateRowData = function (rowDataTransaction) {
  29102. var message = 'ag-Grid: as of v23.1, grid API updateRowData(transaction) is now called applyTransaction(transaction). updateRowData is deprecated and will be removed in a future major release.';
  29103. _.doOnce(function () { return console.warn(message); }, 'updateRowData deprecated');
  29104. return this.applyTransaction(rowDataTransaction);
  29105. };
  29106. GridApi.prototype.applyTransactionAsync = function (rowDataTransaction, callback) {
  29107. if (!this.clientSideRowModel) {
  29108. console.error('ag-Grid: api.applyTransactionAsync() only works with ClientSideRowModel.');
  29109. return;
  29110. }
  29111. this.clientSideRowModel.batchUpdateRowData(rowDataTransaction, callback);
  29112. };
  29113. /** @deprecated */
  29114. GridApi.prototype.batchUpdateRowData = function (rowDataTransaction, callback) {
  29115. var message = 'ag-Grid: as of v23.1, grid API batchUpdateRowData(transaction, callback) is now called applyTransactionAsync(transaction, callback). batchUpdateRowData is deprecated and will be removed in a future major release.';
  29116. _.doOnce(function () { return console.warn(message); }, 'batchUpdateRowData deprecated');
  29117. this.applyTransactionAsync(rowDataTransaction, callback);
  29118. };
  29119. GridApi.prototype.insertItemsAtIndex = function (index, items, skipRefresh) {
  29120. console.warn('ag-Grid: insertItemsAtIndex() is deprecated, use updateRowData(transaction) instead.');
  29121. this.updateRowData({ add: items, addIndex: index, update: null, remove: null });
  29122. };
  29123. GridApi.prototype.removeItems = function (rowNodes, skipRefresh) {
  29124. console.warn('ag-Grid: removeItems() is deprecated, use updateRowData(transaction) instead.');
  29125. var dataToRemove = rowNodes.map(function (rowNode) { return rowNode.data; });
  29126. this.updateRowData({ add: null, addIndex: null, update: null, remove: dataToRemove });
  29127. };
  29128. GridApi.prototype.addItems = function (items, skipRefresh) {
  29129. console.warn('ag-Grid: addItems() is deprecated, use updateRowData(transaction) instead.');
  29130. this.updateRowData({ add: items, addIndex: null, update: null, remove: null });
  29131. };
  29132. GridApi.prototype.refreshVirtualPageCache = function () {
  29133. console.warn('ag-Grid: refreshVirtualPageCache() is now called refreshInfiniteCache(), please call refreshInfiniteCache() instead');
  29134. this.refreshInfiniteCache();
  29135. };
  29136. GridApi.prototype.refreshInfinitePageCache = function () {
  29137. console.warn('ag-Grid: refreshInfinitePageCache() is now called refreshInfiniteCache(), please call refreshInfiniteCache() instead');
  29138. this.refreshInfiniteCache();
  29139. };
  29140. GridApi.prototype.refreshInfiniteCache = function () {
  29141. if (this.infiniteRowModel) {
  29142. this.infiniteRowModel.refreshCache();
  29143. }
  29144. else {
  29145. console.warn("ag-Grid: api.refreshInfiniteCache is only available when rowModelType='infinite'.");
  29146. }
  29147. };
  29148. GridApi.prototype.purgeVirtualPageCache = function () {
  29149. console.warn('ag-Grid: purgeVirtualPageCache() is now called purgeInfiniteCache(), please call purgeInfiniteCache() instead');
  29150. this.purgeInfinitePageCache();
  29151. };
  29152. GridApi.prototype.purgeInfinitePageCache = function () {
  29153. console.warn('ag-Grid: purgeInfinitePageCache() is now called purgeInfiniteCache(), please call purgeInfiniteCache() instead');
  29154. this.purgeInfiniteCache();
  29155. };
  29156. GridApi.prototype.purgeInfiniteCache = function () {
  29157. if (this.infiniteRowModel) {
  29158. this.infiniteRowModel.purgeCache();
  29159. }
  29160. else {
  29161. console.warn("ag-Grid: api.purgeInfiniteCache is only available when rowModelType='infinite'.");
  29162. }
  29163. };
  29164. /** @deprecated */
  29165. GridApi.prototype.purgeEnterpriseCache = function (route) {
  29166. console.warn("ag-grid: since version 18.x, api.purgeEnterpriseCache() should be replaced with api.purgeServerSideCache()");
  29167. this.purgeServerSideCache(route);
  29168. };
  29169. GridApi.prototype.purgeServerSideCache = function (route) {
  29170. if (this.serverSideRowModel) {
  29171. this.serverSideRowModel.purgeCache(route);
  29172. }
  29173. else {
  29174. console.warn("ag-Grid: api.purgeServerSideCache is only available when rowModelType='enterprise'.");
  29175. }
  29176. };
  29177. GridApi.prototype.getVirtualRowCount = function () {
  29178. console.warn('ag-Grid: getVirtualRowCount() is now called getInfiniteRowCount(), please call getInfiniteRowCount() instead');
  29179. return this.getInfiniteRowCount();
  29180. };
  29181. GridApi.prototype.getInfiniteRowCount = function () {
  29182. if (this.infiniteRowModel) {
  29183. return this.infiniteRowModel.getVirtualRowCount();
  29184. }
  29185. else {
  29186. console.warn("ag-Grid: api.getVirtualRowCount is only available when rowModelType='virtual'.");
  29187. }
  29188. };
  29189. GridApi.prototype.isMaxRowFound = function () {
  29190. if (this.infiniteRowModel) {
  29191. return this.infiniteRowModel.isMaxRowFound();
  29192. }
  29193. else {
  29194. console.warn("ag-Grid: api.isMaxRowFound is only available when rowModelType='virtual'.");
  29195. }
  29196. };
  29197. GridApi.prototype.setVirtualRowCount = function (rowCount, maxRowFound) {
  29198. console.warn('ag-Grid: setVirtualRowCount() is now called setInfiniteRowCount(), please call setInfiniteRowCount() instead');
  29199. this.setInfiniteRowCount(rowCount, maxRowFound);
  29200. };
  29201. GridApi.prototype.setInfiniteRowCount = function (rowCount, maxRowFound) {
  29202. if (this.infiniteRowModel) {
  29203. this.infiniteRowModel.setVirtualRowCount(rowCount, maxRowFound);
  29204. }
  29205. else {
  29206. console.warn("ag-Grid: api.setVirtualRowCount is only available when rowModelType='virtual'.");
  29207. }
  29208. };
  29209. GridApi.prototype.getVirtualPageState = function () {
  29210. console.warn('ag-Grid: getVirtualPageState() is now called getCacheBlockState(), please call getCacheBlockState() instead');
  29211. return this.getCacheBlockState();
  29212. };
  29213. GridApi.prototype.getInfinitePageState = function () {
  29214. console.warn('ag-Grid: getInfinitePageState() is now called getCacheBlockState(), please call getCacheBlockState() instead');
  29215. return this.getCacheBlockState();
  29216. };
  29217. GridApi.prototype.getCacheBlockState = function () {
  29218. if (this.infiniteRowModel) {
  29219. return this.infiniteRowModel.getBlockState();
  29220. }
  29221. else if (this.serverSideRowModel) {
  29222. return this.serverSideRowModel.getBlockState();
  29223. }
  29224. else {
  29225. console.warn("ag-Grid: api.getCacheBlockState() is only available when rowModelType='infinite' or rowModelType='serverSide'.");
  29226. }
  29227. };
  29228. GridApi.prototype.checkGridSize = function () {
  29229. this.gridPanel.setHeaderAndFloatingHeights();
  29230. };
  29231. GridApi.prototype.getFirstRenderedRow = function () {
  29232. console.warn('in ag-Grid v12, getFirstRenderedRow() was renamed to getFirstDisplayedRow()');
  29233. return this.getFirstDisplayedRow();
  29234. };
  29235. GridApi.prototype.getFirstDisplayedRow = function () {
  29236. return this.rowRenderer.getFirstVirtualRenderedRow();
  29237. };
  29238. GridApi.prototype.getLastRenderedRow = function () {
  29239. console.warn('in ag-Grid v12, getLastRenderedRow() was renamed to getLastDisplayedRow()');
  29240. return this.getLastDisplayedRow();
  29241. };
  29242. GridApi.prototype.getLastDisplayedRow = function () {
  29243. return this.rowRenderer.getLastVirtualRenderedRow();
  29244. };
  29245. GridApi.prototype.getDisplayedRowAtIndex = function (index) {
  29246. return this.rowModel.getRow(index);
  29247. };
  29248. GridApi.prototype.getDisplayedRowCount = function () {
  29249. return this.rowModel.getRowCount();
  29250. };
  29251. GridApi.prototype.paginationIsLastPageFound = function () {
  29252. return this.paginationProxy.isLastPageFound();
  29253. };
  29254. GridApi.prototype.paginationGetPageSize = function () {
  29255. return this.paginationProxy.getPageSize();
  29256. };
  29257. GridApi.prototype.paginationSetPageSize = function (size) {
  29258. this.gridOptionsWrapper.setProperty('paginationPageSize', size);
  29259. };
  29260. GridApi.prototype.paginationGetCurrentPage = function () {
  29261. return this.paginationProxy.getCurrentPage();
  29262. };
  29263. GridApi.prototype.paginationGetTotalPages = function () {
  29264. return this.paginationProxy.getTotalPages();
  29265. };
  29266. GridApi.prototype.paginationGetRowCount = function () {
  29267. return this.paginationProxy.getMasterRowCount();
  29268. };
  29269. GridApi.prototype.paginationGoToNextPage = function () {
  29270. this.paginationProxy.goToNextPage();
  29271. };
  29272. GridApi.prototype.paginationGoToPreviousPage = function () {
  29273. this.paginationProxy.goToPreviousPage();
  29274. };
  29275. GridApi.prototype.paginationGoToFirstPage = function () {
  29276. this.paginationProxy.goToFirstPage();
  29277. };
  29278. GridApi.prototype.paginationGoToLastPage = function () {
  29279. this.paginationProxy.goToLastPage();
  29280. };
  29281. GridApi.prototype.paginationGoToPage = function (page) {
  29282. this.paginationProxy.goToPage(page);
  29283. };
  29284. __decorate$10([
  29285. Optional('immutableService')
  29286. ], GridApi.prototype, "immutableService", void 0);
  29287. __decorate$10([
  29288. Optional('csvCreator')
  29289. ], GridApi.prototype, "csvCreator", void 0);
  29290. __decorate$10([
  29291. Optional('excelCreator')
  29292. ], GridApi.prototype, "excelCreator", void 0);
  29293. __decorate$10([
  29294. Autowired('rowRenderer')
  29295. ], GridApi.prototype, "rowRenderer", void 0);
  29296. __decorate$10([
  29297. Autowired('filterManager')
  29298. ], GridApi.prototype, "filterManager", void 0);
  29299. __decorate$10([
  29300. Autowired('columnController')
  29301. ], GridApi.prototype, "columnController", void 0);
  29302. __decorate$10([
  29303. Autowired('selectionController')
  29304. ], GridApi.prototype, "selectionController", void 0);
  29305. __decorate$10([
  29306. Autowired('gridOptionsWrapper')
  29307. ], GridApi.prototype, "gridOptionsWrapper", void 0);
  29308. __decorate$10([
  29309. Autowired('valueService')
  29310. ], GridApi.prototype, "valueService", void 0);
  29311. __decorate$10([
  29312. Autowired('alignedGridsService')
  29313. ], GridApi.prototype, "alignedGridsService", void 0);
  29314. __decorate$10([
  29315. Autowired('eventService')
  29316. ], GridApi.prototype, "eventService", void 0);
  29317. __decorate$10([
  29318. Autowired('pinnedRowModel')
  29319. ], GridApi.prototype, "pinnedRowModel", void 0);
  29320. __decorate$10([
  29321. Autowired('context')
  29322. ], GridApi.prototype, "context", void 0);
  29323. __decorate$10([
  29324. Autowired('rowModel')
  29325. ], GridApi.prototype, "rowModel", void 0);
  29326. __decorate$10([
  29327. Autowired('sortController')
  29328. ], GridApi.prototype, "sortController", void 0);
  29329. __decorate$10([
  29330. Autowired('paginationProxy')
  29331. ], GridApi.prototype, "paginationProxy", void 0);
  29332. __decorate$10([
  29333. Autowired('focusController')
  29334. ], GridApi.prototype, "focusController", void 0);
  29335. __decorate$10([
  29336. Autowired('dragAndDropService')
  29337. ], GridApi.prototype, "dragAndDropService", void 0);
  29338. __decorate$10([
  29339. Optional('rangeController')
  29340. ], GridApi.prototype, "rangeController", void 0);
  29341. __decorate$10([
  29342. Optional('clipboardService')
  29343. ], GridApi.prototype, "clipboardService", void 0);
  29344. __decorate$10([
  29345. Optional('aggFuncService')
  29346. ], GridApi.prototype, "aggFuncService", void 0);
  29347. __decorate$10([
  29348. Autowired('menuFactory')
  29349. ], GridApi.prototype, "menuFactory", void 0);
  29350. __decorate$10([
  29351. Optional('contextMenuFactory')
  29352. ], GridApi.prototype, "contextMenuFactory", void 0);
  29353. __decorate$10([
  29354. Autowired('cellRendererFactory')
  29355. ], GridApi.prototype, "cellRendererFactory", void 0);
  29356. __decorate$10([
  29357. Autowired('valueCache')
  29358. ], GridApi.prototype, "valueCache", void 0);
  29359. __decorate$10([
  29360. Autowired('animationFrameService')
  29361. ], GridApi.prototype, "animationFrameService", void 0);
  29362. __decorate$10([
  29363. Optional('statusBarService')
  29364. ], GridApi.prototype, "statusBarService", void 0);
  29365. __decorate$10([
  29366. Optional('chartService')
  29367. ], GridApi.prototype, "chartService", void 0);
  29368. __decorate$10([
  29369. Optional('undoRedoService')
  29370. ], GridApi.prototype, "undoRedoService", void 0);
  29371. __decorate$10([
  29372. PostConstruct
  29373. ], GridApi.prototype, "init", null);
  29374. GridApi = __decorate$10([
  29375. Bean('gridApi')
  29376. ], GridApi);
  29377. return GridApi;
  29378. }());
  29379. /**
  29380. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  29381. * @version v23.2.1
  29382. * @link http://www.ag-grid.com/
  29383. * @license MIT
  29384. */
  29385. var __extends$12 = (undefined && undefined.__extends) || (function () {
  29386. var extendStatics = function (d, b) {
  29387. extendStatics = Object.setPrototypeOf ||
  29388. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  29389. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  29390. return extendStatics(d, b);
  29391. };
  29392. return function (d, b) {
  29393. extendStatics(d, b);
  29394. function __() { this.constructor = d; }
  29395. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  29396. };
  29397. })();
  29398. var __decorate$11 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  29399. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  29400. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  29401. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  29402. return c > 3 && r && Object.defineProperty(target, key, r), r;
  29403. };
  29404. var __param$6 = (undefined && undefined.__param) || function (paramIndex, decorator) {
  29405. return function (target, key) { decorator(target, key, paramIndex); }
  29406. };
  29407. var ExpressionService = /** @class */ (function (_super) {
  29408. __extends$12(ExpressionService, _super);
  29409. function ExpressionService() {
  29410. var _this = _super !== null && _super.apply(this, arguments) || this;
  29411. _this.expressionToFunctionCache = {};
  29412. return _this;
  29413. }
  29414. ExpressionService.prototype.setBeans = function (loggerFactory) {
  29415. this.logger = loggerFactory.create('ExpressionService');
  29416. };
  29417. ExpressionService.prototype.evaluate = function (expressionOrFunc, params) {
  29418. if (typeof expressionOrFunc === 'function') {
  29419. // valueGetter is a function, so just call it
  29420. var func = expressionOrFunc;
  29421. return func(params);
  29422. }
  29423. else if (typeof expressionOrFunc === 'string') {
  29424. // valueGetter is an expression, so execute the expression
  29425. var expression = expressionOrFunc;
  29426. return this.evaluateExpression(expression, params);
  29427. }
  29428. else {
  29429. console.error('ag-Grid: value should be either a string or a function', expressionOrFunc);
  29430. }
  29431. };
  29432. ExpressionService.prototype.evaluateExpression = function (expression, params) {
  29433. try {
  29434. var javaScriptFunction = this.createExpressionFunction(expression);
  29435. // the params don't have all these values, rather we add every possible
  29436. // value a params can have, which makes whatever is in the params available.
  29437. var result = javaScriptFunction(params.value, params.context, params.oldValue, params.newValue, params.value, params.node, params.data, params.colDef, params.rowIndex, params.api, params.columnApi, params.getValue, params.column, params.columnGroup);
  29438. return result;
  29439. }
  29440. catch (e) {
  29441. // the expression failed, which can happen, as it's the client that
  29442. // provides the expression. so print a nice message
  29443. // tslint:disable-next-line
  29444. console.log('Processing of the expression failed');
  29445. // tslint:disable-next-line
  29446. console.log('Expression = ' + expression);
  29447. // tslint:disable-next-line
  29448. console.log('Params =', params);
  29449. // tslint:disable-next-line
  29450. console.log('Exception = ' + e);
  29451. return null;
  29452. }
  29453. };
  29454. ExpressionService.prototype.createExpressionFunction = function (expression) {
  29455. // check cache first
  29456. if (this.expressionToFunctionCache[expression]) {
  29457. return this.expressionToFunctionCache[expression];
  29458. }
  29459. // if not found in cache, return the function
  29460. var functionBody = this.createFunctionBody(expression);
  29461. var theFunction = new Function('x, ctx, oldValue, newValue, value, node, data, colDef, rowIndex, api, columnApi, getValue, column, columnGroup', functionBody);
  29462. // store in cache
  29463. this.expressionToFunctionCache[expression] = theFunction;
  29464. return theFunction;
  29465. };
  29466. ExpressionService.prototype.createFunctionBody = function (expression) {
  29467. // if the expression has the 'return' word in it, then use as is,
  29468. // if not, then wrap it with return and ';' to make a function
  29469. if (expression.indexOf('return') >= 0) {
  29470. return expression;
  29471. }
  29472. else {
  29473. return 'return ' + expression + ';';
  29474. }
  29475. };
  29476. __decorate$11([
  29477. __param$6(0, Qualifier('loggerFactory'))
  29478. ], ExpressionService.prototype, "setBeans", null);
  29479. ExpressionService = __decorate$11([
  29480. Bean('expressionService')
  29481. ], ExpressionService);
  29482. return ExpressionService;
  29483. }(BeanStub));
  29484. /**
  29485. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  29486. * @version v23.2.1
  29487. * @link http://www.ag-grid.com/
  29488. * @license MIT
  29489. */
  29490. var __extends$13 = (undefined && undefined.__extends) || (function () {
  29491. var extendStatics = function (d, b) {
  29492. extendStatics = Object.setPrototypeOf ||
  29493. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  29494. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  29495. return extendStatics(d, b);
  29496. };
  29497. return function (d, b) {
  29498. extendStatics(d, b);
  29499. function __() { this.constructor = d; }
  29500. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  29501. };
  29502. })();
  29503. var __decorate$12 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  29504. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  29505. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  29506. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  29507. return c > 3 && r && Object.defineProperty(target, key, r), r;
  29508. };
  29509. var TemplateService = /** @class */ (function (_super) {
  29510. __extends$13(TemplateService, _super);
  29511. function TemplateService() {
  29512. var _this = _super !== null && _super.apply(this, arguments) || this;
  29513. _this.templateCache = {};
  29514. _this.waitingCallbacks = {};
  29515. return _this;
  29516. }
  29517. // returns the template if it is loaded, or null if it is not loaded
  29518. // but will call the callback when it is loaded
  29519. TemplateService.prototype.getTemplate = function (url, callback) {
  29520. var templateFromCache = this.templateCache[url];
  29521. if (templateFromCache) {
  29522. return templateFromCache;
  29523. }
  29524. var callbackList = this.waitingCallbacks[url];
  29525. var that = this;
  29526. if (!callbackList) {
  29527. // first time this was called, so need a new list for callbacks
  29528. callbackList = [];
  29529. this.waitingCallbacks[url] = callbackList;
  29530. // and also need to do the http request
  29531. var client = new XMLHttpRequest();
  29532. client.onload = function () {
  29533. that.handleHttpResult(this, url);
  29534. };
  29535. client.open("GET", url);
  29536. client.send();
  29537. }
  29538. // add this callback
  29539. if (callback) {
  29540. callbackList.push(callback);
  29541. }
  29542. // caller needs to wait for template to load, so return null
  29543. return null;
  29544. };
  29545. TemplateService.prototype.handleHttpResult = function (httpResult, url) {
  29546. if (httpResult.status !== 200 || httpResult.response === null) {
  29547. console.warn("Unable to get template error " + httpResult.status + " - " + url);
  29548. return;
  29549. }
  29550. // response success, so process it
  29551. // in IE9 the response is in - responseText
  29552. this.templateCache[url] = httpResult.response || httpResult.responseText;
  29553. // inform all listeners that this is now in the cache
  29554. var callbacks = this.waitingCallbacks[url];
  29555. for (var i = 0; i < callbacks.length; i++) {
  29556. var callback = callbacks[i];
  29557. // we could pass the callback the response, however we know the client of this code
  29558. // is the cell renderer, and it passes the 'cellRefresh' method in as the callback
  29559. // which doesn't take any parameters.
  29560. callback();
  29561. }
  29562. if (this.$scope) {
  29563. var that_1 = this;
  29564. window.setTimeout(function () {
  29565. that_1.$scope.$apply();
  29566. }, 0);
  29567. }
  29568. };
  29569. __decorate$12([
  29570. Autowired('$scope')
  29571. ], TemplateService.prototype, "$scope", void 0);
  29572. TemplateService = __decorate$12([
  29573. Bean('templateService')
  29574. ], TemplateService);
  29575. return TemplateService;
  29576. }(BeanStub));
  29577. /**
  29578. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  29579. * @version v23.2.1
  29580. * @link http://www.ag-grid.com/
  29581. * @license MIT
  29582. */
  29583. var __extends$14 = (undefined && undefined.__extends) || (function () {
  29584. var extendStatics = function (d, b) {
  29585. extendStatics = Object.setPrototypeOf ||
  29586. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  29587. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  29588. return extendStatics(d, b);
  29589. };
  29590. return function (d, b) {
  29591. extendStatics(d, b);
  29592. function __() { this.constructor = d; }
  29593. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  29594. };
  29595. })();
  29596. var __decorate$13 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  29597. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  29598. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  29599. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  29600. return c > 3 && r && Object.defineProperty(target, key, r), r;
  29601. };
  29602. var PopupService = /** @class */ (function (_super) {
  29603. __extends$14(PopupService, _super);
  29604. function PopupService() {
  29605. var _this = _super !== null && _super.apply(this, arguments) || this;
  29606. _this.popupList = [];
  29607. return _this;
  29608. }
  29609. PopupService.prototype.init = function () {
  29610. var _this = this;
  29611. this.addManagedListener(this.eventService, Events.EVENT_KEYBOARD_FOCUS, function () {
  29612. _this.popupList.forEach(function (popup) {
  29613. _.addCssClass(popup.element, 'ag-keyboard-focus');
  29614. });
  29615. });
  29616. this.addManagedListener(this.eventService, Events.EVENT_MOUSE_FOCUS, function () {
  29617. _this.popupList.forEach(function (popup) {
  29618. _.removeCssClass(popup.element, 'ag-keyboard-focus');
  29619. });
  29620. });
  29621. };
  29622. PopupService.prototype.registerGridCore = function (gridCore) {
  29623. this.gridCore = gridCore;
  29624. };
  29625. PopupService.prototype.getPopupParent = function () {
  29626. var ePopupParent = this.gridOptionsWrapper.getPopupParent();
  29627. if (ePopupParent) {
  29628. return ePopupParent;
  29629. }
  29630. return this.gridCore.getRootGui();
  29631. };
  29632. PopupService.prototype.positionPopupForMenu = function (params) {
  29633. var sourceRect = params.eventSource.getBoundingClientRect();
  29634. var parentRect = this.getParentRect();
  29635. var y = this.keepYWithinBounds(params, sourceRect.top - parentRect.top);
  29636. var minWidth = (params.ePopup.clientWidth > 0) ? params.ePopup.clientWidth : 200;
  29637. params.ePopup.style.minWidth = minWidth + "px";
  29638. var widthOfParent = parentRect.right - parentRect.left;
  29639. var maxX = widthOfParent - minWidth;
  29640. // the x position of the popup depends on RTL or LTR. for normal cases, LTR, we put the child popup
  29641. // to the right, unless it doesn't fit and we then put it to the left. for RTL it's the other way around,
  29642. // we try place it first to the left, and then if not to the right.
  29643. var x;
  29644. if (this.gridOptionsWrapper.isEnableRtl()) {
  29645. // for RTL, try left first
  29646. x = xLeftPosition();
  29647. if (x < 0) {
  29648. x = xRightPosition();
  29649. }
  29650. if (x > maxX) {
  29651. x = 0;
  29652. }
  29653. }
  29654. else {
  29655. // for LTR, try right first
  29656. x = xRightPosition();
  29657. if (x > maxX) {
  29658. x = xLeftPosition();
  29659. }
  29660. if (x < 0) {
  29661. x = 0;
  29662. }
  29663. }
  29664. params.ePopup.style.left = x + "px";
  29665. params.ePopup.style.top = y + "px";
  29666. function xRightPosition() {
  29667. return sourceRect.right - parentRect.left - 2;
  29668. }
  29669. function xLeftPosition() {
  29670. return sourceRect.left - parentRect.left - minWidth;
  29671. }
  29672. };
  29673. PopupService.prototype.positionPopupUnderMouseEvent = function (params) {
  29674. var _a = this.calculatePointerAlign(params.mouseEvent), x = _a.x, y = _a.y;
  29675. var ePopup = params.ePopup, nudgeX = params.nudgeX, nudgeY = params.nudgeY;
  29676. this.positionPopup({
  29677. ePopup: ePopup,
  29678. x: x,
  29679. y: y,
  29680. nudgeX: nudgeX,
  29681. nudgeY: nudgeY,
  29682. keepWithinBounds: true
  29683. });
  29684. this.callPostProcessPopup(params.type, params.ePopup, null, params.mouseEvent, params.column, params.rowNode);
  29685. };
  29686. PopupService.prototype.calculatePointerAlign = function (e) {
  29687. var parentRect = this.getParentRect();
  29688. return {
  29689. x: e.clientX - parentRect.left,
  29690. y: e.clientY - parentRect.top
  29691. };
  29692. };
  29693. PopupService.prototype.positionPopupUnderComponent = function (params) {
  29694. var sourceRect = params.eventSource.getBoundingClientRect();
  29695. var alignSide = params.alignSide || 'left';
  29696. var parentRect = this.getParentRect();
  29697. var x = sourceRect.left - parentRect.left;
  29698. if (alignSide === 'right') {
  29699. x -= (params.ePopup.offsetWidth - sourceRect.width);
  29700. }
  29701. this.positionPopup({
  29702. ePopup: params.ePopup,
  29703. minWidth: params.minWidth,
  29704. minHeight: params.minHeight,
  29705. nudgeX: params.nudgeX,
  29706. nudgeY: params.nudgeY,
  29707. x: x,
  29708. y: sourceRect.top - parentRect.top + sourceRect.height,
  29709. keepWithinBounds: params.keepWithinBounds
  29710. });
  29711. this.callPostProcessPopup(params.type, params.ePopup, params.eventSource, null, params.column, params.rowNode);
  29712. };
  29713. PopupService.prototype.positionPopupOverComponent = function (params) {
  29714. var sourceRect = params.eventSource.getBoundingClientRect();
  29715. var parentRect = this.getParentRect();
  29716. this.positionPopup({
  29717. ePopup: params.ePopup,
  29718. minWidth: params.minWidth,
  29719. nudgeX: params.nudgeX,
  29720. nudgeY: params.nudgeY,
  29721. x: sourceRect.left - parentRect.left,
  29722. y: sourceRect.top - parentRect.top,
  29723. keepWithinBounds: params.keepWithinBounds
  29724. });
  29725. this.callPostProcessPopup(params.type, params.ePopup, params.eventSource, null, params.column, params.rowNode);
  29726. };
  29727. PopupService.prototype.callPostProcessPopup = function (type, ePopup, eventSource, mouseEvent, column, rowNode) {
  29728. var callback = this.gridOptionsWrapper.getPostProcessPopupFunc();
  29729. if (callback) {
  29730. var params = {
  29731. column: column,
  29732. rowNode: rowNode,
  29733. ePopup: ePopup,
  29734. type: type,
  29735. eventSource: eventSource,
  29736. mouseEvent: mouseEvent
  29737. };
  29738. callback(params);
  29739. }
  29740. };
  29741. PopupService.prototype.positionPopup = function (params) {
  29742. var x = params.x;
  29743. var y = params.y;
  29744. if (params.nudgeX) {
  29745. x += params.nudgeX;
  29746. }
  29747. if (params.nudgeY) {
  29748. y += params.nudgeY;
  29749. }
  29750. // if popup is overflowing to the bottom, move it up
  29751. if (params.keepWithinBounds) {
  29752. x = this.keepXWithinBounds(params, x);
  29753. y = this.keepYWithinBounds(params, y);
  29754. }
  29755. params.ePopup.style.left = x + "px";
  29756. params.ePopup.style.top = y + "px";
  29757. };
  29758. PopupService.prototype.getActivePopups = function () {
  29759. return this.popupList.map(function (popup) { return popup.element; });
  29760. };
  29761. PopupService.prototype.getParentRect = function () {
  29762. // subtract the popup parent borders, because popupParent.getBoundingClientRect
  29763. // returns the rect outside the borders, but the 0,0 coordinate for absolute
  29764. // positioning is inside the border, leading the popup to be off by the width
  29765. // of the border
  29766. var popupParent = this.getPopupParent();
  29767. var eDocument = this.gridOptionsWrapper.getDocument();
  29768. if (popupParent === eDocument.body) {
  29769. popupParent = eDocument.documentElement;
  29770. }
  29771. var style = getComputedStyle(popupParent);
  29772. var bounds = popupParent.getBoundingClientRect();
  29773. return {
  29774. top: bounds.top + parseFloat(style.borderTopWidth) || 0,
  29775. left: bounds.left + parseFloat(style.borderLeftWidth) || 0,
  29776. right: bounds.right + parseFloat(style.borderRightWidth) || 0,
  29777. bottom: bounds.bottom + parseFloat(style.borderBottomWidth) || 0,
  29778. };
  29779. };
  29780. PopupService.prototype.keepYWithinBounds = function (params, y) {
  29781. var eDocument = this.gridOptionsWrapper.getDocument();
  29782. var docElement = eDocument.documentElement;
  29783. var popupParent = this.getPopupParent();
  29784. var parentRect = popupParent.getBoundingClientRect();
  29785. var documentRect = eDocument.documentElement.getBoundingClientRect();
  29786. var isBody = popupParent === eDocument.body;
  29787. var minHeight = Math.min(200, parentRect.height);
  29788. var diff = 0;
  29789. if (params.minHeight && params.minHeight < minHeight) {
  29790. minHeight = params.minHeight;
  29791. }
  29792. else if (params.ePopup.offsetHeight > 0) {
  29793. minHeight = params.ePopup.clientHeight;
  29794. diff = _.getAbsoluteHeight(params.ePopup) - minHeight;
  29795. }
  29796. var heightOfParent = isBody ? (_.getAbsoluteHeight(docElement) + docElement.scrollTop) : parentRect.height;
  29797. if (isBody) {
  29798. heightOfParent -= Math.abs(documentRect.top - parentRect.top);
  29799. }
  29800. var maxY = heightOfParent - minHeight - diff;
  29801. return Math.min(Math.max(y, 0), Math.abs(maxY));
  29802. };
  29803. PopupService.prototype.keepXWithinBounds = function (params, x) {
  29804. var eDocument = this.gridOptionsWrapper.getDocument();
  29805. var docElement = eDocument.documentElement;
  29806. var popupParent = this.getPopupParent();
  29807. var parentRect = popupParent.getBoundingClientRect();
  29808. var documentRect = eDocument.documentElement.getBoundingClientRect();
  29809. var isBody = popupParent === eDocument.body;
  29810. var ePopup = params.ePopup;
  29811. var minWidth = Math.min(200, parentRect.width);
  29812. var diff = 0;
  29813. if (params.minWidth && params.minWidth < minWidth) {
  29814. minWidth = params.minWidth;
  29815. }
  29816. else if (ePopup.offsetWidth > 0) {
  29817. minWidth = ePopup.offsetWidth;
  29818. ePopup.style.minWidth = minWidth + "px";
  29819. diff = _.getAbsoluteWidth(ePopup) - minWidth;
  29820. }
  29821. var widthOfParent = isBody ? (_.getAbsoluteWidth(docElement) + docElement.scrollLeft) : parentRect.width;
  29822. if (isBody) {
  29823. widthOfParent -= Math.abs(documentRect.left - parentRect.left);
  29824. }
  29825. var maxX = widthOfParent - minWidth - diff;
  29826. return Math.min(Math.max(x, 0), Math.abs(maxX));
  29827. };
  29828. // adds an element to a div, but also listens to background checking for clicks,
  29829. // so that when the background is clicked, the child is removed again, giving
  29830. // a model look to popups.
  29831. PopupService.prototype.addAsModalPopup = function (eChild, closeOnEsc, closedCallback, click) {
  29832. return this.addPopup(true, eChild, closeOnEsc, closedCallback, click);
  29833. };
  29834. PopupService.prototype.addPopup = function (modal, eChild, closeOnEsc, closedCallback, click, alwaysOnTop) {
  29835. var _this = this;
  29836. var eDocument = this.gridOptionsWrapper.getDocument();
  29837. if (!eDocument) {
  29838. console.warn('ag-grid: could not find the document, document is empty');
  29839. return function () { };
  29840. }
  29841. var pos = _.findIndex(this.popupList, function (popup) { return popup.element === eChild; });
  29842. if (pos !== -1) {
  29843. var popup = this.popupList[pos];
  29844. return popup.hideFunc;
  29845. }
  29846. var ePopupParent = this.getPopupParent();
  29847. // for angular specifically, but shouldn't cause an issue with js or other fw's
  29848. // https://github.com/angular/angular/issues/8563
  29849. ePopupParent.appendChild(eChild);
  29850. eChild.style.top = '0px';
  29851. eChild.style.left = '0px';
  29852. // add env CSS class to child, in case user provided a popup parent, which means
  29853. // theme class may be missing
  29854. var eWrapper = document.createElement('div');
  29855. var theme = this.environment.getTheme().theme;
  29856. if (theme) {
  29857. _.addCssClass(eWrapper, theme);
  29858. }
  29859. _.addCssClass(eWrapper, 'ag-popup');
  29860. _.addCssClass(eChild, this.gridOptionsWrapper.isEnableRtl() ? 'ag-rtl' : 'ag-ltr');
  29861. _.addCssClass(eChild, 'ag-popup-child');
  29862. eWrapper.appendChild(eChild);
  29863. ePopupParent.appendChild(eWrapper);
  29864. if (alwaysOnTop) {
  29865. this.setAlwaysOnTop(eWrapper, true);
  29866. }
  29867. else {
  29868. this.bringPopupToFront(eWrapper);
  29869. }
  29870. var popupHidden = false;
  29871. var hidePopupOnKeyboardEvent = function (event) {
  29872. var key = event.which || event.keyCode;
  29873. if (!eWrapper.contains(document.activeElement)) {
  29874. return;
  29875. }
  29876. switch (key) {
  29877. case Constants.KEY_ESCAPE:
  29878. hidePopup({ keyboardEvent: event });
  29879. }
  29880. };
  29881. var hidePopupOnMouseEvent = function (event) {
  29882. hidePopup({ mouseEvent: event });
  29883. };
  29884. var hidePopupOnTouchEvent = function (event) {
  29885. hidePopup({ touchEvent: event });
  29886. };
  29887. var hidePopup = function (params) {
  29888. if (params === void 0) { params = {}; }
  29889. var mouseEvent = params.mouseEvent, touchEvent = params.touchEvent, keyboardEvent = params.keyboardEvent;
  29890. if (
  29891. // we don't hide popup if the event was on the child, or any
  29892. // children of this child
  29893. _this.isEventFromCurrentPopup({ mouseEvent: mouseEvent, touchEvent: touchEvent }, eChild) ||
  29894. // if the event to close is actually the open event, then ignore it
  29895. _this.isEventSameChainAsOriginalEvent({ originalMouseEvent: click, mouseEvent: mouseEvent, touchEvent: touchEvent }) ||
  29896. // this method should only be called once. the client can have different
  29897. // paths, each one wanting to close, so this method may be called multiple times.
  29898. popupHidden) {
  29899. return;
  29900. }
  29901. popupHidden = true;
  29902. ePopupParent.removeChild(eWrapper);
  29903. eDocument.removeEventListener('keydown', hidePopupOnKeyboardEvent);
  29904. eDocument.removeEventListener('mousedown', hidePopupOnMouseEvent);
  29905. eDocument.removeEventListener('touchstart', hidePopupOnTouchEvent);
  29906. eDocument.removeEventListener('contextmenu', hidePopupOnMouseEvent);
  29907. _this.eventService.removeEventListener(Events.EVENT_DRAG_STARTED, hidePopupOnMouseEvent);
  29908. if (closedCallback) {
  29909. closedCallback(mouseEvent || touchEvent || keyboardEvent);
  29910. }
  29911. _this.popupList = _this.popupList.filter(function (popup) { return popup.element !== eChild; });
  29912. };
  29913. // if we add these listeners now, then the current mouse
  29914. // click will be included, which we don't want
  29915. window.setTimeout(function () {
  29916. if (closeOnEsc) {
  29917. eDocument.addEventListener('keydown', hidePopupOnKeyboardEvent);
  29918. }
  29919. if (modal) {
  29920. eDocument.addEventListener('mousedown', hidePopupOnMouseEvent);
  29921. _this.eventService.addEventListener(Events.EVENT_DRAG_STARTED, hidePopupOnMouseEvent);
  29922. eDocument.addEventListener('touchstart', hidePopupOnTouchEvent);
  29923. eDocument.addEventListener('contextmenu', hidePopupOnMouseEvent);
  29924. }
  29925. }, 0);
  29926. this.popupList.push({
  29927. element: eChild,
  29928. hideFunc: hidePopup
  29929. });
  29930. return hidePopup;
  29931. };
  29932. PopupService.prototype.isEventFromCurrentPopup = function (params, target) {
  29933. var mouseEvent = params.mouseEvent, touchEvent = params.touchEvent;
  29934. var event = mouseEvent ? mouseEvent : touchEvent;
  29935. if (!event) {
  29936. return false;
  29937. }
  29938. var indexOfThisChild = _.findIndex(this.popupList, function (popup) { return popup.element === target; });
  29939. if (indexOfThisChild === -1) {
  29940. return false;
  29941. }
  29942. for (var i = indexOfThisChild; i < this.popupList.length; i++) {
  29943. var popup = this.popupList[i];
  29944. if (_.isElementInEventPath(popup.element, event)) {
  29945. return true;
  29946. }
  29947. }
  29948. // if the user did not write their own Custom Element to be rendered as popup
  29949. // and this component has an additional popup element, they should have the
  29950. // `ag-custom-component-popup` class to be detected as part of the Custom Component
  29951. return this.isElementWithinCustomPopup(event.target);
  29952. };
  29953. PopupService.prototype.isElementWithinCustomPopup = function (el) {
  29954. if (!this.popupList.length) {
  29955. return false;
  29956. }
  29957. while (el && el !== document.body) {
  29958. if (el.classList.contains('ag-custom-component-popup') || el.parentElement === null) {
  29959. return true;
  29960. }
  29961. el = el.parentElement;
  29962. }
  29963. return false;
  29964. };
  29965. // in some browsers, the context menu event can be fired before the click event, which means
  29966. // the context menu event could open the popup, but then the click event closes it straight away.
  29967. PopupService.prototype.isEventSameChainAsOriginalEvent = function (params) {
  29968. var originalMouseEvent = params.originalMouseEvent, mouseEvent = params.mouseEvent, touchEvent = params.touchEvent;
  29969. // we check the coordinates of the event, to see if it's the same event. there is a 1 / 1000 chance that
  29970. // the event is a different event, however that is an edge case that is not very relevant (the user clicking
  29971. // twice on the same location isn't a normal path).
  29972. // event could be mouse event or touch event.
  29973. var mouseEventOrTouch = null;
  29974. if (mouseEvent) {
  29975. // mouse event can be used direction, it has coordinates
  29976. mouseEventOrTouch = mouseEvent;
  29977. }
  29978. else if (touchEvent) {
  29979. // touch event doesn't have coordinates, need it's touch object
  29980. mouseEventOrTouch = touchEvent.touches[0];
  29981. }
  29982. if (mouseEventOrTouch && originalMouseEvent) {
  29983. // for x, allow 4px margin, to cover iPads, where touch (which opens menu) is followed
  29984. // by browser click (when you finger up, touch is interrupted as click in browser)
  29985. var screenX_1 = mouseEvent ? mouseEvent.screenX : 0;
  29986. var screenY_1 = mouseEvent ? mouseEvent.screenY : 0;
  29987. var xMatch = Math.abs(originalMouseEvent.screenX - screenX_1) < 5;
  29988. var yMatch = Math.abs(originalMouseEvent.screenY - screenY_1) < 5;
  29989. if (xMatch && yMatch) {
  29990. return true;
  29991. }
  29992. }
  29993. return false;
  29994. };
  29995. PopupService.prototype.getWrapper = function (ePopup) {
  29996. while (!_.containsClass(ePopup, 'ag-popup') && ePopup.parentElement) {
  29997. ePopup = ePopup.parentElement;
  29998. }
  29999. return _.containsClass(ePopup, 'ag-popup') ? ePopup : null;
  30000. };
  30001. PopupService.prototype.setAlwaysOnTop = function (ePopup, alwaysOnTop) {
  30002. var eWrapper = this.getWrapper(ePopup);
  30003. if (!eWrapper) {
  30004. return;
  30005. }
  30006. _.addOrRemoveCssClass(eWrapper, 'ag-always-on-top', !!alwaysOnTop);
  30007. if (alwaysOnTop) {
  30008. this.bringPopupToFront(eWrapper);
  30009. }
  30010. };
  30011. PopupService.prototype.bringPopupToFront = function (ePopup) {
  30012. var parent = this.getPopupParent();
  30013. var popupList = Array.prototype.slice.call(parent.querySelectorAll('.ag-popup'));
  30014. var popupLen = popupList.length;
  30015. var alwaysOnTopList = Array.prototype.slice.call(parent.querySelectorAll('.ag-popup.ag-always-on-top'));
  30016. var onTopLength = alwaysOnTopList.length;
  30017. var eWrapper = this.getWrapper(ePopup);
  30018. if (!eWrapper || popupLen <= 1 || !parent.contains(ePopup)) {
  30019. return;
  30020. }
  30021. var pos = popupList.indexOf(eWrapper);
  30022. if (onTopLength) {
  30023. var isPopupAlwaysOnTop = _.containsClass(eWrapper, 'ag-always-on-top');
  30024. if (isPopupAlwaysOnTop) {
  30025. if (pos !== popupLen - 1) {
  30026. _.last(alwaysOnTopList).insertAdjacentElement('afterend', eWrapper);
  30027. }
  30028. }
  30029. else if (pos !== popupLen - onTopLength - 1) {
  30030. alwaysOnTopList[0].insertAdjacentElement('beforebegin', eWrapper);
  30031. }
  30032. }
  30033. else if (pos !== popupLen - 1) {
  30034. _.last(popupList).insertAdjacentElement('afterend', eWrapper);
  30035. }
  30036. var params = {
  30037. type: 'popupToFront',
  30038. api: this.gridOptionsWrapper.getApi(),
  30039. columnApi: this.gridOptionsWrapper.getColumnApi(),
  30040. eWrapper: eWrapper
  30041. };
  30042. this.eventService.dispatchEvent(params);
  30043. };
  30044. __decorate$13([
  30045. Autowired('gridOptionsWrapper')
  30046. ], PopupService.prototype, "gridOptionsWrapper", void 0);
  30047. __decorate$13([
  30048. Autowired('environment')
  30049. ], PopupService.prototype, "environment", void 0);
  30050. __decorate$13([
  30051. PostConstruct
  30052. ], PopupService.prototype, "init", null);
  30053. PopupService = __decorate$13([
  30054. Bean('popupService')
  30055. ], PopupService);
  30056. return PopupService;
  30057. }(BeanStub));
  30058. /**
  30059. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  30060. * @version v23.2.1
  30061. * @link http://www.ag-grid.com/
  30062. * @license MIT
  30063. */
  30064. var __extends$15 = (undefined && undefined.__extends) || (function () {
  30065. var extendStatics = function (d, b) {
  30066. extendStatics = Object.setPrototypeOf ||
  30067. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  30068. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  30069. return extendStatics(d, b);
  30070. };
  30071. return function (d, b) {
  30072. extendStatics(d, b);
  30073. function __() { this.constructor = d; }
  30074. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  30075. };
  30076. })();
  30077. var __decorate$14 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  30078. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  30079. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  30080. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  30081. return c > 3 && r && Object.defineProperty(target, key, r), r;
  30082. };
  30083. var __param$7 = (undefined && undefined.__param) || function (paramIndex, decorator) {
  30084. return function (target, key) { decorator(target, key, paramIndex); }
  30085. };
  30086. var LoggerFactory = /** @class */ (function (_super) {
  30087. __extends$15(LoggerFactory, _super);
  30088. function LoggerFactory() {
  30089. return _super !== null && _super.apply(this, arguments) || this;
  30090. }
  30091. LoggerFactory.prototype.setBeans = function (gridOptionsWrapper) {
  30092. this.logging = gridOptionsWrapper.isDebug();
  30093. };
  30094. LoggerFactory.prototype.create = function (name) {
  30095. return new Logger(name, this.isLogging.bind(this));
  30096. };
  30097. LoggerFactory.prototype.isLogging = function () {
  30098. return this.logging;
  30099. };
  30100. __decorate$14([
  30101. __param$7(0, Qualifier('gridOptionsWrapper'))
  30102. ], LoggerFactory.prototype, "setBeans", null);
  30103. LoggerFactory = __decorate$14([
  30104. Bean('loggerFactory')
  30105. ], LoggerFactory);
  30106. return LoggerFactory;
  30107. }(BeanStub));
  30108. var Logger = /** @class */ (function () {
  30109. function Logger(name, isLoggingFunc) {
  30110. this.name = name;
  30111. this.isLoggingFunc = isLoggingFunc;
  30112. }
  30113. Logger.prototype.isLogging = function () {
  30114. return this.isLoggingFunc();
  30115. };
  30116. Logger.prototype.log = function (message) {
  30117. if (this.isLoggingFunc()) {
  30118. // tslint:disable-next-line
  30119. console.log('ag-Grid.' + this.name + ': ' + message);
  30120. }
  30121. };
  30122. return Logger;
  30123. }());
  30124. /**
  30125. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  30126. * @version v23.2.1
  30127. * @link http://www.ag-grid.com/
  30128. * @license MIT
  30129. */
  30130. var __extends$16 = (undefined && undefined.__extends) || (function () {
  30131. var extendStatics = function (d, b) {
  30132. extendStatics = Object.setPrototypeOf ||
  30133. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  30134. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  30135. return extendStatics(d, b);
  30136. };
  30137. return function (d, b) {
  30138. extendStatics(d, b);
  30139. function __() { this.constructor = d; }
  30140. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  30141. };
  30142. })();
  30143. var __decorate$15 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  30144. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  30145. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  30146. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  30147. return c > 3 && r && Object.defineProperty(target, key, r), r;
  30148. };
  30149. var AutoWidthCalculator = /** @class */ (function (_super) {
  30150. __extends$16(AutoWidthCalculator, _super);
  30151. function AutoWidthCalculator() {
  30152. return _super !== null && _super.apply(this, arguments) || this;
  30153. }
  30154. AutoWidthCalculator.prototype.registerGridComp = function (gridPanel) {
  30155. this.gridPanel = gridPanel;
  30156. };
  30157. AutoWidthCalculator.prototype.registerHeaderRootComp = function (headerRootComp) {
  30158. this.headerRootComp = headerRootComp;
  30159. };
  30160. // this is the trick: we create a dummy container and clone all the cells
  30161. // into the dummy, then check the dummy's width. then destroy the dummy
  30162. // as we don't need it any more.
  30163. // drawback: only the cells visible on the screen are considered
  30164. AutoWidthCalculator.prototype.getPreferredWidthForColumn = function (column, skipHeader) {
  30165. var eHeaderCell = this.getHeaderCellForColumn(column);
  30166. // cell isn't visible
  30167. if (!eHeaderCell) {
  30168. return -1;
  30169. }
  30170. var eDummyContainer = document.createElement('span');
  30171. // position fixed, so it isn't restricted to the boundaries of the parent
  30172. eDummyContainer.style.position = 'fixed';
  30173. // we put the dummy into the body container, so it will inherit all the
  30174. // css styles that the real cells are inheriting
  30175. var eBodyContainer = this.gridPanel.getCenterContainer();
  30176. eBodyContainer.appendChild(eDummyContainer);
  30177. // get all the cells that are currently displayed (this only brings back
  30178. // rendered cells, rows not rendered due to row visualisation will not be here)
  30179. this.putRowCellsIntoDummyContainer(column, eDummyContainer);
  30180. if (!skipHeader) {
  30181. // we only consider the lowest level cell, not the group cell. in 99% of the time, this
  30182. // will be enough. if we consider groups, then it gets too complicated for what it's worth,
  30183. // as the groups can span columns and this class only considers one column at a time.
  30184. this.cloneItemIntoDummy(eHeaderCell, eDummyContainer);
  30185. }
  30186. // at this point, all the clones are lined up vertically with natural widths. the dummy
  30187. // container will have a width wide enough just to fit the largest.
  30188. var dummyContainerWidth = eDummyContainer.offsetWidth;
  30189. // we are finished with the dummy container, so get rid of it
  30190. eBodyContainer.removeChild(eDummyContainer);
  30191. // we add padding as I found sometimes the gui still put '...' after some of the texts. so the
  30192. // user can configure the grid to add a few more pixels after the calculated width
  30193. var autoSizePadding = this.gridOptionsWrapper.getAutoSizePadding();
  30194. return dummyContainerWidth + autoSizePadding;
  30195. };
  30196. AutoWidthCalculator.prototype.getHeaderCellForColumn = function (column) {
  30197. var comp = null;
  30198. // find the rendered header cell
  30199. this.headerRootComp.forEachHeaderElement(function (headerElement) {
  30200. if (headerElement instanceof HeaderWrapperComp) {
  30201. var headerWrapperComp = headerElement;
  30202. if (headerWrapperComp.getColumn() === column) {
  30203. comp = headerWrapperComp;
  30204. }
  30205. }
  30206. });
  30207. return comp ? comp.getGui() : null;
  30208. };
  30209. AutoWidthCalculator.prototype.putRowCellsIntoDummyContainer = function (column, eDummyContainer) {
  30210. var _this = this;
  30211. var eCells = this.rowRenderer.getAllCellsForColumn(column);
  30212. eCells.forEach(function (eCell) { return _this.cloneItemIntoDummy(eCell, eDummyContainer); });
  30213. };
  30214. AutoWidthCalculator.prototype.cloneItemIntoDummy = function (eCell, eDummyContainer) {
  30215. // make a deep clone of the cell
  30216. var eCellClone = eCell.cloneNode(true);
  30217. // the original has a fixed width, we remove this to allow the natural width based on content
  30218. eCellClone.style.width = '';
  30219. // the original has position = absolute, we need to remove this so it's positioned normally
  30220. eCellClone.style.position = 'static';
  30221. eCellClone.style.left = '';
  30222. // we put the cell into a containing div, as otherwise the cells would just line up
  30223. // on the same line, standard flow layout, by putting them into divs, they are laid
  30224. // out one per line
  30225. var eCloneParent = document.createElement('div');
  30226. if (_.containsClass(eCellClone, 'ag-header-cell')) {
  30227. _.addCssClass(eCloneParent, 'ag-header');
  30228. _.addCssClass(eCloneParent, 'ag-header-row');
  30229. eCloneParent.style.position = 'static';
  30230. }
  30231. // table-row, so that each cell is on a row. i also tried display='block', but this
  30232. // didn't work in IE
  30233. eCloneParent.style.display = 'table-row';
  30234. // the twig on the branch, the branch on the tree, the tree in the hole,
  30235. // the hole in the bog, the bog in the clone, the clone in the parent,
  30236. // the parent in the dummy, and the dummy down in the vall-e-ooo, OOOOOOOOO! Oh row the rattling bog....
  30237. eCloneParent.appendChild(eCellClone);
  30238. eDummyContainer.appendChild(eCloneParent);
  30239. };
  30240. __decorate$15([
  30241. Autowired('rowRenderer')
  30242. ], AutoWidthCalculator.prototype, "rowRenderer", void 0);
  30243. __decorate$15([
  30244. Autowired('gridOptionsWrapper')
  30245. ], AutoWidthCalculator.prototype, "gridOptionsWrapper", void 0);
  30246. AutoWidthCalculator = __decorate$15([
  30247. Bean('autoWidthCalculator')
  30248. ], AutoWidthCalculator);
  30249. return AutoWidthCalculator;
  30250. }(BeanStub));
  30251. /**
  30252. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  30253. * @version v23.2.1
  30254. * @link http://www.ag-grid.com/
  30255. * @license MIT
  30256. */
  30257. var __extends$17 = (undefined && undefined.__extends) || (function () {
  30258. var extendStatics = function (d, b) {
  30259. extendStatics = Object.setPrototypeOf ||
  30260. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  30261. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  30262. return extendStatics(d, b);
  30263. };
  30264. return function (d, b) {
  30265. extendStatics(d, b);
  30266. function __() { this.constructor = d; }
  30267. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  30268. };
  30269. })();
  30270. var __decorate$16 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  30271. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  30272. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  30273. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  30274. return c > 3 && r && Object.defineProperty(target, key, r), r;
  30275. };
  30276. var HorizontalResizeService = /** @class */ (function (_super) {
  30277. __extends$17(HorizontalResizeService, _super);
  30278. function HorizontalResizeService() {
  30279. return _super !== null && _super.apply(this, arguments) || this;
  30280. }
  30281. HorizontalResizeService.prototype.addResizeBar = function (params) {
  30282. var _this = this;
  30283. var dragSource = {
  30284. dragStartPixels: params.dragStartPixels || 0,
  30285. eElement: params.eResizeBar,
  30286. onDragStart: this.onDragStart.bind(this, params),
  30287. onDragStop: this.onDragStop.bind(this, params),
  30288. onDragging: this.onDragging.bind(this, params)
  30289. };
  30290. this.dragService.addDragSource(dragSource, true);
  30291. // we pass remove func back to the caller, so call can tell us when they
  30292. // are finished, and then we remove the listener from the drag source
  30293. var finishedWithResizeFunc = function () { return _this.dragService.removeDragSource(dragSource); };
  30294. return finishedWithResizeFunc;
  30295. };
  30296. HorizontalResizeService.prototype.onDragStart = function (params, mouseEvent) {
  30297. this.dragStartX = mouseEvent.clientX;
  30298. this.setResizeIcons();
  30299. var shiftKey = mouseEvent instanceof MouseEvent ? mouseEvent.shiftKey === true : false;
  30300. params.onResizeStart(shiftKey);
  30301. };
  30302. HorizontalResizeService.prototype.setResizeIcons = function () {
  30303. this.oldBodyCursor = this.eGridDiv.style.cursor;
  30304. this.oldMsUserSelect = this.eGridDiv.style.msUserSelect;
  30305. this.oldWebkitUserSelect = this.eGridDiv.style.webkitUserSelect;
  30306. // change the body cursor, so when drag moves out of the drag bar, the cursor is still 'resize' (or 'move'
  30307. this.eGridDiv.style.cursor = 'ew-resize';
  30308. // we don't want text selection outside the grid (otherwise it looks weird as text highlights when we move)
  30309. this.eGridDiv.style.msUserSelect = 'none';
  30310. this.eGridDiv.style.webkitUserSelect = 'none';
  30311. };
  30312. HorizontalResizeService.prototype.onDragStop = function (params, mouseEvent) {
  30313. params.onResizeEnd(this.resizeAmount);
  30314. this.resetIcons();
  30315. };
  30316. HorizontalResizeService.prototype.resetIcons = function () {
  30317. // we don't want text selection outside the grid (otherwise it looks weird as text highlights when we move)
  30318. this.eGridDiv.style.cursor = this.oldBodyCursor;
  30319. this.eGridDiv.style.msUserSelect = this.oldMsUserSelect;
  30320. this.eGridDiv.style.webkitUserSelect = this.oldWebkitUserSelect;
  30321. };
  30322. HorizontalResizeService.prototype.onDragging = function (params, mouseEvent) {
  30323. this.resizeAmount = mouseEvent.clientX - this.dragStartX;
  30324. params.onResizing(this.resizeAmount);
  30325. };
  30326. __decorate$16([
  30327. Autowired('dragService')
  30328. ], HorizontalResizeService.prototype, "dragService", void 0);
  30329. __decorate$16([
  30330. Autowired('eGridDiv')
  30331. ], HorizontalResizeService.prototype, "eGridDiv", void 0);
  30332. HorizontalResizeService = __decorate$16([
  30333. Bean('horizontalResizeService')
  30334. ], HorizontalResizeService);
  30335. return HorizontalResizeService;
  30336. }(BeanStub));
  30337. /**
  30338. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  30339. * @version v23.2.1
  30340. * @link http://www.ag-grid.com/
  30341. * @license MIT
  30342. */
  30343. var __extends$18 = (undefined && undefined.__extends) || (function () {
  30344. var extendStatics = function (d, b) {
  30345. extendStatics = Object.setPrototypeOf ||
  30346. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  30347. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  30348. return extendStatics(d, b);
  30349. };
  30350. return function (d, b) {
  30351. extendStatics(d, b);
  30352. function __() { this.constructor = d; }
  30353. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  30354. };
  30355. })();
  30356. var __decorate$17 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  30357. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  30358. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  30359. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  30360. return c > 3 && r && Object.defineProperty(target, key, r), r;
  30361. };
  30362. var GridCore = /** @class */ (function (_super) {
  30363. __extends$18(GridCore, _super);
  30364. function GridCore() {
  30365. return _super !== null && _super.apply(this, arguments) || this;
  30366. }
  30367. GridCore.prototype.postConstruct = function () {
  30368. var _this = this;
  30369. this.logger = this.loggerFactory.create('GridCore');
  30370. var template = this.createTemplate();
  30371. this.setTemplate(template);
  30372. // register with services that need grid core
  30373. [
  30374. this.gridApi,
  30375. this.rowRenderer,
  30376. this.popupService,
  30377. this.focusController
  30378. ].forEach(function (service) { return service.registerGridCore(_this); });
  30379. if (ModuleRegistry.isRegistered(exports.ModuleNames.ClipboardModule)) {
  30380. this.clipboardService.registerGridCore(this);
  30381. }
  30382. this.gridOptionsWrapper.addLayoutElement(this.getGui());
  30383. this.eGridDiv.appendChild(this.getGui());
  30384. this.addDestroyFunc(function () {
  30385. _this.eGridDiv.removeChild(_this.getGui());
  30386. });
  30387. // if using angular, watch for quickFilter changes
  30388. if (this.$scope) {
  30389. var quickFilterUnregisterFn = this.$scope.$watch(this.quickFilterOnScope, function (newFilter) { return _this.filterManager.setQuickFilter(newFilter); });
  30390. this.addDestroyFunc(quickFilterUnregisterFn);
  30391. }
  30392. // important to set rtl before doLayout, as setting the RTL class impacts the scroll position,
  30393. // which doLayout indirectly depends on
  30394. this.addRtlSupport();
  30395. this.logger.log('ready');
  30396. this.gridOptionsWrapper.addLayoutElement(this.eRootWrapperBody);
  30397. var unsubscribeFromResize = this.resizeObserverService.observeResize(this.eGridDiv, this.onGridSizeChanged.bind(this));
  30398. this.addDestroyFunc(function () { return unsubscribeFromResize(); });
  30399. var eGui = this.getGui();
  30400. this.addManagedListener(this.eventService, Events.EVENT_KEYBOARD_FOCUS, function () {
  30401. _.addCssClass(eGui, 'ag-keyboard-focus');
  30402. });
  30403. this.addManagedListener(this.eventService, Events.EVENT_MOUSE_FOCUS, function () {
  30404. _.removeCssClass(eGui, 'ag-keyboard-focus');
  30405. });
  30406. _super.prototype.postConstruct.call(this);
  30407. };
  30408. GridCore.prototype.getFocusableElement = function () {
  30409. return this.eRootWrapperBody;
  30410. };
  30411. GridCore.prototype.createTemplate = function () {
  30412. var sideBarModuleLoaded = ModuleRegistry.isRegistered(exports.ModuleNames.SideBarModule);
  30413. var statusBarModuleLoaded = ModuleRegistry.isRegistered(exports.ModuleNames.StatusBarModule);
  30414. var rowGroupingLoaded = ModuleRegistry.isRegistered(exports.ModuleNames.RowGroupingModule);
  30415. var enterpriseCoreLoaded = ModuleRegistry.isRegistered(exports.ModuleNames.EnterpriseCoreModule);
  30416. var dropZones = rowGroupingLoaded ? '<ag-grid-header-drop-zones></ag-grid-header-drop-zones>' : '';
  30417. var sideBar = sideBarModuleLoaded ? '<ag-side-bar ref="sideBar"></ag-side-bar>' : '';
  30418. var statusBar = statusBarModuleLoaded ? '<ag-status-bar ref="statusBar"></ag-status-bar>' : '';
  30419. var watermark = enterpriseCoreLoaded ? '<ag-watermark></ag-watermark>' : '';
  30420. var template = "<div ref=\"eRootWrapper\" class=\"ag-root-wrapper\">\n " + dropZones + "\n <div class=\"ag-root-wrapper-body\" ref=\"rootWrapperBody\">\n <ag-grid-comp ref=\"gridPanel\"></ag-grid-comp>\n " + sideBar + "\n </div>\n " + statusBar + "\n <ag-pagination></ag-pagination>\n " + watermark + "\n </div>";
  30421. return template;
  30422. };
  30423. GridCore.prototype.isFocusableContainer = function () {
  30424. return true;
  30425. };
  30426. GridCore.prototype.getFocusableContainers = function () {
  30427. var focusableContainers = [
  30428. this.gridPanel.getGui()
  30429. ];
  30430. if (this.sideBarComp) {
  30431. focusableContainers.push(this.sideBarComp.getGui());
  30432. }
  30433. return focusableContainers.filter(function (el) { return _.isVisible(el); });
  30434. };
  30435. GridCore.prototype.focusNextInnerContainer = function (backwards) {
  30436. var focusableContainers = this.getFocusableContainers();
  30437. var idxWithFocus = _.findIndex(focusableContainers, function (container) { return container.contains(document.activeElement); });
  30438. var nextIdx = idxWithFocus + (backwards ? -1 : 1);
  30439. if (nextIdx < 0 || nextIdx >= focusableContainers.length) {
  30440. return false;
  30441. }
  30442. if (nextIdx === 0) {
  30443. return this.focusGridHeader();
  30444. }
  30445. return this.focusController.focusFirstFocusableElement(focusableContainers[nextIdx]);
  30446. };
  30447. GridCore.prototype.focusInnerElement = function (fromBottom) {
  30448. var focusableContainers = this.getFocusableContainers();
  30449. if (fromBottom && focusableContainers.length > 1) {
  30450. return this.focusController.focusFirstFocusableElement(_.last(focusableContainers));
  30451. }
  30452. return this.focusGridHeader();
  30453. };
  30454. GridCore.prototype.focusGridHeader = function () {
  30455. var firstColumn = this.columnController.getAllDisplayedColumns()[0];
  30456. if (!firstColumn) {
  30457. return false;
  30458. }
  30459. if (firstColumn.getParent()) {
  30460. firstColumn = this.columnController.getColumnGroupAtLevel(firstColumn, 0);
  30461. }
  30462. this.focusController.focusHeaderPosition({
  30463. headerRowIndex: 0,
  30464. column: firstColumn
  30465. });
  30466. return true;
  30467. };
  30468. GridCore.prototype.onGridSizeChanged = function () {
  30469. var event = {
  30470. type: Events.EVENT_GRID_SIZE_CHANGED,
  30471. api: this.gridApi,
  30472. columnApi: this.columnApi,
  30473. clientWidth: this.eGridDiv.clientWidth,
  30474. clientHeight: this.eGridDiv.clientHeight
  30475. };
  30476. this.eventService.dispatchEvent(event);
  30477. };
  30478. GridCore.prototype.addRtlSupport = function () {
  30479. var cssClass = this.gridOptionsWrapper.isEnableRtl() ? 'ag-rtl' : 'ag-ltr';
  30480. _.addCssClass(this.getGui(), cssClass);
  30481. };
  30482. GridCore.prototype.getRootGui = function () {
  30483. return this.getGui();
  30484. };
  30485. GridCore.prototype.isSideBarVisible = function () {
  30486. if (!this.sideBarComp) {
  30487. return false;
  30488. }
  30489. return this.sideBarComp.isDisplayed();
  30490. };
  30491. GridCore.prototype.setSideBarVisible = function (show) {
  30492. if (!this.sideBarComp) {
  30493. if (show) {
  30494. console.warn('ag-Grid: sideBar is not loaded');
  30495. }
  30496. return;
  30497. }
  30498. this.sideBarComp.setDisplayed(show);
  30499. };
  30500. GridCore.prototype.setSideBarPosition = function (position) {
  30501. if (!this.sideBarComp) {
  30502. console.warn('ag-Grid: sideBar is not loaded');
  30503. return;
  30504. }
  30505. this.sideBarComp.setSideBarPosition(position);
  30506. };
  30507. GridCore.prototype.closeToolPanel = function () {
  30508. if (!this.sideBarComp) {
  30509. console.warn('ag-Grid: toolPanel is only available in ag-Grid Enterprise');
  30510. return;
  30511. }
  30512. this.sideBarComp.close();
  30513. };
  30514. GridCore.prototype.getSideBar = function () {
  30515. return this.gridOptions.sideBar;
  30516. };
  30517. GridCore.prototype.getToolPanelInstance = function (key) {
  30518. if (!this.sideBarComp) {
  30519. console.warn('ag-Grid: toolPanel is only available in ag-Grid Enterprise');
  30520. return;
  30521. }
  30522. return this.sideBarComp.getToolPanelInstance(key);
  30523. };
  30524. GridCore.prototype.refreshSideBar = function () {
  30525. if (this.sideBarComp) {
  30526. this.sideBarComp.refresh();
  30527. }
  30528. };
  30529. GridCore.prototype.setSideBar = function (def) {
  30530. if (!this.sideBarComp) {
  30531. return;
  30532. }
  30533. this.eRootWrapperBody.removeChild(this.sideBarComp.getGui());
  30534. this.gridOptions.sideBar = SideBarDefParser.parse(def);
  30535. this.sideBarComp.reset();
  30536. this.eRootWrapperBody.appendChild(this.sideBarComp.getGui());
  30537. };
  30538. GridCore.prototype.getOpenedToolPanel = function () {
  30539. if (!this.sideBarComp) {
  30540. return null;
  30541. }
  30542. return this.sideBarComp.openedItem();
  30543. };
  30544. GridCore.prototype.openToolPanel = function (key) {
  30545. if (!this.sideBarComp) {
  30546. console.warn('ag-Grid: toolPanel is only available in ag-Grid Enterprise');
  30547. return;
  30548. }
  30549. this.sideBarComp.openToolPanel(key);
  30550. };
  30551. GridCore.prototype.isToolPanelShowing = function () {
  30552. return this.sideBarComp.isToolPanelShowing();
  30553. };
  30554. GridCore.prototype.destroy = function () {
  30555. this.logger.log('Grid DOM removed');
  30556. _super.prototype.destroy.call(this);
  30557. };
  30558. // Valid values for position are bottom, middle and top
  30559. GridCore.prototype.ensureNodeVisible = function (comparator, position) {
  30560. if (position === void 0) { position = null; }
  30561. if (this.doingVirtualPaging) {
  30562. throw new Error('Cannot use ensureNodeVisible when doing virtual paging, as we cannot check rows that are not in memory');
  30563. }
  30564. // look for the node index we want to display
  30565. var rowCount = this.rowModel.getRowCount();
  30566. var comparatorIsAFunction = typeof comparator === 'function';
  30567. var indexToSelect = -1;
  30568. // go through all the nodes, find the one we want to show
  30569. for (var i = 0; i < rowCount; i++) {
  30570. var node = this.rowModel.getRow(i);
  30571. if (comparatorIsAFunction) {
  30572. if (comparator(node)) {
  30573. indexToSelect = i;
  30574. break;
  30575. }
  30576. }
  30577. else {
  30578. // check object equality against node and data
  30579. if (comparator === node || comparator === node.data) {
  30580. indexToSelect = i;
  30581. break;
  30582. }
  30583. }
  30584. }
  30585. if (indexToSelect >= 0) {
  30586. this.gridPanel.ensureIndexVisible(indexToSelect, position);
  30587. }
  30588. };
  30589. __decorate$17([
  30590. Autowired('gridOptions')
  30591. ], GridCore.prototype, "gridOptions", void 0);
  30592. __decorate$17([
  30593. Autowired('gridOptionsWrapper')
  30594. ], GridCore.prototype, "gridOptionsWrapper", void 0);
  30595. __decorate$17([
  30596. Autowired('rowModel')
  30597. ], GridCore.prototype, "rowModel", void 0);
  30598. __decorate$17([
  30599. Autowired('resizeObserverService')
  30600. ], GridCore.prototype, "resizeObserverService", void 0);
  30601. __decorate$17([
  30602. Autowired('rowRenderer')
  30603. ], GridCore.prototype, "rowRenderer", void 0);
  30604. __decorate$17([
  30605. Autowired('filterManager')
  30606. ], GridCore.prototype, "filterManager", void 0);
  30607. __decorate$17([
  30608. Autowired('eGridDiv')
  30609. ], GridCore.prototype, "eGridDiv", void 0);
  30610. __decorate$17([
  30611. Autowired('$scope')
  30612. ], GridCore.prototype, "$scope", void 0);
  30613. __decorate$17([
  30614. Autowired('quickFilterOnScope')
  30615. ], GridCore.prototype, "quickFilterOnScope", void 0);
  30616. __decorate$17([
  30617. Autowired('popupService')
  30618. ], GridCore.prototype, "popupService", void 0);
  30619. __decorate$17([
  30620. Autowired('columnController')
  30621. ], GridCore.prototype, "columnController", void 0);
  30622. __decorate$17([
  30623. Autowired('loggerFactory')
  30624. ], GridCore.prototype, "loggerFactory", void 0);
  30625. __decorate$17([
  30626. Autowired('columnApi')
  30627. ], GridCore.prototype, "columnApi", void 0);
  30628. __decorate$17([
  30629. Autowired('gridApi')
  30630. ], GridCore.prototype, "gridApi", void 0);
  30631. __decorate$17([
  30632. Optional('clipboardService')
  30633. ], GridCore.prototype, "clipboardService", void 0);
  30634. __decorate$17([
  30635. RefSelector('gridPanel')
  30636. ], GridCore.prototype, "gridPanel", void 0);
  30637. __decorate$17([
  30638. RefSelector('sideBar')
  30639. ], GridCore.prototype, "sideBarComp", void 0);
  30640. __decorate$17([
  30641. RefSelector('rootWrapperBody')
  30642. ], GridCore.prototype, "eRootWrapperBody", void 0);
  30643. return GridCore;
  30644. }(ManagedFocusComponent));
  30645. /**
  30646. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  30647. * @version v23.2.1
  30648. * @link http://www.ag-grid.com/
  30649. * @license MIT
  30650. */
  30651. var __extends$19 = (undefined && undefined.__extends) || (function () {
  30652. var extendStatics = function (d, b) {
  30653. extendStatics = Object.setPrototypeOf ||
  30654. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  30655. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  30656. return extendStatics(d, b);
  30657. };
  30658. return function (d, b) {
  30659. extendStatics(d, b);
  30660. function __() { this.constructor = d; }
  30661. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  30662. };
  30663. })();
  30664. var __decorate$18 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  30665. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  30666. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  30667. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  30668. return c > 3 && r && Object.defineProperty(target, key, r), r;
  30669. };
  30670. var StandardMenuFactory = /** @class */ (function (_super) {
  30671. __extends$19(StandardMenuFactory, _super);
  30672. function StandardMenuFactory() {
  30673. return _super !== null && _super.apply(this, arguments) || this;
  30674. }
  30675. StandardMenuFactory.prototype.hideActiveMenu = function () {
  30676. if (this.hidePopup) {
  30677. this.hidePopup();
  30678. }
  30679. };
  30680. StandardMenuFactory.prototype.showMenuAfterMouseEvent = function (column, mouseEvent) {
  30681. var _this = this;
  30682. this.showPopup(column, function (eMenu) {
  30683. _this.popupService.positionPopupUnderMouseEvent({
  30684. column: column,
  30685. type: 'columnMenu',
  30686. mouseEvent: mouseEvent,
  30687. ePopup: eMenu
  30688. });
  30689. }, mouseEvent.target);
  30690. };
  30691. StandardMenuFactory.prototype.showMenuAfterButtonClick = function (column, eventSource) {
  30692. var _this = this;
  30693. this.showPopup(column, function (eMenu) {
  30694. _this.popupService.positionPopupUnderComponent({
  30695. type: 'columnMenu',
  30696. eventSource: eventSource,
  30697. ePopup: eMenu,
  30698. keepWithinBounds: true,
  30699. column: column
  30700. });
  30701. }, eventSource);
  30702. };
  30703. StandardMenuFactory.prototype.showPopup = function (column, positionCallback, eventSource) {
  30704. var _this = this;
  30705. var filterWrapper = this.filterManager.getOrCreateFilterWrapper(column, 'COLUMN_MENU');
  30706. var eMenu = document.createElement('div');
  30707. _.addCssClass(eMenu, 'ag-menu');
  30708. this.tabListener = this.addManagedListener(eMenu, 'keydown', function (e) { return _this.trapFocusWithin(e, eMenu); });
  30709. filterWrapper.guiPromise.then(function (gui) { return eMenu.appendChild(gui); });
  30710. var hidePopup;
  30711. var bodyScrollListener = function (event) {
  30712. // if h scroll, popup is no longer over the column
  30713. if (event.direction === 'horizontal') {
  30714. hidePopup();
  30715. }
  30716. };
  30717. this.eventService.addEventListener('bodyScroll', bodyScrollListener);
  30718. var closedCallback = function (e) {
  30719. _this.eventService.removeEventListener('bodyScroll', bodyScrollListener);
  30720. column.setMenuVisible(false, 'contextMenu');
  30721. var isKeyboardEvent = e instanceof KeyboardEvent;
  30722. if (_this.tabListener) {
  30723. _this.tabListener = _this.tabListener();
  30724. }
  30725. if (isKeyboardEvent && eventSource && _.isVisible(eventSource)) {
  30726. var focusableEl = _this.focusController.findTabbableParent(eventSource);
  30727. if (focusableEl) {
  30728. focusableEl.focus();
  30729. }
  30730. }
  30731. };
  30732. // need to show filter before positioning, as only after filter
  30733. // is visible can we find out what the width of it is
  30734. hidePopup = this.popupService.addAsModalPopup(eMenu, true, closedCallback);
  30735. positionCallback(eMenu);
  30736. filterWrapper.filterPromise.then(function (filter) {
  30737. if (filter.afterGuiAttached) {
  30738. var params = {
  30739. hidePopup: hidePopup
  30740. };
  30741. filter.afterGuiAttached(params);
  30742. }
  30743. });
  30744. this.hidePopup = hidePopup;
  30745. column.setMenuVisible(true, 'contextMenu');
  30746. };
  30747. StandardMenuFactory.prototype.trapFocusWithin = function (e, menu) {
  30748. if (e.keyCode !== Constants.KEY_TAB) {
  30749. return;
  30750. }
  30751. if (this.focusController.findNextFocusableElement(menu, false, e.shiftKey)) {
  30752. return;
  30753. }
  30754. e.preventDefault();
  30755. if (e.shiftKey) {
  30756. this.focusController.focusLastFocusableElement(menu);
  30757. }
  30758. else {
  30759. this.focusController.focusFirstFocusableElement(menu);
  30760. }
  30761. };
  30762. StandardMenuFactory.prototype.isMenuEnabled = function (column) {
  30763. // for standard, we show menu if filter is enabled, and the menu is not suppressed
  30764. return column.isFilterAllowed();
  30765. };
  30766. __decorate$18([
  30767. Autowired('filterManager')
  30768. ], StandardMenuFactory.prototype, "filterManager", void 0);
  30769. __decorate$18([
  30770. Autowired('popupService')
  30771. ], StandardMenuFactory.prototype, "popupService", void 0);
  30772. __decorate$18([
  30773. Autowired('focusController')
  30774. ], StandardMenuFactory.prototype, "focusController", void 0);
  30775. StandardMenuFactory = __decorate$18([
  30776. Bean('menuFactory')
  30777. ], StandardMenuFactory);
  30778. return StandardMenuFactory;
  30779. }(BeanStub));
  30780. /**
  30781. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  30782. * @version v23.2.1
  30783. * @link http://www.ag-grid.com/
  30784. * @license MIT
  30785. */
  30786. var __extends$1a = (undefined && undefined.__extends) || (function () {
  30787. var extendStatics = function (d, b) {
  30788. extendStatics = Object.setPrototypeOf ||
  30789. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  30790. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  30791. return extendStatics(d, b);
  30792. };
  30793. return function (d, b) {
  30794. extendStatics(d, b);
  30795. function __() { this.constructor = d; }
  30796. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  30797. };
  30798. })();
  30799. var __decorate$19 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  30800. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  30801. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  30802. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  30803. return c > 3 && r && Object.defineProperty(target, key, r), r;
  30804. };
  30805. /** Adds drag listening onto an element. In ag-Grid this is used twice, first is resizing columns,
  30806. * second is moving the columns and column groups around (ie the 'drag' part of Drag and Drop. */
  30807. var DragService = /** @class */ (function (_super) {
  30808. __extends$1a(DragService, _super);
  30809. function DragService() {
  30810. var _this = _super !== null && _super.apply(this, arguments) || this;
  30811. _this.dragEndFunctions = [];
  30812. _this.dragSources = [];
  30813. return _this;
  30814. }
  30815. DragService.prototype.init = function () {
  30816. this.logger = this.loggerFactory.create('DragService');
  30817. };
  30818. DragService.prototype.removeAllListeners = function () {
  30819. this.dragSources.forEach(this.removeListener.bind(this));
  30820. this.dragSources.length = 0;
  30821. };
  30822. DragService.prototype.removeListener = function (dragSourceAndListener) {
  30823. var element = dragSourceAndListener.dragSource.eElement;
  30824. var mouseDownListener = dragSourceAndListener.mouseDownListener;
  30825. element.removeEventListener('mousedown', mouseDownListener);
  30826. // remove touch listener only if it exists
  30827. if (dragSourceAndListener.touchEnabled) {
  30828. var touchStartListener = dragSourceAndListener.touchStartListener;
  30829. element.removeEventListener('touchstart', touchStartListener, { passive: true });
  30830. }
  30831. };
  30832. DragService.prototype.removeDragSource = function (params) {
  30833. var dragSourceAndListener = _.find(this.dragSources, function (item) { return item.dragSource === params; });
  30834. if (!dragSourceAndListener) {
  30835. return;
  30836. }
  30837. this.removeListener(dragSourceAndListener);
  30838. _.removeFromArray(this.dragSources, dragSourceAndListener);
  30839. };
  30840. DragService.prototype.setNoSelectToBody = function (noSelect) {
  30841. var eDocument = this.gridOptionsWrapper.getDocument();
  30842. var eBody = eDocument.querySelector('body');
  30843. if (_.exists(eBody)) {
  30844. // when we drag the mouse in ag-Grid, this class gets added / removed from the body, so that
  30845. // the mouse isn't selecting text when dragging.
  30846. _.addOrRemoveCssClass(eBody, 'ag-unselectable', noSelect);
  30847. }
  30848. };
  30849. DragService.prototype.addDragSource = function (params, includeTouch) {
  30850. if (includeTouch === void 0) { includeTouch = false; }
  30851. var mouseListener = this.onMouseDown.bind(this, params);
  30852. params.eElement.addEventListener('mousedown', mouseListener);
  30853. var touchListener = null;
  30854. var suppressTouch = this.gridOptionsWrapper.isSuppressTouch();
  30855. if (includeTouch && !suppressTouch) {
  30856. touchListener = this.onTouchStart.bind(this, params);
  30857. params.eElement.addEventListener('touchstart', touchListener, { passive: false });
  30858. }
  30859. this.dragSources.push({
  30860. dragSource: params,
  30861. mouseDownListener: mouseListener,
  30862. touchStartListener: touchListener,
  30863. touchEnabled: includeTouch
  30864. });
  30865. };
  30866. // gets called whenever mouse down on any drag source
  30867. DragService.prototype.onTouchStart = function (params, touchEvent) {
  30868. var _this = this;
  30869. this.currentDragParams = params;
  30870. this.dragging = false;
  30871. var touch = touchEvent.touches[0];
  30872. this.touchLastTime = touch;
  30873. this.touchStart = touch;
  30874. if (touchEvent.cancelable) {
  30875. touchEvent.preventDefault();
  30876. }
  30877. var touchMoveEvent = function (e) { return _this.onTouchMove(e, params.eElement); };
  30878. var touchEndEvent = function (e) { return _this.onTouchUp(e, params.eElement); };
  30879. var target = params.eElement;
  30880. var events = [
  30881. { target: target, type: 'touchmove', listener: touchMoveEvent, options: { passive: true } },
  30882. { target: target, type: 'touchend', listener: touchEndEvent, options: { passive: true } },
  30883. { target: target, type: 'touchcancel', listener: touchEndEvent, options: { passive: true } }
  30884. ];
  30885. // temporally add these listeners, for the duration of the drag
  30886. this.addTemporaryEvents(events);
  30887. // see if we want to start dragging straight away
  30888. if (params.dragStartPixels === 0) {
  30889. this.onCommonMove(touch, this.touchStart, params.eElement);
  30890. }
  30891. };
  30892. // gets called whenever mouse down on any drag source
  30893. DragService.prototype.onMouseDown = function (params, mouseEvent) {
  30894. var _this = this;
  30895. var e = mouseEvent;
  30896. if (params.skipMouseEvent && params.skipMouseEvent(mouseEvent)) {
  30897. return;
  30898. }
  30899. // if there are two elements with parent / child relationship, and both are draggable,
  30900. // when we drag the child, we should NOT drag the parent. an example of this is row moving
  30901. // and range selection - row moving should get preference when use drags the rowDrag component.
  30902. if (e._alreadyProcessedByDragService) {
  30903. return;
  30904. }
  30905. e._alreadyProcessedByDragService = true;
  30906. // only interested in left button clicks
  30907. if (mouseEvent.button !== 0) {
  30908. return;
  30909. }
  30910. this.currentDragParams = params;
  30911. this.dragging = false;
  30912. this.mouseStartEvent = mouseEvent;
  30913. var eDocument = this.gridOptionsWrapper.getDocument();
  30914. this.setNoSelectToBody(true);
  30915. var mouseMoveEvent = function (e, el) { return _this.onMouseMove(e, params.eElement); };
  30916. var mouseUpEvent = function (e, el) { return _this.onMouseUp(e, params.eElement); };
  30917. var contextEvent = function (e) { return e.preventDefault(); };
  30918. var target = eDocument;
  30919. var events = [
  30920. { target: target, type: 'mousemove', listener: mouseMoveEvent },
  30921. { target: target, type: 'mouseup', listener: mouseUpEvent },
  30922. { target: target, type: 'contextmenu', listener: contextEvent }
  30923. ];
  30924. // temporally add these listeners, for the duration of the drag
  30925. this.addTemporaryEvents(events);
  30926. //see if we want to start dragging straight away
  30927. if (params.dragStartPixels === 0) {
  30928. this.onMouseMove(mouseEvent, params.eElement);
  30929. }
  30930. };
  30931. DragService.prototype.addTemporaryEvents = function (events) {
  30932. events.forEach(function (currentEvent) {
  30933. var target = currentEvent.target, type = currentEvent.type, listener = currentEvent.listener, options = currentEvent.options;
  30934. target.addEventListener(type, listener, options);
  30935. });
  30936. this.dragEndFunctions.push(function () {
  30937. events.forEach(function (currentEvent) {
  30938. var target = currentEvent.target, type = currentEvent.type, listener = currentEvent.listener, options = currentEvent.options;
  30939. target.removeEventListener(type, listener, options);
  30940. });
  30941. });
  30942. };
  30943. // returns true if the event is close to the original event by X pixels either vertically or horizontally.
  30944. // we only start dragging after X pixels so this allows us to know if we should start dragging yet.
  30945. DragService.prototype.isEventNearStartEvent = function (currentEvent, startEvent) {
  30946. // by default, we wait 4 pixels before starting the drag
  30947. var dragStartPixels = this.currentDragParams.dragStartPixels;
  30948. var requiredPixelDiff = _.exists(dragStartPixels) ? dragStartPixels : 4;
  30949. return _.areEventsNear(currentEvent, startEvent, requiredPixelDiff);
  30950. };
  30951. DragService.prototype.getFirstActiveTouch = function (touchList) {
  30952. for (var i = 0; i < touchList.length; i++) {
  30953. if (touchList[i].identifier === this.touchStart.identifier) {
  30954. return touchList[i];
  30955. }
  30956. }
  30957. return null;
  30958. };
  30959. DragService.prototype.onCommonMove = function (currentEvent, startEvent, el) {
  30960. if (!this.dragging) {
  30961. // if mouse hasn't travelled from the start position enough, do nothing
  30962. if (!this.dragging && this.isEventNearStartEvent(currentEvent, startEvent)) {
  30963. return;
  30964. }
  30965. this.dragging = true;
  30966. var event_1 = {
  30967. type: Events.EVENT_DRAG_STARTED,
  30968. api: this.gridApi,
  30969. columnApi: this.columnApi,
  30970. target: el
  30971. };
  30972. this.eventService.dispatchEvent(event_1);
  30973. this.currentDragParams.onDragStart(startEvent);
  30974. }
  30975. this.currentDragParams.onDragging(currentEvent);
  30976. };
  30977. DragService.prototype.onTouchMove = function (touchEvent, el) {
  30978. var touch = this.getFirstActiveTouch(touchEvent.touches);
  30979. if (!touch) {
  30980. return;
  30981. }
  30982. // this.___statusPanel.setInfoText(Math.random() + ' onTouchMove preventDefault stopPropagation');
  30983. // if we don't preview default, then the browser will try and do it's own touch stuff,
  30984. // like do 'back button' (chrome does this) or scroll the page (eg drag column could be confused
  30985. // with scroll page in the app)
  30986. // touchEvent.preventDefault();
  30987. this.onCommonMove(touch, this.touchStart, el);
  30988. };
  30989. // only gets called after a mouse down - as this is only added after mouseDown
  30990. // and is removed when mouseUp happens
  30991. DragService.prototype.onMouseMove = function (mouseEvent, el) {
  30992. this.onCommonMove(mouseEvent, this.mouseStartEvent, el);
  30993. };
  30994. DragService.prototype.onTouchUp = function (touchEvent, el) {
  30995. var touch = this.getFirstActiveTouch(touchEvent.changedTouches);
  30996. // i haven't worked this out yet, but there is no matching touch
  30997. // when we get the touch up event. to get around this, we swap in
  30998. // the last touch. this is a hack to 'get it working' while we
  30999. // figure out what's going on, why we are not getting a touch in
  31000. // current event.
  31001. if (!touch) {
  31002. touch = this.touchLastTime;
  31003. }
  31004. // if mouse was left up before we started to move, then this is a tap.
  31005. // we check this before onUpCommon as onUpCommon resets the dragging
  31006. // let tap = !this.dragging;
  31007. // let tapTarget = this.currentDragParams.eElement;
  31008. this.onUpCommon(touch, el);
  31009. // if tap, tell user
  31010. // console.log(`${Math.random()} tap = ${tap}`);
  31011. // if (tap) {
  31012. // tapTarget.click();
  31013. // }
  31014. };
  31015. DragService.prototype.onMouseUp = function (mouseEvent, el) {
  31016. this.onUpCommon(mouseEvent, el);
  31017. };
  31018. DragService.prototype.onUpCommon = function (eventOrTouch, el) {
  31019. if (this.dragging) {
  31020. this.dragging = false;
  31021. this.currentDragParams.onDragStop(eventOrTouch);
  31022. var event_2 = {
  31023. type: Events.EVENT_DRAG_STOPPED,
  31024. api: this.gridApi,
  31025. columnApi: this.columnApi,
  31026. target: el
  31027. };
  31028. this.eventService.dispatchEvent(event_2);
  31029. }
  31030. this.setNoSelectToBody(false);
  31031. this.mouseStartEvent = null;
  31032. this.touchStart = null;
  31033. this.touchLastTime = null;
  31034. this.currentDragParams = null;
  31035. this.dragEndFunctions.forEach(function (func) { return func(); });
  31036. this.dragEndFunctions.length = 0;
  31037. };
  31038. __decorate$19([
  31039. Autowired('loggerFactory')
  31040. ], DragService.prototype, "loggerFactory", void 0);
  31041. __decorate$19([
  31042. Autowired('gridOptionsWrapper')
  31043. ], DragService.prototype, "gridOptionsWrapper", void 0);
  31044. __decorate$19([
  31045. Autowired('columnApi')
  31046. ], DragService.prototype, "columnApi", void 0);
  31047. __decorate$19([
  31048. Autowired('gridApi')
  31049. ], DragService.prototype, "gridApi", void 0);
  31050. __decorate$19([
  31051. PostConstruct
  31052. ], DragService.prototype, "init", null);
  31053. __decorate$19([
  31054. PreDestroy
  31055. ], DragService.prototype, "removeAllListeners", null);
  31056. DragService = __decorate$19([
  31057. Bean('dragService')
  31058. ], DragService);
  31059. return DragService;
  31060. }(BeanStub));
  31061. /**
  31062. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  31063. * @version v23.2.1
  31064. * @link http://www.ag-grid.com/
  31065. * @license MIT
  31066. */
  31067. var __extends$1b = (undefined && undefined.__extends) || (function () {
  31068. var extendStatics = function (d, b) {
  31069. extendStatics = Object.setPrototypeOf ||
  31070. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  31071. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  31072. return extendStatics(d, b);
  31073. };
  31074. return function (d, b) {
  31075. extendStatics(d, b);
  31076. function __() { this.constructor = d; }
  31077. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  31078. };
  31079. })();
  31080. var __decorate$1a = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  31081. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  31082. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  31083. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  31084. return c > 3 && r && Object.defineProperty(target, key, r), r;
  31085. };
  31086. var SortController = /** @class */ (function (_super) {
  31087. __extends$1b(SortController, _super);
  31088. function SortController() {
  31089. var _this = _super !== null && _super.apply(this, arguments) || this;
  31090. // used by the public api, for saving the sort model
  31091. _this.getSortModel = function () {
  31092. return _this.getColumnsWithSortingOrdered().map(function (column) { return ({
  31093. colId: column.getColId(),
  31094. sort: column.getSort()
  31095. }); });
  31096. };
  31097. return _this;
  31098. }
  31099. SortController_1 = SortController;
  31100. SortController.prototype.progressSort = function (column, multiSort, source) {
  31101. if (source === void 0) { source = "api"; }
  31102. var nextDirection = this.getNextSortDirection(column);
  31103. this.setSortForColumn(column, nextDirection, multiSort, source);
  31104. };
  31105. SortController.prototype.setSortForColumn = function (column, sort, multiSort, source) {
  31106. if (source === void 0) { source = "api"; }
  31107. // auto correct - if sort not legal value, then set it to 'no sort' (which is null)
  31108. if (sort !== Constants.SORT_ASC && sort !== Constants.SORT_DESC) {
  31109. sort = null;
  31110. }
  31111. // update sort on current col
  31112. column.setSort(sort, source);
  31113. // sortedAt used for knowing order of cols when multi-col sort
  31114. if (column.getSort()) {
  31115. var sortedAt = Number(new Date().valueOf());
  31116. column.setSortedAt(sortedAt);
  31117. }
  31118. else {
  31119. column.setSortedAt(null);
  31120. }
  31121. var doingMultiSort = multiSort && !this.gridOptionsWrapper.isSuppressMultiSort();
  31122. // clear sort on all columns except this one, and update the icons
  31123. if (!doingMultiSort) {
  31124. this.clearSortBarThisColumn(column, source);
  31125. }
  31126. this.dispatchSortChangedEvents();
  31127. };
  31128. // gets called by API, so if data changes, use can call this, which will end up
  31129. // working out the sort order again of the rows.
  31130. SortController.prototype.onSortChanged = function () {
  31131. this.dispatchSortChangedEvents();
  31132. };
  31133. SortController.prototype.dispatchSortChangedEvents = function () {
  31134. var event = {
  31135. type: Events.EVENT_SORT_CHANGED,
  31136. api: this.gridApi,
  31137. columnApi: this.columnApi
  31138. };
  31139. this.eventService.dispatchEvent(event);
  31140. };
  31141. SortController.prototype.clearSortBarThisColumn = function (columnToSkip, source) {
  31142. this.columnController.getPrimaryAndSecondaryAndAutoColumns().forEach(function (columnToClear) {
  31143. // Do not clear if either holding shift, or if column in question was clicked
  31144. if (!(columnToClear === columnToSkip)) {
  31145. // setting to 'undefined' as null means 'none' rather than cleared, otherwise issue will arise
  31146. // if sort order is: ['desc', null , 'asc'], as it will start at null rather than 'desc'.
  31147. columnToClear.setSort(undefined, source);
  31148. }
  31149. });
  31150. };
  31151. SortController.prototype.getNextSortDirection = function (column) {
  31152. var sortingOrder;
  31153. if (column.getColDef().sortingOrder) {
  31154. sortingOrder = column.getColDef().sortingOrder;
  31155. }
  31156. else if (this.gridOptionsWrapper.getSortingOrder()) {
  31157. sortingOrder = this.gridOptionsWrapper.getSortingOrder();
  31158. }
  31159. else {
  31160. sortingOrder = SortController_1.DEFAULT_SORTING_ORDER;
  31161. }
  31162. if (!Array.isArray(sortingOrder) || sortingOrder.length <= 0) {
  31163. console.warn("ag-grid: sortingOrder must be an array with at least one element, currently it's " + sortingOrder);
  31164. return null;
  31165. }
  31166. var currentIndex = sortingOrder.indexOf(column.getSort());
  31167. var notInArray = currentIndex < 0;
  31168. var lastItemInArray = currentIndex == sortingOrder.length - 1;
  31169. var result;
  31170. if (notInArray || lastItemInArray) {
  31171. result = sortingOrder[0];
  31172. }
  31173. else {
  31174. result = sortingOrder[currentIndex + 1];
  31175. }
  31176. // verify the sort type exists, as the user could provide the sortingOrder, need to make sure it's valid
  31177. if (SortController_1.DEFAULT_SORTING_ORDER.indexOf(result) < 0) {
  31178. console.warn('ag-grid: invalid sort type ' + result);
  31179. return null;
  31180. }
  31181. return result;
  31182. };
  31183. SortController.prototype.setSortModel = function (sortModel, source) {
  31184. var _this = this;
  31185. if (source === void 0) { source = "api"; }
  31186. // first up, clear any previous sort
  31187. var sortModelProvided = sortModel && sortModel.length > 0;
  31188. var allColumnsIncludingAuto = this.columnController.getPrimaryAndSecondaryAndAutoColumns();
  31189. allColumnsIncludingAuto.forEach(function (column) {
  31190. var sortForCol = null;
  31191. var sortedAt = -1;
  31192. if (sortModelProvided && column.getColDef().sortable) {
  31193. for (var j = 0; j < sortModel.length; j++) {
  31194. var sortModelEntry = sortModel[j];
  31195. if (typeof sortModelEntry.colId === 'string'
  31196. && typeof column.getColId() === 'string'
  31197. && _this.compareColIds(sortModelEntry, column)) {
  31198. sortForCol = sortModelEntry.sort;
  31199. sortedAt = j;
  31200. }
  31201. }
  31202. }
  31203. if (sortForCol) {
  31204. column.setSort(sortForCol, source);
  31205. column.setSortedAt(sortedAt);
  31206. }
  31207. else {
  31208. column.setSort(null, source);
  31209. column.setSortedAt(null);
  31210. }
  31211. });
  31212. this.dispatchSortChangedEvents();
  31213. };
  31214. SortController.prototype.compareColIds = function (sortModelEntry, column) {
  31215. return sortModelEntry.colId === column.getColId();
  31216. };
  31217. SortController.prototype.getColumnsWithSortingOrdered = function () {
  31218. // pull out all the columns that have sorting set
  31219. var allColumnsIncludingAuto = this.columnController.getPrimaryAndSecondaryAndAutoColumns();
  31220. var columnsWithSorting = allColumnsIncludingAuto.filter(function (column) { return !!column.getSort(); });
  31221. // put the columns in order of which one got sorted first
  31222. columnsWithSorting.sort(function (a, b) { return a.sortedAt - b.sortedAt; });
  31223. return columnsWithSorting;
  31224. };
  31225. // used by row controller, when doing the sorting
  31226. SortController.prototype.getSortForRowController = function () {
  31227. return this.getColumnsWithSortingOrdered().map(function (column) {
  31228. var isAscending = column.getSort() === Constants.SORT_ASC;
  31229. return {
  31230. inverter: isAscending ? 1 : -1,
  31231. column: column
  31232. };
  31233. });
  31234. };
  31235. var SortController_1;
  31236. SortController.DEFAULT_SORTING_ORDER = [Constants.SORT_ASC, Constants.SORT_DESC, null];
  31237. __decorate$1a([
  31238. Autowired('gridOptionsWrapper')
  31239. ], SortController.prototype, "gridOptionsWrapper", void 0);
  31240. __decorate$1a([
  31241. Autowired('columnController')
  31242. ], SortController.prototype, "columnController", void 0);
  31243. __decorate$1a([
  31244. Autowired('columnApi')
  31245. ], SortController.prototype, "columnApi", void 0);
  31246. __decorate$1a([
  31247. Autowired('gridApi')
  31248. ], SortController.prototype, "gridApi", void 0);
  31249. SortController = SortController_1 = __decorate$1a([
  31250. Bean('sortController')
  31251. ], SortController);
  31252. return SortController;
  31253. }(BeanStub));
  31254. /**
  31255. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  31256. * @version v23.2.1
  31257. * @link http://www.ag-grid.com/
  31258. * @license MIT
  31259. */
  31260. var __extends$1c = (undefined && undefined.__extends) || (function () {
  31261. var extendStatics = function (d, b) {
  31262. extendStatics = Object.setPrototypeOf ||
  31263. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  31264. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  31265. return extendStatics(d, b);
  31266. };
  31267. return function (d, b) {
  31268. extendStatics(d, b);
  31269. function __() { this.constructor = d; }
  31270. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  31271. };
  31272. })();
  31273. var __decorate$1b = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  31274. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  31275. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  31276. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  31277. return c > 3 && r && Object.defineProperty(target, key, r), r;
  31278. };
  31279. var FocusController = /** @class */ (function (_super) {
  31280. __extends$1c(FocusController, _super);
  31281. function FocusController() {
  31282. var _this = _super !== null && _super.apply(this, arguments) || this;
  31283. _this.keyboardFocusActive = false;
  31284. return _this;
  31285. }
  31286. FocusController_1 = FocusController;
  31287. FocusController.prototype.init = function () {
  31288. var eDocument = this.gridOptionsWrapper.getDocument();
  31289. var clearFocusedCellListener = this.clearFocusedCell.bind(this);
  31290. this.addManagedListener(this.eventService, Events.EVENT_COLUMN_PIVOT_MODE_CHANGED, clearFocusedCellListener);
  31291. this.addManagedListener(this.eventService, Events.EVENT_COLUMN_EVERYTHING_CHANGED, this.onColumnEverythingChanged.bind(this));
  31292. this.addManagedListener(this.eventService, Events.EVENT_COLUMN_GROUP_OPENED, clearFocusedCellListener);
  31293. this.addManagedListener(this.eventService, Events.EVENT_COLUMN_ROW_GROUP_CHANGED, clearFocusedCellListener);
  31294. this.addManagedListener(eDocument, 'keydown', this.activateKeyboardMode.bind(this));
  31295. this.addManagedListener(eDocument, 'mousedown', this.activateMouseMode.bind(this));
  31296. };
  31297. FocusController.prototype.registerGridCore = function (gridCore) {
  31298. this.gridCore = gridCore;
  31299. };
  31300. FocusController.prototype.onColumnEverythingChanged = function () {
  31301. // if the columns change, check and see if this column still exists. if it does,
  31302. // then we can keep the focused cell. if it doesn't, then we need to drop the focused
  31303. // cell.
  31304. if (this.focusedCellPosition) {
  31305. var col = this.focusedCellPosition.column;
  31306. var colFromColumnController = this.columnController.getGridColumn(col.getId());
  31307. if (col !== colFromColumnController) {
  31308. this.clearFocusedCell();
  31309. }
  31310. }
  31311. };
  31312. FocusController.prototype.isKeyboardFocus = function () {
  31313. return this.keyboardFocusActive;
  31314. };
  31315. FocusController.prototype.activateMouseMode = function () {
  31316. this.keyboardFocusActive = false;
  31317. this.eventService.dispatchEvent({ type: Events.EVENT_MOUSE_FOCUS });
  31318. };
  31319. FocusController.prototype.activateKeyboardMode = function () {
  31320. this.keyboardFocusActive = true;
  31321. this.eventService.dispatchEvent({ type: Events.EVENT_KEYBOARD_FOCUS });
  31322. };
  31323. // we check if the browser is focusing something, and if it is, and
  31324. // it's the cell we think is focused, then return the cell. so this
  31325. // methods returns the cell if a) we think it has focus and b) the
  31326. // browser thinks it has focus. this then returns nothing if we
  31327. // first focus a cell, then second click outside the grid, as then the
  31328. // grid cell will still be focused as far as the grid is concerned,
  31329. // however the browser focus will have moved somewhere else.
  31330. FocusController.prototype.getFocusCellToUseAfterRefresh = function () {
  31331. if (this.gridOptionsWrapper.isSuppressFocusAfterRefresh() || !this.focusedCellPosition) {
  31332. return null;
  31333. }
  31334. // we check that the browser is actually focusing on the grid, if it is not, then
  31335. // we have nothing to worry about
  31336. var browserFocusedCell = this.getGridCellForDomElement(document.activeElement);
  31337. if (!browserFocusedCell) {
  31338. return null;
  31339. }
  31340. return this.focusedCellPosition;
  31341. };
  31342. FocusController.prototype.getGridCellForDomElement = function (eBrowserCell) {
  31343. var ePointer = eBrowserCell;
  31344. while (ePointer) {
  31345. var cellComp = this.gridOptionsWrapper.getDomData(ePointer, CellComp.DOM_DATA_KEY_CELL_COMP);
  31346. if (cellComp) {
  31347. return cellComp.getCellPosition();
  31348. }
  31349. ePointer = ePointer.parentNode;
  31350. }
  31351. return null;
  31352. };
  31353. FocusController.prototype.clearFocusedCell = function () {
  31354. this.focusedCellPosition = null;
  31355. this.onCellFocused(false);
  31356. };
  31357. FocusController.prototype.getFocusedCell = function () {
  31358. return this.focusedCellPosition;
  31359. };
  31360. FocusController.prototype.setFocusedCell = function (rowIndex, colKey, floating, forceBrowserFocus) {
  31361. if (forceBrowserFocus === void 0) { forceBrowserFocus = false; }
  31362. var column = _.makeNull(this.columnController.getGridColumn(colKey));
  31363. this.focusedCellPosition = { rowIndex: rowIndex, rowPinned: _.makeNull(floating), column: column };
  31364. this.onCellFocused(forceBrowserFocus);
  31365. };
  31366. FocusController.prototype.isCellFocused = function (cellPosition) {
  31367. if (_.missing(this.focusedCellPosition)) {
  31368. return false;
  31369. }
  31370. return this.focusedCellPosition.column === cellPosition.column && this.isRowFocused(cellPosition.rowIndex, cellPosition.rowPinned);
  31371. };
  31372. FocusController.prototype.isRowNodeFocused = function (rowNode) {
  31373. return this.isRowFocused(rowNode.rowIndex, rowNode.rowPinned);
  31374. };
  31375. FocusController.prototype.isHeaderWrapperFocused = function (headerWrapper) {
  31376. if (_.missing(this.focusedHeaderPosition)) {
  31377. return false;
  31378. }
  31379. var column = headerWrapper.getColumn();
  31380. var headerRowIndex = headerWrapper.getParentComponent().getRowIndex();
  31381. var pinned = headerWrapper.getPinned();
  31382. var _a = this.focusedHeaderPosition, focusedColumn = _a.column, focusedHeaderRowIndex = _a.headerRowIndex;
  31383. return column === focusedColumn &&
  31384. headerRowIndex === focusedHeaderRowIndex &&
  31385. pinned == focusedColumn.getPinned();
  31386. };
  31387. FocusController.prototype.clearFocusedHeader = function () {
  31388. this.focusedHeaderPosition = null;
  31389. };
  31390. FocusController.prototype.getFocusedHeader = function () {
  31391. return this.focusedHeaderPosition;
  31392. };
  31393. FocusController.prototype.setFocusedHeader = function (headerRowIndex, column) {
  31394. this.focusedHeaderPosition = { headerRowIndex: headerRowIndex, column: column };
  31395. };
  31396. FocusController.prototype.focusHeaderPosition = function (headerPosition, direction) {
  31397. this.headerNavigationService.scrollToColumn(headerPosition.column, direction);
  31398. var childContainer = this.headerNavigationService.getHeaderContainer(headerPosition.column.getPinned());
  31399. var rowComps = childContainer.getRowComps();
  31400. var nextRowComp = rowComps[headerPosition.headerRowIndex];
  31401. var headerComps = nextRowComp.getHeaderComps();
  31402. var nextHeader = headerComps[headerPosition.column.getUniqueId()];
  31403. if (nextHeader) {
  31404. // this will automatically call the setFocusedHeader method above
  31405. nextHeader.getFocusableElement().focus();
  31406. return true;
  31407. }
  31408. return false;
  31409. };
  31410. FocusController.prototype.isAnyCellFocused = function () {
  31411. return !!this.focusedCellPosition;
  31412. };
  31413. FocusController.prototype.isRowFocused = function (rowIndex, floating) {
  31414. if (_.missing(this.focusedCellPosition)) {
  31415. return false;
  31416. }
  31417. var floatingOrNull = _.makeNull(floating);
  31418. return this.focusedCellPosition.rowIndex === rowIndex && this.focusedCellPosition.rowPinned === floatingOrNull;
  31419. };
  31420. FocusController.prototype.findFocusableElements = function (rootNode, exclude, onlyUnmanaged) {
  31421. var focusableString = FocusController_1.FOCUSABLE_SELECTOR;
  31422. var excludeString = FocusController_1.FOCUSABLE_EXCLUDE;
  31423. if (exclude) {
  31424. excludeString += ', ' + exclude;
  31425. }
  31426. if (onlyUnmanaged) {
  31427. excludeString += ', [tabindex="-1"]';
  31428. }
  31429. var nodes = Array.prototype.slice.apply(rootNode.querySelectorAll(focusableString));
  31430. var excludeNodes = Array.prototype.slice.apply(rootNode.querySelectorAll(excludeString));
  31431. if (!excludeNodes.length) {
  31432. return nodes;
  31433. }
  31434. var diff = function (a, b) { return a.filter(function (element) { return b.indexOf(element) === -1; }); };
  31435. return diff(nodes, excludeNodes);
  31436. };
  31437. FocusController.prototype.focusFirstFocusableElement = function (rootNode, onlyUnmanaged) {
  31438. var focusable = this.findFocusableElements(rootNode, null, onlyUnmanaged)[0];
  31439. if (focusable) {
  31440. focusable.focus();
  31441. return true;
  31442. }
  31443. return false;
  31444. };
  31445. FocusController.prototype.focusLastFocusableElement = function (rootNode, onlyUnmanaged) {
  31446. var focusable = _.last(this.findFocusableElements(rootNode, null, onlyUnmanaged));
  31447. if (focusable) {
  31448. focusable.focus();
  31449. return true;
  31450. }
  31451. return false;
  31452. };
  31453. FocusController.prototype.findNextFocusableElement = function (rootNode, onlyManaged, backwards) {
  31454. var focusable = this.findFocusableElements(rootNode, onlyManaged ? ':not([tabindex="-1"])' : null);
  31455. var currentIndex;
  31456. if (onlyManaged) {
  31457. currentIndex = _.findIndex(focusable, function (el) { return el.contains(document.activeElement); });
  31458. }
  31459. else {
  31460. currentIndex = focusable.indexOf(document.activeElement);
  31461. }
  31462. var nextIndex = currentIndex + (backwards ? -1 : 1);
  31463. if (nextIndex < 0 || nextIndex > focusable.length) {
  31464. return;
  31465. }
  31466. return focusable[nextIndex];
  31467. };
  31468. FocusController.prototype.isFocusUnderManagedComponent = function (rootNode) {
  31469. var managedContainers = rootNode.querySelectorAll("." + ManagedFocusComponent.FOCUS_MANAGED_CLASS);
  31470. if (!managedContainers.length) {
  31471. return false;
  31472. }
  31473. for (var i = 0; i < managedContainers.length; i++) {
  31474. if (managedContainers[i].contains(document.activeElement)) {
  31475. return true;
  31476. }
  31477. }
  31478. return false;
  31479. };
  31480. FocusController.prototype.findTabbableParent = function (node, limit) {
  31481. if (limit === void 0) { limit = 5; }
  31482. var counter = 0;
  31483. while (node && _.getTabIndex(node) === null && ++counter <= limit) {
  31484. node = node.parentElement;
  31485. }
  31486. if (_.getTabIndex(node) === null) {
  31487. return null;
  31488. }
  31489. return node;
  31490. };
  31491. FocusController.prototype.onCellFocused = function (forceBrowserFocus) {
  31492. var event = {
  31493. type: Events.EVENT_CELL_FOCUSED,
  31494. forceBrowserFocus: forceBrowserFocus,
  31495. rowIndex: null,
  31496. column: null,
  31497. floating: null,
  31498. api: this.gridApi,
  31499. columnApi: this.columnApi,
  31500. rowPinned: null
  31501. };
  31502. if (this.focusedCellPosition) {
  31503. event.rowIndex = this.focusedCellPosition.rowIndex;
  31504. event.column = this.focusedCellPosition.column;
  31505. event.rowPinned = this.focusedCellPosition.rowPinned;
  31506. }
  31507. this.eventService.dispatchEvent(event);
  31508. };
  31509. FocusController.prototype.focusGridView = function (column) {
  31510. var firstRow = this.rowPositionUtils.getFirstRow();
  31511. if (!firstRow) {
  31512. return false;
  31513. }
  31514. var rowIndex = firstRow.rowIndex, rowPinned = firstRow.rowPinned;
  31515. var focusedHeader = this.getFocusedHeader();
  31516. if (!column) {
  31517. column = focusedHeader.column;
  31518. }
  31519. if (!_.exists(rowIndex)) {
  31520. return false;
  31521. }
  31522. this.rowRenderer.ensureCellVisible({ rowIndex: rowIndex, column: column, rowPinned: rowPinned });
  31523. this.setFocusedCell(rowIndex, column, _.makeNull(rowPinned), true);
  31524. if (this.rangeController) {
  31525. var cellPosition = { rowIndex: rowIndex, rowPinned: rowPinned, column: column };
  31526. this.rangeController.setRangeToCell(cellPosition);
  31527. }
  31528. return true;
  31529. };
  31530. FocusController.prototype.focusNextGridCoreContainer = function (backwards) {
  31531. if (this.gridCore.focusNextInnerContainer(backwards)) {
  31532. return true;
  31533. }
  31534. if (!backwards) {
  31535. this.gridCore.forceFocusOutOfContainer();
  31536. }
  31537. };
  31538. var FocusController_1;
  31539. FocusController.FOCUSABLE_SELECTOR = '[tabindex], input, select, button, textarea';
  31540. FocusController.FOCUSABLE_EXCLUDE = '.ag-hidden, .ag-hidden *, .ag-disabled, .ag-disabled *';
  31541. __decorate$1b([
  31542. Autowired('gridOptionsWrapper')
  31543. ], FocusController.prototype, "gridOptionsWrapper", void 0);
  31544. __decorate$1b([
  31545. Autowired('columnController')
  31546. ], FocusController.prototype, "columnController", void 0);
  31547. __decorate$1b([
  31548. Autowired('headerNavigationService')
  31549. ], FocusController.prototype, "headerNavigationService", void 0);
  31550. __decorate$1b([
  31551. Autowired('columnApi')
  31552. ], FocusController.prototype, "columnApi", void 0);
  31553. __decorate$1b([
  31554. Autowired('gridApi')
  31555. ], FocusController.prototype, "gridApi", void 0);
  31556. __decorate$1b([
  31557. Autowired('rowRenderer')
  31558. ], FocusController.prototype, "rowRenderer", void 0);
  31559. __decorate$1b([
  31560. Autowired('rowPositionUtils')
  31561. ], FocusController.prototype, "rowPositionUtils", void 0);
  31562. __decorate$1b([
  31563. Optional('rangeController')
  31564. ], FocusController.prototype, "rangeController", void 0);
  31565. __decorate$1b([
  31566. PostConstruct
  31567. ], FocusController.prototype, "init", null);
  31568. FocusController = FocusController_1 = __decorate$1b([
  31569. Bean('focusController')
  31570. ], FocusController);
  31571. return FocusController;
  31572. }(BeanStub));
  31573. /**
  31574. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  31575. * @version v23.2.1
  31576. * @link http://www.ag-grid.com/
  31577. * @license MIT
  31578. */
  31579. var __extends$1d = (undefined && undefined.__extends) || (function () {
  31580. var extendStatics = function (d, b) {
  31581. extendStatics = Object.setPrototypeOf ||
  31582. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  31583. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  31584. return extendStatics(d, b);
  31585. };
  31586. return function (d, b) {
  31587. extendStatics(d, b);
  31588. function __() { this.constructor = d; }
  31589. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  31590. };
  31591. })();
  31592. var __decorate$1c = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  31593. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  31594. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  31595. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  31596. return c > 3 && r && Object.defineProperty(target, key, r), r;
  31597. };
  31598. var MouseEventService = /** @class */ (function (_super) {
  31599. __extends$1d(MouseEventService, _super);
  31600. function MouseEventService() {
  31601. var _this = _super !== null && _super.apply(this, arguments) || this;
  31602. _this.gridInstanceId = MouseEventService_1.gridInstanceSequence.next();
  31603. return _this;
  31604. }
  31605. MouseEventService_1 = MouseEventService;
  31606. MouseEventService.prototype.init = function () {
  31607. this.stampDomElementWithGridInstance();
  31608. };
  31609. MouseEventService.prototype.registerGridComp = function (gridPanel) {
  31610. this.gridPanel = gridPanel;
  31611. };
  31612. // we put the instance id onto the main DOM element. this is used for events, when grids are inside grids,
  31613. // so the grid can work out if the even came from this grid or a grid inside this one. see the ctrl+v logic
  31614. // for where this is used.
  31615. MouseEventService.prototype.stampDomElementWithGridInstance = function () {
  31616. this.eGridDiv[MouseEventService_1.GRID_DOM_KEY] = this.gridInstanceId;
  31617. };
  31618. MouseEventService.prototype.getRenderedCellForEvent = function (event) {
  31619. return _.getCellCompForEvent(this.gridOptionsWrapper, event);
  31620. };
  31621. // walks the path of the event, and returns true if this grid is the first one that it finds. if doing
  31622. // master / detail grids, and a child grid is found, then it returns false. this stops things like copy/paste
  31623. // getting executed on many grids at the same time.
  31624. MouseEventService.prototype.isEventFromThisGrid = function (event) {
  31625. var path = _.getEventPath(event);
  31626. for (var i = 0; i < path.length; i++) {
  31627. var element = path[i];
  31628. var instanceId = element[MouseEventService_1.GRID_DOM_KEY];
  31629. if (_.exists(instanceId)) {
  31630. var eventFromThisGrid = instanceId === this.gridInstanceId;
  31631. return eventFromThisGrid;
  31632. }
  31633. }
  31634. return false;
  31635. };
  31636. MouseEventService.prototype.getCellPositionForEvent = function (event) {
  31637. var cellComp = this.getRenderedCellForEvent(event);
  31638. return cellComp ? cellComp.getCellPosition() : null;
  31639. };
  31640. MouseEventService.prototype.getNormalisedPosition = function (event) {
  31641. var gridPanelHasScrolls = this.gridOptionsWrapper.getDomLayout() === Constants.DOM_LAYOUT_NORMAL;
  31642. var x = event.x, y = event.y;
  31643. if (gridPanelHasScrolls) {
  31644. var vRange = this.gridPanel.getVScrollPosition();
  31645. var hRange = this.gridPanel.getHScrollPosition();
  31646. return { x: x + hRange.left, y: y + vRange.top };
  31647. }
  31648. return { x: x, y: y };
  31649. };
  31650. var MouseEventService_1;
  31651. MouseEventService.gridInstanceSequence = new NumberSequence();
  31652. MouseEventService.GRID_DOM_KEY = '__ag_grid_instance';
  31653. __decorate$1c([
  31654. Autowired('gridOptionsWrapper')
  31655. ], MouseEventService.prototype, "gridOptionsWrapper", void 0);
  31656. __decorate$1c([
  31657. Autowired('eGridDiv')
  31658. ], MouseEventService.prototype, "eGridDiv", void 0);
  31659. __decorate$1c([
  31660. PostConstruct
  31661. ], MouseEventService.prototype, "init", null);
  31662. MouseEventService = MouseEventService_1 = __decorate$1c([
  31663. Bean('mouseEventService')
  31664. ], MouseEventService);
  31665. return MouseEventService;
  31666. }(BeanStub));
  31667. /**
  31668. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  31669. * @version v23.2.1
  31670. * @link http://www.ag-grid.com/
  31671. * @license MIT
  31672. */
  31673. var __extends$1e = (undefined && undefined.__extends) || (function () {
  31674. var extendStatics = function (d, b) {
  31675. extendStatics = Object.setPrototypeOf ||
  31676. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  31677. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  31678. return extendStatics(d, b);
  31679. };
  31680. return function (d, b) {
  31681. extendStatics(d, b);
  31682. function __() { this.constructor = d; }
  31683. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  31684. };
  31685. })();
  31686. var __decorate$1d = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  31687. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  31688. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  31689. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  31690. return c > 3 && r && Object.defineProperty(target, key, r), r;
  31691. };
  31692. var CellNavigationService = /** @class */ (function (_super) {
  31693. __extends$1e(CellNavigationService, _super);
  31694. function CellNavigationService() {
  31695. return _super !== null && _super.apply(this, arguments) || this;
  31696. }
  31697. // returns null if no cell to focus on, ie at the end of the grid
  31698. CellNavigationService.prototype.getNextCellToFocus = function (key, lastCellToFocus) {
  31699. // starting with the provided cell, we keep moving until we find a cell we can
  31700. // focus on.
  31701. var pointer = lastCellToFocus;
  31702. var finished = false;
  31703. // finished will be true when either:
  31704. // a) cell found that we can focus on
  31705. // b) run out of cells (ie the method returns null)
  31706. while (!finished) {
  31707. switch (key) {
  31708. case Constants.KEY_UP:
  31709. pointer = this.getCellAbove(pointer);
  31710. break;
  31711. case Constants.KEY_DOWN:
  31712. pointer = this.getCellBelow(pointer);
  31713. break;
  31714. case Constants.KEY_RIGHT:
  31715. if (this.gridOptionsWrapper.isEnableRtl()) {
  31716. pointer = this.getCellToLeft(pointer);
  31717. }
  31718. else {
  31719. pointer = this.getCellToRight(pointer);
  31720. }
  31721. break;
  31722. case Constants.KEY_LEFT:
  31723. if (this.gridOptionsWrapper.isEnableRtl()) {
  31724. pointer = this.getCellToRight(pointer);
  31725. }
  31726. else {
  31727. pointer = this.getCellToLeft(pointer);
  31728. }
  31729. break;
  31730. default:
  31731. pointer = null;
  31732. console.warn('ag-Grid: unknown key for navigation ' + key);
  31733. break;
  31734. }
  31735. if (pointer) {
  31736. finished = this.isCellGoodToFocusOn(pointer);
  31737. }
  31738. else {
  31739. finished = true;
  31740. }
  31741. }
  31742. return pointer;
  31743. };
  31744. CellNavigationService.prototype.isCellGoodToFocusOn = function (gridCell) {
  31745. var column = gridCell.column;
  31746. var rowNode;
  31747. switch (gridCell.rowPinned) {
  31748. case Constants.PINNED_TOP:
  31749. rowNode = this.pinnedRowModel.getPinnedTopRow(gridCell.rowIndex);
  31750. break;
  31751. case Constants.PINNED_BOTTOM:
  31752. rowNode = this.pinnedRowModel.getPinnedBottomRow(gridCell.rowIndex);
  31753. break;
  31754. default:
  31755. rowNode = this.rowModel.getRow(gridCell.rowIndex);
  31756. break;
  31757. }
  31758. var suppressNavigable = column.isSuppressNavigable(rowNode);
  31759. return !suppressNavigable;
  31760. };
  31761. CellNavigationService.prototype.getCellToLeft = function (lastCell) {
  31762. if (!lastCell) {
  31763. return null;
  31764. }
  31765. var colToLeft = this.columnController.getDisplayedColBefore(lastCell.column);
  31766. if (!colToLeft) {
  31767. return null;
  31768. }
  31769. return {
  31770. rowIndex: lastCell.rowIndex,
  31771. column: colToLeft,
  31772. rowPinned: lastCell.rowPinned
  31773. };
  31774. };
  31775. CellNavigationService.prototype.getCellToRight = function (lastCell) {
  31776. if (!lastCell) {
  31777. return null;
  31778. }
  31779. var colToRight = this.columnController.getDisplayedColAfter(lastCell.column);
  31780. // if already on right, do nothing
  31781. if (!colToRight) {
  31782. return null;
  31783. }
  31784. return {
  31785. rowIndex: lastCell.rowIndex,
  31786. column: colToRight,
  31787. rowPinned: lastCell.rowPinned
  31788. };
  31789. };
  31790. CellNavigationService.prototype.getRowBelow = function (rowPosition) {
  31791. // if already on top row, do nothing
  31792. var index = rowPosition.rowIndex;
  31793. var pinned = rowPosition.rowPinned;
  31794. if (this.isLastRowInContainer(rowPosition)) {
  31795. switch (pinned) {
  31796. case Constants.PINNED_BOTTOM:
  31797. // never any rows after pinned bottom
  31798. return null;
  31799. case Constants.PINNED_TOP:
  31800. // if on last row of pinned top, then next row is main body (if rows exist),
  31801. // otherwise it's the pinned bottom
  31802. if (this.rowModel.isRowsToRender()) {
  31803. return { rowIndex: 0, rowPinned: null };
  31804. }
  31805. else if (this.pinnedRowModel.isRowsToRender(Constants.PINNED_BOTTOM)) {
  31806. return { rowIndex: 0, rowPinned: Constants.PINNED_BOTTOM };
  31807. }
  31808. return null;
  31809. default:
  31810. // if in the main body, then try pinned bottom, otherwise return nothing
  31811. if (this.pinnedRowModel.isRowsToRender(Constants.PINNED_BOTTOM)) {
  31812. return { rowIndex: 0, rowPinned: Constants.PINNED_BOTTOM };
  31813. }
  31814. return null;
  31815. }
  31816. }
  31817. return { rowIndex: index + 1, rowPinned: pinned };
  31818. };
  31819. CellNavigationService.prototype.getCellBelow = function (lastCell) {
  31820. if (!lastCell) {
  31821. return null;
  31822. }
  31823. var rowBelow = this.getRowBelow(lastCell);
  31824. if (rowBelow) {
  31825. return {
  31826. rowIndex: rowBelow.rowIndex,
  31827. column: lastCell.column,
  31828. rowPinned: rowBelow.rowPinned
  31829. };
  31830. }
  31831. return null;
  31832. };
  31833. CellNavigationService.prototype.isLastRowInContainer = function (rowPosition) {
  31834. var pinned = rowPosition.rowPinned;
  31835. var index = rowPosition.rowIndex;
  31836. if (pinned === Constants.PINNED_TOP) {
  31837. var lastTopIndex = this.pinnedRowModel.getPinnedTopRowData().length - 1;
  31838. return lastTopIndex <= index;
  31839. }
  31840. else if (pinned === Constants.PINNED_BOTTOM) {
  31841. var lastBottomIndex = this.pinnedRowModel.getPinnedBottomRowData().length - 1;
  31842. return lastBottomIndex <= index;
  31843. }
  31844. var lastBodyIndex = this.rowModel.getRowCount() - 1;
  31845. return lastBodyIndex <= index;
  31846. };
  31847. CellNavigationService.prototype.getRowAbove = function (rowPosition) {
  31848. // if already on top row, do nothing
  31849. var index = rowPosition.rowIndex;
  31850. var pinned = rowPosition.rowPinned;
  31851. // if already on top row, do nothing
  31852. if (index === 0) {
  31853. if (pinned === Constants.PINNED_TOP) {
  31854. return null;
  31855. }
  31856. else if (!pinned) {
  31857. if (this.pinnedRowModel.isRowsToRender(Constants.PINNED_TOP)) {
  31858. return this.getLastFloatingTopRow();
  31859. }
  31860. return null;
  31861. }
  31862. else {
  31863. // last floating bottom
  31864. if (this.rowModel.isRowsToRender()) {
  31865. return this.getLastBodyCell();
  31866. }
  31867. else if (this.pinnedRowModel.isRowsToRender(Constants.PINNED_TOP)) {
  31868. return this.getLastFloatingTopRow();
  31869. }
  31870. return null;
  31871. }
  31872. }
  31873. return { rowIndex: index - 1, rowPinned: pinned };
  31874. };
  31875. CellNavigationService.prototype.getCellAbove = function (lastCell) {
  31876. if (!lastCell) {
  31877. return null;
  31878. }
  31879. var rowAbove = this.getRowAbove({ rowIndex: lastCell.rowIndex, rowPinned: lastCell.rowPinned });
  31880. if (rowAbove) {
  31881. return {
  31882. rowIndex: rowAbove.rowIndex,
  31883. column: lastCell.column,
  31884. rowPinned: rowAbove.rowPinned
  31885. };
  31886. }
  31887. return null;
  31888. };
  31889. CellNavigationService.prototype.getLastBodyCell = function () {
  31890. var lastBodyRow = this.rowModel.getRowCount() - 1;
  31891. return { rowIndex: lastBodyRow, rowPinned: null };
  31892. };
  31893. CellNavigationService.prototype.getLastFloatingTopRow = function () {
  31894. var lastFloatingRow = this.pinnedRowModel.getPinnedTopRowData().length - 1;
  31895. return { rowIndex: lastFloatingRow, rowPinned: Constants.PINNED_TOP };
  31896. };
  31897. CellNavigationService.prototype.getNextTabbedCell = function (gridCell, backwards) {
  31898. if (backwards) {
  31899. return this.getNextTabbedCellBackwards(gridCell);
  31900. }
  31901. return this.getNextTabbedCellForwards(gridCell);
  31902. };
  31903. CellNavigationService.prototype.getNextTabbedCellForwards = function (gridCell) {
  31904. var displayedColumns = this.columnController.getAllDisplayedColumns();
  31905. var newRowIndex = gridCell.rowIndex;
  31906. var newFloating = gridCell.rowPinned;
  31907. // move along to the next cell
  31908. var newColumn = this.columnController.getDisplayedColAfter(gridCell.column);
  31909. // check if end of the row, and if so, go forward a row
  31910. if (!newColumn) {
  31911. newColumn = displayedColumns[0];
  31912. var rowBelow = this.getRowBelow(gridCell);
  31913. if (_.missing(rowBelow)) {
  31914. return null;
  31915. }
  31916. newRowIndex = rowBelow ? rowBelow.rowIndex : null;
  31917. newFloating = rowBelow ? rowBelow.rowPinned : null;
  31918. }
  31919. return { rowIndex: newRowIndex, column: newColumn, rowPinned: newFloating };
  31920. };
  31921. CellNavigationService.prototype.getNextTabbedCellBackwards = function (gridCell) {
  31922. var displayedColumns = this.columnController.getAllDisplayedColumns();
  31923. var newRowIndex = gridCell.rowIndex;
  31924. var newFloating = gridCell.rowPinned;
  31925. // move along to the next cell
  31926. var newColumn = this.columnController.getDisplayedColBefore(gridCell.column);
  31927. // check if end of the row, and if so, go forward a row
  31928. if (!newColumn) {
  31929. newColumn = _.last(displayedColumns);
  31930. var rowAbove = this.getRowAbove({ rowIndex: gridCell.rowIndex, rowPinned: gridCell.rowPinned });
  31931. if (_.missing(rowAbove)) {
  31932. return null;
  31933. }
  31934. newRowIndex = rowAbove ? rowAbove.rowIndex : null;
  31935. newFloating = rowAbove ? rowAbove.rowPinned : null;
  31936. }
  31937. return { rowIndex: newRowIndex, column: newColumn, rowPinned: newFloating };
  31938. };
  31939. __decorate$1d([
  31940. Autowired('columnController')
  31941. ], CellNavigationService.prototype, "columnController", void 0);
  31942. __decorate$1d([
  31943. Autowired('rowModel')
  31944. ], CellNavigationService.prototype, "rowModel", void 0);
  31945. __decorate$1d([
  31946. Autowired('pinnedRowModel')
  31947. ], CellNavigationService.prototype, "pinnedRowModel", void 0);
  31948. __decorate$1d([
  31949. Autowired('gridOptionsWrapper')
  31950. ], CellNavigationService.prototype, "gridOptionsWrapper", void 0);
  31951. CellNavigationService = __decorate$1d([
  31952. Bean('cellNavigationService')
  31953. ], CellNavigationService);
  31954. return CellNavigationService;
  31955. }(BeanStub));
  31956. /**
  31957. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  31958. * @version v23.2.1
  31959. * @link http://www.ag-grid.com/
  31960. * @license MIT
  31961. */
  31962. var __decorate$1e = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  31963. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  31964. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  31965. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  31966. return c > 3 && r && Object.defineProperty(target, key, r), r;
  31967. };
  31968. var CellRendererFactory = /** @class */ (function () {
  31969. function CellRendererFactory() {
  31970. this.cellRendererMap = {};
  31971. }
  31972. CellRendererFactory_1 = CellRendererFactory;
  31973. CellRendererFactory.prototype.init = function () {
  31974. this.cellRendererMap[CellRendererFactory_1.ANIMATE_SLIDE] = AnimateSlideCellRenderer;
  31975. this.cellRendererMap[CellRendererFactory_1.ANIMATE_SHOW_CHANGE] = AnimateShowChangeCellRenderer;
  31976. this.cellRendererMap[CellRendererFactory_1.GROUP] = GroupCellRenderer;
  31977. // this.registerRenderersFromGridOptions();
  31978. };
  31979. // private registerRenderersFromGridOptions(): void {
  31980. // let userProvidedCellRenderers = this.gridOptionsWrapper.getCellRenderers();
  31981. // _.iterateObject(userProvidedCellRenderers, (key: string, cellRenderer: {new(): ICellRenderer} | ICellRendererFunc)=> {
  31982. // this.addCellRenderer(key, cellRenderer);
  31983. // });
  31984. // }
  31985. CellRendererFactory.prototype.addCellRenderer = function (key, cellRenderer) {
  31986. this.cellRendererMap[key] = cellRenderer;
  31987. };
  31988. CellRendererFactory.prototype.getCellRenderer = function (key) {
  31989. var result = this.cellRendererMap[key];
  31990. if (_.missing(result)) {
  31991. console.warn('ag-Grid: unable to find cellRenderer for key ' + key);
  31992. return null;
  31993. }
  31994. return result;
  31995. };
  31996. var CellRendererFactory_1;
  31997. CellRendererFactory.ANIMATE_SLIDE = 'animateSlide';
  31998. CellRendererFactory.ANIMATE_SHOW_CHANGE = 'animateShowChange';
  31999. CellRendererFactory.GROUP = 'group';
  32000. __decorate$1e([
  32001. Autowired('gridOptionsWrapper')
  32002. ], CellRendererFactory.prototype, "gridOptionsWrapper", void 0);
  32003. __decorate$1e([
  32004. Autowired('expressionService')
  32005. ], CellRendererFactory.prototype, "expressionService", void 0);
  32006. __decorate$1e([
  32007. Autowired('eventService')
  32008. ], CellRendererFactory.prototype, "eventService", void 0);
  32009. __decorate$1e([
  32010. PostConstruct
  32011. ], CellRendererFactory.prototype, "init", null);
  32012. CellRendererFactory = CellRendererFactory_1 = __decorate$1e([
  32013. Bean('cellRendererFactory')
  32014. ], CellRendererFactory);
  32015. return CellRendererFactory;
  32016. }());
  32017. /**
  32018. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  32019. * @version v23.2.1
  32020. * @link http://www.ag-grid.com/
  32021. * @license MIT
  32022. */
  32023. var __extends$1f = (undefined && undefined.__extends) || (function () {
  32024. var extendStatics = function (d, b) {
  32025. extendStatics = Object.setPrototypeOf ||
  32026. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  32027. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  32028. return extendStatics(d, b);
  32029. };
  32030. return function (d, b) {
  32031. extendStatics(d, b);
  32032. function __() { this.constructor = d; }
  32033. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  32034. };
  32035. })();
  32036. var __decorate$1f = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  32037. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  32038. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  32039. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  32040. return c > 3 && r && Object.defineProperty(target, key, r), r;
  32041. };
  32042. var ValueFormatterService = /** @class */ (function (_super) {
  32043. __extends$1f(ValueFormatterService, _super);
  32044. function ValueFormatterService() {
  32045. return _super !== null && _super.apply(this, arguments) || this;
  32046. }
  32047. ValueFormatterService.prototype.formatValue = function (column, node, $scope, value, suppliedFormatter, useFormatterFromColumn) {
  32048. if (useFormatterFromColumn === void 0) { useFormatterFromColumn = true; }
  32049. var result = null;
  32050. var formatter;
  32051. var colDef = column.getColDef();
  32052. if (suppliedFormatter) {
  32053. // use supplied formatter if provided, e.g. set filter items can have their own value formatters
  32054. formatter = suppliedFormatter;
  32055. }
  32056. else if (useFormatterFromColumn) {
  32057. // if row is pinned, give preference to the pinned formatter
  32058. formatter = node && node.rowPinned && colDef.pinnedRowValueFormatter ?
  32059. colDef.pinnedRowValueFormatter : colDef.valueFormatter;
  32060. }
  32061. if (formatter) {
  32062. var params = {
  32063. value: value,
  32064. node: node,
  32065. data: node ? node.data : null,
  32066. colDef: colDef,
  32067. column: column,
  32068. api: this.gridOptionsWrapper.getApi(),
  32069. columnApi: this.gridOptionsWrapper.getColumnApi(),
  32070. context: this.gridOptionsWrapper.getContext()
  32071. };
  32072. // originally we put the angular 1 scope here, but we don't want the scope
  32073. // in the params interface, as other frameworks will see the interface, and
  32074. // angular 1 is not cool any more. so we hack the scope in here (we cannot
  32075. // include it above, as it's not in the interface, so would cause a compile error).
  32076. // in the future, when we stop supporting angular 1, we can take this out.
  32077. params.$scope = $scope;
  32078. result = this.expressionService.evaluate(formatter, params);
  32079. }
  32080. else if (colDef.refData) {
  32081. return colDef.refData[value] || '';
  32082. }
  32083. // if we don't do this, then arrays get displayed as 1,2,3, but we want 1, 2, 3 (i.e. with spaces)
  32084. if (result == null && Array.isArray(value)) {
  32085. result = value.join(', ');
  32086. }
  32087. return result;
  32088. };
  32089. __decorate$1f([
  32090. Autowired('gridOptionsWrapper')
  32091. ], ValueFormatterService.prototype, "gridOptionsWrapper", void 0);
  32092. __decorate$1f([
  32093. Autowired('expressionService')
  32094. ], ValueFormatterService.prototype, "expressionService", void 0);
  32095. ValueFormatterService = __decorate$1f([
  32096. Bean('valueFormatterService')
  32097. ], ValueFormatterService);
  32098. return ValueFormatterService;
  32099. }(BeanStub));
  32100. /**
  32101. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  32102. * @version v23.2.1
  32103. * @link http://www.ag-grid.com/
  32104. * @license MIT
  32105. */
  32106. var __extends$1g = (undefined && undefined.__extends) || (function () {
  32107. var extendStatics = function (d, b) {
  32108. extendStatics = Object.setPrototypeOf ||
  32109. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  32110. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  32111. return extendStatics(d, b);
  32112. };
  32113. return function (d, b) {
  32114. extendStatics(d, b);
  32115. function __() { this.constructor = d; }
  32116. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  32117. };
  32118. })();
  32119. var AgRadioButton = /** @class */ (function (_super) {
  32120. __extends$1g(AgRadioButton, _super);
  32121. function AgRadioButton() {
  32122. var _this = _super !== null && _super.apply(this, arguments) || this;
  32123. _this.className = 'ag-radio-button';
  32124. _this.inputType = 'radio';
  32125. return _this;
  32126. }
  32127. AgRadioButton.prototype.isSelected = function () {
  32128. return this.eInput.checked;
  32129. };
  32130. AgRadioButton.prototype.toggle = function () {
  32131. var nextValue = this.getNextValue();
  32132. this.setValue(nextValue);
  32133. };
  32134. AgRadioButton.prototype.addInputListeners = function () {
  32135. _super.prototype.addInputListeners.call(this);
  32136. this.addManagedListener(this.eventService, Events.EVENT_CHECKBOX_CHANGED, this.onChange.bind(this));
  32137. };
  32138. /**
  32139. * This ensures that if another radio button in the same named group is selected, we deselect this radio button.
  32140. * By default the browser does this for you, but we are managing classes ourselves in order to ensure input
  32141. * elements are styled correctly in IE11, and the DOM 'changed' event is only fired when a button is selected,
  32142. * not deselected, so we need to use our own event.
  32143. */
  32144. AgRadioButton.prototype.onChange = function (event) {
  32145. if (event.selected &&
  32146. event.name &&
  32147. this.eInput.name &&
  32148. this.eInput.name === event.name &&
  32149. event.id &&
  32150. this.eInput.id !== event.id) {
  32151. this.setValue(false, true);
  32152. }
  32153. };
  32154. return AgRadioButton;
  32155. }(AgCheckbox));
  32156. /**
  32157. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  32158. * @version v23.2.1
  32159. * @link http://www.ag-grid.com/
  32160. * @license MIT
  32161. */
  32162. /** The base frameworks, eg React & Angular 2, override this bean with implementations specific to their requirement. */
  32163. var VanillaFrameworkOverrides = /** @class */ (function () {
  32164. function VanillaFrameworkOverrides() {
  32165. }
  32166. // for Vanilla JS, we use simple timeout
  32167. VanillaFrameworkOverrides.prototype.setTimeout = function (action, timeout) {
  32168. window.setTimeout(action, timeout);
  32169. };
  32170. // for Vanilla JS, we just add the event to the element
  32171. VanillaFrameworkOverrides.prototype.addEventListenerOutsideAngular = function (element, type, listener, useCapture) {
  32172. element.addEventListener(type, listener, useCapture);
  32173. };
  32174. return VanillaFrameworkOverrides;
  32175. }());
  32176. /**
  32177. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  32178. * @version v23.2.1
  32179. * @link http://www.ag-grid.com/
  32180. * @license MIT
  32181. */
  32182. var __extends$1h = (undefined && undefined.__extends) || (function () {
  32183. var extendStatics = function (d, b) {
  32184. extendStatics = Object.setPrototypeOf ||
  32185. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  32186. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  32187. return extendStatics(d, b);
  32188. };
  32189. return function (d, b) {
  32190. extendStatics(d, b);
  32191. function __() { this.constructor = d; }
  32192. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  32193. };
  32194. })();
  32195. var __decorate$1g = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  32196. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  32197. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  32198. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  32199. return c > 3 && r && Object.defineProperty(target, key, r), r;
  32200. };
  32201. var ScrollVisibleService = /** @class */ (function (_super) {
  32202. __extends$1h(ScrollVisibleService, _super);
  32203. function ScrollVisibleService() {
  32204. return _super !== null && _super.apply(this, arguments) || this;
  32205. }
  32206. ScrollVisibleService.prototype.setScrollsVisible = function (params) {
  32207. var atLeastOneDifferent = this.horizontalScrollShowing !== params.horizontalScrollShowing ||
  32208. this.verticalScrollShowing !== params.verticalScrollShowing;
  32209. if (atLeastOneDifferent) {
  32210. this.horizontalScrollShowing = params.horizontalScrollShowing;
  32211. this.verticalScrollShowing = params.verticalScrollShowing;
  32212. var event_1 = {
  32213. type: Events.EVENT_SCROLL_VISIBILITY_CHANGED,
  32214. api: this.gridApi,
  32215. columnApi: this.columnApi
  32216. };
  32217. this.eventService.dispatchEvent(event_1);
  32218. }
  32219. };
  32220. // used by pagination service - to know page height
  32221. ScrollVisibleService.prototype.isHorizontalScrollShowing = function () {
  32222. return this.horizontalScrollShowing;
  32223. };
  32224. // used by header container
  32225. ScrollVisibleService.prototype.isVerticalScrollShowing = function () {
  32226. return this.verticalScrollShowing;
  32227. };
  32228. __decorate$1g([
  32229. Autowired('columnController')
  32230. ], ScrollVisibleService.prototype, "columnController", void 0);
  32231. __decorate$1g([
  32232. Autowired('columnApi')
  32233. ], ScrollVisibleService.prototype, "columnApi", void 0);
  32234. __decorate$1g([
  32235. Autowired('gridApi')
  32236. ], ScrollVisibleService.prototype, "gridApi", void 0);
  32237. __decorate$1g([
  32238. Autowired('gridOptionsWrapper')
  32239. ], ScrollVisibleService.prototype, "gridOptionsWrapper", void 0);
  32240. ScrollVisibleService = __decorate$1g([
  32241. Bean('scrollVisibleService')
  32242. ], ScrollVisibleService);
  32243. return ScrollVisibleService;
  32244. }(BeanStub));
  32245. /**
  32246. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  32247. * @version v23.2.1
  32248. * @link http://www.ag-grid.com/
  32249. * @license MIT
  32250. */
  32251. var __extends$1i = (undefined && undefined.__extends) || (function () {
  32252. var extendStatics = function (d, b) {
  32253. extendStatics = Object.setPrototypeOf ||
  32254. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  32255. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  32256. return extendStatics(d, b);
  32257. };
  32258. return function (d, b) {
  32259. extendStatics(d, b);
  32260. function __() { this.constructor = d; }
  32261. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  32262. };
  32263. })();
  32264. var __decorate$1h = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  32265. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  32266. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  32267. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  32268. return c > 3 && r && Object.defineProperty(target, key, r), r;
  32269. };
  32270. var StylingService = /** @class */ (function (_super) {
  32271. __extends$1i(StylingService, _super);
  32272. function StylingService() {
  32273. return _super !== null && _super.apply(this, arguments) || this;
  32274. }
  32275. StylingService.prototype.processAllCellClasses = function (colDef, params, onApplicableClass, onNotApplicableClass) {
  32276. this.processClassRules(colDef.cellClassRules, params, onApplicableClass, onNotApplicableClass);
  32277. this.processStaticCellClasses(colDef, params, onApplicableClass);
  32278. };
  32279. StylingService.prototype.processClassRules = function (classRules, params, onApplicableClass, onNotApplicableClass) {
  32280. if (typeof classRules === 'object' && classRules !== null) {
  32281. var classNames = Object.keys(classRules);
  32282. for (var i = 0; i < classNames.length; i++) {
  32283. var className = classNames[i];
  32284. var rule = classRules[className];
  32285. var resultOfRule = void 0;
  32286. if (typeof rule === 'string') {
  32287. resultOfRule = this.expressionService.evaluate(rule, params);
  32288. }
  32289. else if (typeof rule === 'function') {
  32290. resultOfRule = rule(params);
  32291. }
  32292. if (resultOfRule) {
  32293. onApplicableClass(className);
  32294. }
  32295. else if (onNotApplicableClass) {
  32296. onNotApplicableClass(className);
  32297. }
  32298. }
  32299. }
  32300. };
  32301. StylingService.prototype.processStaticCellClasses = function (colDef, params, onApplicableClass) {
  32302. var cellClass = colDef.cellClass;
  32303. if (cellClass) {
  32304. var classOrClasses = void 0;
  32305. if (typeof colDef.cellClass === 'function') {
  32306. var cellClassFunc = colDef.cellClass;
  32307. classOrClasses = cellClassFunc(params);
  32308. }
  32309. else {
  32310. classOrClasses = colDef.cellClass;
  32311. }
  32312. if (typeof classOrClasses === 'string') {
  32313. onApplicableClass(classOrClasses);
  32314. }
  32315. else if (Array.isArray(classOrClasses)) {
  32316. classOrClasses.forEach(function (cssClassItem) {
  32317. onApplicableClass(cssClassItem);
  32318. });
  32319. }
  32320. }
  32321. };
  32322. __decorate$1h([
  32323. Autowired('expressionService')
  32324. ], StylingService.prototype, "expressionService", void 0);
  32325. StylingService = __decorate$1h([
  32326. Bean('stylingService')
  32327. ], StylingService);
  32328. return StylingService;
  32329. }(BeanStub));
  32330. /**
  32331. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  32332. * @version v23.2.1
  32333. * @link http://www.ag-grid.com/
  32334. * @license MIT
  32335. */
  32336. var __extends$1j = (undefined && undefined.__extends) || (function () {
  32337. var extendStatics = function (d, b) {
  32338. extendStatics = Object.setPrototypeOf ||
  32339. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  32340. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  32341. return extendStatics(d, b);
  32342. };
  32343. return function (d, b) {
  32344. extendStatics(d, b);
  32345. function __() { this.constructor = d; }
  32346. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  32347. };
  32348. })();
  32349. var __decorate$1i = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  32350. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  32351. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  32352. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  32353. return c > 3 && r && Object.defineProperty(target, key, r), r;
  32354. };
  32355. var ColumnHoverService = /** @class */ (function (_super) {
  32356. __extends$1j(ColumnHoverService, _super);
  32357. function ColumnHoverService() {
  32358. return _super !== null && _super.apply(this, arguments) || this;
  32359. }
  32360. ColumnHoverService.prototype.setMouseOver = function (columns) {
  32361. this.selectedColumns = columns;
  32362. var event = {
  32363. type: Events.EVENT_COLUMN_HOVER_CHANGED,
  32364. api: this.gridApi,
  32365. columnApi: this.columnApi
  32366. };
  32367. this.eventService.dispatchEvent(event);
  32368. };
  32369. ColumnHoverService.prototype.clearMouseOver = function () {
  32370. this.selectedColumns = null;
  32371. var event = {
  32372. type: Events.EVENT_COLUMN_HOVER_CHANGED,
  32373. api: this.gridApi,
  32374. columnApi: this.columnApi
  32375. };
  32376. this.eventService.dispatchEvent(event);
  32377. };
  32378. ColumnHoverService.prototype.isHovered = function (column) {
  32379. return this.selectedColumns && this.selectedColumns.indexOf(column) >= 0;
  32380. };
  32381. __decorate$1i([
  32382. Autowired('columnApi')
  32383. ], ColumnHoverService.prototype, "columnApi", void 0);
  32384. __decorate$1i([
  32385. Autowired('gridApi')
  32386. ], ColumnHoverService.prototype, "gridApi", void 0);
  32387. ColumnHoverService = __decorate$1i([
  32388. Bean('columnHoverService')
  32389. ], ColumnHoverService);
  32390. return ColumnHoverService;
  32391. }(BeanStub));
  32392. /**
  32393. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  32394. * @version v23.2.1
  32395. * @link http://www.ag-grid.com/
  32396. * @license MIT
  32397. */
  32398. var __extends$1k = (undefined && undefined.__extends) || (function () {
  32399. var extendStatics = function (d, b) {
  32400. extendStatics = Object.setPrototypeOf ||
  32401. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  32402. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  32403. return extendStatics(d, b);
  32404. };
  32405. return function (d, b) {
  32406. extendStatics(d, b);
  32407. function __() { this.constructor = d; }
  32408. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  32409. };
  32410. })();
  32411. var __decorate$1j = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  32412. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  32413. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  32414. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  32415. return c > 3 && r && Object.defineProperty(target, key, r), r;
  32416. };
  32417. var ColumnAnimationService = /** @class */ (function (_super) {
  32418. __extends$1k(ColumnAnimationService, _super);
  32419. function ColumnAnimationService() {
  32420. var _this = _super !== null && _super.apply(this, arguments) || this;
  32421. _this.executeNextFuncs = [];
  32422. _this.executeLaterFuncs = [];
  32423. _this.active = false;
  32424. _this.animationThreadCount = 0;
  32425. return _this;
  32426. }
  32427. ColumnAnimationService.prototype.registerGridComp = function (gridPanel) {
  32428. this.gridPanel = gridPanel;
  32429. };
  32430. ColumnAnimationService.prototype.isActive = function () {
  32431. return this.active;
  32432. };
  32433. ColumnAnimationService.prototype.start = function () {
  32434. if (this.active) {
  32435. return;
  32436. }
  32437. if (this.gridOptionsWrapper.isSuppressColumnMoveAnimation()) {
  32438. return;
  32439. }
  32440. // if doing RTL, we don't animate open / close as due to how the pixels are inverted,
  32441. // the animation moves all the row the the right rather than to the left (ie it's the static
  32442. // columns that actually get their coordinates updated)
  32443. if (this.gridOptionsWrapper.isEnableRtl()) {
  32444. return;
  32445. }
  32446. this.ensureAnimationCssClassPresent();
  32447. this.active = true;
  32448. };
  32449. ColumnAnimationService.prototype.finish = function () {
  32450. if (!this.active) {
  32451. return;
  32452. }
  32453. this.flush();
  32454. this.active = false;
  32455. };
  32456. ColumnAnimationService.prototype.executeNextVMTurn = function (func) {
  32457. if (this.active) {
  32458. this.executeNextFuncs.push(func);
  32459. }
  32460. else {
  32461. func();
  32462. }
  32463. };
  32464. ColumnAnimationService.prototype.executeLaterVMTurn = function (func) {
  32465. if (this.active) {
  32466. this.executeLaterFuncs.push(func);
  32467. }
  32468. else {
  32469. func();
  32470. }
  32471. };
  32472. ColumnAnimationService.prototype.ensureAnimationCssClassPresent = function () {
  32473. var _this = this;
  32474. // up the count, so we can tell if someone else has updated the count
  32475. // by the time the 'wait' func executes
  32476. this.animationThreadCount++;
  32477. var animationThreadCountCopy = this.animationThreadCount;
  32478. this.gridPanel.setColumnMovingCss(true);
  32479. this.executeLaterFuncs.push(function () {
  32480. // only remove the class if this thread was the last one to update it
  32481. if (_this.animationThreadCount === animationThreadCountCopy) {
  32482. _this.gridPanel.setColumnMovingCss(false);
  32483. }
  32484. });
  32485. };
  32486. ColumnAnimationService.prototype.flush = function () {
  32487. var nowFuncs = this.executeNextFuncs;
  32488. this.executeNextFuncs = [];
  32489. var waitFuncs = this.executeLaterFuncs;
  32490. this.executeLaterFuncs = [];
  32491. if (nowFuncs.length === 0 && waitFuncs.length === 0) {
  32492. return;
  32493. }
  32494. window.setTimeout(function () { return nowFuncs.forEach(function (func) { return func(); }); }, 0);
  32495. window.setTimeout(function () { return waitFuncs.forEach(function (func) { return func(); }); }, 300);
  32496. };
  32497. __decorate$1j([
  32498. Autowired('gridOptionsWrapper')
  32499. ], ColumnAnimationService.prototype, "gridOptionsWrapper", void 0);
  32500. ColumnAnimationService = __decorate$1j([
  32501. Bean('columnAnimationService')
  32502. ], ColumnAnimationService);
  32503. return ColumnAnimationService;
  32504. }(BeanStub));
  32505. /**
  32506. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  32507. * @version v23.2.1
  32508. * @link http://www.ag-grid.com/
  32509. * @license MIT
  32510. */
  32511. var __extends$1l = (undefined && undefined.__extends) || (function () {
  32512. var extendStatics = function (d, b) {
  32513. extendStatics = Object.setPrototypeOf ||
  32514. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  32515. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  32516. return extendStatics(d, b);
  32517. };
  32518. return function (d, b) {
  32519. extendStatics(d, b);
  32520. function __() { this.constructor = d; }
  32521. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  32522. };
  32523. })();
  32524. var __decorate$1k = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  32525. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  32526. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  32527. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  32528. return c > 3 && r && Object.defineProperty(target, key, r), r;
  32529. };
  32530. var AutoGroupColService = /** @class */ (function (_super) {
  32531. __extends$1l(AutoGroupColService, _super);
  32532. function AutoGroupColService() {
  32533. return _super !== null && _super.apply(this, arguments) || this;
  32534. }
  32535. AutoGroupColService_1 = AutoGroupColService;
  32536. AutoGroupColService.prototype.createAutoGroupColumns = function (rowGroupColumns) {
  32537. var _this = this;
  32538. var groupAutoColumns = [];
  32539. var doingTreeData = this.gridOptionsWrapper.isTreeData();
  32540. var doingMultiAutoColumn = this.gridOptionsWrapper.isGroupMultiAutoColumn();
  32541. if (doingTreeData && doingMultiAutoColumn) {
  32542. console.warn('ag-Grid: you cannot mix groupMultiAutoColumn with treeData, only one column can be used to display groups when doing tree data');
  32543. doingMultiAutoColumn = false;
  32544. }
  32545. // if doing groupMultiAutoColumn, then we call the method multiple times, once
  32546. // for each column we are grouping by
  32547. if (doingMultiAutoColumn) {
  32548. rowGroupColumns.forEach(function (rowGroupCol, index) {
  32549. groupAutoColumns.push(_this.createOneAutoGroupColumn(rowGroupCol, index));
  32550. });
  32551. }
  32552. else {
  32553. groupAutoColumns.push(this.createOneAutoGroupColumn());
  32554. }
  32555. return groupAutoColumns;
  32556. };
  32557. // rowGroupCol and index are missing if groupMultiAutoColumn=false
  32558. AutoGroupColService.prototype.createOneAutoGroupColumn = function (rowGroupCol, index) {
  32559. // if one provided by user, use it, otherwise create one
  32560. var defaultAutoColDef = this.generateDefaultColDef(rowGroupCol);
  32561. // if doing multi, set the field
  32562. var colId;
  32563. if (rowGroupCol) {
  32564. colId = Constants.GROUP_AUTO_COLUMN_ID + "-" + rowGroupCol.getId();
  32565. }
  32566. else {
  32567. colId = AutoGroupColService_1.GROUP_AUTO_COLUMN_BUNDLE_ID;
  32568. }
  32569. var userAutoColDef = this.gridOptionsWrapper.getAutoGroupColumnDef();
  32570. _.mergeDeep(defaultAutoColDef, userAutoColDef);
  32571. defaultAutoColDef = this.columnFactory.mergeColDefs(defaultAutoColDef);
  32572. defaultAutoColDef.colId = colId;
  32573. // For tree data the filter is always allowed
  32574. if (!this.gridOptionsWrapper.isTreeData()) {
  32575. // we would only allow filter if the user has provided field or value getter. otherwise the filter
  32576. // would not be able to work.
  32577. var noFieldOrValueGetter = _.missing(defaultAutoColDef.field) && _.missing(defaultAutoColDef.valueGetter) && _.missing(defaultAutoColDef.filterValueGetter);
  32578. if (noFieldOrValueGetter) {
  32579. defaultAutoColDef.filter = false;
  32580. }
  32581. }
  32582. // if showing many cols, we don't want to show more than one with a checkbox for selection
  32583. if (index && index > 0) {
  32584. defaultAutoColDef.headerCheckboxSelection = false;
  32585. }
  32586. var newCol = new Column(defaultAutoColDef, null, colId, true);
  32587. this.context.createBean(newCol);
  32588. return newCol;
  32589. };
  32590. AutoGroupColService.prototype.generateDefaultColDef = function (rowGroupCol) {
  32591. var userAutoColDef = this.gridOptionsWrapper.getAutoGroupColumnDef();
  32592. var localeTextFunc = this.gridOptionsWrapper.getLocaleTextFunc();
  32593. var defaultAutoColDef = {
  32594. headerName: localeTextFunc('group', 'Group')
  32595. };
  32596. var userHasProvidedGroupCellRenderer = userAutoColDef && (userAutoColDef.cellRenderer || userAutoColDef.cellRendererFramework);
  32597. // only add the default group cell renderer if user hasn't provided one
  32598. if (!userHasProvidedGroupCellRenderer) {
  32599. defaultAutoColDef.cellRenderer = 'agGroupCellRenderer';
  32600. }
  32601. // we never allow moving the group column
  32602. // defaultAutoColDef.suppressMovable = true;
  32603. if (rowGroupCol) {
  32604. var rowGroupColDef = rowGroupCol.getColDef();
  32605. _.assign(defaultAutoColDef, {
  32606. // cellRendererParams.groupKey: colDefToCopy.field;
  32607. headerName: this.columnController.getDisplayNameForColumn(rowGroupCol, 'header'),
  32608. headerValueGetter: rowGroupColDef.headerValueGetter
  32609. });
  32610. if (rowGroupColDef.cellRenderer) {
  32611. _.assign(defaultAutoColDef, {
  32612. cellRendererParams: {
  32613. innerRenderer: rowGroupColDef.cellRenderer,
  32614. innerRendererParams: rowGroupColDef.cellRendererParams
  32615. }
  32616. });
  32617. }
  32618. defaultAutoColDef.showRowGroup = rowGroupCol.getColId();
  32619. }
  32620. else {
  32621. defaultAutoColDef.showRowGroup = true;
  32622. }
  32623. return defaultAutoColDef;
  32624. };
  32625. var AutoGroupColService_1;
  32626. AutoGroupColService.GROUP_AUTO_COLUMN_BUNDLE_ID = Constants.GROUP_AUTO_COLUMN_ID;
  32627. __decorate$1k([
  32628. Autowired('gridOptionsWrapper')
  32629. ], AutoGroupColService.prototype, "gridOptionsWrapper", void 0);
  32630. __decorate$1k([
  32631. Autowired('columnController')
  32632. ], AutoGroupColService.prototype, "columnController", void 0);
  32633. __decorate$1k([
  32634. Autowired('columnFactory')
  32635. ], AutoGroupColService.prototype, "columnFactory", void 0);
  32636. AutoGroupColService = AutoGroupColService_1 = __decorate$1k([
  32637. Bean('autoGroupColService')
  32638. ], AutoGroupColService);
  32639. return AutoGroupColService;
  32640. }(BeanStub));
  32641. /**
  32642. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  32643. * @version v23.2.1
  32644. * @link http://www.ag-grid.com/
  32645. * @license MIT
  32646. */
  32647. var __extends$1m = (undefined && undefined.__extends) || (function () {
  32648. var extendStatics = function (d, b) {
  32649. extendStatics = Object.setPrototypeOf ||
  32650. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  32651. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  32652. return extendStatics(d, b);
  32653. };
  32654. return function (d, b) {
  32655. extendStatics(d, b);
  32656. function __() { this.constructor = d; }
  32657. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  32658. };
  32659. })();
  32660. var __decorate$1l = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  32661. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  32662. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  32663. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  32664. return c > 3 && r && Object.defineProperty(target, key, r), r;
  32665. };
  32666. var PaginationProxy = /** @class */ (function (_super) {
  32667. __extends$1m(PaginationProxy, _super);
  32668. function PaginationProxy() {
  32669. var _this = _super !== null && _super.apply(this, arguments) || this;
  32670. _this.currentPage = 0;
  32671. _this.topDisplayedRowIndex = 0;
  32672. _this.bottomDisplayedRowIndex = 0;
  32673. _this.pixelOffset = 0;
  32674. _this.masterRowCount = 0;
  32675. return _this;
  32676. }
  32677. PaginationProxy.prototype.postConstruct = function () {
  32678. this.active = this.gridOptionsWrapper.isPagination();
  32679. this.paginateChildRows = this.gridOptionsWrapper.isPaginateChildRows();
  32680. this.addManagedListener(this.eventService, Events.EVENT_MODEL_UPDATED, this.onModelUpdated.bind(this));
  32681. this.addManagedListener(this.gridOptionsWrapper, 'paginationPageSize', this.onModelUpdated.bind(this));
  32682. this.onModelUpdated();
  32683. };
  32684. PaginationProxy.prototype.ensureRowHeightsValid = function (startPixel, endPixel, startLimitIndex, endLimitIndex) {
  32685. var res = this.rowModel.ensureRowHeightsValid(startPixel, endPixel, this.getPageFirstRow(), this.getPageLastRow());
  32686. if (res) {
  32687. this.calculatePages();
  32688. }
  32689. return res;
  32690. };
  32691. PaginationProxy.prototype.onModelUpdated = function (modelUpdatedEvent) {
  32692. this.calculatePages();
  32693. var paginationChangedEvent = {
  32694. type: Events.EVENT_PAGINATION_CHANGED,
  32695. animate: modelUpdatedEvent ? modelUpdatedEvent.animate : false,
  32696. newData: modelUpdatedEvent ? modelUpdatedEvent.newData : false,
  32697. newPage: modelUpdatedEvent ? modelUpdatedEvent.newPage : false,
  32698. keepRenderedRows: modelUpdatedEvent ? modelUpdatedEvent.keepRenderedRows : false,
  32699. api: this.gridApi,
  32700. columnApi: this.columnApi
  32701. };
  32702. this.eventService.dispatchEvent(paginationChangedEvent);
  32703. };
  32704. PaginationProxy.prototype.goToPage = function (page) {
  32705. if (!this.active) {
  32706. return;
  32707. }
  32708. if (this.currentPage === page) {
  32709. return;
  32710. }
  32711. this.currentPage = page;
  32712. var event = {
  32713. type: Events.EVENT_MODEL_UPDATED,
  32714. animate: false,
  32715. keepRenderedRows: false,
  32716. newData: false,
  32717. newPage: true,
  32718. api: this.gridApi,
  32719. columnApi: this.columnApi
  32720. };
  32721. this.onModelUpdated(event);
  32722. };
  32723. PaginationProxy.prototype.getPixelOffset = function () {
  32724. return this.pixelOffset;
  32725. };
  32726. PaginationProxy.prototype.getRow = function (index) {
  32727. return this.rowModel.getRow(index);
  32728. };
  32729. PaginationProxy.prototype.getRowNode = function (id) {
  32730. return this.rowModel.getRowNode(id);
  32731. };
  32732. PaginationProxy.prototype.getRowIndexAtPixel = function (pixel) {
  32733. return this.rowModel.getRowIndexAtPixel(pixel);
  32734. };
  32735. PaginationProxy.prototype.getCurrentPageHeight = function () {
  32736. if (_.missing(this.topRowBounds) || _.missing(this.bottomRowBounds)) {
  32737. return 0;
  32738. }
  32739. return Math.max(this.bottomRowBounds.rowTop + this.bottomRowBounds.rowHeight - this.topRowBounds.rowTop, 0);
  32740. };
  32741. PaginationProxy.prototype.isRowPresent = function (rowNode) {
  32742. if (!this.rowModel.isRowPresent(rowNode)) {
  32743. return false;
  32744. }
  32745. var nodeIsInPage = rowNode.rowIndex >= this.topDisplayedRowIndex && rowNode.rowIndex <= this.bottomDisplayedRowIndex;
  32746. return nodeIsInPage;
  32747. };
  32748. PaginationProxy.prototype.isEmpty = function () {
  32749. return this.rowModel.isEmpty();
  32750. };
  32751. PaginationProxy.prototype.isRowsToRender = function () {
  32752. return this.rowModel.isRowsToRender();
  32753. };
  32754. PaginationProxy.prototype.getNodesInRangeForSelection = function (firstInRange, lastInRange) {
  32755. return this.rowModel.getNodesInRangeForSelection(firstInRange, lastInRange);
  32756. };
  32757. PaginationProxy.prototype.forEachNode = function (callback) {
  32758. return this.rowModel.forEachNode(callback);
  32759. };
  32760. PaginationProxy.prototype.getType = function () {
  32761. return this.rowModel.getType();
  32762. };
  32763. PaginationProxy.prototype.getRowBounds = function (index) {
  32764. var res = this.rowModel.getRowBounds(index);
  32765. res.rowIndex = index;
  32766. return res;
  32767. };
  32768. PaginationProxy.prototype.getPageFirstRow = function () {
  32769. return this.topRowBounds ? this.topRowBounds.rowIndex : -1;
  32770. };
  32771. PaginationProxy.prototype.getPageLastRow = function () {
  32772. return this.bottomRowBounds ? this.bottomRowBounds.rowIndex : -1;
  32773. };
  32774. PaginationProxy.prototype.getRowCount = function () {
  32775. return this.rowModel.getRowCount();
  32776. };
  32777. PaginationProxy.prototype.goToPageWithIndex = function (index) {
  32778. if (!this.active) {
  32779. return;
  32780. }
  32781. var pageNumber = Math.floor(index / this.pageSize);
  32782. this.goToPage(pageNumber);
  32783. };
  32784. PaginationProxy.prototype.isLastPageFound = function () {
  32785. return this.rowModel.isLastRowFound();
  32786. };
  32787. PaginationProxy.prototype.getCurrentPage = function () {
  32788. return this.currentPage;
  32789. };
  32790. PaginationProxy.prototype.goToNextPage = function () {
  32791. this.goToPage(this.currentPage + 1);
  32792. };
  32793. PaginationProxy.prototype.goToPreviousPage = function () {
  32794. this.goToPage(this.currentPage - 1);
  32795. };
  32796. PaginationProxy.prototype.goToFirstPage = function () {
  32797. this.goToPage(0);
  32798. };
  32799. PaginationProxy.prototype.goToLastPage = function () {
  32800. var rowCount = this.rowModel.getRowCount();
  32801. var lastPage = Math.floor(rowCount / this.pageSize);
  32802. this.goToPage(lastPage);
  32803. };
  32804. PaginationProxy.prototype.getPageSize = function () {
  32805. return this.pageSize;
  32806. };
  32807. PaginationProxy.prototype.getTotalPages = function () {
  32808. return this.totalPages;
  32809. };
  32810. PaginationProxy.prototype.setPageSize = function () {
  32811. // show put this into super class
  32812. this.pageSize = this.gridOptionsWrapper.getPaginationPageSize();
  32813. if (!(this.pageSize >= 1)) {
  32814. this.pageSize = 100;
  32815. }
  32816. };
  32817. PaginationProxy.prototype.calculatePages = function () {
  32818. if (this.active) {
  32819. this.setPageSize();
  32820. if (this.paginateChildRows) {
  32821. this.calculatePagesAllRows();
  32822. }
  32823. else {
  32824. this.calculatePagesMasterRowsOnly();
  32825. }
  32826. }
  32827. else {
  32828. this.calculatedPagesNotActive();
  32829. }
  32830. this.topRowBounds = this.rowModel.getRowBounds(this.topDisplayedRowIndex);
  32831. if (this.topRowBounds) {
  32832. this.topRowBounds.rowIndex = this.topDisplayedRowIndex;
  32833. }
  32834. this.bottomRowBounds = this.rowModel.getRowBounds(this.bottomDisplayedRowIndex);
  32835. if (this.bottomRowBounds) {
  32836. this.bottomRowBounds.rowIndex = this.bottomDisplayedRowIndex;
  32837. }
  32838. this.pixelOffset = _.exists(this.topRowBounds) ? this.topRowBounds.rowTop : 0;
  32839. };
  32840. PaginationProxy.prototype.setZeroRows = function () {
  32841. this.topDisplayedRowIndex = 0;
  32842. this.bottomDisplayedRowIndex = -1;
  32843. this.currentPage = 0;
  32844. this.totalPages = 0;
  32845. };
  32846. PaginationProxy.prototype.calculatePagesMasterRowsOnly = function () {
  32847. // const csrm = <ClientSideRowModel> this.rowModel;
  32848. // const rootNode = csrm.getRootNode();
  32849. // const masterRows = rootNode.childrenAfterSort;
  32850. this.masterRowCount = this.rowModel.getTopLevelRowCount();
  32851. if (this.masterRowCount === 0) {
  32852. this.setZeroRows();
  32853. return;
  32854. }
  32855. var masterLastRowIndex = this.masterRowCount - 1;
  32856. this.totalPages = Math.floor((masterLastRowIndex) / this.pageSize) + 1;
  32857. if (this.currentPage >= this.totalPages) {
  32858. this.currentPage = this.totalPages - 1;
  32859. }
  32860. if (!_.isNumeric(this.currentPage) || this.currentPage < 0) {
  32861. this.currentPage = 0;
  32862. }
  32863. var masterPageStartIndex = this.pageSize * this.currentPage;
  32864. var masterPageEndIndex = (this.pageSize * (this.currentPage + 1)) - 1;
  32865. if (masterPageEndIndex > masterLastRowIndex) {
  32866. masterPageEndIndex = masterLastRowIndex;
  32867. }
  32868. this.topDisplayedRowIndex = this.rowModel.getTopLevelRowDisplayedIndex(masterPageStartIndex);
  32869. // masterRows[masterPageStartIndex].rowIndex;
  32870. if (masterPageEndIndex === masterLastRowIndex) {
  32871. // if showing the last master row, then we want to show the very last row of the model
  32872. this.bottomDisplayedRowIndex = this.rowModel.getRowCount() - 1;
  32873. }
  32874. else {
  32875. var firstIndexNotToShow = this.rowModel.getTopLevelRowDisplayedIndex(masterPageEndIndex + 1);
  32876. //masterRows[masterPageEndIndex + 1].rowIndex;
  32877. // this gets the index of the last child - eg current row is open, we want to display all children,
  32878. // the index of the last child is one less than the index of the next parent row.
  32879. this.bottomDisplayedRowIndex = firstIndexNotToShow - 1;
  32880. }
  32881. };
  32882. PaginationProxy.prototype.getMasterRowCount = function () {
  32883. return this.masterRowCount;
  32884. };
  32885. PaginationProxy.prototype.calculatePagesAllRows = function () {
  32886. this.masterRowCount = this.rowModel.getRowCount();
  32887. if (this.masterRowCount === 0) {
  32888. this.setZeroRows();
  32889. return;
  32890. }
  32891. var maxRowIndex = this.masterRowCount - 1;
  32892. this.totalPages = Math.floor((maxRowIndex) / this.pageSize) + 1;
  32893. if (this.currentPage >= this.totalPages) {
  32894. this.currentPage = this.totalPages - 1;
  32895. }
  32896. if (!_.isNumeric(this.currentPage) || this.currentPage < 0) {
  32897. this.currentPage = 0;
  32898. }
  32899. this.topDisplayedRowIndex = this.pageSize * this.currentPage;
  32900. this.bottomDisplayedRowIndex = (this.pageSize * (this.currentPage + 1)) - 1;
  32901. if (this.bottomDisplayedRowIndex > maxRowIndex) {
  32902. this.bottomDisplayedRowIndex = maxRowIndex;
  32903. }
  32904. };
  32905. PaginationProxy.prototype.calculatedPagesNotActive = function () {
  32906. this.pageSize = this.rowModel.getRowCount();
  32907. this.totalPages = 1;
  32908. this.currentPage = 0;
  32909. this.topDisplayedRowIndex = 0;
  32910. this.bottomDisplayedRowIndex = this.rowModel.getRowCount() - 1;
  32911. };
  32912. __decorate$1l([
  32913. Autowired('rowModel')
  32914. ], PaginationProxy.prototype, "rowModel", void 0);
  32915. __decorate$1l([
  32916. Autowired('gridOptionsWrapper')
  32917. ], PaginationProxy.prototype, "gridOptionsWrapper", void 0);
  32918. __decorate$1l([
  32919. Autowired('selectionController')
  32920. ], PaginationProxy.prototype, "selectionController", void 0);
  32921. __decorate$1l([
  32922. Autowired('columnApi')
  32923. ], PaginationProxy.prototype, "columnApi", void 0);
  32924. __decorate$1l([
  32925. Autowired('gridApi')
  32926. ], PaginationProxy.prototype, "gridApi", void 0);
  32927. __decorate$1l([
  32928. PostConstruct
  32929. ], PaginationProxy.prototype, "postConstruct", null);
  32930. PaginationProxy = __decorate$1l([
  32931. Bean('paginationProxy')
  32932. ], PaginationProxy);
  32933. return PaginationProxy;
  32934. }(BeanStub));
  32935. /**
  32936. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  32937. * @version v23.2.1
  32938. * @link http://www.ag-grid.com/
  32939. * @license MIT
  32940. */
  32941. var __extends$1n = (undefined && undefined.__extends) || (function () {
  32942. var extendStatics = function (d, b) {
  32943. extendStatics = Object.setPrototypeOf ||
  32944. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  32945. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  32946. return extendStatics(d, b);
  32947. };
  32948. return function (d, b) {
  32949. extendStatics(d, b);
  32950. function __() { this.constructor = d; }
  32951. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  32952. };
  32953. })();
  32954. var __decorate$1m = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  32955. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  32956. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  32957. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  32958. return c > 3 && r && Object.defineProperty(target, key, r), r;
  32959. };
  32960. var PaginationAutoPageSizeService = /** @class */ (function (_super) {
  32961. __extends$1n(PaginationAutoPageSizeService, _super);
  32962. function PaginationAutoPageSizeService() {
  32963. return _super !== null && _super.apply(this, arguments) || this;
  32964. }
  32965. PaginationAutoPageSizeService.prototype.registerGridComp = function (gridPanel) {
  32966. this.gridPanel = gridPanel;
  32967. this.addManagedListener(this.eventService, Events.EVENT_BODY_HEIGHT_CHANGED, this.onBodyHeightChanged.bind(this));
  32968. this.addManagedListener(this.eventService, Events.EVENT_SCROLL_VISIBILITY_CHANGED, this.onScrollVisibilityChanged.bind(this));
  32969. this.checkPageSize();
  32970. };
  32971. PaginationAutoPageSizeService.prototype.notActive = function () {
  32972. return !this.gridOptionsWrapper.isPaginationAutoPageSize();
  32973. };
  32974. PaginationAutoPageSizeService.prototype.onScrollVisibilityChanged = function () {
  32975. this.checkPageSize();
  32976. };
  32977. PaginationAutoPageSizeService.prototype.onBodyHeightChanged = function () {
  32978. this.checkPageSize();
  32979. };
  32980. PaginationAutoPageSizeService.prototype.checkPageSize = function () {
  32981. if (this.notActive()) {
  32982. return;
  32983. }
  32984. var rowHeight = this.gridOptionsWrapper.getRowHeightAsNumber();
  32985. var bodyHeight = this.gridPanel.getBodyHeight();
  32986. if (bodyHeight > 0) {
  32987. var newPageSize = Math.floor(bodyHeight / rowHeight);
  32988. this.gridOptionsWrapper.setProperty('paginationPageSize', newPageSize);
  32989. }
  32990. };
  32991. __decorate$1m([
  32992. Autowired('gridOptionsWrapper')
  32993. ], PaginationAutoPageSizeService.prototype, "gridOptionsWrapper", void 0);
  32994. PaginationAutoPageSizeService = __decorate$1m([
  32995. Bean('paginationAutoPageSizeService')
  32996. ], PaginationAutoPageSizeService);
  32997. return PaginationAutoPageSizeService;
  32998. }(BeanStub));
  32999. /**
  33000. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  33001. * @version v23.2.1
  33002. * @link http://www.ag-grid.com/
  33003. * @license MIT
  33004. */
  33005. var __extends$1o = (undefined && undefined.__extends) || (function () {
  33006. var extendStatics = function (d, b) {
  33007. extendStatics = Object.setPrototypeOf ||
  33008. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  33009. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  33010. return extendStatics(d, b);
  33011. };
  33012. return function (d, b) {
  33013. extendStatics(d, b);
  33014. function __() { this.constructor = d; }
  33015. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  33016. };
  33017. })();
  33018. var __decorate$1n = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  33019. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  33020. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  33021. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  33022. return c > 3 && r && Object.defineProperty(target, key, r), r;
  33023. };
  33024. var ValueCache = /** @class */ (function (_super) {
  33025. __extends$1o(ValueCache, _super);
  33026. function ValueCache() {
  33027. var _this = _super !== null && _super.apply(this, arguments) || this;
  33028. _this.cacheVersion = 0;
  33029. return _this;
  33030. }
  33031. ValueCache.prototype.init = function () {
  33032. this.active = this.gridOptionsWrapper.isValueCache();
  33033. this.neverExpires = this.gridOptionsWrapper.isValueCacheNeverExpires();
  33034. };
  33035. ValueCache.prototype.onDataChanged = function () {
  33036. if (this.neverExpires) {
  33037. return;
  33038. }
  33039. this.expire();
  33040. };
  33041. ValueCache.prototype.expire = function () {
  33042. this.cacheVersion++;
  33043. };
  33044. ValueCache.prototype.setValue = function (rowNode, colId, value) {
  33045. if (this.active) {
  33046. if (rowNode.__cacheVersion !== this.cacheVersion) {
  33047. rowNode.__cacheVersion = this.cacheVersion;
  33048. rowNode.__cacheData = {};
  33049. }
  33050. rowNode.__cacheData[colId] = value;
  33051. }
  33052. };
  33053. ValueCache.prototype.getValue = function (rowNode, colId) {
  33054. if (!this.active || rowNode.__cacheVersion !== this.cacheVersion) {
  33055. return undefined;
  33056. }
  33057. return rowNode.__cacheData[colId];
  33058. };
  33059. __decorate$1n([
  33060. Autowired('gridOptionsWrapper')
  33061. ], ValueCache.prototype, "gridOptionsWrapper", void 0);
  33062. __decorate$1n([
  33063. PostConstruct
  33064. ], ValueCache.prototype, "init", null);
  33065. ValueCache = __decorate$1n([
  33066. Bean('valueCache')
  33067. ], ValueCache);
  33068. return ValueCache;
  33069. }(BeanStub));
  33070. /**
  33071. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  33072. * @version v23.2.1
  33073. * @link http://www.ag-grid.com/
  33074. * @license MIT
  33075. */
  33076. var __extends$1p = (undefined && undefined.__extends) || (function () {
  33077. var extendStatics = function (d, b) {
  33078. extendStatics = Object.setPrototypeOf ||
  33079. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  33080. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  33081. return extendStatics(d, b);
  33082. };
  33083. return function (d, b) {
  33084. extendStatics(d, b);
  33085. function __() { this.constructor = d; }
  33086. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  33087. };
  33088. })();
  33089. var __decorate$1o = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  33090. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  33091. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  33092. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  33093. return c > 3 && r && Object.defineProperty(target, key, r), r;
  33094. };
  33095. var ChangeDetectionService = /** @class */ (function (_super) {
  33096. __extends$1p(ChangeDetectionService, _super);
  33097. function ChangeDetectionService() {
  33098. return _super !== null && _super.apply(this, arguments) || this;
  33099. }
  33100. ChangeDetectionService.prototype.init = function () {
  33101. if (this.rowModel.getType() === Constants.ROW_MODEL_TYPE_CLIENT_SIDE) {
  33102. this.clientSideRowModel = this.rowModel;
  33103. }
  33104. this.addManagedListener(this.eventService, Events.EVENT_CELL_VALUE_CHANGED, this.onCellValueChanged.bind(this));
  33105. };
  33106. ChangeDetectionService.prototype.onCellValueChanged = function (event) {
  33107. // Clipboard service manages its own change detection, so no need to do it here.
  33108. // The clipboard manages its own as otherwise this would happen once for every cell
  33109. // that got updated as part of a paste operation, so e.g. if 100 cells in a paste operation,
  33110. // this doChangeDetection would get called 100 times (once for each cell), instead clipboard
  33111. // service executes the logic we have here once (in essence batching up all cell changes
  33112. // into one change detection).
  33113. if (event.source === Constants.SOURCE_PASTE) {
  33114. return;
  33115. }
  33116. this.doChangeDetection(event.node, event.column);
  33117. };
  33118. ChangeDetectionService.prototype.doChangeDetection = function (rowNode, column) {
  33119. if (this.gridOptionsWrapper.isSuppressChangeDetection()) {
  33120. return;
  33121. }
  33122. // step 1 of change detection is to update the aggregated values
  33123. if (this.clientSideRowModel && !rowNode.isRowPinned()) {
  33124. var onlyChangedColumns = this.gridOptionsWrapper.isAggregateOnlyChangedColumns();
  33125. var changedPath = new ChangedPath(onlyChangedColumns, this.clientSideRowModel.getRootNode());
  33126. changedPath.addParentNode(rowNode.parent, [column]);
  33127. this.clientSideRowModel.doAggregate(changedPath);
  33128. }
  33129. // step 2 of change detection is to refresh the cells
  33130. this.rowRenderer.refreshCells();
  33131. };
  33132. __decorate$1o([
  33133. Autowired('gridOptionsWrapper')
  33134. ], ChangeDetectionService.prototype, "gridOptionsWrapper", void 0);
  33135. __decorate$1o([
  33136. Autowired('rowModel')
  33137. ], ChangeDetectionService.prototype, "rowModel", void 0);
  33138. __decorate$1o([
  33139. Autowired('rowRenderer')
  33140. ], ChangeDetectionService.prototype, "rowRenderer", void 0);
  33141. __decorate$1o([
  33142. PostConstruct
  33143. ], ChangeDetectionService.prototype, "init", null);
  33144. ChangeDetectionService = __decorate$1o([
  33145. Bean('changeDetectionService')
  33146. ], ChangeDetectionService);
  33147. return ChangeDetectionService;
  33148. }(BeanStub));
  33149. /**
  33150. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  33151. * @version v23.2.1
  33152. * @link http://www.ag-grid.com/
  33153. * @license MIT
  33154. */
  33155. var __extends$1q = (undefined && undefined.__extends) || (function () {
  33156. var extendStatics = function (d, b) {
  33157. extendStatics = Object.setPrototypeOf ||
  33158. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  33159. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  33160. return extendStatics(d, b);
  33161. };
  33162. return function (d, b) {
  33163. extendStatics(d, b);
  33164. function __() { this.constructor = d; }
  33165. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  33166. };
  33167. })();
  33168. var __decorate$1p = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  33169. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  33170. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  33171. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  33172. return c > 3 && r && Object.defineProperty(target, key, r), r;
  33173. };
  33174. var __param$8 = (undefined && undefined.__param) || function (paramIndex, decorator) {
  33175. return function (target, key) { decorator(target, key, paramIndex); }
  33176. };
  33177. var AlignedGridsService = /** @class */ (function (_super) {
  33178. __extends$1q(AlignedGridsService, _super);
  33179. function AlignedGridsService() {
  33180. var _this = _super !== null && _super.apply(this, arguments) || this;
  33181. // flag to mark if we are consuming. to avoid cyclic events (ie other grid firing back to master
  33182. // while processing a master event) we mark this if consuming an event, and if we are, then
  33183. // we don't fire back any events.
  33184. _this.consuming = false;
  33185. return _this;
  33186. }
  33187. AlignedGridsService.prototype.setBeans = function (loggerFactory) {
  33188. this.logger = loggerFactory.create('AlignedGridsService');
  33189. };
  33190. AlignedGridsService.prototype.registerGridComp = function (gridPanel) {
  33191. this.gridPanel = gridPanel;
  33192. };
  33193. AlignedGridsService.prototype.init = function () {
  33194. this.addManagedListener(this.eventService, Events.EVENT_COLUMN_MOVED, this.fireColumnEvent.bind(this));
  33195. this.addManagedListener(this.eventService, Events.EVENT_COLUMN_VISIBLE, this.fireColumnEvent.bind(this));
  33196. this.addManagedListener(this.eventService, Events.EVENT_COLUMN_PINNED, this.fireColumnEvent.bind(this));
  33197. this.addManagedListener(this.eventService, Events.EVENT_COLUMN_GROUP_OPENED, this.fireColumnEvent.bind(this));
  33198. this.addManagedListener(this.eventService, Events.EVENT_COLUMN_RESIZED, this.fireColumnEvent.bind(this));
  33199. this.addManagedListener(this.eventService, Events.EVENT_BODY_SCROLL, this.fireScrollEvent.bind(this));
  33200. };
  33201. // common logic across all the fire methods
  33202. AlignedGridsService.prototype.fireEvent = function (callback) {
  33203. // if we are already consuming, then we are acting on an event from a master,
  33204. // so we don't cause a cyclic firing of events
  33205. if (this.consuming) {
  33206. return;
  33207. }
  33208. // iterate through the aligned grids, and pass each aligned grid service to the callback
  33209. var otherGrids = this.gridOptionsWrapper.getAlignedGrids();
  33210. if (otherGrids) {
  33211. otherGrids.forEach(function (otherGridOptions) {
  33212. if (otherGridOptions.api) {
  33213. var alignedGridService = otherGridOptions.api.__getAlignedGridService();
  33214. callback(alignedGridService);
  33215. }
  33216. });
  33217. }
  33218. };
  33219. // common logic across all consume methods. very little common logic, however extracting
  33220. // guarantees consistency across the methods.
  33221. AlignedGridsService.prototype.onEvent = function (callback) {
  33222. this.consuming = true;
  33223. callback();
  33224. this.consuming = false;
  33225. };
  33226. AlignedGridsService.prototype.fireColumnEvent = function (event) {
  33227. this.fireEvent(function (alignedGridsService) {
  33228. alignedGridsService.onColumnEvent(event);
  33229. });
  33230. };
  33231. AlignedGridsService.prototype.fireScrollEvent = function (event) {
  33232. if (event.direction !== 'horizontal') {
  33233. return;
  33234. }
  33235. this.fireEvent(function (alignedGridsService) {
  33236. alignedGridsService.onScrollEvent(event);
  33237. });
  33238. };
  33239. AlignedGridsService.prototype.onScrollEvent = function (event) {
  33240. var _this = this;
  33241. this.onEvent(function () {
  33242. _this.gridPanel.setHorizontalScrollPosition(event.left);
  33243. });
  33244. };
  33245. AlignedGridsService.prototype.getMasterColumns = function (event) {
  33246. var result = [];
  33247. if (event.columns) {
  33248. event.columns.forEach(function (column) {
  33249. result.push(column);
  33250. });
  33251. }
  33252. else if (event.column) {
  33253. result.push(event.column);
  33254. }
  33255. return result;
  33256. };
  33257. AlignedGridsService.prototype.getColumnIds = function (event) {
  33258. var result = [];
  33259. if (event.columns) {
  33260. event.columns.forEach(function (column) {
  33261. result.push(column.getColId());
  33262. });
  33263. }
  33264. else if (event.column) {
  33265. result.push(event.column.getColId());
  33266. }
  33267. return result;
  33268. };
  33269. AlignedGridsService.prototype.onColumnEvent = function (event) {
  33270. var _this = this;
  33271. this.onEvent(function () {
  33272. switch (event.type) {
  33273. case Events.EVENT_COLUMN_MOVED:
  33274. case Events.EVENT_COLUMN_VISIBLE:
  33275. case Events.EVENT_COLUMN_PINNED:
  33276. case Events.EVENT_COLUMN_RESIZED:
  33277. var colEvent = event;
  33278. _this.processColumnEvent(colEvent);
  33279. break;
  33280. case Events.EVENT_COLUMN_GROUP_OPENED:
  33281. var groupOpenedEvent = event;
  33282. _this.processGroupOpenedEvent(groupOpenedEvent);
  33283. break;
  33284. case Events.EVENT_COLUMN_PIVOT_CHANGED:
  33285. // we cannot support pivoting with aligned grids as the columns will be out of sync as the
  33286. // grids will have columns created based on the row data of the grid.
  33287. console.warn('ag-Grid: pivoting is not supported with aligned grids. ' +
  33288. 'You can only use one of these features at a time in a grid.');
  33289. break;
  33290. }
  33291. });
  33292. };
  33293. AlignedGridsService.prototype.processGroupOpenedEvent = function (groupOpenedEvent) {
  33294. // likewise for column group
  33295. var masterColumnGroup = groupOpenedEvent.columnGroup;
  33296. var otherColumnGroup;
  33297. if (masterColumnGroup) {
  33298. var groupId = masterColumnGroup.getGroupId();
  33299. otherColumnGroup = this.columnController.getOriginalColumnGroup(groupId);
  33300. }
  33301. if (masterColumnGroup && !otherColumnGroup) {
  33302. return;
  33303. }
  33304. this.logger.log('onColumnEvent-> processing ' + groupOpenedEvent + ' expanded = ' + masterColumnGroup.isExpanded());
  33305. this.columnController.setColumnGroupOpened(otherColumnGroup, masterColumnGroup.isExpanded(), "alignedGridChanged");
  33306. };
  33307. AlignedGridsService.prototype.processColumnEvent = function (colEvent) {
  33308. var _this = this;
  33309. // the column in the event is from the master grid. need to
  33310. // look up the equivalent from this (other) grid
  33311. var masterColumn = colEvent.column;
  33312. var otherColumn;
  33313. if (masterColumn) {
  33314. otherColumn = this.columnController.getPrimaryColumn(masterColumn.getColId());
  33315. }
  33316. // if event was with respect to a master column, that is not present in this
  33317. // grid, then we ignore the event
  33318. if (masterColumn && !otherColumn) {
  33319. return;
  33320. }
  33321. // in time, all the methods below should use the column ids, it's a more generic way
  33322. // of handling columns, and also allows for single or multi column events
  33323. var columnIds = this.getColumnIds(colEvent);
  33324. var masterColumns = this.getMasterColumns(colEvent);
  33325. switch (colEvent.type) {
  33326. case Events.EVENT_COLUMN_MOVED:
  33327. var movedEvent = colEvent;
  33328. this.logger.log("onColumnEvent-> processing " + colEvent.type + " toIndex = " + movedEvent.toIndex);
  33329. this.columnController.moveColumns(columnIds, movedEvent.toIndex, "alignedGridChanged");
  33330. break;
  33331. case Events.EVENT_COLUMN_VISIBLE:
  33332. var visibleEvent = colEvent;
  33333. this.logger.log("onColumnEvent-> processing " + colEvent.type + " visible = " + visibleEvent.visible);
  33334. this.columnController.setColumnsVisible(columnIds, visibleEvent.visible, "alignedGridChanged");
  33335. break;
  33336. case Events.EVENT_COLUMN_PINNED:
  33337. var pinnedEvent = colEvent;
  33338. this.logger.log("onColumnEvent-> processing " + colEvent.type + " pinned = " + pinnedEvent.pinned);
  33339. this.columnController.setColumnsPinned(columnIds, pinnedEvent.pinned, "alignedGridChanged");
  33340. break;
  33341. case Events.EVENT_COLUMN_RESIZED:
  33342. var resizedEvent_1 = colEvent;
  33343. masterColumns.forEach(function (column) {
  33344. _this.logger.log("onColumnEvent-> processing " + colEvent.type + " actualWidth = " + column.getActualWidth());
  33345. var columnWidths = [{ key: column.getColId(), newWidth: column.getActualWidth() }];
  33346. _this.columnController.setColumnWidths(columnWidths, false, resizedEvent_1.finished, "alignedGridChanged");
  33347. });
  33348. break;
  33349. }
  33350. var isVerticalScrollShowing = this.gridPanel.isVerticalScrollShowing();
  33351. var alignedGrids = this.gridOptionsWrapper.getAlignedGrids();
  33352. alignedGrids.forEach(function (grid) {
  33353. grid.api.setAlwaysShowVerticalScroll(isVerticalScrollShowing);
  33354. });
  33355. };
  33356. __decorate$1p([
  33357. Autowired('gridOptionsWrapper')
  33358. ], AlignedGridsService.prototype, "gridOptionsWrapper", void 0);
  33359. __decorate$1p([
  33360. Autowired('columnController')
  33361. ], AlignedGridsService.prototype, "columnController", void 0);
  33362. __decorate$1p([
  33363. __param$8(0, Qualifier('loggerFactory'))
  33364. ], AlignedGridsService.prototype, "setBeans", null);
  33365. __decorate$1p([
  33366. PostConstruct
  33367. ], AlignedGridsService.prototype, "init", null);
  33368. AlignedGridsService = __decorate$1p([
  33369. Bean('alignedGridsService')
  33370. ], AlignedGridsService);
  33371. return AlignedGridsService;
  33372. }(BeanStub));
  33373. /**
  33374. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  33375. * @version v23.2.1
  33376. * @link http://www.ag-grid.com/
  33377. * @license MIT
  33378. */
  33379. var __extends$1r = (undefined && undefined.__extends) || (function () {
  33380. var extendStatics = function (d, b) {
  33381. extendStatics = Object.setPrototypeOf ||
  33382. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  33383. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  33384. return extendStatics(d, b);
  33385. };
  33386. return function (d, b) {
  33387. extendStatics(d, b);
  33388. function __() { this.constructor = d; }
  33389. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  33390. };
  33391. })();
  33392. var __decorate$1q = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  33393. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  33394. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  33395. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  33396. return c > 3 && r && Object.defineProperty(target, key, r), r;
  33397. };
  33398. var AgComponentUtils = /** @class */ (function (_super) {
  33399. __extends$1r(AgComponentUtils, _super);
  33400. function AgComponentUtils() {
  33401. return _super !== null && _super.apply(this, arguments) || this;
  33402. }
  33403. AgComponentUtils.prototype.adaptFunction = function (propertyName, hardcodedJsFunction, componentFromFramework, source) {
  33404. if (hardcodedJsFunction == null) {
  33405. return {
  33406. component: null,
  33407. componentFromFramework: componentFromFramework,
  33408. source: source,
  33409. paramsFromSelector: null
  33410. };
  33411. }
  33412. var metadata = this.componentMetadataProvider.retrieve(propertyName);
  33413. if (metadata && metadata.functionAdapter) {
  33414. return {
  33415. componentFromFramework: componentFromFramework,
  33416. component: metadata.functionAdapter(hardcodedJsFunction),
  33417. source: source,
  33418. paramsFromSelector: null
  33419. };
  33420. }
  33421. return null;
  33422. };
  33423. AgComponentUtils.prototype.adaptCellRendererFunction = function (callback) {
  33424. var Adapter = /** @class */ (function () {
  33425. function Adapter() {
  33426. }
  33427. Adapter.prototype.refresh = function (params) {
  33428. return false;
  33429. };
  33430. Adapter.prototype.getGui = function () {
  33431. var callbackResult = callback(this.params);
  33432. var type = typeof callbackResult;
  33433. if (type === 'string' || type === 'number' || type === 'boolean') {
  33434. return _.loadTemplate('<span>' + callbackResult + '</span>');
  33435. }
  33436. else {
  33437. return callbackResult;
  33438. }
  33439. };
  33440. Adapter.prototype.init = function (params) {
  33441. this.params = params;
  33442. };
  33443. return Adapter;
  33444. }());
  33445. return Adapter;
  33446. };
  33447. AgComponentUtils.prototype.doesImplementIComponent = function (candidate) {
  33448. if (!candidate) {
  33449. return false;
  33450. }
  33451. return candidate.prototype && 'getGui' in candidate.prototype;
  33452. };
  33453. __decorate$1q([
  33454. Autowired("componentMetadataProvider")
  33455. ], AgComponentUtils.prototype, "componentMetadataProvider", void 0);
  33456. AgComponentUtils = __decorate$1q([
  33457. Bean("agComponentUtils")
  33458. ], AgComponentUtils);
  33459. return AgComponentUtils;
  33460. }(BeanStub));
  33461. /**
  33462. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  33463. * @version v23.2.1
  33464. * @link http://www.ag-grid.com/
  33465. * @license MIT
  33466. */
  33467. var __extends$1s = (undefined && undefined.__extends) || (function () {
  33468. var extendStatics = function (d, b) {
  33469. extendStatics = Object.setPrototypeOf ||
  33470. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  33471. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  33472. return extendStatics(d, b);
  33473. };
  33474. return function (d, b) {
  33475. extendStatics(d, b);
  33476. function __() { this.constructor = d; }
  33477. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  33478. };
  33479. })();
  33480. var __decorate$1r = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  33481. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  33482. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  33483. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  33484. return c > 3 && r && Object.defineProperty(target, key, r), r;
  33485. };
  33486. var ComponentMetadataProvider = /** @class */ (function (_super) {
  33487. __extends$1s(ComponentMetadataProvider, _super);
  33488. function ComponentMetadataProvider() {
  33489. return _super !== null && _super.apply(this, arguments) || this;
  33490. }
  33491. ComponentMetadataProvider.prototype.postConstruct = function () {
  33492. this.componentMetaData = {
  33493. dateComponent: {
  33494. mandatoryMethodList: ['getDate', 'setDate'],
  33495. optionalMethodList: ['afterGuiAttached', 'setInputPlaceholder']
  33496. },
  33497. detailCellRenderer: {
  33498. mandatoryMethodList: [],
  33499. optionalMethodList: ['refresh']
  33500. },
  33501. headerComponent: {
  33502. mandatoryMethodList: [],
  33503. optionalMethodList: []
  33504. },
  33505. headerGroupComponent: {
  33506. mandatoryMethodList: [],
  33507. optionalMethodList: []
  33508. },
  33509. loadingCellRenderer: {
  33510. mandatoryMethodList: [],
  33511. optionalMethodList: []
  33512. },
  33513. loadingOverlayComponent: {
  33514. mandatoryMethodList: [],
  33515. optionalMethodList: []
  33516. },
  33517. noRowsOverlayComponent: {
  33518. mandatoryMethodList: [],
  33519. optionalMethodList: []
  33520. },
  33521. floatingFilterComponent: {
  33522. mandatoryMethodList: ['onParentModelChanged'],
  33523. optionalMethodList: ['afterGuiAttached']
  33524. },
  33525. floatingFilterWrapperComponent: {
  33526. mandatoryMethodList: [],
  33527. optionalMethodList: []
  33528. },
  33529. cellRenderer: {
  33530. mandatoryMethodList: [],
  33531. optionalMethodList: ['refresh', 'afterGuiAttached'],
  33532. functionAdapter: this.agComponentUtils.adaptCellRendererFunction.bind(this.agComponentUtils)
  33533. },
  33534. cellEditor: {
  33535. mandatoryMethodList: ['getValue'],
  33536. optionalMethodList: ['isPopup', 'isCancelBeforeStart', 'isCancelAfterEnd', 'getPopupPosition', 'focusIn', 'focusOut', 'afterGuiAttached']
  33537. },
  33538. innerRenderer: {
  33539. mandatoryMethodList: [],
  33540. optionalMethodList: ['afterGuiAttached'],
  33541. functionAdapter: this.agComponentUtils.adaptCellRendererFunction.bind(this.agComponentUtils)
  33542. },
  33543. fullWidthCellRenderer: {
  33544. mandatoryMethodList: [],
  33545. optionalMethodList: ['refresh', 'afterGuiAttached'],
  33546. functionAdapter: this.agComponentUtils.adaptCellRendererFunction.bind(this.agComponentUtils)
  33547. },
  33548. pinnedRowCellRenderer: {
  33549. mandatoryMethodList: [],
  33550. optionalMethodList: ['refresh', 'afterGuiAttached'],
  33551. functionAdapter: this.agComponentUtils.adaptCellRendererFunction.bind(this.agComponentUtils)
  33552. },
  33553. groupRowInnerRenderer: {
  33554. mandatoryMethodList: [],
  33555. optionalMethodList: ['afterGuiAttached'],
  33556. functionAdapter: this.agComponentUtils.adaptCellRendererFunction.bind(this.agComponentUtils)
  33557. },
  33558. groupRowRenderer: {
  33559. mandatoryMethodList: [],
  33560. optionalMethodList: ['afterGuiAttached'],
  33561. functionAdapter: this.agComponentUtils.adaptCellRendererFunction.bind(this.agComponentUtils)
  33562. },
  33563. filter: {
  33564. mandatoryMethodList: ['isFilterActive', 'doesFilterPass', 'getModel', 'setModel'],
  33565. optionalMethodList: ['afterGuiAttached', 'onNewRowsLoaded', 'getModelAsString', 'onFloatingFilterChanged']
  33566. },
  33567. filterComponent: {
  33568. mandatoryMethodList: ['isFilterActive', 'doesFilterPass', 'getModel', 'setModel'],
  33569. optionalMethodList: ['afterGuiAttached', 'onNewRowsLoaded', 'getModelAsString', 'onFloatingFilterChanged']
  33570. },
  33571. statusPanel: {
  33572. mandatoryMethodList: [],
  33573. optionalMethodList: ['afterGuiAttached'],
  33574. },
  33575. toolPanel: {
  33576. mandatoryMethodList: [],
  33577. optionalMethodList: ['refresh', 'afterGuiAttached']
  33578. },
  33579. tooltipComponent: {
  33580. mandatoryMethodList: [],
  33581. optionalMethodList: []
  33582. }
  33583. };
  33584. };
  33585. ComponentMetadataProvider.prototype.retrieve = function (name) {
  33586. return this.componentMetaData[name];
  33587. };
  33588. __decorate$1r([
  33589. Autowired("agComponentUtils")
  33590. ], ComponentMetadataProvider.prototype, "agComponentUtils", void 0);
  33591. __decorate$1r([
  33592. PostConstruct
  33593. ], ComponentMetadataProvider.prototype, "postConstruct", null);
  33594. ComponentMetadataProvider = __decorate$1r([
  33595. Bean("componentMetadataProvider")
  33596. ], ComponentMetadataProvider);
  33597. return ComponentMetadataProvider;
  33598. }(BeanStub));
  33599. /**
  33600. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  33601. * @version v23.2.1
  33602. * @link http://www.ag-grid.com/
  33603. * @license MIT
  33604. */
  33605. var __decorate$1s = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  33606. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  33607. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  33608. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  33609. return c > 3 && r && Object.defineProperty(target, key, r), r;
  33610. };
  33611. /** Using the IoC has a slight performance consideration, which is no problem most of the
  33612. * time, unless we are trashing objects - which is the case when scrolling and rowComp
  33613. * and cellComp. So for performance reasons, RowComp and CellComp do not get autowired
  33614. * with the IoC. Instead they get passed this object which is all the beans the RowComp
  33615. * and CellComp need. Not autowiring all the cells gives performance improvement. */
  33616. var Beans = /** @class */ (function () {
  33617. function Beans() {
  33618. }
  33619. Beans.prototype.registerGridComp = function (gridPanel) {
  33620. this.gridPanel = gridPanel;
  33621. };
  33622. Beans.prototype.postConstruct = function () {
  33623. this.doingMasterDetail = this.gridOptionsWrapper.isMasterDetail();
  33624. };
  33625. __decorate$1s([
  33626. Autowired('paginationProxy')
  33627. ], Beans.prototype, "paginationProxy", void 0);
  33628. __decorate$1s([
  33629. Autowired('context')
  33630. ], Beans.prototype, "context", void 0);
  33631. __decorate$1s([
  33632. Autowired('columnApi')
  33633. ], Beans.prototype, "columnApi", void 0);
  33634. __decorate$1s([
  33635. Autowired('gridApi')
  33636. ], Beans.prototype, "gridApi", void 0);
  33637. __decorate$1s([
  33638. Autowired('gridOptionsWrapper')
  33639. ], Beans.prototype, "gridOptionsWrapper", void 0);
  33640. __decorate$1s([
  33641. Autowired('expressionService')
  33642. ], Beans.prototype, "expressionService", void 0);
  33643. __decorate$1s([
  33644. Autowired('rowRenderer')
  33645. ], Beans.prototype, "rowRenderer", void 0);
  33646. __decorate$1s([
  33647. Autowired('$compile')
  33648. ], Beans.prototype, "$compile", void 0);
  33649. __decorate$1s([
  33650. Autowired('templateService')
  33651. ], Beans.prototype, "templateService", void 0);
  33652. __decorate$1s([
  33653. Autowired('valueService')
  33654. ], Beans.prototype, "valueService", void 0);
  33655. __decorate$1s([
  33656. Autowired('eventService')
  33657. ], Beans.prototype, "eventService", void 0);
  33658. __decorate$1s([
  33659. Autowired('columnController')
  33660. ], Beans.prototype, "columnController", void 0);
  33661. __decorate$1s([
  33662. Autowired('headerNavigationService')
  33663. ], Beans.prototype, "headerNavigationService", void 0);
  33664. __decorate$1s([
  33665. Autowired('columnAnimationService')
  33666. ], Beans.prototype, "columnAnimationService", void 0);
  33667. __decorate$1s([
  33668. Optional('rangeController')
  33669. ], Beans.prototype, "rangeController", void 0);
  33670. __decorate$1s([
  33671. Autowired('focusController')
  33672. ], Beans.prototype, "focusController", void 0);
  33673. __decorate$1s([
  33674. Optional('contextMenuFactory')
  33675. ], Beans.prototype, "contextMenuFactory", void 0);
  33676. __decorate$1s([
  33677. Autowired('cellRendererFactory')
  33678. ], Beans.prototype, "cellRendererFactory", void 0);
  33679. __decorate$1s([
  33680. Autowired('popupService')
  33681. ], Beans.prototype, "popupService", void 0);
  33682. __decorate$1s([
  33683. Autowired('valueFormatterService')
  33684. ], Beans.prototype, "valueFormatterService", void 0);
  33685. __decorate$1s([
  33686. Autowired('stylingService')
  33687. ], Beans.prototype, "stylingService", void 0);
  33688. __decorate$1s([
  33689. Autowired('columnHoverService')
  33690. ], Beans.prototype, "columnHoverService", void 0);
  33691. __decorate$1s([
  33692. Autowired('userComponentFactory')
  33693. ], Beans.prototype, "userComponentFactory", void 0);
  33694. __decorate$1s([
  33695. Autowired('animationFrameService')
  33696. ], Beans.prototype, "taskQueue", void 0);
  33697. __decorate$1s([
  33698. Autowired('dragAndDropService')
  33699. ], Beans.prototype, "dragAndDropService", void 0);
  33700. __decorate$1s([
  33701. Autowired('sortController')
  33702. ], Beans.prototype, "sortController", void 0);
  33703. __decorate$1s([
  33704. Autowired('filterManager')
  33705. ], Beans.prototype, "filterManager", void 0);
  33706. __decorate$1s([
  33707. Autowired('maxDivHeightScaler')
  33708. ], Beans.prototype, "maxDivHeightScaler", void 0);
  33709. __decorate$1s([
  33710. Autowired('frameworkOverrides')
  33711. ], Beans.prototype, "frameworkOverrides", void 0);
  33712. __decorate$1s([
  33713. Autowired('detailRowCompCache')
  33714. ], Beans.prototype, "detailRowCompCache", void 0);
  33715. __decorate$1s([
  33716. Autowired('cellPositionUtils')
  33717. ], Beans.prototype, "cellPositionUtils", void 0);
  33718. __decorate$1s([
  33719. Autowired('rowPositionUtils')
  33720. ], Beans.prototype, "rowPositionUtils", void 0);
  33721. __decorate$1s([
  33722. Autowired('selectionController')
  33723. ], Beans.prototype, "selectionController", void 0);
  33724. __decorate$1s([
  33725. Optional('selectionHandleFactory')
  33726. ], Beans.prototype, "selectionHandleFactory", void 0);
  33727. __decorate$1s([
  33728. PostConstruct
  33729. ], Beans.prototype, "postConstruct", null);
  33730. Beans = __decorate$1s([
  33731. Bean('beans')
  33732. ], Beans);
  33733. return Beans;
  33734. }());
  33735. /**
  33736. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  33737. * @version v23.2.1
  33738. * @link http://www.ag-grid.com/
  33739. * @license MIT
  33740. */
  33741. var __extends$1t = (undefined && undefined.__extends) || (function () {
  33742. var extendStatics = function (d, b) {
  33743. extendStatics = Object.setPrototypeOf ||
  33744. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  33745. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  33746. return extendStatics(d, b);
  33747. };
  33748. return function (d, b) {
  33749. extendStatics(d, b);
  33750. function __() { this.constructor = d; }
  33751. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  33752. };
  33753. })();
  33754. var __decorate$1t = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  33755. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  33756. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  33757. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  33758. return c > 3 && r && Object.defineProperty(target, key, r), r;
  33759. };
  33760. var MAT_GRID_SIZE = 8;
  33761. var BASE_GRID_SIZE = 4;
  33762. var BALHAM_GRID_SIZE = 4;
  33763. var ALPINE_GRID_SIZE = 6;
  33764. var HARD_CODED_SIZES = {
  33765. // this item is required for custom themes
  33766. 'ag-theme-custom': {
  33767. headerHeight: 25,
  33768. headerCellMinWidth: 24,
  33769. listItemHeight: BASE_GRID_SIZE * 5,
  33770. rowHeight: 25,
  33771. chartMenuPanelWidth: 220
  33772. },
  33773. 'ag-theme-material': {
  33774. headerHeight: MAT_GRID_SIZE * 7,
  33775. headerCellMinWidth: 48,
  33776. listItemHeight: MAT_GRID_SIZE * 5,
  33777. rowHeight: MAT_GRID_SIZE * 6,
  33778. chartMenuPanelWidth: 240
  33779. },
  33780. 'ag-theme-balham': {
  33781. headerHeight: BALHAM_GRID_SIZE * 8,
  33782. headerCellMinWidth: 24,
  33783. listItemHeight: BALHAM_GRID_SIZE * 7,
  33784. rowHeight: BALHAM_GRID_SIZE * 7,
  33785. chartMenuPanelWidth: 220
  33786. },
  33787. 'ag-theme-alpine': {
  33788. headerHeight: ALPINE_GRID_SIZE * 8,
  33789. headerCellMinWidth: 36,
  33790. listItemHeight: ALPINE_GRID_SIZE * 5,
  33791. rowHeight: ALPINE_GRID_SIZE * 7,
  33792. chartMenuPanelWidth: 240
  33793. }
  33794. };
  33795. /**
  33796. * this object contains a list of Sass variables and an array
  33797. * of CSS styles required to get the correct value.
  33798. * eg. $virtual-item-height requires a structure, so we can get its height.
  33799. * <div class="ag-theme-balham">
  33800. * <div class="ag-virtual-list-container">
  33801. * <div class="ag-virtual-list-item"></div>
  33802. * </div>
  33803. * </div>
  33804. */
  33805. var SASS_PROPERTY_BUILDER = {
  33806. headerHeight: ['ag-header-row'],
  33807. headerCellMinWidth: ['ag-header-cell'],
  33808. listItemHeight: ['ag-virtual-list-item'],
  33809. rowHeight: ['ag-row'],
  33810. chartMenuPanelWidth: ['ag-chart-docked-container']
  33811. };
  33812. var CALCULATED_SIZES = {};
  33813. var Environment = /** @class */ (function (_super) {
  33814. __extends$1t(Environment, _super);
  33815. function Environment() {
  33816. return _super !== null && _super.apply(this, arguments) || this;
  33817. }
  33818. Environment.prototype.getSassVariable = function (theme, key) {
  33819. var useTheme = 'ag-theme-' + (theme.match('material') ? 'material' : theme.match('balham') ? 'balham' : theme.match('alpine') ? 'alpine' : 'custom');
  33820. var defaultValue = HARD_CODED_SIZES[useTheme][key];
  33821. var calculatedValue = 0;
  33822. if (!CALCULATED_SIZES[theme]) {
  33823. CALCULATED_SIZES[theme] = {};
  33824. }
  33825. if (CALCULATED_SIZES[theme][key]) {
  33826. return CALCULATED_SIZES[theme][key];
  33827. }
  33828. if (SASS_PROPERTY_BUILDER[key]) {
  33829. var classList = SASS_PROPERTY_BUILDER[key];
  33830. var div = document.createElement('div');
  33831. div.style.position = 'absolute';
  33832. var el = classList.reduce(function (el, currentClass, idx) {
  33833. if (idx === 0) {
  33834. _.addCssClass(el, theme);
  33835. }
  33836. var div = document.createElement('div');
  33837. div.style.position = 'static';
  33838. _.addCssClass(div, currentClass);
  33839. el.appendChild(div);
  33840. return div;
  33841. }, div);
  33842. if (document.body) {
  33843. document.body.appendChild(div);
  33844. var sizeName = key.toLowerCase().indexOf('height') !== -1 ? 'height' : 'width';
  33845. calculatedValue = parseInt(window.getComputedStyle(el)[sizeName], 10);
  33846. document.body.removeChild(div);
  33847. }
  33848. }
  33849. CALCULATED_SIZES[theme][key] = calculatedValue || defaultValue;
  33850. return CALCULATED_SIZES[theme][key];
  33851. };
  33852. Environment.prototype.isThemeDark = function () {
  33853. var theme = this.getTheme().theme;
  33854. return !!theme && theme.indexOf('dark') >= 0;
  33855. };
  33856. Environment.prototype.chartMenuPanelWidth = function () {
  33857. var theme = this.getTheme().themeFamily;
  33858. return this.getSassVariable(theme, 'chartMenuPanelWidth');
  33859. };
  33860. Environment.prototype.getTheme = function () {
  33861. var reg = /\bag-(material|(?:theme-([\w\-]*)))\b/;
  33862. var el = this.eGridDiv;
  33863. var themeMatch;
  33864. while (el) {
  33865. themeMatch = reg.exec(el.className);
  33866. if (!themeMatch) {
  33867. el = el.parentElement;
  33868. }
  33869. else {
  33870. break;
  33871. }
  33872. }
  33873. if (!themeMatch) {
  33874. return {};
  33875. }
  33876. var theme = themeMatch[0];
  33877. var usingOldTheme = themeMatch[2] === undefined;
  33878. if (usingOldTheme) {
  33879. var newTheme_1 = theme.replace('ag-', 'ag-theme-');
  33880. _.doOnce(function () { return console.warn("ag-Grid: As of v19 old theme are no longer provided. Please replace " + theme + " with " + newTheme_1 + "."); }, 'using-old-theme');
  33881. }
  33882. return { theme: theme, el: el, themeFamily: theme.replace(/-dark$/, '') };
  33883. };
  33884. __decorate$1t([
  33885. Autowired('eGridDiv')
  33886. ], Environment.prototype, "eGridDiv", void 0);
  33887. Environment = __decorate$1t([
  33888. Bean('environment')
  33889. ], Environment);
  33890. return Environment;
  33891. }(BeanStub));
  33892. /**
  33893. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  33894. * @version v23.2.1
  33895. * @link http://www.ag-grid.com/
  33896. * @license MIT
  33897. */
  33898. var __extends$1u = (undefined && undefined.__extends) || (function () {
  33899. var extendStatics = function (d, b) {
  33900. extendStatics = Object.setPrototypeOf ||
  33901. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  33902. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  33903. return extendStatics(d, b);
  33904. };
  33905. return function (d, b) {
  33906. extendStatics(d, b);
  33907. function __() { this.constructor = d; }
  33908. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  33909. };
  33910. })();
  33911. var __decorate$1u = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  33912. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  33913. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  33914. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  33915. return c > 3 && r && Object.defineProperty(target, key, r), r;
  33916. };
  33917. var AnimationFrameService = /** @class */ (function (_super) {
  33918. __extends$1u(AnimationFrameService, _super);
  33919. function AnimationFrameService() {
  33920. var _this = _super !== null && _super.apply(this, arguments) || this;
  33921. // p1 and p2 are create tasks are to do with row and cell creation.
  33922. // for them we want to execute according to row order, so we use
  33923. // TaskItem so we know what index the item is for.
  33924. _this.createTasksP1 = { list: [], sorted: false }; // eg drawing back-ground of rows
  33925. _this.createTasksP2 = { list: [], sorted: false }; // eg cell renderers, adding hover functionality
  33926. // destroy tasks are to do with row removal. they are done after row creation as the user will need to see new
  33927. // rows first (as blank is scrolled into view), when we remove the old rows (no longer in view) is not as
  33928. // important.
  33929. _this.destroyTasks = [];
  33930. _this.ticking = false;
  33931. // we need to know direction of scroll, to build up rows in the direction of
  33932. // the scroll. eg if user scrolls down, we extend the rows by building down.
  33933. _this.scrollGoingDown = true;
  33934. _this.lastScrollTop = 0;
  33935. _this.taskCount = 0;
  33936. _this.cancelledTasks = new Set();
  33937. return _this;
  33938. }
  33939. AnimationFrameService.prototype.setScrollTop = function (scrollTop) {
  33940. this.scrollGoingDown = scrollTop > this.lastScrollTop;
  33941. this.lastScrollTop = scrollTop;
  33942. };
  33943. AnimationFrameService.prototype.init = function () {
  33944. this.useAnimationFrame = !this.gridOptionsWrapper.isSuppressAnimationFrame();
  33945. };
  33946. // this method is for our ag-Grid sanity only - if animation frames are turned off,
  33947. // then no place in the code should be looking to add any work to be done in animation
  33948. // frames. this stops bugs - where some code is asking for a frame to be executed
  33949. // when it should not.
  33950. AnimationFrameService.prototype.verifyAnimationFrameOn = function (methodName) {
  33951. if (this.useAnimationFrame === false) {
  33952. console.warn("ag-Grid: AnimationFrameService." + methodName + " called but animation frames are off");
  33953. }
  33954. };
  33955. AnimationFrameService.prototype.createTask = function (task, index, list) {
  33956. this.verifyAnimationFrameOn(list);
  33957. var taskItem = { task: task, index: index, createOrder: ++this.taskCount };
  33958. this.addTaskToList(this[list], taskItem);
  33959. this.schedule();
  33960. };
  33961. AnimationFrameService.prototype.cancelTask = function (task) {
  33962. this.cancelledTasks.add(task);
  33963. };
  33964. AnimationFrameService.prototype.addTaskToList = function (taskList, task) {
  33965. taskList.list.push(task);
  33966. taskList.sorted = false;
  33967. };
  33968. AnimationFrameService.prototype.sortTaskList = function (taskList) {
  33969. if (taskList.sorted) {
  33970. return;
  33971. }
  33972. var sortDirection = this.scrollGoingDown ? 1 : -1;
  33973. // sort first by row index (taking into account scroll direction), then by
  33974. // order of task creation (always ascending, so cells will render left-to-right)
  33975. taskList.list.sort(function (a, b) { return a.index !== b.index ? sortDirection * (b.index - a.index) : b.createOrder - a.createOrder; });
  33976. taskList.sorted = true;
  33977. };
  33978. AnimationFrameService.prototype.addDestroyTask = function (task) {
  33979. this.verifyAnimationFrameOn('createTasksP3');
  33980. this.destroyTasks.push(task);
  33981. this.schedule();
  33982. };
  33983. AnimationFrameService.prototype.executeFrame = function (millis) {
  33984. this.verifyAnimationFrameOn('executeFrame');
  33985. var p1TaskList = this.createTasksP1;
  33986. var p1Tasks = p1TaskList.list;
  33987. var p2TaskList = this.createTasksP2;
  33988. var p2Tasks = p2TaskList.list;
  33989. var destroyTasks = this.destroyTasks;
  33990. var frameStart = new Date().getTime();
  33991. var duration = (new Date().getTime()) - frameStart;
  33992. // 16ms is 60 fps
  33993. var noMaxMillis = millis <= 0;
  33994. while (noMaxMillis || duration < millis) {
  33995. var task = void 0;
  33996. if (p1Tasks.length) {
  33997. this.sortTaskList(p1TaskList);
  33998. task = p1Tasks.pop().task;
  33999. }
  34000. else if (p2Tasks.length) {
  34001. this.sortTaskList(p2TaskList);
  34002. task = p2Tasks.pop().task;
  34003. }
  34004. else if (destroyTasks.length) {
  34005. task = destroyTasks.pop();
  34006. }
  34007. else {
  34008. this.cancelledTasks.clear();
  34009. break;
  34010. }
  34011. if (!this.cancelledTasks.has(task)) {
  34012. task();
  34013. }
  34014. duration = (new Date().getTime()) - frameStart;
  34015. }
  34016. if (p1Tasks.length || p2Tasks.length || destroyTasks.length) {
  34017. this.requestFrame();
  34018. }
  34019. else {
  34020. this.stopTicking();
  34021. }
  34022. };
  34023. AnimationFrameService.prototype.stopTicking = function () {
  34024. this.ticking = false;
  34025. var event = {
  34026. type: Events.EVENT_ANIMATION_QUEUE_EMPTY,
  34027. columnApi: this.gridOptionsWrapper.getColumnApi(),
  34028. api: this.gridOptionsWrapper.getApi()
  34029. };
  34030. this.eventService.dispatchEvent(event);
  34031. };
  34032. AnimationFrameService.prototype.flushAllFrames = function () {
  34033. if (!this.useAnimationFrame) {
  34034. return;
  34035. }
  34036. this.executeFrame(-1);
  34037. };
  34038. AnimationFrameService.prototype.schedule = function () {
  34039. if (!this.useAnimationFrame) {
  34040. return;
  34041. }
  34042. if (!this.ticking) {
  34043. this.ticking = true;
  34044. this.requestFrame();
  34045. }
  34046. };
  34047. AnimationFrameService.prototype.requestFrame = function () {
  34048. // check for the existence of requestAnimationFrame, and if
  34049. // it's missing, then we polyfill it with setTimeout()
  34050. var callback = this.executeFrame.bind(this, 60);
  34051. if (window.requestAnimationFrame) {
  34052. window.requestAnimationFrame(callback);
  34053. }
  34054. else if (window.webkitRequestAnimationFrame) {
  34055. window.webkitRequestAnimationFrame(callback);
  34056. }
  34057. else {
  34058. window.setTimeout(callback, 0);
  34059. }
  34060. };
  34061. AnimationFrameService.prototype.isQueueEmpty = function () {
  34062. return !this.ticking;
  34063. };
  34064. __decorate$1u([
  34065. Autowired('gridOptionsWrapper')
  34066. ], AnimationFrameService.prototype, "gridOptionsWrapper", void 0);
  34067. __decorate$1u([
  34068. PostConstruct
  34069. ], AnimationFrameService.prototype, "init", null);
  34070. AnimationFrameService = __decorate$1u([
  34071. Bean('animationFrameService')
  34072. ], AnimationFrameService);
  34073. return AnimationFrameService;
  34074. }(BeanStub));
  34075. /**
  34076. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  34077. * @version v23.2.1
  34078. * @link http://www.ag-grid.com/
  34079. * @license MIT
  34080. */
  34081. var __extends$1v = (undefined && undefined.__extends) || (function () {
  34082. var extendStatics = function (d, b) {
  34083. extendStatics = Object.setPrototypeOf ||
  34084. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  34085. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  34086. return extendStatics(d, b);
  34087. };
  34088. return function (d, b) {
  34089. extendStatics(d, b);
  34090. function __() { this.constructor = d; }
  34091. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  34092. };
  34093. })();
  34094. var __decorate$1v = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  34095. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  34096. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  34097. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  34098. return c > 3 && r && Object.defineProperty(target, key, r), r;
  34099. };
  34100. var NavigationService = /** @class */ (function (_super) {
  34101. __extends$1v(NavigationService, _super);
  34102. function NavigationService() {
  34103. var _this = _super !== null && _super.apply(this, arguments) || this;
  34104. _this.timeLastPageEventProcessed = 0;
  34105. return _this;
  34106. }
  34107. NavigationService.prototype.init = function () {
  34108. this.scrollWidth = this.gridOptionsWrapper.getScrollbarWidth();
  34109. };
  34110. NavigationService.prototype.registerGridComp = function (gridPanel) {
  34111. this.gridPanel = gridPanel;
  34112. };
  34113. NavigationService.prototype.handlePageScrollingKey = function (event) {
  34114. var key = event.which || event.keyCode;
  34115. var alt = event.altKey;
  34116. var ctrl = event.ctrlKey;
  34117. var currentCell = this.mouseEventService.getCellPositionForEvent(event);
  34118. if (!currentCell) {
  34119. return false;
  34120. }
  34121. var processed = false;
  34122. switch (key) {
  34123. case Constants.KEY_PAGE_HOME:
  34124. case Constants.KEY_PAGE_END:
  34125. // handle home and end when ctrl & alt are NOT pressed
  34126. if (!ctrl && !alt) {
  34127. this.onHomeOrEndKey(key);
  34128. processed = true;
  34129. }
  34130. break;
  34131. case Constants.KEY_LEFT:
  34132. case Constants.KEY_RIGHT:
  34133. // handle left and right when ctrl is pressed only
  34134. if (ctrl && !alt) {
  34135. this.onCtrlLeftOrRight(key, currentCell);
  34136. processed = true;
  34137. }
  34138. break;
  34139. case Constants.KEY_UP:
  34140. case Constants.KEY_DOWN:
  34141. // handle up and down when ctrl is pressed only
  34142. if (ctrl && !alt) {
  34143. this.onCtrlUpOrDown(key, currentCell);
  34144. processed = true;
  34145. }
  34146. break;
  34147. case Constants.KEY_PAGE_DOWN:
  34148. // handle page up and page down when ctrl & alt are NOT pressed
  34149. if (!ctrl && !alt) {
  34150. this.onPageDown(currentCell);
  34151. processed = true;
  34152. }
  34153. break;
  34154. case Constants.KEY_PAGE_UP:
  34155. // handle page up and page down when ctrl & alt are NOT pressed
  34156. if (!ctrl && !alt) {
  34157. this.onPageUp(currentCell);
  34158. processed = true;
  34159. }
  34160. break;
  34161. }
  34162. if (processed) {
  34163. event.preventDefault();
  34164. }
  34165. return processed;
  34166. };
  34167. // the page up/down keys caused a problem, in that if the user
  34168. // held the page up/down key down, lots of events got generated,
  34169. // which clogged up the event queue (as they take time to process)
  34170. // which in turn froze the grid. Logic below makes sure we wait 100ms
  34171. // between processing the page up/down events, so when user has finger
  34172. // held down on key, we ignore page up/down events until 100ms has passed,
  34173. // which effectively empties the queue of page up/down events.
  34174. NavigationService.prototype.isTimeSinceLastPageEventToRecent = function () {
  34175. var now = new Date().getTime();
  34176. var diff = now - this.timeLastPageEventProcessed;
  34177. return (diff < 100);
  34178. };
  34179. NavigationService.prototype.setTimeLastPageEventProcessed = function () {
  34180. this.timeLastPageEventProcessed = new Date().getTime();
  34181. };
  34182. NavigationService.prototype.onPageDown = function (gridCell) {
  34183. if (this.isTimeSinceLastPageEventToRecent()) {
  34184. return;
  34185. }
  34186. var scrollPosition = this.gridPanel.getVScrollPosition();
  34187. var pixelsInOnePage = scrollPosition.bottom - scrollPosition.top;
  34188. if (this.gridPanel.isHorizontalScrollShowing()) {
  34189. pixelsInOnePage -= this.scrollWidth;
  34190. }
  34191. var pagingPixelOffset = this.paginationProxy.getPixelOffset();
  34192. var currentPageBottomPixel = scrollPosition.top + pixelsInOnePage;
  34193. var currentPageBottomRow = this.paginationProxy.getRowIndexAtPixel(currentPageBottomPixel + pagingPixelOffset);
  34194. var scrollIndex = currentPageBottomRow;
  34195. var currentCellPixel = this.paginationProxy.getRow(gridCell.rowIndex).rowTop;
  34196. var nextCellPixel = currentCellPixel + pixelsInOnePage - pagingPixelOffset;
  34197. var focusIndex = this.paginationProxy.getRowIndexAtPixel(nextCellPixel + pagingPixelOffset);
  34198. var pageLastRow = this.paginationProxy.getPageLastRow();
  34199. if (focusIndex > pageLastRow) {
  34200. focusIndex = pageLastRow;
  34201. }
  34202. if (scrollIndex > pageLastRow) {
  34203. scrollIndex = pageLastRow;
  34204. }
  34205. this.navigateTo(scrollIndex, 'top', null, focusIndex, gridCell.column);
  34206. this.setTimeLastPageEventProcessed();
  34207. };
  34208. NavigationService.prototype.onPageUp = function (gridCell) {
  34209. if (this.isTimeSinceLastPageEventToRecent()) {
  34210. return;
  34211. }
  34212. var scrollPosition = this.gridPanel.getVScrollPosition();
  34213. var pixelsInOnePage = scrollPosition.bottom - scrollPosition.top;
  34214. if (this.gridPanel.isHorizontalScrollShowing()) {
  34215. pixelsInOnePage -= this.scrollWidth;
  34216. }
  34217. var pagingPixelOffset = this.paginationProxy.getPixelOffset();
  34218. var currentPageTopPixel = scrollPosition.top;
  34219. var currentPageTopRow = this.paginationProxy.getRowIndexAtPixel(currentPageTopPixel + pagingPixelOffset);
  34220. var scrollIndex = currentPageTopRow;
  34221. var currentRowNode = this.paginationProxy.getRow(gridCell.rowIndex);
  34222. var nextCellPixel = currentRowNode.rowTop + currentRowNode.rowHeight - pixelsInOnePage - pagingPixelOffset;
  34223. var focusIndex = this.paginationProxy.getRowIndexAtPixel(nextCellPixel + pagingPixelOffset);
  34224. var firstRow = this.paginationProxy.getPageFirstRow();
  34225. if (focusIndex < firstRow) {
  34226. focusIndex = firstRow;
  34227. }
  34228. if (scrollIndex < firstRow) {
  34229. scrollIndex = firstRow;
  34230. }
  34231. this.navigateTo(scrollIndex, 'bottom', null, focusIndex, gridCell.column);
  34232. this.setTimeLastPageEventProcessed();
  34233. };
  34234. // common logic to navigate. takes parameters:
  34235. // scrollIndex - what row to vertically scroll to
  34236. // scrollType - what position to put scroll index ie top/bottom
  34237. // scrollColumn - what column to horizontally scroll to
  34238. // focusIndex / focusColumn - for page up / down, we want to scroll to one row/column, but focus another
  34239. NavigationService.prototype.navigateTo = function (scrollIndex, scrollType, scrollColumn, focusIndex, focusColumn) {
  34240. if (_.exists(scrollColumn)) {
  34241. this.gridPanel.ensureColumnVisible(scrollColumn);
  34242. }
  34243. if (_.exists(scrollIndex)) {
  34244. this.gridPanel.ensureIndexVisible(scrollIndex, scrollType);
  34245. }
  34246. // make sure the cell is rendered, needed if we are to focus
  34247. this.animationFrameService.flushAllFrames();
  34248. // if we don't do this, the range will be left on the last cell, which will leave the last focused cell
  34249. // highlighted.
  34250. this.focusController.setFocusedCell(focusIndex, focusColumn, null, true);
  34251. if (this.rangeController) {
  34252. var cellPosition = { rowIndex: focusIndex, rowPinned: null, column: focusColumn };
  34253. this.rangeController.setRangeToCell(cellPosition);
  34254. }
  34255. };
  34256. // ctrl + up/down will bring focus to same column, first/last row. no horizontal scrolling.
  34257. NavigationService.prototype.onCtrlUpOrDown = function (key, gridCell) {
  34258. var upKey = key === Constants.KEY_UP;
  34259. var rowIndexToScrollTo = upKey ? 0 : this.paginationProxy.getPageLastRow();
  34260. this.navigateTo(rowIndexToScrollTo, null, gridCell.column, rowIndexToScrollTo, gridCell.column);
  34261. };
  34262. // ctrl + left/right will bring focus to same row, first/last cell. no vertical scrolling.
  34263. NavigationService.prototype.onCtrlLeftOrRight = function (key, gridCell) {
  34264. var leftKey = key === Constants.KEY_LEFT;
  34265. var allColumns = this.columnController.getAllDisplayedColumns();
  34266. var columnToSelect = leftKey ? allColumns[0] : _.last(allColumns);
  34267. this.navigateTo(gridCell.rowIndex, null, columnToSelect, gridCell.rowIndex, columnToSelect);
  34268. };
  34269. // home brings focus to top left cell, end brings focus to bottom right, grid scrolled to bring
  34270. // same cell into view (which means either scroll all the way up, or all the way down).
  34271. NavigationService.prototype.onHomeOrEndKey = function (key) {
  34272. var homeKey = key === Constants.KEY_PAGE_HOME;
  34273. var allColumns = this.columnController.getAllDisplayedColumns();
  34274. var columnToSelect = homeKey ? allColumns[0] : _.last(allColumns);
  34275. var rowIndexToScrollTo = homeKey ? 0 : this.paginationProxy.getPageLastRow();
  34276. this.navigateTo(rowIndexToScrollTo, null, columnToSelect, rowIndexToScrollTo, columnToSelect);
  34277. };
  34278. __decorate$1v([
  34279. Autowired('mouseEventService')
  34280. ], NavigationService.prototype, "mouseEventService", void 0);
  34281. __decorate$1v([
  34282. Autowired('paginationProxy')
  34283. ], NavigationService.prototype, "paginationProxy", void 0);
  34284. __decorate$1v([
  34285. Autowired('focusController')
  34286. ], NavigationService.prototype, "focusController", void 0);
  34287. __decorate$1v([
  34288. Autowired('animationFrameService')
  34289. ], NavigationService.prototype, "animationFrameService", void 0);
  34290. __decorate$1v([
  34291. Optional('rangeController')
  34292. ], NavigationService.prototype, "rangeController", void 0);
  34293. __decorate$1v([
  34294. Autowired('columnController')
  34295. ], NavigationService.prototype, "columnController", void 0);
  34296. __decorate$1v([
  34297. Autowired('gridOptionsWrapper')
  34298. ], NavigationService.prototype, "gridOptionsWrapper", void 0);
  34299. __decorate$1v([
  34300. PostConstruct
  34301. ], NavigationService.prototype, "init", null);
  34302. NavigationService = __decorate$1v([
  34303. Bean('navigationService')
  34304. ], NavigationService);
  34305. return NavigationService;
  34306. }(BeanStub));
  34307. /**
  34308. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  34309. * @version v23.2.1
  34310. * @link http://www.ag-grid.com/
  34311. * @license MIT
  34312. */
  34313. var __extends$1w = (undefined && undefined.__extends) || (function () {
  34314. var extendStatics = function (d, b) {
  34315. extendStatics = Object.setPrototypeOf ||
  34316. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  34317. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  34318. return extendStatics(d, b);
  34319. };
  34320. return function (d, b) {
  34321. extendStatics(d, b);
  34322. function __() { this.constructor = d; }
  34323. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  34324. };
  34325. })();
  34326. var __decorate$1w = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  34327. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  34328. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  34329. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  34330. return c > 3 && r && Object.defineProperty(target, key, r), r;
  34331. };
  34332. /**
  34333. * This class solves the 'max height' problem, where the user might want to show more data than
  34334. * the max div height actually allows.
  34335. */
  34336. var MaxDivHeightScaler = /** @class */ (function (_super) {
  34337. __extends$1w(MaxDivHeightScaler, _super);
  34338. function MaxDivHeightScaler() {
  34339. var _this = _super !== null && _super.apply(this, arguments) || this;
  34340. // the scrollY position
  34341. _this.scrollY = 0;
  34342. // how tall the body is
  34343. _this.uiBodyHeight = 0;
  34344. return _this;
  34345. }
  34346. MaxDivHeightScaler.prototype.postConstruct = function () {
  34347. this.addManagedListener(this.eventService, Events.EVENT_BODY_HEIGHT_CHANGED, this.updateOffset.bind(this));
  34348. this.scrollBarWidth = this.gridOptionsWrapper.getScrollbarWidth();
  34349. this.maxDivHeight = _.getMaxDivHeight();
  34350. };
  34351. MaxDivHeightScaler.prototype.registerGridComp = function (gridPanel) {
  34352. this.gridPanel = gridPanel;
  34353. };
  34354. MaxDivHeightScaler.prototype.isScaling = function () {
  34355. return this.scaling;
  34356. };
  34357. MaxDivHeightScaler.prototype.getOffset = function () {
  34358. return this.offset;
  34359. };
  34360. MaxDivHeightScaler.prototype.updateOffset = function () {
  34361. if (!this.scaling) {
  34362. return;
  34363. }
  34364. var newScrollY = this.gridPanel.getVScrollPosition().top;
  34365. var newBodyHeight = this.getUiBodyHeight();
  34366. var atLeastOneChanged = newScrollY !== this.scrollY || newBodyHeight !== this.uiBodyHeight;
  34367. if (atLeastOneChanged) {
  34368. this.scrollY = newScrollY;
  34369. this.uiBodyHeight = newBodyHeight;
  34370. this.calculateOffset();
  34371. }
  34372. };
  34373. MaxDivHeightScaler.prototype.calculateOffset = function () {
  34374. this.uiContainerHeight = this.maxDivHeight;
  34375. this.pixelsToShave = this.modelHeight - this.uiContainerHeight;
  34376. this.maxScrollY = this.uiContainerHeight - this.uiBodyHeight;
  34377. var scrollPercent = this.scrollY / this.maxScrollY;
  34378. this.setOffset(scrollPercent * this.pixelsToShave);
  34379. };
  34380. MaxDivHeightScaler.prototype.clearOffset = function () {
  34381. this.uiContainerHeight = this.modelHeight;
  34382. this.pixelsToShave = 0;
  34383. this.setOffset(0);
  34384. };
  34385. MaxDivHeightScaler.prototype.setOffset = function (newOffset) {
  34386. // because we are talking pixels, no point in confusing things with half numbers
  34387. var newOffsetFloor = typeof newOffset === 'number' ? Math.floor(newOffset) : null;
  34388. if (this.offset === newOffsetFloor) {
  34389. return;
  34390. }
  34391. this.offset = newOffsetFloor;
  34392. this.eventService.dispatchEvent({ type: Events.EVENT_HEIGHT_SCALE_CHANGED });
  34393. };
  34394. MaxDivHeightScaler.prototype.setModelHeight = function (modelHeight) {
  34395. this.modelHeight = modelHeight;
  34396. this.scaling = this.maxDivHeight > 0 && modelHeight > this.maxDivHeight;
  34397. if (this.scaling) {
  34398. this.calculateOffset();
  34399. }
  34400. else {
  34401. this.clearOffset();
  34402. }
  34403. };
  34404. MaxDivHeightScaler.prototype.getUiContainerHeight = function () {
  34405. return this.uiContainerHeight;
  34406. };
  34407. MaxDivHeightScaler.prototype.getRealPixelPosition = function (modelPixel) {
  34408. return modelPixel - this.offset;
  34409. };
  34410. MaxDivHeightScaler.prototype.getUiBodyHeight = function () {
  34411. var pos = this.gridPanel.getVScrollPosition();
  34412. return pos.bottom - pos.top;
  34413. };
  34414. MaxDivHeightScaler.prototype.getScrollPositionForPixel = function (rowTop) {
  34415. if (this.pixelsToShave <= 0) {
  34416. return rowTop;
  34417. }
  34418. var modelMaxScroll = this.modelHeight - this.getUiBodyHeight();
  34419. var scrollPercent = rowTop / modelMaxScroll;
  34420. var scrollPixel = this.maxScrollY * scrollPercent;
  34421. return scrollPixel;
  34422. };
  34423. __decorate$1w([
  34424. Autowired('gridOptionsWrapper')
  34425. ], MaxDivHeightScaler.prototype, "gridOptionsWrapper", void 0);
  34426. __decorate$1w([
  34427. PostConstruct
  34428. ], MaxDivHeightScaler.prototype, "postConstruct", null);
  34429. MaxDivHeightScaler = __decorate$1w([
  34430. Bean('maxDivHeightScaler')
  34431. ], MaxDivHeightScaler);
  34432. return MaxDivHeightScaler;
  34433. }(BeanStub));
  34434. /**
  34435. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  34436. * @version v23.2.1
  34437. * @link http://www.ag-grid.com/
  34438. * @license MIT
  34439. */
  34440. var __extends$1x = (undefined && undefined.__extends) || (function () {
  34441. var extendStatics = function (d, b) {
  34442. extendStatics = Object.setPrototypeOf ||
  34443. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  34444. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  34445. return extendStatics(d, b);
  34446. };
  34447. return function (d, b) {
  34448. extendStatics(d, b);
  34449. function __() { this.constructor = d; }
  34450. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  34451. };
  34452. })();
  34453. var __decorate$1x = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  34454. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  34455. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  34456. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  34457. return c > 3 && r && Object.defineProperty(target, key, r), r;
  34458. };
  34459. var SelectableService = /** @class */ (function (_super) {
  34460. __extends$1x(SelectableService, _super);
  34461. function SelectableService() {
  34462. return _super !== null && _super.apply(this, arguments) || this;
  34463. }
  34464. SelectableService.prototype.init = function () {
  34465. this.groupSelectsChildren = this.gridOptionsWrapper.isGroupSelectsChildren();
  34466. this.isRowSelectableFunc = this.gridOptionsWrapper.getIsRowSelectableFunc();
  34467. };
  34468. SelectableService.prototype.updateSelectableAfterGrouping = function (rowNode) {
  34469. if (this.isRowSelectableFunc) {
  34470. var nextChildrenFunc = function (rowNode) { return rowNode.childrenAfterGroup; };
  34471. this.recurseDown(rowNode.childrenAfterGroup, nextChildrenFunc);
  34472. }
  34473. };
  34474. SelectableService.prototype.updateSelectableAfterFiltering = function (rowNode) {
  34475. if (this.isRowSelectableFunc) {
  34476. var nextChildrenFunc = function (rowNode) { return rowNode.childrenAfterFilter; };
  34477. this.recurseDown(rowNode.childrenAfterGroup, nextChildrenFunc);
  34478. }
  34479. };
  34480. SelectableService.prototype.recurseDown = function (children, nextChildrenFunc) {
  34481. var _this = this;
  34482. children.forEach(function (child) {
  34483. if (!child.group) {
  34484. return;
  34485. } // only interested in groups
  34486. if (child.hasChildren()) {
  34487. _this.recurseDown(nextChildrenFunc(child), nextChildrenFunc);
  34488. }
  34489. var rowSelectable;
  34490. if (_this.groupSelectsChildren) {
  34491. // have this group selectable if at least one direct child is selectable
  34492. var firstSelectable = _.find(nextChildrenFunc(child), 'selectable', true);
  34493. rowSelectable = _.exists(firstSelectable);
  34494. }
  34495. else {
  34496. // directly retrieve selectable value from user callback
  34497. rowSelectable = _this.isRowSelectableFunc ? _this.isRowSelectableFunc(child) : false;
  34498. }
  34499. child.setRowSelectable(rowSelectable);
  34500. });
  34501. };
  34502. __decorate$1x([
  34503. Autowired('gridOptionsWrapper')
  34504. ], SelectableService.prototype, "gridOptionsWrapper", void 0);
  34505. __decorate$1x([
  34506. PostConstruct
  34507. ], SelectableService.prototype, "init", null);
  34508. SelectableService = __decorate$1x([
  34509. Bean('selectableService')
  34510. ], SelectableService);
  34511. return SelectableService;
  34512. }(BeanStub));
  34513. /**
  34514. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  34515. * @version v23.2.1
  34516. * @link http://www.ag-grid.com/
  34517. * @license MIT
  34518. */
  34519. var __extends$1y = (undefined && undefined.__extends) || (function () {
  34520. var extendStatics = function (d, b) {
  34521. extendStatics = Object.setPrototypeOf ||
  34522. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  34523. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  34524. return extendStatics(d, b);
  34525. };
  34526. return function (d, b) {
  34527. extendStatics(d, b);
  34528. function __() { this.constructor = d; }
  34529. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  34530. };
  34531. })();
  34532. var __decorate$1y = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  34533. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  34534. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  34535. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  34536. return c > 3 && r && Object.defineProperty(target, key, r), r;
  34537. };
  34538. var AutoHeightCalculator = /** @class */ (function (_super) {
  34539. __extends$1y(AutoHeightCalculator, _super);
  34540. function AutoHeightCalculator() {
  34541. return _super !== null && _super.apply(this, arguments) || this;
  34542. }
  34543. AutoHeightCalculator.prototype.registerGridComp = function (gridPanel) {
  34544. this.gridPanel = gridPanel;
  34545. };
  34546. AutoHeightCalculator.prototype.getPreferredHeightForRow = function (rowNode) {
  34547. var _this = this;
  34548. if (!this.eDummyContainer) {
  34549. this.eDummyContainer = document.createElement('div');
  34550. // so any styles on row also get applied in dummy, otherwise
  34551. // the content in dummy may differ to the real
  34552. _.addCssClass(this.eDummyContainer, 'ag-row ag-row-no-focus');
  34553. }
  34554. // we put the dummy into the body container, so it will inherit all the
  34555. // css styles that the real cells are inheriting
  34556. var eBodyContainer = this.gridPanel.getCenterContainer();
  34557. eBodyContainer.appendChild(this.eDummyContainer);
  34558. var cellComps = [];
  34559. var autoRowHeightCols = this.columnController.getAllAutoRowHeightCols();
  34560. var visibleAutoRowHeightCols = autoRowHeightCols.filter(function (col) { return col.isVisible(); });
  34561. visibleAutoRowHeightCols.forEach(function (col) {
  34562. var cellComp = new CellComp(_this.$scope, _this.beans, col, rowNode, null, true, false);
  34563. cellComp.setParentRow(_this.eDummyContainer);
  34564. cellComps.push(cellComp);
  34565. });
  34566. var template = cellComps.map(function (cellComp) { return cellComp.getCreateTemplate(); }).join(' ');
  34567. this.eDummyContainer.innerHTML = template;
  34568. // this gets any cellComps that are using components to put the components in
  34569. cellComps.forEach(function (cellComp) { return cellComp.afterAttached(); });
  34570. // we should be able to just take the height of the row at this point, however
  34571. // the row isn't expanding to cover the cell heights, i don't know why, i couldn't
  34572. // figure it out so instead looking at the individual cells instead
  34573. var maxCellHeight = 0;
  34574. for (var i = 0; i < this.eDummyContainer.children.length; i++) {
  34575. var child = this.eDummyContainer.children[i];
  34576. if (child.offsetHeight > maxCellHeight) {
  34577. maxCellHeight = child.offsetHeight;
  34578. }
  34579. }
  34580. // we are finished with the dummy container, so get rid of it
  34581. eBodyContainer.removeChild(this.eDummyContainer);
  34582. cellComps.forEach(function (cellComp) {
  34583. // dunno why we need to detach first, doing it here to be consistent with code in RowComp
  34584. cellComp.detach();
  34585. cellComp.destroy();
  34586. });
  34587. // in case anything left over from last time
  34588. _.clearElement(this.eDummyContainer);
  34589. return maxCellHeight;
  34590. };
  34591. __decorate$1y([
  34592. Autowired('beans')
  34593. ], AutoHeightCalculator.prototype, "beans", void 0);
  34594. __decorate$1y([
  34595. Autowired("$scope")
  34596. ], AutoHeightCalculator.prototype, "$scope", void 0);
  34597. __decorate$1y([
  34598. Autowired("columnController")
  34599. ], AutoHeightCalculator.prototype, "columnController", void 0);
  34600. AutoHeightCalculator = __decorate$1y([
  34601. Bean('autoHeightCalculator')
  34602. ], AutoHeightCalculator);
  34603. return AutoHeightCalculator;
  34604. }(BeanStub));
  34605. /**
  34606. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  34607. * @version v23.2.1
  34608. * @link http://www.ag-grid.com/
  34609. * @license MIT
  34610. */
  34611. var __extends$1z = (undefined && undefined.__extends) || (function () {
  34612. var extendStatics = function (d, b) {
  34613. extendStatics = Object.setPrototypeOf ||
  34614. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  34615. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  34616. return extendStatics(d, b);
  34617. };
  34618. return function (d, b) {
  34619. extendStatics(d, b);
  34620. function __() { this.constructor = d; }
  34621. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  34622. };
  34623. })();
  34624. var __decorate$1z = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  34625. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  34626. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  34627. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  34628. return c > 3 && r && Object.defineProperty(target, key, r), r;
  34629. };
  34630. var PaginationComp = /** @class */ (function (_super) {
  34631. __extends$1z(PaginationComp, _super);
  34632. function PaginationComp() {
  34633. var _this = _super.call(this) || this;
  34634. _this.previousAndFirstButtonsDisabled = false;
  34635. _this.nextButtonDisabled = false;
  34636. _this.lastButtonDisabled = false;
  34637. return _this;
  34638. }
  34639. PaginationComp.prototype.postConstruct = function () {
  34640. var isRtl = this.gridOptionsWrapper.isEnableRtl();
  34641. this.setTemplate(this.getTemplate());
  34642. this.btFirst.insertAdjacentElement('afterbegin', _.createIconNoSpan(isRtl ? 'last' : 'first', this.gridOptionsWrapper));
  34643. this.btPrevious.insertAdjacentElement('afterbegin', _.createIconNoSpan(isRtl ? 'next' : 'previous', this.gridOptionsWrapper));
  34644. this.btNext.insertAdjacentElement('afterbegin', _.createIconNoSpan(isRtl ? 'previous' : 'next', this.gridOptionsWrapper));
  34645. this.btLast.insertAdjacentElement('afterbegin', _.createIconNoSpan(isRtl ? 'first' : 'last', this.gridOptionsWrapper));
  34646. if (this.rowModel.getType() === Constants.ROW_MODEL_TYPE_SERVER_SIDE) {
  34647. this.serverSideRowModel = this.rowModel;
  34648. }
  34649. var isPaging = this.gridOptionsWrapper.isPagination();
  34650. var paginationPanelEnabled = isPaging && !this.gridOptionsWrapper.isSuppressPaginationPanel();
  34651. if (!paginationPanelEnabled) {
  34652. this.setDisplayed(false);
  34653. return;
  34654. }
  34655. this.addManagedListener(this.eventService, Events.EVENT_PAGINATION_CHANGED, this.onPaginationChanged.bind(this));
  34656. this.addManagedListener(this.btFirst, 'click', this.onBtFirst.bind(this));
  34657. this.addManagedListener(this.btLast, 'click', this.onBtLast.bind(this));
  34658. this.addManagedListener(this.btNext, 'click', this.onBtNext.bind(this));
  34659. this.addManagedListener(this.btPrevious, 'click', this.onBtPrevious.bind(this));
  34660. this.onPaginationChanged();
  34661. };
  34662. PaginationComp.prototype.onPaginationChanged = function () {
  34663. this.enableOrDisableButtons();
  34664. this.updateRowLabels();
  34665. this.setCurrentPageLabel();
  34666. this.setTotalLabels();
  34667. };
  34668. PaginationComp.prototype.onBtFirst = function () {
  34669. if (!this.previousAndFirstButtonsDisabled) {
  34670. this.paginationProxy.goToFirstPage();
  34671. }
  34672. };
  34673. PaginationComp.prototype.setCurrentPageLabel = function () {
  34674. var pagesExist = this.paginationProxy.getTotalPages() > 0;
  34675. var currentPage = this.paginationProxy.getCurrentPage();
  34676. var toDisplay = pagesExist ? currentPage + 1 : 0;
  34677. this.lbCurrent.innerHTML = this.formatNumber(toDisplay);
  34678. };
  34679. PaginationComp.prototype.formatNumber = function (value) {
  34680. var userFunc = this.gridOptionsWrapper.getPaginationNumberFormatterFunc();
  34681. if (userFunc) {
  34682. return userFunc({ value: value });
  34683. }
  34684. else {
  34685. return _.formatNumberCommas(value);
  34686. }
  34687. };
  34688. PaginationComp.prototype.getTemplate = function () {
  34689. var localeTextFunc = this.gridOptionsWrapper.getLocaleTextFunc();
  34690. var strPage = localeTextFunc('page', 'Page');
  34691. var strTo = localeTextFunc('to', 'to');
  34692. var strOf = localeTextFunc('of', 'of');
  34693. var strFirst = localeTextFunc('first', 'First');
  34694. var strPrevious = localeTextFunc('previous', 'Previous');
  34695. var strNext = localeTextFunc('next', 'Next');
  34696. var strLast = localeTextFunc('last', 'Last');
  34697. return "<div class=\"ag-paging-panel ag-unselectable\">\n <span ref=\"eSummaryPanel\" class=\"ag-paging-row-summary-panel\">\n <span ref=\"lbFirstRowOnPage\" class=\"ag-paging-row-summary-panel-number\"></span>\n " + strTo + "\n <span ref=\"lbLastRowOnPage\" class=\"ag-paging-row-summary-panel-number\"></span>\n " + strOf + "\n <span ref=\"lbRecordCount\" class=\"ag-paging-row-summary-panel-number\"></span>\n </span>\n <span class=\"ag-paging-page-summary-panel\">\n <div ref=\"btFirst\" class=\"ag-paging-button-wrapper\">\n <button type=\"button\" class=\"ag-paging-button\">" + strFirst + "</button>\n </div>\n <div ref=\"btPrevious\" class=\"ag-paging-button-wrapper\">\n <button type=\"button\" class=\"ag-paging-button\">" + strPrevious + "</button>\n </div>\n <span class=\"ag-paging-description\">\n " + strPage + "\n <span ref=\"lbCurrent\" class=\"ag-paging-number\"></span>\n " + strOf + "\n <span ref=\"lbTotal\" class=\"ag-paging-number\"></span>\n </span>\n <span ref=\"lbTotal\" class=\"ag-paging-number\"></span>\n <div ref=\"btNext\" class=\"ag-paging-button-wrapper\">\n <button type=\"button\" class=\"ag-paging-button\">" + strNext + "</button>\n </div>\n <div ref=\"btLast\" class=\"ag-paging-button-wrapper\">\n <button type=\"button\" class=\"ag-paging-button\">" + strLast + "</button>\n </div>\n </span>\n </div>";
  34698. };
  34699. PaginationComp.prototype.onBtNext = function () {
  34700. if (!this.nextButtonDisabled) {
  34701. this.paginationProxy.goToNextPage();
  34702. }
  34703. };
  34704. PaginationComp.prototype.onBtPrevious = function () {
  34705. if (!this.previousAndFirstButtonsDisabled) {
  34706. this.paginationProxy.goToPreviousPage();
  34707. }
  34708. };
  34709. PaginationComp.prototype.onBtLast = function () {
  34710. if (!this.lastButtonDisabled) {
  34711. this.paginationProxy.goToLastPage();
  34712. }
  34713. };
  34714. PaginationComp.prototype.enableOrDisableButtons = function () {
  34715. var currentPage = this.paginationProxy.getCurrentPage();
  34716. var maxRowFound = this.paginationProxy.isLastPageFound();
  34717. var totalPages = this.paginationProxy.getTotalPages();
  34718. this.previousAndFirstButtonsDisabled = currentPage === 0;
  34719. _.addOrRemoveCssClass(this.btPrevious, 'ag-disabled', this.previousAndFirstButtonsDisabled);
  34720. _.addOrRemoveCssClass(this.btFirst, 'ag-disabled', this.previousAndFirstButtonsDisabled);
  34721. var zeroPagesToDisplay = this.isZeroPagesToDisplay();
  34722. var onLastPage = maxRowFound && currentPage === (totalPages - 1);
  34723. this.nextButtonDisabled = onLastPage || zeroPagesToDisplay;
  34724. _.addOrRemoveCssClass(this.btNext, 'ag-disabled', this.nextButtonDisabled);
  34725. this.lastButtonDisabled = !maxRowFound || zeroPagesToDisplay || currentPage === (totalPages - 1);
  34726. _.addOrRemoveCssClass(this.btLast, 'ag-disabled', this.lastButtonDisabled);
  34727. };
  34728. PaginationComp.prototype.updateRowLabels = function () {
  34729. var currentPage = this.paginationProxy.getCurrentPage();
  34730. var pageSize = this.paginationProxy.getPageSize();
  34731. var maxRowFound = this.paginationProxy.isLastPageFound();
  34732. var rowCount = this.paginationProxy.isLastPageFound() ?
  34733. this.paginationProxy.getMasterRowCount() : null;
  34734. var startRow;
  34735. var endRow;
  34736. if (this.isZeroPagesToDisplay()) {
  34737. startRow = 0;
  34738. endRow = 0;
  34739. }
  34740. else {
  34741. startRow = (pageSize * currentPage) + 1;
  34742. endRow = startRow + pageSize - 1;
  34743. if (maxRowFound && endRow > rowCount) {
  34744. endRow = rowCount;
  34745. }
  34746. }
  34747. this.lbFirstRowOnPage.innerHTML = this.formatNumber(startRow);
  34748. if (this.serverSideRowModel && this.serverSideRowModel.isLoading()) {
  34749. this.lbLastRowOnPage.innerHTML = '?';
  34750. }
  34751. else {
  34752. this.lbLastRowOnPage.innerHTML = this.formatNumber(endRow);
  34753. }
  34754. };
  34755. PaginationComp.prototype.isZeroPagesToDisplay = function () {
  34756. var maxRowFound = this.paginationProxy.isLastPageFound();
  34757. var totalPages = this.paginationProxy.getTotalPages();
  34758. return maxRowFound && totalPages === 0;
  34759. };
  34760. PaginationComp.prototype.setTotalLabels = function () {
  34761. var lastPageFound = this.paginationProxy.isLastPageFound();
  34762. var totalPages = this.paginationProxy.getTotalPages();
  34763. var rowCount = this.paginationProxy.isLastPageFound() ?
  34764. this.paginationProxy.getMasterRowCount() : null;
  34765. if (lastPageFound) {
  34766. this.lbTotal.innerHTML = this.formatNumber(totalPages);
  34767. this.lbRecordCount.innerHTML = this.formatNumber(rowCount);
  34768. }
  34769. else {
  34770. var moreText = this.gridOptionsWrapper.getLocaleTextFunc()('more', 'more');
  34771. this.lbTotal.innerHTML = moreText;
  34772. this.lbRecordCount.innerHTML = moreText;
  34773. }
  34774. };
  34775. __decorate$1z([
  34776. Autowired('gridOptionsWrapper')
  34777. ], PaginationComp.prototype, "gridOptionsWrapper", void 0);
  34778. __decorate$1z([
  34779. Autowired('paginationProxy')
  34780. ], PaginationComp.prototype, "paginationProxy", void 0);
  34781. __decorate$1z([
  34782. Autowired('rowRenderer')
  34783. ], PaginationComp.prototype, "rowRenderer", void 0);
  34784. __decorate$1z([
  34785. Autowired('rowModel')
  34786. ], PaginationComp.prototype, "rowModel", void 0);
  34787. __decorate$1z([
  34788. RefSelector('btFirst')
  34789. ], PaginationComp.prototype, "btFirst", void 0);
  34790. __decorate$1z([
  34791. RefSelector('btPrevious')
  34792. ], PaginationComp.prototype, "btPrevious", void 0);
  34793. __decorate$1z([
  34794. RefSelector('btNext')
  34795. ], PaginationComp.prototype, "btNext", void 0);
  34796. __decorate$1z([
  34797. RefSelector('btLast')
  34798. ], PaginationComp.prototype, "btLast", void 0);
  34799. __decorate$1z([
  34800. RefSelector('lbRecordCount')
  34801. ], PaginationComp.prototype, "lbRecordCount", void 0);
  34802. __decorate$1z([
  34803. RefSelector('lbFirstRowOnPage')
  34804. ], PaginationComp.prototype, "lbFirstRowOnPage", void 0);
  34805. __decorate$1z([
  34806. RefSelector('lbLastRowOnPage')
  34807. ], PaginationComp.prototype, "lbLastRowOnPage", void 0);
  34808. __decorate$1z([
  34809. RefSelector('eSummaryPanel')
  34810. ], PaginationComp.prototype, "eSummaryPanel", void 0);
  34811. __decorate$1z([
  34812. RefSelector('lbCurrent')
  34813. ], PaginationComp.prototype, "lbCurrent", void 0);
  34814. __decorate$1z([
  34815. RefSelector('lbTotal')
  34816. ], PaginationComp.prototype, "lbTotal", void 0);
  34817. __decorate$1z([
  34818. PostConstruct
  34819. ], PaginationComp.prototype, "postConstruct", null);
  34820. return PaginationComp;
  34821. }(Component));
  34822. /**
  34823. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  34824. * @version v23.2.1
  34825. * @link http://www.ag-grid.com/
  34826. * @license MIT
  34827. */
  34828. var __extends$1A = (undefined && undefined.__extends) || (function () {
  34829. var extendStatics = function (d, b) {
  34830. extendStatics = Object.setPrototypeOf ||
  34831. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  34832. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  34833. return extendStatics(d, b);
  34834. };
  34835. return function (d, b) {
  34836. extendStatics(d, b);
  34837. function __() { this.constructor = d; }
  34838. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  34839. };
  34840. })();
  34841. var __decorate$1A = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  34842. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  34843. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  34844. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  34845. return c > 3 && r && Object.defineProperty(target, key, r), r;
  34846. };
  34847. var ResizeObserverService = /** @class */ (function (_super) {
  34848. __extends$1A(ResizeObserverService, _super);
  34849. function ResizeObserverService() {
  34850. return _super !== null && _super.apply(this, arguments) || this;
  34851. }
  34852. ResizeObserverService.prototype.observeResize = function (element, callback, debounceDelay) {
  34853. if (debounceDelay === void 0) { debounceDelay = 50; }
  34854. // put in variable, so available to usePolyfill() function below
  34855. var frameworkFactory = this.getFrameworkOverrides();
  34856. // this gets fired too often and might cause some relayout issues
  34857. // so we add a debounce to the callback here to avoid the flashing effect.
  34858. var debouncedCallback = _.debounce(callback, debounceDelay);
  34859. var useBrowserResizeObserver = function () {
  34860. var resizeObserver = new window.ResizeObserver(debouncedCallback);
  34861. resizeObserver.observe(element);
  34862. return function () { return resizeObserver.disconnect(); };
  34863. };
  34864. var usePolyfill = function () {
  34865. // initialise to the current width and height, so first call will have no changes
  34866. var widthLastTime = _.offsetWidth(element);
  34867. var heightLastTime = _.offsetHeight(element);
  34868. // when finished, this gets turned to false.
  34869. var running = true;
  34870. var periodicallyCheckWidthAndHeight = function () {
  34871. if (running) {
  34872. var newWidth = _.offsetWidth(element);
  34873. var newHeight = _.offsetHeight(element);
  34874. var changed = newWidth !== widthLastTime || newHeight !== heightLastTime;
  34875. if (changed) {
  34876. widthLastTime = newWidth;
  34877. heightLastTime = newHeight;
  34878. callback();
  34879. }
  34880. frameworkFactory.setTimeout(periodicallyCheckWidthAndHeight, debounceDelay);
  34881. }
  34882. };
  34883. periodicallyCheckWidthAndHeight();
  34884. // the callback function we return sets running to false
  34885. return function () { return running = false; };
  34886. };
  34887. var suppressResize = this.gridOptionsWrapper.isSuppressBrowserResizeObserver();
  34888. var resizeObserverExists = !!window.ResizeObserver;
  34889. if (resizeObserverExists && !suppressResize) {
  34890. return useBrowserResizeObserver();
  34891. }
  34892. else {
  34893. return usePolyfill();
  34894. }
  34895. };
  34896. __decorate$1A([
  34897. Autowired('gridOptionsWrapper')
  34898. ], ResizeObserverService.prototype, "gridOptionsWrapper", void 0);
  34899. ResizeObserverService = __decorate$1A([
  34900. Bean('resizeObserverService')
  34901. ], ResizeObserverService);
  34902. return ResizeObserverService;
  34903. }(BeanStub));
  34904. /**
  34905. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  34906. * @version v23.2.1
  34907. * @link http://www.ag-grid.com/
  34908. * @license MIT
  34909. */
  34910. var __extends$1B = (undefined && undefined.__extends) || (function () {
  34911. var extendStatics = function (d, b) {
  34912. extendStatics = Object.setPrototypeOf ||
  34913. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  34914. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  34915. return extendStatics(d, b);
  34916. };
  34917. return function (d, b) {
  34918. extendStatics(d, b);
  34919. function __() { this.constructor = d; }
  34920. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  34921. };
  34922. })();
  34923. var __decorate$1B = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  34924. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  34925. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  34926. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  34927. return c > 3 && r && Object.defineProperty(target, key, r), r;
  34928. };
  34929. var LoadingType;
  34930. (function (LoadingType) {
  34931. LoadingType[LoadingType["Loading"] = 0] = "Loading";
  34932. LoadingType[LoadingType["NoRows"] = 1] = "NoRows";
  34933. })(LoadingType || (LoadingType = {}));
  34934. var OverlayWrapperComponent = /** @class */ (function (_super) {
  34935. __extends$1B(OverlayWrapperComponent, _super);
  34936. function OverlayWrapperComponent() {
  34937. var _this = _super.call(this, OverlayWrapperComponent.TEMPLATE) || this;
  34938. _this.inProgress = false;
  34939. _this.destroyRequested = false;
  34940. return _this;
  34941. }
  34942. OverlayWrapperComponent.prototype.postConstruct = function () {
  34943. this.gridOptionsWrapper.addLayoutElement(this.eOverlayWrapper);
  34944. this.setDisplayed(false);
  34945. };
  34946. OverlayWrapperComponent.prototype.setWrapperTypeClass = function (loadingType) {
  34947. _.addOrRemoveCssClass(this.eOverlayWrapper, 'ag-overlay-loading-wrapper', loadingType === LoadingType.Loading);
  34948. _.addOrRemoveCssClass(this.eOverlayWrapper, 'ag-overlay-no-rows-wrapper', loadingType === LoadingType.NoRows);
  34949. };
  34950. OverlayWrapperComponent.prototype.showLoadingOverlay = function () {
  34951. var workItem = this.userComponentFactory.newLoadingOverlayComponent({
  34952. api: this.gridOptionsWrapper.getApi()
  34953. });
  34954. this.showOverlay(workItem, LoadingType.Loading);
  34955. };
  34956. OverlayWrapperComponent.prototype.showNoRowsOverlay = function () {
  34957. var workItem = this.userComponentFactory.newNoRowsOverlayComponent({
  34958. api: this.gridOptionsWrapper.getApi()
  34959. });
  34960. this.showOverlay(workItem, LoadingType.NoRows);
  34961. };
  34962. OverlayWrapperComponent.prototype.showOverlay = function (workItem, type) {
  34963. var _this = this;
  34964. if (this.inProgress) {
  34965. return;
  34966. }
  34967. this.setWrapperTypeClass(type);
  34968. this.destroyActiveOverlay();
  34969. this.inProgress = true;
  34970. workItem.then(function (comp) {
  34971. _this.inProgress = false;
  34972. _this.eOverlayWrapper.appendChild(comp.getGui());
  34973. _this.activeOverlay = comp;
  34974. if (_this.destroyRequested) {
  34975. _this.destroyRequested = false;
  34976. _this.destroyActiveOverlay();
  34977. }
  34978. });
  34979. this.setDisplayed(true);
  34980. };
  34981. OverlayWrapperComponent.prototype.destroyActiveOverlay = function () {
  34982. if (this.inProgress) {
  34983. this.destroyRequested = true;
  34984. return;
  34985. }
  34986. if (!this.activeOverlay) {
  34987. return;
  34988. }
  34989. this.activeOverlay = this.getContext().destroyBean(this.activeOverlay);
  34990. _.clearElement(this.eOverlayWrapper);
  34991. };
  34992. OverlayWrapperComponent.prototype.hideOverlay = function () {
  34993. this.destroyActiveOverlay();
  34994. this.setDisplayed(false);
  34995. };
  34996. OverlayWrapperComponent.prototype.destroy = function () {
  34997. this.destroyActiveOverlay();
  34998. _super.prototype.destroy.call(this);
  34999. };
  35000. // wrapping in outer div, and wrapper, is needed to center the loading icon
  35001. // The idea for centering came from here: http://www.vanseodesign.com/css/vertical-centering/
  35002. OverlayWrapperComponent.TEMPLATE = "\n <div class=\"ag-overlay\" aria-hidden=\"true\">\n <div class=\"ag-overlay-panel\">\n <div class=\"ag-overlay-wrapper\" ref=\"eOverlayWrapper\"></div>\n </div>\n </div>";
  35003. __decorate$1B([
  35004. Autowired('gridOptionsWrapper')
  35005. ], OverlayWrapperComponent.prototype, "gridOptionsWrapper", void 0);
  35006. __decorate$1B([
  35007. Autowired('userComponentFactory')
  35008. ], OverlayWrapperComponent.prototype, "userComponentFactory", void 0);
  35009. __decorate$1B([
  35010. RefSelector('eOverlayWrapper')
  35011. ], OverlayWrapperComponent.prototype, "eOverlayWrapper", void 0);
  35012. __decorate$1B([
  35013. PostConstruct
  35014. ], OverlayWrapperComponent.prototype, "postConstruct", null);
  35015. return OverlayWrapperComponent;
  35016. }(Component));
  35017. /**
  35018. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  35019. * @version v23.2.1
  35020. * @link http://www.ag-grid.com/
  35021. * @license MIT
  35022. */
  35023. var __extends$1C = (undefined && undefined.__extends) || (function () {
  35024. var extendStatics = function (d, b) {
  35025. extendStatics = Object.setPrototypeOf ||
  35026. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  35027. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  35028. return extendStatics(d, b);
  35029. };
  35030. return function (d, b) {
  35031. extendStatics(d, b);
  35032. function __() { this.constructor = d; }
  35033. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  35034. };
  35035. })();
  35036. var __decorate$1C = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  35037. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  35038. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  35039. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  35040. return c > 3 && r && Object.defineProperty(target, key, r), r;
  35041. };
  35042. var AgGroupComponent = /** @class */ (function (_super) {
  35043. __extends$1C(AgGroupComponent, _super);
  35044. function AgGroupComponent(params) {
  35045. if (params === void 0) { params = {}; }
  35046. var _this = _super.call(this, AgGroupComponent.getTemplate(params)) || this;
  35047. _this.suppressEnabledCheckbox = true;
  35048. _this.suppressOpenCloseIcons = false;
  35049. var title = params.title, enabled = params.enabled, items = params.items, suppressEnabledCheckbox = params.suppressEnabledCheckbox, suppressOpenCloseIcons = params.suppressOpenCloseIcons;
  35050. _this.title = title;
  35051. _this.cssIdentifier = params.cssIdentifier || 'default';
  35052. _this.enabled = enabled != null ? enabled : true;
  35053. _this.items = items || [];
  35054. _this.alignItems = params.alignItems || 'center';
  35055. if (suppressEnabledCheckbox != null) {
  35056. _this.suppressEnabledCheckbox = suppressEnabledCheckbox;
  35057. }
  35058. if (suppressOpenCloseIcons != null) {
  35059. _this.suppressOpenCloseIcons = suppressOpenCloseIcons;
  35060. }
  35061. return _this;
  35062. }
  35063. AgGroupComponent.getTemplate = function (params) {
  35064. var cssIdentifier = params.cssIdentifier || 'default';
  35065. var direction = params.direction || 'vertical';
  35066. return /* html */ "<div class=\"ag-group ag-" + cssIdentifier + "-group\">\n <div class=\"ag-group-title-bar ag-" + cssIdentifier + "-group-title-bar ag-unselectable\" ref=\"eTitleBar\">\n <span class=\"ag-group-title-bar-icon ag-" + cssIdentifier + "-group-title-bar-icon\" ref=\"eGroupOpenedIcon\"></span>\n <span class=\"ag-group-title-bar-icon ag-" + cssIdentifier + "-group-title-bar-icon\" ref=\"eGroupClosedIcon\"></span>\n <span ref=\"eTitle\" class=\"ag-group-title ag-" + cssIdentifier + "-group-title\"></span>\n </div>\n <div ref=\"eToolbar\" class=\"ag-group-toolbar ag-" + cssIdentifier + "-group-toolbar\">\n <ag-checkbox ref=\"cbGroupEnabled\"></ag-checkbox>\n </div>\n <div ref=\"eContainer\" class=\"ag-group-container ag-group-container-" + direction + " ag-" + cssIdentifier + "-group-container\"></div>\n </div>";
  35067. };
  35068. AgGroupComponent.prototype.postConstruct = function () {
  35069. if (this.items.length) {
  35070. var initialItems = this.items;
  35071. this.items = [];
  35072. this.addItems(initialItems);
  35073. }
  35074. var localeTextFunc = this.gridOptionsWrapper.getLocaleTextFunc();
  35075. this.cbGroupEnabled.setLabel(localeTextFunc('enabled', 'Enabled'));
  35076. if (this.title) {
  35077. this.setTitle(this.title);
  35078. }
  35079. if (this.enabled) {
  35080. this.setEnabled(this.enabled);
  35081. }
  35082. this.setAlignItems(this.alignItems);
  35083. this.hideEnabledCheckbox(this.suppressEnabledCheckbox);
  35084. this.hideOpenCloseIcons(this.suppressOpenCloseIcons);
  35085. this.setupExpandContract();
  35086. this.refreshChildDisplay();
  35087. };
  35088. AgGroupComponent.prototype.setupExpandContract = function () {
  35089. var _this = this;
  35090. this.eGroupClosedIcon.appendChild(_.createIcon('columnSelectClosed', this.gridOptionsWrapper, null));
  35091. this.eGroupOpenedIcon.appendChild(_.createIcon('columnSelectOpen', this.gridOptionsWrapper, null));
  35092. this.addManagedListener(this.eTitleBar, 'click', function () { return _this.toggleGroupExpand(); });
  35093. this.addManagedListener(this.eTitleBar, 'keydown', function (e) {
  35094. if (e.keyCode === Constants.KEY_ENTER) {
  35095. _this.toggleGroupExpand();
  35096. }
  35097. });
  35098. };
  35099. AgGroupComponent.prototype.refreshChildDisplay = function () {
  35100. var showIcon = !this.suppressOpenCloseIcons;
  35101. _.setDisplayed(this.eGroupClosedIcon, showIcon && !this.expanded);
  35102. _.setDisplayed(this.eGroupOpenedIcon, showIcon && this.expanded);
  35103. _.setDisplayed(this.eToolbar, this.expanded && !this.suppressEnabledCheckbox);
  35104. };
  35105. AgGroupComponent.prototype.isExpanded = function () {
  35106. return this.expanded;
  35107. };
  35108. AgGroupComponent.prototype.setAlignItems = function (alignment) {
  35109. var eGui = this.getGui();
  35110. if (this.alignItems !== alignment) {
  35111. _.removeCssClass(eGui, "ag-group-item-alignment-" + this.alignItems);
  35112. }
  35113. this.alignItems = alignment;
  35114. var newCls = "ag-group-item-alignment-" + this.alignItems;
  35115. _.addCssClass(eGui, newCls);
  35116. return this;
  35117. };
  35118. AgGroupComponent.prototype.toggleGroupExpand = function (expanded) {
  35119. if (this.suppressOpenCloseIcons) {
  35120. this.expanded = true;
  35121. this.refreshChildDisplay();
  35122. _.setDisplayed(this.eContainer, true);
  35123. return this;
  35124. }
  35125. expanded = expanded != null ? expanded : !this.expanded;
  35126. if (this.expanded === expanded) {
  35127. return this;
  35128. }
  35129. this.expanded = expanded;
  35130. this.refreshChildDisplay();
  35131. _.setDisplayed(this.eContainer, expanded);
  35132. if (this.expanded) {
  35133. this.dispatchEvent({ type: AgGroupComponent.EVENT_EXPANDED });
  35134. }
  35135. else {
  35136. this.dispatchEvent({ type: AgGroupComponent.EVENT_COLLAPSED });
  35137. }
  35138. return this;
  35139. };
  35140. AgGroupComponent.prototype.addItems = function (items) {
  35141. var _this = this;
  35142. items.forEach(function (item) { return _this.addItem(item); });
  35143. };
  35144. AgGroupComponent.prototype.addItem = function (item) {
  35145. var container = this.eContainer;
  35146. var el = item instanceof Component ? item.getGui() : item;
  35147. _.addCssClass(el, 'ag-group-item');
  35148. _.addCssClass(el, "ag-" + this.cssIdentifier + "-group-item");
  35149. container.appendChild(el);
  35150. this.items.push(el);
  35151. };
  35152. AgGroupComponent.prototype.hideItem = function (hide, index) {
  35153. var itemToHide = this.items[index];
  35154. _.addOrRemoveCssClass(itemToHide, 'ag-hidden', hide);
  35155. };
  35156. AgGroupComponent.prototype.setTitle = function (title) {
  35157. this.eTitle.innerText = title;
  35158. return this;
  35159. };
  35160. AgGroupComponent.prototype.addCssClassToTitleBar = function (cssClass) {
  35161. _.addCssClass(this.eTitleBar, cssClass);
  35162. };
  35163. AgGroupComponent.prototype.setEnabled = function (enabled, skipToggle) {
  35164. this.enabled = enabled;
  35165. this.refreshDisabledStyles();
  35166. this.toggleGroupExpand(enabled);
  35167. if (!skipToggle) {
  35168. this.cbGroupEnabled.setValue(enabled);
  35169. }
  35170. return this;
  35171. };
  35172. AgGroupComponent.prototype.isEnabled = function () {
  35173. return this.enabled;
  35174. };
  35175. AgGroupComponent.prototype.onEnableChange = function (callbackFn) {
  35176. var _this = this;
  35177. this.cbGroupEnabled.onValueChange(function (newSelection) {
  35178. _this.setEnabled(newSelection, true);
  35179. callbackFn(newSelection);
  35180. });
  35181. return this;
  35182. };
  35183. AgGroupComponent.prototype.hideEnabledCheckbox = function (hide) {
  35184. this.suppressEnabledCheckbox = hide;
  35185. this.refreshChildDisplay();
  35186. this.refreshDisabledStyles();
  35187. return this;
  35188. };
  35189. AgGroupComponent.prototype.hideOpenCloseIcons = function (hide) {
  35190. this.suppressOpenCloseIcons = hide;
  35191. if (hide) {
  35192. this.toggleGroupExpand(true);
  35193. }
  35194. return this;
  35195. };
  35196. AgGroupComponent.prototype.refreshDisabledStyles = function () {
  35197. _.addOrRemoveCssClass(this.getGui(), 'ag-disabled', !this.enabled);
  35198. if (this.suppressEnabledCheckbox && !this.enabled) {
  35199. _.addCssClass(this.eTitleBar, 'ag-disabled-group-title-bar');
  35200. this.eTitleBar.removeAttribute('tabindex');
  35201. }
  35202. else {
  35203. _.removeCssClass(this.eTitleBar, 'ag-disabled-group-title-bar');
  35204. this.eTitleBar.setAttribute('tabindex', '0');
  35205. }
  35206. _.addOrRemoveCssClass(this.eContainer, 'ag-disabled-group-container', !this.enabled);
  35207. };
  35208. AgGroupComponent.EVENT_EXPANDED = 'expanded';
  35209. AgGroupComponent.EVENT_COLLAPSED = 'collapsed';
  35210. __decorate$1C([
  35211. Autowired('gridOptionsWrapper')
  35212. ], AgGroupComponent.prototype, "gridOptionsWrapper", void 0);
  35213. __decorate$1C([
  35214. RefSelector('eTitleBar')
  35215. ], AgGroupComponent.prototype, "eTitleBar", void 0);
  35216. __decorate$1C([
  35217. RefSelector('eGroupOpenedIcon')
  35218. ], AgGroupComponent.prototype, "eGroupOpenedIcon", void 0);
  35219. __decorate$1C([
  35220. RefSelector('eGroupClosedIcon')
  35221. ], AgGroupComponent.prototype, "eGroupClosedIcon", void 0);
  35222. __decorate$1C([
  35223. RefSelector('eToolbar')
  35224. ], AgGroupComponent.prototype, "eToolbar", void 0);
  35225. __decorate$1C([
  35226. RefSelector('cbGroupEnabled')
  35227. ], AgGroupComponent.prototype, "cbGroupEnabled", void 0);
  35228. __decorate$1C([
  35229. RefSelector('eTitle')
  35230. ], AgGroupComponent.prototype, "eTitle", void 0);
  35231. __decorate$1C([
  35232. RefSelector('eContainer')
  35233. ], AgGroupComponent.prototype, "eContainer", void 0);
  35234. __decorate$1C([
  35235. PostConstruct
  35236. ], AgGroupComponent.prototype, "postConstruct", null);
  35237. return AgGroupComponent;
  35238. }(Component));
  35239. /**
  35240. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  35241. * @version v23.2.1
  35242. * @link http://www.ag-grid.com/
  35243. * @license MIT
  35244. */
  35245. var __extends$1D = (undefined && undefined.__extends) || (function () {
  35246. var extendStatics = function (d, b) {
  35247. extendStatics = Object.setPrototypeOf ||
  35248. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  35249. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  35250. return extendStatics(d, b);
  35251. };
  35252. return function (d, b) {
  35253. extendStatics(d, b);
  35254. function __() { this.constructor = d; }
  35255. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  35256. };
  35257. })();
  35258. var __decorate$1D = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  35259. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  35260. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  35261. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  35262. return c > 3 && r && Object.defineProperty(target, key, r), r;
  35263. };
  35264. var AgPanel = /** @class */ (function (_super) {
  35265. __extends$1D(AgPanel, _super);
  35266. function AgPanel(config) {
  35267. var _this = _super.call(this, AgPanel.getTemplate(config)) || this;
  35268. _this.closable = true;
  35269. _this.positioned = false;
  35270. _this.dragStartPosition = {
  35271. x: 0,
  35272. y: 0
  35273. };
  35274. _this.position = {
  35275. x: 0,
  35276. y: 0
  35277. };
  35278. _this.size = {
  35279. width: undefined,
  35280. height: undefined
  35281. };
  35282. _this.config = config;
  35283. return _this;
  35284. }
  35285. AgPanel.getTemplate = function (config) {
  35286. var cssIdentifier = (config && config.cssIdentifier) || 'default';
  35287. return /* html */ "<div class=\"ag-panel ag-" + cssIdentifier + "-panel\" tabindex=\"-1\">\n <div ref=\"eTitleBar\" class=\"ag-panel-title-bar ag-" + cssIdentifier + "-panel-title-bar ag-unselectable\">\n <span ref=\"eTitle\" class=\"ag-panel-title-bar-title ag-" + cssIdentifier + "-panel-title-bar-title\"></span>\n <div ref=\"eTitleBarButtons\" class=\"ag-panel-title-bar-buttons ag-" + cssIdentifier + "-panel-title-bar-buttons\"></div>\n </div>\n <div ref=\"eContentWrapper\" class=\"ag-panel-content-wrapper ag-" + cssIdentifier + "-panel-content-wrapper\"></div>\n </div>";
  35288. };
  35289. AgPanel.prototype.postConstruct = function () {
  35290. var _this = this;
  35291. var _a = this.config, component = _a.component, closable = _a.closable, hideTitleBar = _a.hideTitleBar, title = _a.title, minWidth = _a.minWidth, width = _a.width, minHeight = _a.minHeight, height = _a.height, centered = _a.centered, x = _a.x, y = _a.y;
  35292. var eGui = this.getGui();
  35293. if (component) {
  35294. this.setBodyComponent(component);
  35295. }
  35296. if (!hideTitleBar) {
  35297. if (title) {
  35298. this.setTitle(title);
  35299. }
  35300. this.setClosable(closable != null ? closable : this.closable);
  35301. }
  35302. else {
  35303. _.addCssClass(this.eTitleBar, 'ag-hidden');
  35304. }
  35305. this.addManagedListener(this.eTitleBar, 'mousedown', function (e) {
  35306. if (eGui.contains(e.relatedTarget) ||
  35307. eGui.contains(document.activeElement) ||
  35308. _this.eTitleBarButtons.contains(e.target)) {
  35309. e.preventDefault();
  35310. return;
  35311. }
  35312. var focusEl = _this.eContentWrapper.querySelector('button, [href], input, select, textarea, [tabindex]');
  35313. if (focusEl) {
  35314. focusEl.focus();
  35315. }
  35316. });
  35317. if (this.positioned) {
  35318. return;
  35319. }
  35320. this.minHeight = minHeight != null ? minHeight : 250;
  35321. this.minWidth = minWidth != null ? minWidth : 250;
  35322. this.popupParent = this.popupService.getPopupParent();
  35323. if (width) {
  35324. this.setWidth(width);
  35325. }
  35326. if (height) {
  35327. this.setHeight(height);
  35328. }
  35329. if (this.renderComponent) {
  35330. this.renderComponent();
  35331. }
  35332. if (!width || !height) {
  35333. this.refreshSize();
  35334. }
  35335. if (centered) {
  35336. this.center();
  35337. }
  35338. else if (x || y) {
  35339. this.offsetElement(x, y);
  35340. }
  35341. this.positioned = true;
  35342. this.eContentWrapper.style.height = '0';
  35343. };
  35344. AgPanel.prototype.renderComponent = function () {
  35345. var _this = this;
  35346. var eGui = this.getGui();
  35347. eGui.focus();
  35348. this.close = function () {
  35349. eGui.parentElement.removeChild(eGui);
  35350. _this.destroy();
  35351. };
  35352. };
  35353. AgPanel.prototype.updateDragStartPosition = function (x, y) {
  35354. this.dragStartPosition = { x: x, y: y };
  35355. };
  35356. AgPanel.prototype.calculateMouseMovement = function (params) {
  35357. var parentRect = this.popupParent.getBoundingClientRect();
  35358. var e = params.e, isLeft = params.isLeft, isTop = params.isTop, anywhereWithin = params.anywhereWithin, topBuffer = params.topBuffer;
  35359. var movementX = e.clientX - this.dragStartPosition.x;
  35360. var movementY = e.clientY - this.dragStartPosition.y;
  35361. var width = this.getWidth();
  35362. var height = this.getHeight();
  35363. // skip if cursor is outside of popupParent horizontally
  35364. var skipX = (parentRect.left >= e.clientX && this.position.x <= 0 ||
  35365. parentRect.right <= e.clientX && parentRect.right <= this.position.x + parentRect.left + width);
  35366. if (!skipX) {
  35367. if (isLeft) {
  35368. skipX = (
  35369. // skip if we are moving to the left and the cursor
  35370. // is positioned to the right of the left side anchor
  35371. (movementX < 0 && e.clientX > this.position.x + parentRect.left) ||
  35372. // skip if we are moving to the right and the cursor
  35373. // is positioned to the left of the dialog
  35374. (movementX > 0 && e.clientX < this.position.x + parentRect.left));
  35375. }
  35376. else {
  35377. if (anywhereWithin) {
  35378. // if anywhereWithin is true, we allow to move
  35379. // as long as the cursor is within the dialog
  35380. skipX = ((movementX < 0 && e.clientX > this.position.x + parentRect.left + width) ||
  35381. (movementX > 0 && e.clientX < this.position.x + parentRect.left));
  35382. }
  35383. else {
  35384. skipX = (
  35385. // if the movement is bound to the right side of the dialog
  35386. // we skip if we are moving to the left and the cursor
  35387. // is to the right of the dialog
  35388. (movementX < 0 && e.clientX > this.position.x + parentRect.left + width) ||
  35389. // or skip if we are moving to the right and the cursor
  35390. // is to the left of the right side anchor
  35391. (movementX > 0 && e.clientX < this.position.x + parentRect.left + width));
  35392. }
  35393. }
  35394. }
  35395. movementX = skipX ? 0 : movementX;
  35396. var skipY = (
  35397. // skip if cursor is outside of popupParent vertically
  35398. parentRect.top >= e.clientY && this.position.y <= 0 ||
  35399. parentRect.bottom <= e.clientY && parentRect.bottom <= this.position.y + parentRect.top + height ||
  35400. isTop && (
  35401. // skip if we are moving to towards top and the cursor is
  35402. // below the top anchor + topBuffer
  35403. // note: topBuffer is used when moving the dialog using the title bar
  35404. (movementY < 0 && e.clientY > this.position.y + parentRect.top + (topBuffer || 0)) ||
  35405. // skip if we are moving to the bottom and the cursor is
  35406. // above the top anchor
  35407. (movementY > 0 && e.clientY < this.position.y + parentRect.top)) ||
  35408. // we are anchored to the bottom of the dialog
  35409. !isTop && (
  35410. // skip if we are moving towards the top and the cursor
  35411. // is below the bottom anchor
  35412. (movementY < 0 && e.clientY > this.position.y + parentRect.top + height) ||
  35413. // skip if we are moving towards the bottom and the cursor
  35414. // is above the bottom anchor
  35415. (movementY > 0 && e.clientY < this.position.y + parentRect.top + height)));
  35416. movementY = skipY ? 0 : movementY;
  35417. return { movementX: movementX, movementY: movementY };
  35418. };
  35419. AgPanel.prototype.refreshSize = function () {
  35420. var _a = this.size, width = _a.width, height = _a.height;
  35421. if (!width) {
  35422. this.setWidth(this.getGui().offsetWidth);
  35423. }
  35424. if (!height) {
  35425. this.setHeight(this.getGui().offsetHeight);
  35426. }
  35427. };
  35428. AgPanel.prototype.offsetElement = function (x, y) {
  35429. if (x === void 0) { x = 0; }
  35430. if (y === void 0) { y = 0; }
  35431. var ePopup = this.getGui();
  35432. this.popupService.positionPopup({
  35433. ePopup: ePopup,
  35434. x: x,
  35435. y: y,
  35436. minWidth: this.minWidth,
  35437. minHeight: this.minHeight,
  35438. keepWithinBounds: true
  35439. });
  35440. this.position.x = parseInt(ePopup.style.left, 10);
  35441. this.position.y = parseInt(ePopup.style.top, 10);
  35442. };
  35443. AgPanel.prototype.getHeight = function () {
  35444. return this.size.height;
  35445. };
  35446. AgPanel.prototype.setHeight = function (height) {
  35447. var eGui = this.getGui();
  35448. var isPercent = false;
  35449. if (typeof height === 'string' && height.indexOf('%') !== -1) {
  35450. _.setFixedHeight(eGui, height);
  35451. height = _.getAbsoluteHeight(eGui);
  35452. isPercent = true;
  35453. }
  35454. else {
  35455. height = Math.max(this.minHeight, height);
  35456. var offsetParent = eGui.offsetParent;
  35457. if (offsetParent && offsetParent.clientHeight && (height + this.position.y > offsetParent.clientHeight)) {
  35458. height = offsetParent.clientHeight - this.position.y;
  35459. }
  35460. }
  35461. if (this.size.height === height) {
  35462. return;
  35463. }
  35464. this.size.height = height;
  35465. if (!isPercent) {
  35466. _.setFixedHeight(eGui, height);
  35467. }
  35468. else {
  35469. eGui.style.maxHeight = 'unset';
  35470. eGui.style.minHeight = 'unset';
  35471. }
  35472. };
  35473. AgPanel.prototype.getWidth = function () {
  35474. return this.size.width;
  35475. };
  35476. AgPanel.prototype.setWidth = function (width) {
  35477. var eGui = this.getGui();
  35478. var isPercent = false;
  35479. if (typeof width === 'string' && width.indexOf('%') !== -1) {
  35480. _.setFixedWidth(eGui, width);
  35481. width = _.getAbsoluteWidth(eGui);
  35482. isPercent = true;
  35483. }
  35484. else {
  35485. width = Math.max(this.minWidth, width);
  35486. var offsetParent = eGui.offsetParent;
  35487. if (offsetParent && offsetParent.clientWidth && (width + this.position.x > offsetParent.clientWidth)) {
  35488. width = offsetParent.clientWidth - this.position.x;
  35489. }
  35490. }
  35491. if (this.size.width === width) {
  35492. return;
  35493. }
  35494. this.size.width = width;
  35495. if (!isPercent) {
  35496. _.setFixedWidth(eGui, width);
  35497. }
  35498. else {
  35499. eGui.style.maxWidth = 'unset';
  35500. eGui.style.minWidth = 'unset';
  35501. }
  35502. };
  35503. AgPanel.prototype.center = function () {
  35504. var eGui = this.getGui();
  35505. var x = (eGui.offsetParent.clientWidth / 2) - (this.getWidth() / 2);
  35506. var y = (eGui.offsetParent.clientHeight / 2) - (this.getHeight() / 2);
  35507. this.offsetElement(x, y);
  35508. };
  35509. AgPanel.prototype.setClosable = function (closable) {
  35510. if (closable !== this.closable) {
  35511. this.closable = closable;
  35512. }
  35513. if (closable) {
  35514. var closeButtonComp = this.closeButtonComp = new Component(AgPanel.CLOSE_BTN_TEMPLATE);
  35515. this.getContext().createBean(closeButtonComp);
  35516. var eGui = closeButtonComp.getGui();
  35517. eGui.appendChild(_.addCssClass(_.createIconNoSpan('close', this.gridOptionsWrapper), 'ag-panel-title-bar-button-icon'));
  35518. this.addTitleBarButton(closeButtonComp);
  35519. closeButtonComp.addManagedListener(eGui, 'click', this.onBtClose.bind(this));
  35520. }
  35521. else if (this.closeButtonComp) {
  35522. var eGui = this.closeButtonComp.getGui();
  35523. eGui.parentElement.removeChild(eGui);
  35524. this.closeButtonComp = this.destroyBean(this.closeButtonComp);
  35525. }
  35526. };
  35527. AgPanel.prototype.setBodyComponent = function (bodyComponent) {
  35528. bodyComponent.setParentComponent(this);
  35529. this.eContentWrapper.appendChild(bodyComponent.getGui());
  35530. };
  35531. AgPanel.prototype.addTitleBarButton = function (button, position) {
  35532. var eTitleBarButtons = this.eTitleBarButtons;
  35533. var buttons = eTitleBarButtons.children;
  35534. var len = buttons.length;
  35535. if (position == null) {
  35536. position = len;
  35537. }
  35538. position = Math.max(0, Math.min(position, len));
  35539. var eGui = button.getGui();
  35540. _.addCssClass(eGui, 'ag-panel-title-bar-button');
  35541. if (position === 0) {
  35542. eTitleBarButtons.insertAdjacentElement('afterbegin', eGui);
  35543. }
  35544. else if (position === len) {
  35545. eTitleBarButtons.insertAdjacentElement('beforeend', eGui);
  35546. }
  35547. else {
  35548. buttons[position - 1].insertAdjacentElement('afterend', eGui);
  35549. }
  35550. button.setParentComponent(this);
  35551. };
  35552. AgPanel.prototype.getBodyHeight = function () {
  35553. return _.getInnerHeight(this.eContentWrapper);
  35554. };
  35555. AgPanel.prototype.getBodyWidth = function () {
  35556. return _.getInnerWidth(this.eContentWrapper);
  35557. };
  35558. AgPanel.prototype.setTitle = function (title) {
  35559. this.eTitle.innerText = title;
  35560. };
  35561. // called when user hits the 'x' in the top right
  35562. AgPanel.prototype.onBtClose = function () {
  35563. this.close();
  35564. };
  35565. AgPanel.prototype.destroy = function () {
  35566. if (this.closeButtonComp) {
  35567. this.closeButtonComp = this.destroyBean(this.closeButtonComp);
  35568. }
  35569. var eGui = this.getGui();
  35570. if (eGui && eGui.offsetParent) {
  35571. this.close();
  35572. }
  35573. _super.prototype.destroy.call(this);
  35574. };
  35575. AgPanel.CLOSE_BTN_TEMPLATE = "<div class=\"ag-button\"></div>";
  35576. __decorate$1D([
  35577. Autowired('popupService')
  35578. ], AgPanel.prototype, "popupService", void 0);
  35579. __decorate$1D([
  35580. Autowired('gridOptionsWrapper')
  35581. ], AgPanel.prototype, "gridOptionsWrapper", void 0);
  35582. __decorate$1D([
  35583. RefSelector('eContentWrapper')
  35584. ], AgPanel.prototype, "eContentWrapper", void 0);
  35585. __decorate$1D([
  35586. RefSelector('eTitleBar')
  35587. ], AgPanel.prototype, "eTitleBar", void 0);
  35588. __decorate$1D([
  35589. RefSelector('eTitleBarButtons')
  35590. ], AgPanel.prototype, "eTitleBarButtons", void 0);
  35591. __decorate$1D([
  35592. RefSelector('eTitle')
  35593. ], AgPanel.prototype, "eTitle", void 0);
  35594. __decorate$1D([
  35595. PostConstruct
  35596. ], AgPanel.prototype, "postConstruct", null);
  35597. return AgPanel;
  35598. }(Component));
  35599. /**
  35600. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  35601. * @version v23.2.1
  35602. * @link http://www.ag-grid.com/
  35603. * @license MIT
  35604. */
  35605. var __extends$1E = (undefined && undefined.__extends) || (function () {
  35606. var extendStatics = function (d, b) {
  35607. extendStatics = Object.setPrototypeOf ||
  35608. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  35609. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  35610. return extendStatics(d, b);
  35611. };
  35612. return function (d, b) {
  35613. extendStatics(d, b);
  35614. function __() { this.constructor = d; }
  35615. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  35616. };
  35617. })();
  35618. var __decorate$1E = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  35619. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  35620. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  35621. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  35622. return c > 3 && r && Object.defineProperty(target, key, r), r;
  35623. };
  35624. var AgDialog = /** @class */ (function (_super) {
  35625. __extends$1E(AgDialog, _super);
  35626. function AgDialog(config) {
  35627. var _this = _super.call(this, config) || this;
  35628. _this.RESIZE_TEMPLATE = "<div class=\"ag-resizer-wrapper\">\n <div ref=\"eTopLeftResizer\" class=\"ag-resizer ag-resizer-topLeft\"></div>\n <div ref=\"eTopResizer\" class=\"ag-resizer ag-resizer-top\"></div>\n <div ref=\"eTopRightResizer\" class=\"ag-resizer ag-resizer-topRight\"></div>\n <div ref=\"eRightResizer\" class=\"ag-resizer ag-resizer-right\"></div>\n <div ref=\"eBottomRightResizer\" class=\"ag-resizer ag-resizer-bottomRight\"></div>\n <div ref=\"eBottomResizer\" class=\"ag-resizer ag-resizer-bottom\"></div>\n <div ref=\"eBottomLeftResizer\" class=\"ag-resizer ag-resizer-bottomLeft\"></div>\n <div ref=\"eLeftResizer\" class=\"ag-resizer ag-resizer-left\"></div>\n </div>";
  35629. _this.MAXIMIZE_BTN_TEMPLATE = "<div class=\"ag-dialog-button\"></span>";
  35630. _this.resizable = {};
  35631. _this.movable = false;
  35632. _this.isMoving = false;
  35633. _this.isMaximizable = false;
  35634. _this.isMaximized = false;
  35635. _this.maximizeListeners = [];
  35636. _this.resizeListenerDestroy = null;
  35637. _this.isResizing = false;
  35638. _this.lastPosition = {
  35639. x: 0,
  35640. y: 0,
  35641. width: 0,
  35642. height: 0
  35643. };
  35644. return _this;
  35645. }
  35646. AgDialog.prototype.postConstruct = function () {
  35647. var _this = this;
  35648. var eGui = this.getGui();
  35649. var _a = this.config, movable = _a.movable, resizable = _a.resizable, maximizable = _a.maximizable;
  35650. _.addCssClass(eGui, 'ag-dialog');
  35651. this.moveElement = this.eTitleBar;
  35652. _super.prototype.postConstruct.call(this);
  35653. this.addManagedListener(eGui, 'focusin', function (e) {
  35654. if (eGui.contains(e.relatedTarget)) {
  35655. return;
  35656. }
  35657. _this.popupService.bringPopupToFront(eGui);
  35658. });
  35659. if (movable) {
  35660. this.setMovable(movable);
  35661. }
  35662. if (maximizable) {
  35663. this.setMaximizable(maximizable);
  35664. }
  35665. this.addResizers();
  35666. if (resizable) {
  35667. this.setResizable(resizable);
  35668. }
  35669. };
  35670. AgDialog.prototype.renderComponent = function () {
  35671. var eGui = this.getGui();
  35672. var _a = this.config, alwaysOnTop = _a.alwaysOnTop, modal = _a.modal;
  35673. this.close = this.popupService.addPopup(modal, eGui, true, this.destroy.bind(this), undefined, alwaysOnTop);
  35674. eGui.focus();
  35675. };
  35676. AgDialog.prototype.addResizers = function () {
  35677. var eGui = this.getGui();
  35678. if (!eGui) {
  35679. return;
  35680. }
  35681. var parser = new DOMParser();
  35682. var resizers = parser.parseFromString(this.RESIZE_TEMPLATE, 'text/html').body;
  35683. eGui.appendChild(resizers.firstChild);
  35684. this.createMap();
  35685. };
  35686. AgDialog.prototype.createMap = function () {
  35687. var eGui = this.getGui();
  35688. this.resizerMap = {
  35689. topLeft: { element: eGui.querySelector('[ref=eTopLeftResizer]') },
  35690. top: { element: eGui.querySelector('[ref=eTopResizer]') },
  35691. topRight: { element: eGui.querySelector('[ref=eTopRightResizer]') },
  35692. right: { element: eGui.querySelector('[ref=eRightResizer]') },
  35693. bottomRight: { element: eGui.querySelector('[ref=eBottomRightResizer]') },
  35694. bottom: { element: eGui.querySelector('[ref=eBottomResizer]') },
  35695. bottomLeft: { element: eGui.querySelector('[ref=eBottomLeftResizer]') },
  35696. left: { element: eGui.querySelector('[ref=eLeftResizer]') }
  35697. };
  35698. };
  35699. AgDialog.prototype.getResizerElement = function (side) {
  35700. return this.resizerMap[side].element;
  35701. };
  35702. AgDialog.prototype.onResizeStart = function (e) {
  35703. this.isResizing = true;
  35704. this.updateDragStartPosition(e.clientX, e.clientY);
  35705. };
  35706. AgDialog.prototype.onResize = function (e, side) {
  35707. if (!this.isResizing) {
  35708. return;
  35709. }
  35710. var isLeft = !!side.match(/left/i);
  35711. var isRight = !!side.match(/right/i);
  35712. var isTop = !!side.match(/top/i);
  35713. var isBottom = !!side.match(/bottom/i);
  35714. var isHorizontal = isLeft || isRight;
  35715. var isVertical = isTop || isBottom;
  35716. var _a = this.calculateMouseMovement({ e: e, isLeft: isLeft, isTop: isTop }), movementX = _a.movementX, movementY = _a.movementY;
  35717. var offsetLeft = 0;
  35718. var offsetTop = 0;
  35719. if (isHorizontal && movementX) {
  35720. var direction = isLeft ? -1 : 1;
  35721. var oldWidth = this.getWidth();
  35722. var newWidth = oldWidth + (movementX * direction);
  35723. var skipWidth = false;
  35724. if (isLeft) {
  35725. offsetLeft = oldWidth - newWidth;
  35726. if (this.position.x + offsetLeft <= 0 || newWidth <= this.minWidth) {
  35727. skipWidth = true;
  35728. offsetLeft = 0;
  35729. }
  35730. }
  35731. if (!skipWidth) {
  35732. this.setWidth(newWidth);
  35733. }
  35734. }
  35735. if (isVertical && movementY) {
  35736. var direction = isTop ? -1 : 1;
  35737. var oldHeight = this.getHeight();
  35738. var newHeight = oldHeight + (movementY * direction);
  35739. var skipHeight = false;
  35740. if (isTop) {
  35741. offsetTop = oldHeight - newHeight;
  35742. if (this.position.y + offsetTop <= 0 || newHeight <= this.minHeight) {
  35743. skipHeight = true;
  35744. offsetTop = 0;
  35745. }
  35746. }
  35747. if (!skipHeight) {
  35748. this.setHeight(newHeight);
  35749. }
  35750. }
  35751. this.updateDragStartPosition(e.clientX, e.clientY);
  35752. if (offsetLeft || offsetTop) {
  35753. this.offsetElement(this.position.x + offsetLeft, this.position.y + offsetTop);
  35754. }
  35755. };
  35756. AgDialog.prototype.onResizeEnd = function () {
  35757. this.isResizing = false;
  35758. var params = {
  35759. type: 'resize',
  35760. api: this.gridOptionsWrapper.getApi(),
  35761. columnApi: this.gridOptionsWrapper.getColumnApi()
  35762. };
  35763. this.dispatchEvent(params);
  35764. };
  35765. AgDialog.prototype.onMoveStart = function (e) {
  35766. this.isMoving = true;
  35767. this.updateDragStartPosition(e.clientX, e.clientY);
  35768. };
  35769. AgDialog.prototype.onMove = function (e) {
  35770. if (!this.isMoving) {
  35771. return;
  35772. }
  35773. var _a = this.position, x = _a.x, y = _a.y;
  35774. var _b = this.calculateMouseMovement({
  35775. e: e,
  35776. isTop: true,
  35777. anywhereWithin: true,
  35778. topBuffer: this.getHeight() - this.getBodyHeight()
  35779. }), movementX = _b.movementX, movementY = _b.movementY;
  35780. this.offsetElement(x + movementX, y + movementY);
  35781. this.updateDragStartPosition(e.clientX, e.clientY);
  35782. };
  35783. AgDialog.prototype.onMoveEnd = function () {
  35784. this.isMoving = false;
  35785. };
  35786. AgDialog.prototype.toggleMaximize = function () {
  35787. if (this.isMaximized) {
  35788. var _a = this.lastPosition, x = _a.x, y = _a.y, width = _a.width, height = _a.height;
  35789. this.setWidth(width);
  35790. this.setHeight(height);
  35791. this.offsetElement(x, y);
  35792. }
  35793. else {
  35794. this.lastPosition.width = this.getWidth();
  35795. this.lastPosition.height = this.getHeight();
  35796. this.lastPosition.x = this.position.x;
  35797. this.lastPosition.y = this.position.y;
  35798. this.offsetElement(0, 0);
  35799. this.setHeight('100%');
  35800. this.setWidth('100%');
  35801. }
  35802. this.isMaximized = !this.isMaximized;
  35803. this.refreshMaximizeIcon();
  35804. };
  35805. AgDialog.prototype.refreshMaximizeIcon = function () {
  35806. _.addOrRemoveCssClass(this.maximizeIcon, 'ag-hidden', this.isMaximized);
  35807. _.addOrRemoveCssClass(this.minimizeIcon, 'ag-hidden', !this.isMaximized);
  35808. };
  35809. AgDialog.prototype.clearMaximizebleListeners = function () {
  35810. if (this.maximizeListeners.length) {
  35811. this.maximizeListeners.forEach(function (destroyListener) { return destroyListener(); });
  35812. this.maximizeListeners.length = 0;
  35813. }
  35814. if (this.resizeListenerDestroy) {
  35815. this.resizeListenerDestroy();
  35816. this.resizeListenerDestroy = null;
  35817. }
  35818. };
  35819. AgDialog.prototype.destroy = function () {
  35820. this.setResizable(false);
  35821. this.setMovable(false);
  35822. this.maximizeButtonComp = this.destroyBean(this.maximizeButtonComp);
  35823. this.clearMaximizebleListeners();
  35824. _super.prototype.destroy.call(this);
  35825. };
  35826. AgDialog.prototype.setResizable = function (resizable) {
  35827. var _this = this;
  35828. if (typeof resizable === 'boolean') {
  35829. resizable = {
  35830. topLeft: resizable,
  35831. top: resizable,
  35832. topRight: resizable,
  35833. right: resizable,
  35834. bottomRight: resizable,
  35835. bottom: resizable,
  35836. bottomLeft: resizable,
  35837. left: resizable
  35838. };
  35839. }
  35840. Object.keys(resizable).forEach(function (side) {
  35841. var r = resizable;
  35842. var s = side;
  35843. var val = !!r[s];
  35844. var el = _this.getResizerElement(s);
  35845. var params = _this.resizerMap[s].dragSource || {
  35846. eElement: el,
  35847. onDragStart: _this.onResizeStart.bind(_this),
  35848. onDragging: function (e) { return _this.onResize(e, s); },
  35849. onDragStop: _this.onResizeEnd.bind(_this),
  35850. };
  35851. if (!!_this.resizable[s] !== val || (!_this.isAlive() && !val)) {
  35852. if (val) {
  35853. _this.dragService.addDragSource(params);
  35854. el.style.pointerEvents = 'all';
  35855. }
  35856. else {
  35857. _this.dragService.removeDragSource(params);
  35858. el.style.pointerEvents = 'none';
  35859. }
  35860. _this.resizerMap[s].dragSource = val ? params : undefined;
  35861. }
  35862. });
  35863. };
  35864. AgDialog.prototype.setMovable = function (movable) {
  35865. if (movable === this.movable) {
  35866. return;
  35867. }
  35868. this.movable = movable;
  35869. var params = this.moveElementDragListener || {
  35870. eElement: this.moveElement,
  35871. onDragStart: this.onMoveStart.bind(this),
  35872. onDragging: this.onMove.bind(this),
  35873. onDragStop: this.onMoveEnd.bind(this)
  35874. };
  35875. if (movable) {
  35876. this.dragService.addDragSource(params);
  35877. this.moveElementDragListener = params;
  35878. }
  35879. else {
  35880. this.dragService.removeDragSource(params);
  35881. this.moveElementDragListener = undefined;
  35882. }
  35883. };
  35884. AgDialog.prototype.setMaximizable = function (maximizable) {
  35885. var _this = this;
  35886. if (maximizable === false) {
  35887. this.clearMaximizebleListeners();
  35888. if (this.maximizeButtonComp) {
  35889. this.destroyBean(this.maximizeButtonComp);
  35890. this.maximizeButtonComp = this.maximizeIcon = this.minimizeIcon = undefined;
  35891. }
  35892. return;
  35893. }
  35894. var eTitleBar = this.eTitleBar;
  35895. if (!eTitleBar || maximizable === this.isMaximizable) {
  35896. return;
  35897. }
  35898. var maximizeButtonComp = this.maximizeButtonComp = new Component(this.MAXIMIZE_BTN_TEMPLATE);
  35899. this.getContext().createBean(maximizeButtonComp);
  35900. var eGui = maximizeButtonComp.getGui();
  35901. eGui.appendChild(this.maximizeIcon = _.createIconNoSpan('maximize', this.gridOptionsWrapper));
  35902. _.addCssClass(this.maximizeIcon, 'ag-panel-title-bar-button-icon');
  35903. eGui.appendChild(this.minimizeIcon = _.createIconNoSpan('minimize', this.gridOptionsWrapper));
  35904. _.addCssClass(this.minimizeIcon, 'ag-panel-title-bar-button-icon');
  35905. _.addCssClass(this.minimizeIcon, 'ag-hidden');
  35906. maximizeButtonComp.addManagedListener(eGui, 'click', this.toggleMaximize.bind(this));
  35907. this.addTitleBarButton(maximizeButtonComp, 0);
  35908. this.maximizeListeners.push(this.addManagedListener(eTitleBar, 'dblclick', this.toggleMaximize.bind(this)));
  35909. this.resizeListenerDestroy = this.addManagedListener(this, 'resize', function () {
  35910. _this.isMaximized = false;
  35911. _this.refreshMaximizeIcon();
  35912. });
  35913. };
  35914. __decorate$1E([
  35915. Autowired('dragService')
  35916. ], AgDialog.prototype, "dragService", void 0);
  35917. return AgDialog;
  35918. }(AgPanel));
  35919. /**
  35920. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  35921. * @version v23.2.1
  35922. * @link http://www.ag-grid.com/
  35923. * @license MIT
  35924. */
  35925. var __extends$1F = (undefined && undefined.__extends) || (function () {
  35926. var extendStatics = function (d, b) {
  35927. extendStatics = Object.setPrototypeOf ||
  35928. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  35929. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  35930. return extendStatics(d, b);
  35931. };
  35932. return function (d, b) {
  35933. extendStatics(d, b);
  35934. function __() { this.constructor = d; }
  35935. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  35936. };
  35937. })();
  35938. var AgInputTextField = /** @class */ (function (_super) {
  35939. __extends$1F(AgInputTextField, _super);
  35940. function AgInputTextField(config) {
  35941. var _this = _super.call(this) || this;
  35942. _this.className = 'ag-text-field';
  35943. _this.displayTag = 'input';
  35944. _this.inputType = 'text';
  35945. _this.setTemplate(_this.TEMPLATE.replace(/%displayField%/g, _this.displayTag));
  35946. if (config) {
  35947. _this.config = config;
  35948. }
  35949. return _this;
  35950. }
  35951. AgInputTextField.prototype.setValue = function (value, silent) {
  35952. var ret = _super.prototype.setValue.call(this, value, silent);
  35953. if (this.eInput.value !== value) {
  35954. this.eInput.value = _.exists(value) ? value : '';
  35955. }
  35956. return ret;
  35957. };
  35958. return AgInputTextField;
  35959. }(AgAbstractInputField));
  35960. /**
  35961. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  35962. * @version v23.2.1
  35963. * @link http://www.ag-grid.com/
  35964. * @license MIT
  35965. */
  35966. var __extends$1G = (undefined && undefined.__extends) || (function () {
  35967. var extendStatics = function (d, b) {
  35968. extendStatics = Object.setPrototypeOf ||
  35969. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  35970. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  35971. return extendStatics(d, b);
  35972. };
  35973. return function (d, b) {
  35974. extendStatics(d, b);
  35975. function __() { this.constructor = d; }
  35976. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  35977. };
  35978. })();
  35979. var AgInputTextArea = /** @class */ (function (_super) {
  35980. __extends$1G(AgInputTextArea, _super);
  35981. function AgInputTextArea(config) {
  35982. var _this = _super.call(this) || this;
  35983. _this.className = 'ag-text-area';
  35984. _this.displayTag = 'textarea';
  35985. _this.inputType = '';
  35986. _this.setTemplate(_this.TEMPLATE.replace(/%displayField%/g, _this.displayTag));
  35987. if (config) {
  35988. _this.config = config;
  35989. }
  35990. return _this;
  35991. }
  35992. AgInputTextArea.prototype.setValue = function (value, silent) {
  35993. var ret = _super.prototype.setValue.call(this, value, silent);
  35994. this.eInput.value = value;
  35995. return ret;
  35996. };
  35997. AgInputTextArea.prototype.setCols = function (cols) {
  35998. this.eInput.cols = cols;
  35999. return this;
  36000. };
  36001. AgInputTextArea.prototype.setRows = function (rows) {
  36002. this.eInput.rows = rows;
  36003. return this;
  36004. };
  36005. return AgInputTextArea;
  36006. }(AgAbstractInputField));
  36007. /**
  36008. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  36009. * @version v23.2.1
  36010. * @link http://www.ag-grid.com/
  36011. * @license MIT
  36012. */
  36013. var __extends$1H = (undefined && undefined.__extends) || (function () {
  36014. var extendStatics = function (d, b) {
  36015. extendStatics = Object.setPrototypeOf ||
  36016. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  36017. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  36018. return extendStatics(d, b);
  36019. };
  36020. return function (d, b) {
  36021. extendStatics(d, b);
  36022. function __() { this.constructor = d; }
  36023. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  36024. };
  36025. })();
  36026. var __decorate$1F = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  36027. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  36028. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  36029. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  36030. return c > 3 && r && Object.defineProperty(target, key, r), r;
  36031. };
  36032. var AgSlider = /** @class */ (function (_super) {
  36033. __extends$1H(AgSlider, _super);
  36034. function AgSlider() {
  36035. var _this = _super.call(this, AgSlider.TEMPLATE) || this;
  36036. _this.labelAlignment = 'top';
  36037. return _this;
  36038. }
  36039. AgSlider.prototype.init = function () {
  36040. _.addCssClass(this.eSlider.getGui(), 'ag-slider-field');
  36041. };
  36042. AgSlider.prototype.onValueChange = function (callbackFn) {
  36043. var _this = this;
  36044. var eventChanged = AgAbstractField.EVENT_CHANGED;
  36045. this.addManagedListener(this.eText, eventChanged, function () {
  36046. var textValue = parseFloat(_this.eText.getValue());
  36047. _this.eSlider.setValue(textValue.toString(), true);
  36048. callbackFn(textValue || 0);
  36049. });
  36050. this.addManagedListener(this.eSlider, eventChanged, function () {
  36051. var sliderValue = _this.eSlider.getValue();
  36052. _this.eText.setValue(sliderValue, true);
  36053. callbackFn(parseFloat(sliderValue));
  36054. });
  36055. return this;
  36056. };
  36057. AgSlider.prototype.setSliderWidth = function (width) {
  36058. this.eSlider.setWidth(width);
  36059. return this;
  36060. };
  36061. AgSlider.prototype.setTextFieldWidth = function (width) {
  36062. this.eText.setWidth(width);
  36063. return this;
  36064. };
  36065. AgSlider.prototype.setMinValue = function (minValue) {
  36066. this.eSlider.setMinValue(minValue);
  36067. this.eText.setMin(minValue);
  36068. return this;
  36069. };
  36070. AgSlider.prototype.setMaxValue = function (maxValue) {
  36071. this.eSlider.setMaxValue(maxValue);
  36072. this.eText.setMax(maxValue);
  36073. return this;
  36074. };
  36075. AgSlider.prototype.getValue = function () {
  36076. return this.eText.getValue();
  36077. };
  36078. AgSlider.prototype.setValue = function (value) {
  36079. if (this.getValue() === value) {
  36080. return this;
  36081. }
  36082. this.eText.setValue(value, true);
  36083. this.eSlider.setValue(value, true);
  36084. this.dispatchEvent({ type: AgAbstractField.EVENT_CHANGED });
  36085. return this;
  36086. };
  36087. AgSlider.prototype.setStep = function (step) {
  36088. this.eSlider.setStep(step);
  36089. this.eText.setStep(step);
  36090. return this;
  36091. };
  36092. AgSlider.TEMPLATE = "<div class=\"ag-slider\">\n <label ref=\"eLabel\"></label>\n <div class=\"ag-wrapper ag-slider-wrapper\">\n <ag-input-range ref=\"eSlider\"></ag-input-range>\n <ag-input-number-field ref=\"eText\"></ag-input-number-field>\n </div>\n </div>";
  36093. __decorate$1F([
  36094. RefSelector('eLabel')
  36095. ], AgSlider.prototype, "eLabel", void 0);
  36096. __decorate$1F([
  36097. RefSelector('eSlider')
  36098. ], AgSlider.prototype, "eSlider", void 0);
  36099. __decorate$1F([
  36100. RefSelector('eText')
  36101. ], AgSlider.prototype, "eText", void 0);
  36102. __decorate$1F([
  36103. PostConstruct
  36104. ], AgSlider.prototype, "init", null);
  36105. return AgSlider;
  36106. }(AgAbstractLabel));
  36107. /**
  36108. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  36109. * @version v23.2.1
  36110. * @link http://www.ag-grid.com/
  36111. * @license MIT
  36112. */
  36113. var __extends$1I = (undefined && undefined.__extends) || (function () {
  36114. var extendStatics = function (d, b) {
  36115. extendStatics = Object.setPrototypeOf ||
  36116. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  36117. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  36118. return extendStatics(d, b);
  36119. };
  36120. return function (d, b) {
  36121. extendStatics(d, b);
  36122. function __() { this.constructor = d; }
  36123. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  36124. };
  36125. })();
  36126. var __decorate$1G = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  36127. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  36128. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  36129. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  36130. return c > 3 && r && Object.defineProperty(target, key, r), r;
  36131. };
  36132. var AgColorPanel = /** @class */ (function (_super) {
  36133. __extends$1I(AgColorPanel, _super);
  36134. function AgColorPanel(config) {
  36135. var _this = _super.call(this, AgColorPanel.TEMPLATE) || this;
  36136. _this.H = 1; // in the [0, 1] range
  36137. _this.S = 1; // in the [0, 1] range
  36138. _this.B = 1; // in the [0, 1] range
  36139. _this.A = 1; // in the [0, 1] range
  36140. _this.isSpectrumDragging = false;
  36141. _this.isSpectrumHueDragging = false;
  36142. _this.isSpectrumAlphaDragging = false;
  36143. _this.colorChanged = false;
  36144. _this.picker = config.picker;
  36145. return _this;
  36146. }
  36147. AgColorPanel.prototype.postConstruct = function () {
  36148. var eGui = this.getGui();
  36149. this.initRecentColors();
  36150. this.addManagedListener(this.spectrumVal, 'mousedown', this.onSpectrumDraggerDown.bind(this));
  36151. this.addManagedListener(eGui, 'mousemove', this.onSpectrumDraggerMove.bind(this));
  36152. this.addManagedListener(this.spectrumHue, 'mousedown', this.onSpectrumHueDown.bind(this));
  36153. this.addManagedListener(eGui, 'mousemove', this.onSpectrumHueMove.bind(this));
  36154. this.addManagedListener(this.spectrumAlpha, 'mousedown', this.onSpectrumAlphaDown.bind(this));
  36155. this.addManagedListener(eGui, 'mousemove', this.onSpectrumAlphaMove.bind(this));
  36156. // Listening to `mouseup` on the document on purpose. The user might release the mouse button
  36157. // outside the UI control. When the mouse returns back to the control's area, the dragging
  36158. // of the thumb is not expected and seen as a bug.
  36159. this.addManagedListener(document, 'mouseup', this.onMouseUp.bind(this));
  36160. this.addManagedListener(this.recentColors, 'click', this.onRecentColorClick.bind(this));
  36161. };
  36162. AgColorPanel.prototype.refreshSpectrumRect = function () {
  36163. return this.spectrumValRect = this.spectrumVal.getBoundingClientRect();
  36164. };
  36165. AgColorPanel.prototype.refreshHueRect = function () {
  36166. return this.spectrumHueRect = this.spectrumHue.getBoundingClientRect();
  36167. };
  36168. AgColorPanel.prototype.refreshAlphaRect = function () {
  36169. return this.spectrumAlphaRect = this.spectrumAlpha.getBoundingClientRect();
  36170. };
  36171. AgColorPanel.prototype.onSpectrumDraggerDown = function (e) {
  36172. this.refreshSpectrumRect();
  36173. this.isSpectrumDragging = true;
  36174. this.moveDragger(e);
  36175. };
  36176. AgColorPanel.prototype.onSpectrumDraggerMove = function (e) {
  36177. if (this.isSpectrumDragging) {
  36178. this.moveDragger(e);
  36179. }
  36180. };
  36181. AgColorPanel.prototype.onSpectrumHueDown = function (e) {
  36182. this.refreshHueRect();
  36183. this.isSpectrumHueDragging = true;
  36184. this.moveHueSlider(e);
  36185. };
  36186. AgColorPanel.prototype.onSpectrumHueMove = function (e) {
  36187. if (this.isSpectrumHueDragging) {
  36188. this.moveHueSlider(e);
  36189. }
  36190. };
  36191. AgColorPanel.prototype.onSpectrumAlphaDown = function (e) {
  36192. this.refreshAlphaRect();
  36193. this.isSpectrumAlphaDragging = true;
  36194. this.moveAlphaSlider(e);
  36195. };
  36196. AgColorPanel.prototype.onSpectrumAlphaMove = function (e) {
  36197. if (this.isSpectrumAlphaDragging) {
  36198. this.moveAlphaSlider(e);
  36199. }
  36200. };
  36201. AgColorPanel.prototype.onMouseUp = function () {
  36202. this.isSpectrumDragging = false;
  36203. this.isSpectrumHueDragging = false;
  36204. this.isSpectrumAlphaDragging = false;
  36205. };
  36206. AgColorPanel.prototype.moveDragger = function (e) {
  36207. var valRect = this.spectrumValRect;
  36208. if (valRect) {
  36209. var x = e.clientX - valRect.left;
  36210. var y = e.clientY - valRect.top;
  36211. x = Math.max(x, 0);
  36212. x = Math.min(x, valRect.width);
  36213. y = Math.max(y, 0);
  36214. y = Math.min(y, valRect.height);
  36215. this.setSpectrumValue(x / valRect.width, 1 - y / valRect.height);
  36216. }
  36217. };
  36218. AgColorPanel.prototype.moveHueSlider = function (e) {
  36219. var hueRect = this.spectrumHueRect;
  36220. if (hueRect) {
  36221. var slider = this.spectrumHueSlider;
  36222. var sliderRect = slider.getBoundingClientRect();
  36223. var x = e.clientX - hueRect.left;
  36224. x = Math.max(x, 0);
  36225. x = Math.min(x, hueRect.width);
  36226. this.H = 1 - x / hueRect.width;
  36227. slider.style.left = (x + sliderRect.width / 2) + 'px';
  36228. this.update();
  36229. }
  36230. };
  36231. AgColorPanel.prototype.moveAlphaSlider = function (e) {
  36232. var alphaRect = this.spectrumAlphaRect;
  36233. if (alphaRect) {
  36234. var slider = this.spectrumAlphaSlider;
  36235. var sliderRect = slider.getBoundingClientRect();
  36236. var x = e.clientX - alphaRect.left;
  36237. x = Math.max(x, 0);
  36238. x = Math.min(x, alphaRect.width);
  36239. this.A = x / alphaRect.width;
  36240. slider.style.left = (x + sliderRect.width / 2) + 'px';
  36241. this.update();
  36242. }
  36243. };
  36244. AgColorPanel.prototype.update = function () {
  36245. var color = Color.fromHSB(this.H * 360, this.S, this.B, this.A);
  36246. var spectrumColor = Color.fromHSB(this.H * 360, 1, 1);
  36247. var rgbaColor = color.toRgbaString();
  36248. // the recent color list needs to know color has actually changed
  36249. var colorPicker = this.picker;
  36250. var existingColor = Color.fromString(colorPicker.getValue());
  36251. if (existingColor.toRgbaString() !== rgbaColor) {
  36252. this.colorChanged = true;
  36253. }
  36254. colorPicker.setValue(rgbaColor);
  36255. this.spectrumColor.style.backgroundColor = spectrumColor.toRgbaString();
  36256. this.spectrumDragger.style.backgroundColor = rgbaColor;
  36257. };
  36258. /**
  36259. * @param saturation In the [0, 1] interval.
  36260. * @param brightness In the [0, 1] interval.
  36261. */
  36262. AgColorPanel.prototype.setSpectrumValue = function (saturation, brightness) {
  36263. var valRect = this.spectrumValRect || this.refreshSpectrumRect();
  36264. if (valRect) {
  36265. var dragger = this.spectrumDragger;
  36266. var draggerRect = dragger.getBoundingClientRect();
  36267. saturation = Math.max(0, saturation);
  36268. saturation = Math.min(1, saturation);
  36269. brightness = Math.max(0, brightness);
  36270. brightness = Math.min(1, brightness);
  36271. this.S = saturation;
  36272. this.B = brightness;
  36273. dragger.style.left = (saturation * valRect.width - draggerRect.width / 2) + 'px';
  36274. dragger.style.top = ((1 - brightness) * valRect.height - draggerRect.height / 2) + 'px';
  36275. this.update();
  36276. }
  36277. };
  36278. AgColorPanel.prototype.initRecentColors = function () {
  36279. var recentColors = AgColorPanel.recentColors;
  36280. var innerHtml = recentColors.map(function (color, index) {
  36281. return "<div class=\"ag-recent-color\" id=" + index + " style=\"background-color: " + color + "; width: 15px; height: 15px;\" recent-color=\"" + color + "\"></div>";
  36282. });
  36283. this.recentColors.innerHTML = innerHtml.join('');
  36284. };
  36285. AgColorPanel.prototype.setValue = function (val) {
  36286. var color = Color.fromString(val);
  36287. var _a = color.toHSB(), h = _a[0], s = _a[1], b = _a[2];
  36288. this.H = (isNaN(h) ? 0 : h) / 360;
  36289. this.A = color.a;
  36290. var spectrumHueRect = this.spectrumHueRect || this.refreshHueRect();
  36291. var spectrumAlphaRect = this.spectrumAlphaRect || this.refreshAlphaRect();
  36292. this.spectrumHueSlider.style.left = ((this.H - 1) * -spectrumHueRect.width) + "px";
  36293. this.spectrumAlphaSlider.style.left = (this.A * spectrumAlphaRect.width) + "px";
  36294. this.setSpectrumValue(s, b);
  36295. };
  36296. AgColorPanel.prototype.onRecentColorClick = function (e) {
  36297. var target = e.target;
  36298. if (!_.exists(target.id)) {
  36299. return;
  36300. }
  36301. var id = parseInt(target.id, 10);
  36302. this.setValue(AgColorPanel.recentColors[id]);
  36303. this.destroy();
  36304. };
  36305. AgColorPanel.prototype.addRecentColor = function () {
  36306. var color = Color.fromHSB(this.H * 360, this.S, this.B, this.A);
  36307. var rgbaColor = color.toRgbaString();
  36308. var recentColors = AgColorPanel.recentColors;
  36309. if (!this.colorChanged || recentColors[0] === rgbaColor) {
  36310. return;
  36311. }
  36312. // remove duplicate color
  36313. recentColors = recentColors.filter(function (color) { return color != rgbaColor; });
  36314. // add color to head
  36315. recentColors = [rgbaColor].concat(recentColors);
  36316. // ensure we don't exceed max number of recent colors
  36317. if (recentColors.length > AgColorPanel.maxRecentColors) {
  36318. recentColors = recentColors.slice(0, AgColorPanel.maxRecentColors);
  36319. }
  36320. AgColorPanel.recentColors = recentColors;
  36321. };
  36322. AgColorPanel.prototype.destroy = function () {
  36323. this.addRecentColor();
  36324. _super.prototype.destroy.call(this);
  36325. };
  36326. AgColorPanel.maxRecentColors = 8;
  36327. AgColorPanel.recentColors = [];
  36328. AgColorPanel.TEMPLATE = "<div class=\"ag-color-panel\">\n <div ref=\"spectrumColor\" class=\"ag-spectrum-color\">\n <div class=\"ag-spectrum-sat ag-spectrum-fill\">\n <div ref=\"spectrumVal\" class=\"ag-spectrum-val ag-spectrum-fill\">\n <div ref=\"spectrumDragger\" class=\"ag-spectrum-dragger\"></div>\n </div>\n </div>\n </div>\n <div class=\"ag-spectrum-tools\">\n <div ref=\"spectrumHue\" class=\"ag-spectrum-hue ag-spectrum-tool\">\n <div class=\"ag-spectrum-hue-background\"></div>\n <div ref=\"spectrumHueSlider\" class=\"ag-spectrum-slider\"></div>\n </div>\n <div ref=\"spectrumAlpha\" class=\"ag-spectrum-alpha ag-spectrum-tool\">\n <div class=\"ag-spectrum-alpha-background\"></div>\n <div ref=\"spectrumAlphaSlider\" class=\"ag-spectrum-slider\"></div>\n </div>\n <div ref=\"recentColors\" class=\"ag-recent-colors\"></div>\n </div>\n </div>";
  36329. __decorate$1G([
  36330. RefSelector('spectrumColor')
  36331. ], AgColorPanel.prototype, "spectrumColor", void 0);
  36332. __decorate$1G([
  36333. RefSelector('spectrumVal')
  36334. ], AgColorPanel.prototype, "spectrumVal", void 0);
  36335. __decorate$1G([
  36336. RefSelector('spectrumDragger')
  36337. ], AgColorPanel.prototype, "spectrumDragger", void 0);
  36338. __decorate$1G([
  36339. RefSelector('spectrumHue')
  36340. ], AgColorPanel.prototype, "spectrumHue", void 0);
  36341. __decorate$1G([
  36342. RefSelector('spectrumHueSlider')
  36343. ], AgColorPanel.prototype, "spectrumHueSlider", void 0);
  36344. __decorate$1G([
  36345. RefSelector('spectrumAlpha')
  36346. ], AgColorPanel.prototype, "spectrumAlpha", void 0);
  36347. __decorate$1G([
  36348. RefSelector('spectrumAlphaSlider')
  36349. ], AgColorPanel.prototype, "spectrumAlphaSlider", void 0);
  36350. __decorate$1G([
  36351. RefSelector('recentColors')
  36352. ], AgColorPanel.prototype, "recentColors", void 0);
  36353. __decorate$1G([
  36354. PostConstruct
  36355. ], AgColorPanel.prototype, "postConstruct", null);
  36356. return AgColorPanel;
  36357. }(Component));
  36358. /**
  36359. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  36360. * @version v23.2.1
  36361. * @link http://www.ag-grid.com/
  36362. * @license MIT
  36363. */
  36364. var __extends$1J = (undefined && undefined.__extends) || (function () {
  36365. var extendStatics = function (d, b) {
  36366. extendStatics = Object.setPrototypeOf ||
  36367. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  36368. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  36369. return extendStatics(d, b);
  36370. };
  36371. return function (d, b) {
  36372. extendStatics(d, b);
  36373. function __() { this.constructor = d; }
  36374. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  36375. };
  36376. })();
  36377. var __decorate$1H = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  36378. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  36379. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  36380. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  36381. return c > 3 && r && Object.defineProperty(target, key, r), r;
  36382. };
  36383. var AgPickerField = /** @class */ (function (_super) {
  36384. __extends$1J(AgPickerField, _super);
  36385. function AgPickerField() {
  36386. var _this = _super !== null && _super.apply(this, arguments) || this;
  36387. _this.TEMPLATE = "<div class=\"ag-picker-field\" role=\"presentation\">\n <label ref=\"eLabel\"></label>\n <div ref=\"eWrapper\" class=\"ag-wrapper ag-picker-field-wrapper\" tabIndex=\"-1\">\n <%displayField% ref=\"eDisplayField\" class=\"ag-picker-field-display\"></%displayField%>\n <div ref=\"eIcon\" class=\"ag-picker-field-icon\"></div>\n </div>\n </div>";
  36388. _this.isDestroyingPicker = false;
  36389. _this.skipClick = false;
  36390. return _this;
  36391. }
  36392. AgPickerField.prototype.postConstruct = function () {
  36393. var _this = this;
  36394. _super.prototype.postConstruct.call(this);
  36395. var clickHandler = function () {
  36396. if (_this.skipClick) {
  36397. _this.skipClick = false;
  36398. return;
  36399. }
  36400. if (_this.isDisabled()) {
  36401. return;
  36402. }
  36403. _this.pickerComponent = _this.showPicker();
  36404. };
  36405. var eGui = this.getGui();
  36406. this.addManagedListener(eGui, 'mousedown', function (e) {
  36407. if (!_this.skipClick &&
  36408. _this.pickerComponent &&
  36409. _this.pickerComponent.isAlive() &&
  36410. _.isVisible(_this.pickerComponent.getGui()) &&
  36411. eGui.contains(e.target)) {
  36412. _this.skipClick = true;
  36413. }
  36414. });
  36415. this.addManagedListener(eGui, 'keydown', function (e) {
  36416. switch (e.keyCode) {
  36417. case Constants.KEY_UP:
  36418. case Constants.KEY_DOWN:
  36419. case Constants.KEY_ENTER:
  36420. case Constants.KEY_SPACE:
  36421. clickHandler();
  36422. case Constants.KEY_ESCAPE:
  36423. e.preventDefault();
  36424. break;
  36425. }
  36426. });
  36427. this.addManagedListener(this.eWrapper, 'click', clickHandler);
  36428. this.addManagedListener(this.eLabel, 'click', clickHandler);
  36429. if (this.pickerIcon) {
  36430. this.eIcon.appendChild(_.createIconNoSpan(this.pickerIcon, this.gridOptionsWrapper, null));
  36431. }
  36432. };
  36433. AgPickerField.prototype.setInputWidth = function (width) {
  36434. _.setElementWidth(this.eWrapper, width);
  36435. return this;
  36436. };
  36437. AgPickerField.prototype.getFocusableElement = function () {
  36438. return this.eWrapper;
  36439. };
  36440. __decorate$1H([
  36441. Autowired('gridOptionsWrapper')
  36442. ], AgPickerField.prototype, "gridOptionsWrapper", void 0);
  36443. __decorate$1H([
  36444. RefSelector('eLabel')
  36445. ], AgPickerField.prototype, "eLabel", void 0);
  36446. __decorate$1H([
  36447. RefSelector('eWrapper')
  36448. ], AgPickerField.prototype, "eWrapper", void 0);
  36449. __decorate$1H([
  36450. RefSelector('eDisplayField')
  36451. ], AgPickerField.prototype, "eDisplayField", void 0);
  36452. __decorate$1H([
  36453. RefSelector('eIcon')
  36454. ], AgPickerField.prototype, "eIcon", void 0);
  36455. return AgPickerField;
  36456. }(AgAbstractField));
  36457. /**
  36458. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  36459. * @version v23.2.1
  36460. * @link http://www.ag-grid.com/
  36461. * @license MIT
  36462. */
  36463. var __extends$1K = (undefined && undefined.__extends) || (function () {
  36464. var extendStatics = function (d, b) {
  36465. extendStatics = Object.setPrototypeOf ||
  36466. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  36467. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  36468. return extendStatics(d, b);
  36469. };
  36470. return function (d, b) {
  36471. extendStatics(d, b);
  36472. function __() { this.constructor = d; }
  36473. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  36474. };
  36475. })();
  36476. var AgColorPicker = /** @class */ (function (_super) {
  36477. __extends$1K(AgColorPicker, _super);
  36478. function AgColorPicker(config) {
  36479. var _this = _super.call(this) || this;
  36480. _this.displayTag = 'div';
  36481. _this.className = 'ag-color-picker';
  36482. _this.pickerIcon = 'colorPicker';
  36483. _this.setTemplate(_this.TEMPLATE.replace(/%displayField%/g, _this.displayTag));
  36484. if (config && config.color) {
  36485. _this.value = config.color;
  36486. }
  36487. return _this;
  36488. }
  36489. AgColorPicker.prototype.postConstruct = function () {
  36490. _super.prototype.postConstruct.call(this);
  36491. if (this.value) {
  36492. this.setValue(this.value);
  36493. }
  36494. };
  36495. AgColorPicker.prototype.showPicker = function () {
  36496. var _this = this;
  36497. var eGuiRect = this.getGui().getBoundingClientRect();
  36498. var colorDialog = new AgDialog({
  36499. closable: false,
  36500. modal: true,
  36501. hideTitleBar: true,
  36502. minWidth: 190,
  36503. width: 190,
  36504. height: 250,
  36505. x: eGuiRect.right - 190,
  36506. y: eGuiRect.top - 250
  36507. });
  36508. this.createBean(colorDialog);
  36509. _.addCssClass(colorDialog.getGui(), 'ag-color-dialog');
  36510. var colorPanel = new AgColorPanel({
  36511. picker: this
  36512. });
  36513. this.createBean(colorPanel);
  36514. colorPanel.addDestroyFunc(function () {
  36515. if (colorDialog.isAlive()) {
  36516. _this.destroyBean(colorDialog);
  36517. }
  36518. });
  36519. colorDialog.setParentComponent(this);
  36520. colorDialog.setBodyComponent(colorPanel);
  36521. colorPanel.setValue(this.getValue());
  36522. colorDialog.addDestroyFunc(function () {
  36523. var wasDestroying = _this.isDestroyingPicker;
  36524. // here we check if the picker was already being
  36525. // destroyed to avoid a stackoverflow
  36526. if (!wasDestroying) {
  36527. _this.isDestroyingPicker = true;
  36528. if (colorPanel.isAlive()) {
  36529. _this.destroyBean(colorPanel);
  36530. }
  36531. }
  36532. else {
  36533. _this.isDestroyingPicker = false;
  36534. }
  36535. if (_this.isAlive()) {
  36536. _this.getFocusableElement().focus();
  36537. }
  36538. });
  36539. return colorDialog;
  36540. };
  36541. AgColorPicker.prototype.setValue = function (color) {
  36542. if (this.value === color) {
  36543. return this;
  36544. }
  36545. this.value = color;
  36546. this.eDisplayField.style.backgroundColor = color;
  36547. this.dispatchEvent({ type: AgAbstractField.EVENT_CHANGED });
  36548. return this;
  36549. };
  36550. AgColorPicker.prototype.getValue = function () {
  36551. return this.value;
  36552. };
  36553. return AgColorPicker;
  36554. }(AgPickerField));
  36555. /**
  36556. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  36557. * @version v23.2.1
  36558. * @link http://www.ag-grid.com/
  36559. * @license MIT
  36560. */
  36561. var __extends$1L = (undefined && undefined.__extends) || (function () {
  36562. var extendStatics = function (d, b) {
  36563. extendStatics = Object.setPrototypeOf ||
  36564. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  36565. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  36566. return extendStatics(d, b);
  36567. };
  36568. return function (d, b) {
  36569. extendStatics(d, b);
  36570. function __() { this.constructor = d; }
  36571. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  36572. };
  36573. })();
  36574. var AgInputNumberField = /** @class */ (function (_super) {
  36575. __extends$1L(AgInputNumberField, _super);
  36576. function AgInputNumberField() {
  36577. var _this = _super !== null && _super.apply(this, arguments) || this;
  36578. _this.className = 'ag-number-field';
  36579. _this.inputType = 'number';
  36580. return _this;
  36581. }
  36582. AgInputNumberField.prototype.postConstruct = function () {
  36583. var _this = this;
  36584. _super.prototype.postConstruct.call(this);
  36585. this.addManagedListener(this.eInput, 'blur', function () {
  36586. var floatedValue = parseFloat(_this.eInput.value);
  36587. var value = isNaN(floatedValue) ? '' : _this.normalizeValue(floatedValue.toString());
  36588. if (_this.value !== value) {
  36589. _this.setValue(value);
  36590. }
  36591. });
  36592. };
  36593. AgInputNumberField.prototype.normalizeValue = function (value) {
  36594. if (value === '') {
  36595. return '';
  36596. }
  36597. if (this.precision) {
  36598. value = this.adjustPrecision(value);
  36599. }
  36600. var val = parseFloat(value);
  36601. if (this.min != null && val < this.min) {
  36602. value = this.min.toString();
  36603. }
  36604. else if (this.max != null && val > this.max) {
  36605. value = this.max.toString();
  36606. }
  36607. return value;
  36608. };
  36609. AgInputNumberField.prototype.adjustPrecision = function (value) {
  36610. if (this.precision) {
  36611. var floatString = parseFloat(value).toFixed(this.precision);
  36612. value = parseFloat(floatString).toString();
  36613. }
  36614. return value;
  36615. };
  36616. AgInputNumberField.prototype.setMin = function (min) {
  36617. if (this.min === min) {
  36618. return this;
  36619. }
  36620. this.min = min;
  36621. if (this.min != null) {
  36622. this.eInput.setAttribute('min', min.toString());
  36623. }
  36624. else {
  36625. this.eInput.removeAttribute('min');
  36626. }
  36627. return this;
  36628. };
  36629. AgInputNumberField.prototype.setMax = function (max) {
  36630. if (this.max === max) {
  36631. return this;
  36632. }
  36633. this.max = max;
  36634. if (this.max != null) {
  36635. this.eInput.setAttribute('max', max.toString());
  36636. }
  36637. else {
  36638. this.eInput.removeAttribute('max');
  36639. }
  36640. return this;
  36641. };
  36642. AgInputNumberField.prototype.setPrecision = function (precision) {
  36643. this.precision = precision;
  36644. return this;
  36645. };
  36646. AgInputNumberField.prototype.setStep = function (step) {
  36647. if (this.step === step) {
  36648. return this;
  36649. }
  36650. this.step = step;
  36651. if (step != null) {
  36652. this.eInput.setAttribute('step', step.toString());
  36653. }
  36654. else {
  36655. this.eInput.removeAttribute('step');
  36656. }
  36657. return this;
  36658. };
  36659. AgInputNumberField.prototype.setValue = function (value, silent) {
  36660. value = this.adjustPrecision(value);
  36661. var normalizedValue = this.normalizeValue(value);
  36662. if (value != normalizedValue) {
  36663. return this;
  36664. }
  36665. return _super.prototype.setValue.call(this, value, silent);
  36666. };
  36667. return AgInputNumberField;
  36668. }(AgInputTextField));
  36669. /**
  36670. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  36671. * @version v23.2.1
  36672. * @link http://www.ag-grid.com/
  36673. * @license MIT
  36674. */
  36675. var __extends$1M = (undefined && undefined.__extends) || (function () {
  36676. var extendStatics = function (d, b) {
  36677. extendStatics = Object.setPrototypeOf ||
  36678. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  36679. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  36680. return extendStatics(d, b);
  36681. };
  36682. return function (d, b) {
  36683. extendStatics(d, b);
  36684. function __() { this.constructor = d; }
  36685. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  36686. };
  36687. })();
  36688. var AgInputRange = /** @class */ (function (_super) {
  36689. __extends$1M(AgInputRange, _super);
  36690. function AgInputRange(config) {
  36691. var _this = _super.call(this) || this;
  36692. _this.className = 'ag-range-field';
  36693. _this.displayTag = 'input';
  36694. _this.inputType = 'range';
  36695. _this.setTemplate(_this.TEMPLATE.replace(/%displayField%/g, _this.displayTag));
  36696. if (config) {
  36697. _this.config = config;
  36698. }
  36699. return _this;
  36700. }
  36701. AgInputRange.prototype.postConstruct = function () {
  36702. _super.prototype.postConstruct.call(this);
  36703. var _a = this.config, min = _a.min, max = _a.max, step = _a.step;
  36704. if (min != null) {
  36705. this.setMinValue(min);
  36706. }
  36707. if (max != null) {
  36708. this.setMaxValue(max);
  36709. }
  36710. this.setStep(step || 1);
  36711. };
  36712. AgInputRange.prototype.addInputListeners = function () {
  36713. var _this = this;
  36714. var isIE = _.isBrowserIE();
  36715. var eventName = isIE ? 'change' : 'input';
  36716. this.addManagedListener(this.eInput, eventName, function (e) {
  36717. var value = e.target.value;
  36718. _this.setValue(value);
  36719. });
  36720. };
  36721. AgInputRange.prototype.setMinValue = function (value) {
  36722. this.min = value;
  36723. this.eInput.setAttribute('min', value.toString());
  36724. return this;
  36725. };
  36726. AgInputRange.prototype.setMaxValue = function (value) {
  36727. this.max = value;
  36728. this.eInput.setAttribute('max', value.toString());
  36729. return this;
  36730. };
  36731. AgInputRange.prototype.setStep = function (value) {
  36732. this.step = value;
  36733. this.eInput.setAttribute('step', value.toString());
  36734. return this;
  36735. };
  36736. AgInputRange.prototype.setValue = function (value, silent) {
  36737. if (this.min != null) {
  36738. value = Math.max(parseFloat(value), this.min).toString();
  36739. }
  36740. if (this.max != null) {
  36741. value = Math.min(parseFloat(value), this.max).toString();
  36742. }
  36743. var ret = _super.prototype.setValue.call(this, value, silent);
  36744. this.eInput.value = value;
  36745. return ret;
  36746. };
  36747. return AgInputRange;
  36748. }(AgAbstractInputField));
  36749. /**
  36750. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  36751. * @version v23.2.1
  36752. * @link http://www.ag-grid.com/
  36753. * @license MIT
  36754. */
  36755. var __extends$1N = (undefined && undefined.__extends) || (function () {
  36756. var extendStatics = function (d, b) {
  36757. extendStatics = Object.setPrototypeOf ||
  36758. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  36759. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  36760. return extendStatics(d, b);
  36761. };
  36762. return function (d, b) {
  36763. extendStatics(d, b);
  36764. function __() { this.constructor = d; }
  36765. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  36766. };
  36767. })();
  36768. var __decorate$1I = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  36769. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  36770. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  36771. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  36772. return c > 3 && r && Object.defineProperty(target, key, r), r;
  36773. };
  36774. var AgList = /** @class */ (function (_super) {
  36775. __extends$1N(AgList, _super);
  36776. function AgList(cssIdentifier) {
  36777. if (cssIdentifier === void 0) { cssIdentifier = 'default'; }
  36778. var _this = _super.call(this, AgList.getTemplate(cssIdentifier)) || this;
  36779. _this.cssIdentifier = cssIdentifier;
  36780. _this.options = [];
  36781. _this.itemEls = [];
  36782. return _this;
  36783. }
  36784. AgList.prototype.init = function () {
  36785. this.addManagedListener(this.getGui(), 'keydown', this.handleKeyDown.bind(this));
  36786. };
  36787. AgList.getTemplate = function (cssIdentifier) {
  36788. return "<div class=\"ag-list ag-" + cssIdentifier + "-list\"></div>";
  36789. };
  36790. AgList.prototype.handleKeyDown = function (e) {
  36791. var key = e.keyCode;
  36792. switch (key) {
  36793. case Constants.KEY_ENTER:
  36794. if (!this.highlightedEl) {
  36795. this.setValue(this.getValue());
  36796. }
  36797. else {
  36798. var pos = this.itemEls.indexOf(this.highlightedEl);
  36799. this.setValueByIndex(pos);
  36800. }
  36801. break;
  36802. case Constants.KEY_DOWN:
  36803. case Constants.KEY_UP:
  36804. var isDown = key === Constants.KEY_DOWN;
  36805. var itemToHighlight = void 0;
  36806. e.preventDefault();
  36807. if (!this.highlightedEl) {
  36808. itemToHighlight = this.itemEls[isDown ? 0 : this.itemEls.length - 1];
  36809. }
  36810. else {
  36811. var currentIdx = this.itemEls.indexOf(this.highlightedEl);
  36812. var nextPos = currentIdx + (isDown ? 1 : -1);
  36813. nextPos = Math.min(Math.max(nextPos, 0), this.itemEls.length - 1);
  36814. itemToHighlight = this.itemEls[nextPos];
  36815. }
  36816. this.highlightItem(itemToHighlight);
  36817. break;
  36818. }
  36819. };
  36820. AgList.prototype.addOptions = function (listOptions) {
  36821. var _this = this;
  36822. listOptions.forEach(function (listOption) { return _this.addOption(listOption); });
  36823. return this;
  36824. };
  36825. AgList.prototype.addOption = function (listOption) {
  36826. var value = listOption.value, text = listOption.text;
  36827. var sanitisedText = _.escape(text === undefined ? value : text);
  36828. this.options.push({ value: value, text: sanitisedText });
  36829. this.renderOption(sanitisedText);
  36830. return this;
  36831. };
  36832. AgList.prototype.renderOption = function (innerText) {
  36833. var _this = this;
  36834. var itemEl = document.createElement('div');
  36835. var itemContentEl = document.createElement('span');
  36836. _.addCssClass(itemEl, 'ag-list-item');
  36837. _.addCssClass(itemEl, "ag-" + this.cssIdentifier + "-list-item");
  36838. itemEl.tabIndex = -1;
  36839. itemContentEl.innerHTML = innerText;
  36840. this.itemEls.push(itemEl);
  36841. this.addManagedListener(itemEl, 'mouseover', function (e) { return _this.highlightItem(itemEl); });
  36842. this.addManagedListener(itemEl, 'mouseleave', function () { return _this.clearHighlighted(); });
  36843. this.addManagedListener(itemEl, 'click', function () {
  36844. var idx = _this.itemEls.indexOf(itemEl);
  36845. _this.setValueByIndex(idx);
  36846. });
  36847. itemEl.appendChild(itemContentEl);
  36848. this.getGui().appendChild(itemEl);
  36849. };
  36850. AgList.prototype.setValue = function (value, silent) {
  36851. if (this.value === value) {
  36852. this.fireItemSelected();
  36853. return this;
  36854. }
  36855. if (value == null) {
  36856. this.reset();
  36857. return this;
  36858. }
  36859. var idx = _.findIndex(this.options, function (option) { return option.value === value; });
  36860. if (idx !== -1) {
  36861. var option = this.options[idx];
  36862. this.value = option.value;
  36863. this.displayValue = option.text != null ? option.text : option.value;
  36864. this.highlightItem(this.itemEls[idx]);
  36865. if (!silent) {
  36866. this.fireChangeEvent();
  36867. }
  36868. }
  36869. return this;
  36870. };
  36871. AgList.prototype.setValueByIndex = function (idx) {
  36872. return this.setValue(this.options[idx].value);
  36873. };
  36874. AgList.prototype.getValue = function () {
  36875. return this.value;
  36876. };
  36877. AgList.prototype.getDisplayValue = function () {
  36878. return this.displayValue;
  36879. };
  36880. AgList.prototype.refreshHighlighted = function () {
  36881. var _this = this;
  36882. this.clearHighlighted();
  36883. var idx = _.findIndex(this.options, function (option) { return option.value === _this.value; });
  36884. if (idx !== -1) {
  36885. this.highlightItem(this.itemEls[idx]);
  36886. }
  36887. };
  36888. AgList.prototype.reset = function () {
  36889. this.value = null;
  36890. this.displayValue = null;
  36891. this.clearHighlighted();
  36892. this.fireChangeEvent();
  36893. };
  36894. AgList.prototype.highlightItem = function (el) {
  36895. if (!el.offsetParent) {
  36896. return;
  36897. }
  36898. _.radioCssClass(el, 'ag-active-item');
  36899. this.highlightedEl = el;
  36900. this.highlightedEl.focus();
  36901. };
  36902. AgList.prototype.clearHighlighted = function () {
  36903. if (!this.highlightedEl || !this.highlightedEl.offsetParent) {
  36904. return;
  36905. }
  36906. _.removeCssClass(this.highlightedEl, 'ag-active-item');
  36907. this.highlightedEl = null;
  36908. };
  36909. AgList.prototype.fireChangeEvent = function () {
  36910. this.dispatchEvent({ type: AgAbstractField.EVENT_CHANGED });
  36911. this.fireItemSelected();
  36912. };
  36913. AgList.prototype.fireItemSelected = function () {
  36914. this.dispatchEvent({ type: AgList.EVENT_ITEM_SELECTED });
  36915. };
  36916. AgList.EVENT_ITEM_SELECTED = 'selectedItem';
  36917. __decorate$1I([
  36918. PostConstruct
  36919. ], AgList.prototype, "init", null);
  36920. return AgList;
  36921. }(Component));
  36922. /**
  36923. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  36924. * @version v23.2.1
  36925. * @link http://www.ag-grid.com/
  36926. * @license MIT
  36927. */
  36928. var __extends$1O = (undefined && undefined.__extends) || (function () {
  36929. var extendStatics = function (d, b) {
  36930. extendStatics = Object.setPrototypeOf ||
  36931. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  36932. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  36933. return extendStatics(d, b);
  36934. };
  36935. return function (d, b) {
  36936. extendStatics(d, b);
  36937. function __() { this.constructor = d; }
  36938. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  36939. };
  36940. })();
  36941. var __decorate$1J = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  36942. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  36943. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  36944. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  36945. return c > 3 && r && Object.defineProperty(target, key, r), r;
  36946. };
  36947. var AgSelect = /** @class */ (function (_super) {
  36948. __extends$1O(AgSelect, _super);
  36949. function AgSelect(config) {
  36950. var _this = _super.call(this) || this;
  36951. _this.displayTag = 'div';
  36952. _this.className = 'ag-select';
  36953. _this.pickerIcon = 'smallDown';
  36954. _this.setTemplate(_this.TEMPLATE.replace(/%displayField%/g, _this.displayTag));
  36955. return _this;
  36956. }
  36957. AgSelect.prototype.init = function () {
  36958. var _this = this;
  36959. this.listComponent = new AgList('select');
  36960. this.getContext().createBean(this.listComponent);
  36961. this.listComponent.setParentComponent(this);
  36962. this.eWrapper.tabIndex = 0;
  36963. this.listComponent.addManagedListener(this.listComponent, AgList.EVENT_ITEM_SELECTED, function () { if (_this.hideList) {
  36964. _this.hideList();
  36965. } });
  36966. this.listComponent.addManagedListener(this.listComponent, AgAbstractField.EVENT_CHANGED, function () {
  36967. _this.setValue(_this.listComponent.getValue(), false, true);
  36968. if (_this.hideList) {
  36969. _this.hideList();
  36970. }
  36971. });
  36972. };
  36973. AgSelect.prototype.showPicker = function () {
  36974. var _this = this;
  36975. var listGui = this.listComponent.getGui();
  36976. var mouseWheelFunc = this.addManagedListener(document.body, 'wheel', function (e) {
  36977. if (!listGui.contains(e.target) && _this.hideList) {
  36978. _this.hideList();
  36979. }
  36980. });
  36981. var focusOutFunc = this.addManagedListener(listGui, 'focusout', function (e) {
  36982. if (!listGui.contains(e.relatedTarget) && _this.hideList) {
  36983. _this.hideList();
  36984. }
  36985. });
  36986. this.hideList = this.popupService.addPopup(true, listGui, true, function () {
  36987. _this.hideList = null;
  36988. focusOutFunc();
  36989. mouseWheelFunc();
  36990. if (_this.isAlive()) {
  36991. _this.getFocusableElement().focus();
  36992. }
  36993. });
  36994. _.setElementWidth(listGui, _.getAbsoluteWidth(this.eWrapper));
  36995. listGui.style.maxHeight = _.getInnerHeight(this.popupService.getPopupParent()) + 'px';
  36996. listGui.style.position = 'absolute';
  36997. this.popupService.positionPopupUnderComponent({
  36998. type: 'ag-list',
  36999. eventSource: this.eWrapper,
  37000. ePopup: listGui,
  37001. keepWithinBounds: true
  37002. });
  37003. this.listComponent.refreshHighlighted();
  37004. return this.listComponent;
  37005. };
  37006. AgSelect.prototype.addOptions = function (options) {
  37007. var _this = this;
  37008. options.forEach(function (option) { return _this.addOption(option); });
  37009. return this;
  37010. };
  37011. AgSelect.prototype.addOption = function (option) {
  37012. this.listComponent.addOption(option);
  37013. return this;
  37014. };
  37015. AgSelect.prototype.setValue = function (value, silent, fromPicker) {
  37016. if (this.value === value) {
  37017. return;
  37018. }
  37019. if (!fromPicker) {
  37020. this.listComponent.setValue(value, true);
  37021. }
  37022. var newValue = this.listComponent.getValue();
  37023. if (newValue === this.getValue()) {
  37024. return;
  37025. }
  37026. this.eDisplayField.innerHTML = this.listComponent.getDisplayValue();
  37027. return _super.prototype.setValue.call(this, value, silent);
  37028. };
  37029. AgSelect.prototype.destroy = function () {
  37030. if (this.hideList) {
  37031. this.hideList();
  37032. }
  37033. this.getContext().destroyBean(this.listComponent);
  37034. _super.prototype.destroy.call(this);
  37035. };
  37036. __decorate$1J([
  37037. Autowired('popupService')
  37038. ], AgSelect.prototype, "popupService", void 0);
  37039. __decorate$1J([
  37040. PostConstruct
  37041. ], AgSelect.prototype, "init", null);
  37042. return AgSelect;
  37043. }(AgPickerField));
  37044. /**
  37045. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  37046. * @version v23.2.1
  37047. * @link http://www.ag-grid.com/
  37048. * @license MIT
  37049. */
  37050. var __extends$1P = (undefined && undefined.__extends) || (function () {
  37051. var extendStatics = function (d, b) {
  37052. extendStatics = Object.setPrototypeOf ||
  37053. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  37054. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  37055. return extendStatics(d, b);
  37056. };
  37057. return function (d, b) {
  37058. extendStatics(d, b);
  37059. function __() { this.constructor = d; }
  37060. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  37061. };
  37062. })();
  37063. var __decorate$1K = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  37064. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  37065. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  37066. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  37067. return c > 3 && r && Object.defineProperty(target, key, r), r;
  37068. };
  37069. var AgAngleSelect = /** @class */ (function (_super) {
  37070. __extends$1P(AgAngleSelect, _super);
  37071. function AgAngleSelect() {
  37072. var _this = _super.call(this, AgAngleSelect.TEMPLATE) || this;
  37073. _this.radius = 0;
  37074. _this.offsetX = 0;
  37075. _this.offsetY = 0;
  37076. return _this;
  37077. }
  37078. AgAngleSelect.prototype.postConstruct = function () {
  37079. var _this = this;
  37080. _super.prototype.postConstruct.call(this);
  37081. this.dragListener = {
  37082. eElement: this.eParentCircle,
  37083. dragStartPixels: 0,
  37084. onDragStart: function (e) {
  37085. _this.parentCircleRect = _this.eParentCircle.getBoundingClientRect();
  37086. },
  37087. onDragging: function (e) { return _this.calculateAngleDrag(e); },
  37088. onDragStop: function () { }
  37089. };
  37090. this.dragService.addDragSource(this.dragListener);
  37091. this.eAngleValue
  37092. .setLabel('')
  37093. .setLabelWidth(5)
  37094. .setInputWidth(45)
  37095. .setMin(0)
  37096. .setMax(360)
  37097. .setValue("" + this.degrees)
  37098. .onValueChange(function (value) {
  37099. if (value == null || value === '') {
  37100. value = '0';
  37101. }
  37102. value = _this.eAngleValue.normalizeValue(value);
  37103. var floatValue = parseFloat(value);
  37104. if (floatValue > 180) {
  37105. floatValue = floatValue - 360;
  37106. }
  37107. _this.setValue(floatValue);
  37108. });
  37109. this.updateNumberInput();
  37110. if (_.exists(this.getValue())) {
  37111. this.eAngleValue.setValue(this.normalizeNegativeValue(this.getValue()).toString());
  37112. }
  37113. this.addManagedListener(this, AgAbstractField.EVENT_CHANGED, function () {
  37114. if (_this.eAngleValue.getInputElement().contains(document.activeElement)) {
  37115. return;
  37116. }
  37117. _this.updateNumberInput();
  37118. });
  37119. };
  37120. AgAngleSelect.prototype.updateNumberInput = function () {
  37121. var normalizedValue = this.normalizeNegativeValue(this.getValue());
  37122. this.eAngleValue.setValue(normalizedValue.toString());
  37123. };
  37124. AgAngleSelect.prototype.positionChildCircle = function (radians) {
  37125. var rect = this.parentCircleRect || { width: 24, height: 24 };
  37126. var eChildCircle = this.eChildCircle;
  37127. var centerX = rect.width / 2;
  37128. var centerY = rect.height / 2;
  37129. eChildCircle.style.left = centerX + Math.cos(radians) * 8 + "px";
  37130. eChildCircle.style.top = centerY + Math.sin(radians) * 8 + "px";
  37131. };
  37132. AgAngleSelect.prototype.calculatePolar = function () {
  37133. var x = this.offsetX;
  37134. var y = this.offsetY;
  37135. var radians = Math.atan2(y, x);
  37136. this.degrees = this.toDegrees(radians);
  37137. this.radius = Math.sqrt((x * x) + (y * y));
  37138. this.positionChildCircle(radians);
  37139. };
  37140. AgAngleSelect.prototype.calculateCartesian = function () {
  37141. var radians = this.toRadians(this.getValue());
  37142. var radius = this.getRadius();
  37143. this
  37144. .setOffsetX(Math.cos(radians) * radius)
  37145. .setOffsetY(Math.sin(radians) * radius);
  37146. };
  37147. AgAngleSelect.prototype.setOffsetX = function (offset) {
  37148. if (this.offsetX !== offset) {
  37149. this.offsetX = offset;
  37150. this.calculatePolar();
  37151. }
  37152. return this;
  37153. };
  37154. AgAngleSelect.prototype.setOffsetY = function (offset) {
  37155. if (this.offsetY !== offset) {
  37156. this.offsetY = offset;
  37157. this.calculatePolar();
  37158. }
  37159. return this;
  37160. };
  37161. AgAngleSelect.prototype.calculateAngleDrag = function (e) {
  37162. var rect = this.parentCircleRect;
  37163. var centerX = rect.width / 2;
  37164. var centerY = rect.height / 2;
  37165. var x = e.clientX - rect.left;
  37166. var y = e.clientY - rect.top;
  37167. var dx = x - centerX;
  37168. var dy = y - centerY;
  37169. var radians = Math.atan2(dy, dx);
  37170. this.setValue(radians, true);
  37171. };
  37172. AgAngleSelect.prototype.toDegrees = function (radians) {
  37173. return radians / Math.PI * 180;
  37174. };
  37175. AgAngleSelect.prototype.toRadians = function (degrees) {
  37176. return degrees / 180 * Math.PI;
  37177. };
  37178. AgAngleSelect.prototype.normalizeNegativeValue = function (degrees) {
  37179. return degrees < 0 ? 360 + degrees : degrees;
  37180. };
  37181. AgAngleSelect.prototype.normalizeAngle180 = function (radians) {
  37182. radians %= Math.PI * 2;
  37183. if (radians < -Math.PI) {
  37184. radians += Math.PI * 2;
  37185. }
  37186. else if (radians >= Math.PI) {
  37187. radians -= Math.PI * 2;
  37188. }
  37189. return radians;
  37190. };
  37191. AgAngleSelect.prototype.getRadius = function () {
  37192. return this.radius;
  37193. };
  37194. AgAngleSelect.prototype.setRadius = function (r) {
  37195. if (this.radius === r) {
  37196. return this;
  37197. }
  37198. this.radius = r;
  37199. this.calculateCartesian();
  37200. return this;
  37201. };
  37202. AgAngleSelect.prototype.onValueChange = function (callbackFn) {
  37203. var _this = this;
  37204. this.addManagedListener(this, AgAbstractField.EVENT_CHANGED, function () {
  37205. callbackFn(_this.degrees);
  37206. });
  37207. return this;
  37208. };
  37209. AgAngleSelect.prototype.getValue = function (radians) {
  37210. return radians ? this.toRadians(this.degrees) : this.degrees;
  37211. };
  37212. AgAngleSelect.prototype.setValue = function (degrees, radians) {
  37213. var radiansValue;
  37214. if (!radians) {
  37215. radiansValue = this.normalizeAngle180(this.toRadians(degrees));
  37216. }
  37217. else {
  37218. radiansValue = degrees;
  37219. }
  37220. degrees = this.toDegrees(radiansValue);
  37221. if (this.degrees !== degrees) {
  37222. this.degrees = Math.floor(degrees);
  37223. this.calculateCartesian();
  37224. this.positionChildCircle(radiansValue);
  37225. this.dispatchEvent({ type: AgAbstractField.EVENT_CHANGED });
  37226. }
  37227. return this;
  37228. };
  37229. AgAngleSelect.prototype.setWidth = function (width) {
  37230. _.setFixedWidth(this.getGui(), width);
  37231. return this;
  37232. };
  37233. AgAngleSelect.prototype.destroy = function () {
  37234. this.dragService.removeDragSource(this.dragListener);
  37235. _super.prototype.destroy.call(this);
  37236. };
  37237. AgAngleSelect.TEMPLATE = "<div class=\"ag-angle-select\">\n <label ref=\"eLabel\"></label>\n <div class=\"ag-wrapper ag-angle-select-wrapper\">\n <div ref=\"eAngleSelectField\" class=\"ag-angle-select-field\">\n <div ref=\"eParentCircle\" class=\"ag-angle-select-parent-circle\">\n <div ref=\"eChildCircle\" class=\"ag-angle-select-child-circle\"></div>\n </div>\n </div>\n <ag-input-number-field ref=\"eAngleValue\"></ag-input-number-field>\n </div>\n </div>";
  37238. __decorate$1K([
  37239. RefSelector('eLabel')
  37240. ], AgAngleSelect.prototype, "eLabel", void 0);
  37241. __decorate$1K([
  37242. RefSelector('eParentCircle')
  37243. ], AgAngleSelect.prototype, "eParentCircle", void 0);
  37244. __decorate$1K([
  37245. RefSelector('eChildCircle')
  37246. ], AgAngleSelect.prototype, "eChildCircle", void 0);
  37247. __decorate$1K([
  37248. RefSelector('eAngleValue')
  37249. ], AgAngleSelect.prototype, "eAngleValue", void 0);
  37250. __decorate$1K([
  37251. Autowired("dragService")
  37252. ], AgAngleSelect.prototype, "dragService", void 0);
  37253. return AgAngleSelect;
  37254. }(AgAbstractLabel));
  37255. /**
  37256. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  37257. * @version v23.2.1
  37258. * @link http://www.ag-grid.com/
  37259. * @license MIT
  37260. */
  37261. var __extends$1Q = (undefined && undefined.__extends) || (function () {
  37262. var extendStatics = function (d, b) {
  37263. extendStatics = Object.setPrototypeOf ||
  37264. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  37265. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  37266. return extendStatics(d, b);
  37267. };
  37268. return function (d, b) {
  37269. extendStatics(d, b);
  37270. function __() { this.constructor = d; }
  37271. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  37272. };
  37273. })();
  37274. var AgToggleButton = /** @class */ (function (_super) {
  37275. __extends$1Q(AgToggleButton, _super);
  37276. function AgToggleButton() {
  37277. var _this = _super !== null && _super.apply(this, arguments) || this;
  37278. _this.className = 'ag-toggle-button';
  37279. _this.inputType = 'checkbox';
  37280. return _this;
  37281. }
  37282. AgToggleButton.prototype.setValue = function (value, silent) {
  37283. _super.prototype.setValue.call(this, value, silent);
  37284. _.addOrRemoveCssClass(this.getGui(), 'ag-selected', this.getValue());
  37285. return this;
  37286. };
  37287. return AgToggleButton;
  37288. }(AgRadioButton));
  37289. /**
  37290. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  37291. * @version v23.2.1
  37292. * @link http://www.ag-grid.com/
  37293. * @license MIT
  37294. */
  37295. var __extends$1R = (undefined && undefined.__extends) || (function () {
  37296. var extendStatics = function (d, b) {
  37297. extendStatics = Object.setPrototypeOf ||
  37298. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  37299. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  37300. return extendStatics(d, b);
  37301. };
  37302. return function (d, b) {
  37303. extendStatics(d, b);
  37304. function __() { this.constructor = d; }
  37305. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  37306. };
  37307. })();
  37308. var __decorate$1L = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  37309. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  37310. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  37311. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  37312. return c > 3 && r && Object.defineProperty(target, key, r), r;
  37313. };
  37314. /**
  37315. * For Master Detail, it is required to keep components between expanding & collapsing parents.
  37316. * For example a user expands row A (and shows a detail grid for this row), then when row A
  37317. * is closed, we want to keep the detail grid, so next time row A is expanded the detail grid
  37318. * is showed with it's context intact, eg if user sorted in the detail grid, that sort should
  37319. * still be applied after the detail grid is shown for the second time.
  37320. */
  37321. var DetailRowCompCache = /** @class */ (function (_super) {
  37322. __extends$1R(DetailRowCompCache, _super);
  37323. function DetailRowCompCache() {
  37324. var _this = _super !== null && _super.apply(this, arguments) || this;
  37325. _this.cacheItems = [];
  37326. return _this;
  37327. }
  37328. DetailRowCompCache.prototype.postConstruct = function () {
  37329. this.active = this.gridOptionsWrapper.isKeepDetailRows();
  37330. this.maxCacheSize = this.gridOptionsWrapper.getKeepDetailRowsCount();
  37331. };
  37332. DetailRowCompCache.prototype.addOrDestroy = function (rowNode, pinned, comp) {
  37333. // only accept detail rows
  37334. var doNotUseCache = !this.active || !rowNode.detail;
  37335. if (doNotUseCache) {
  37336. this.destroyFullWidthRow(comp);
  37337. return;
  37338. }
  37339. var item = this.getCacheItem(rowNode, true);
  37340. // put the comp in the right location of the item.
  37341. // we also destroy any previous comp - this should never happen
  37342. // as the logic outside of this class shouldn't be adding same item to the
  37343. // cache twice, however we cater for it in case in future releases code
  37344. // outside of this class is changed and this could happen.
  37345. switch (pinned) {
  37346. case Constants.PINNED_LEFT:
  37347. this.destroyFullWidthRow(item.left);
  37348. item.left = comp;
  37349. break;
  37350. case Constants.PINNED_RIGHT:
  37351. this.destroyFullWidthRow(item.right);
  37352. item.right = comp;
  37353. break;
  37354. default:
  37355. this.destroyFullWidthRow(item.center);
  37356. item.center = comp;
  37357. break;
  37358. }
  37359. this.cacheItems.sort(function (a, b) {
  37360. return b.lastAccessedTime - a.lastAccessedTime;
  37361. });
  37362. this.purgeCache(this.maxCacheSize);
  37363. };
  37364. DetailRowCompCache.prototype.getCacheItem = function (rowNode, autoCreate) {
  37365. if (autoCreate === void 0) { autoCreate = false; }
  37366. var res;
  37367. for (var i = 0; i < this.cacheItems.length; i++) {
  37368. var item = this.cacheItems[i];
  37369. if (item.rowNode === rowNode) {
  37370. res = item;
  37371. break;
  37372. }
  37373. }
  37374. if (!res && autoCreate) {
  37375. res = {
  37376. rowNode: rowNode
  37377. };
  37378. this.cacheItems.push(res);
  37379. }
  37380. if (res) {
  37381. this.stampCacheItem(res);
  37382. }
  37383. return res;
  37384. };
  37385. DetailRowCompCache.prototype.stampCacheItem = function (item) {
  37386. item.lastAccessedTime = new Date().getTime();
  37387. };
  37388. DetailRowCompCache.prototype.destroyFullWidthRow = function (comp) {
  37389. this.getContext().destroyBean(comp);
  37390. };
  37391. DetailRowCompCache.prototype.purgeCache = function (startIndex) {
  37392. // delete all rows past the index of interest
  37393. for (var i = startIndex; i < this.cacheItems.length; i++) {
  37394. var item = this.cacheItems[i];
  37395. this.destroyFullWidthRow(item.center);
  37396. this.destroyFullWidthRow(item.left);
  37397. this.destroyFullWidthRow(item.right);
  37398. }
  37399. // change the length of the array so it no longer contains the deleted items
  37400. if (this.cacheItems.length > startIndex) {
  37401. this.cacheItems.length = startIndex;
  37402. }
  37403. };
  37404. DetailRowCompCache.prototype.get = function (rowNode, pinned) {
  37405. if (!rowNode.detail) {
  37406. return undefined;
  37407. }
  37408. var item = this.getCacheItem(rowNode);
  37409. var res;
  37410. if (item) {
  37411. switch (pinned) {
  37412. case Constants.PINNED_LEFT:
  37413. if (item.left) {
  37414. res = item.left;
  37415. item.left = undefined;
  37416. }
  37417. break;
  37418. case Constants.PINNED_RIGHT:
  37419. if (item.right) {
  37420. res = item.right;
  37421. item.right = undefined;
  37422. }
  37423. break;
  37424. default:
  37425. if (item.center) {
  37426. res = item.center;
  37427. item.center = undefined;
  37428. }
  37429. break;
  37430. }
  37431. }
  37432. return res;
  37433. };
  37434. DetailRowCompCache.prototype.destroy = function () {
  37435. _super.prototype.destroy.call(this);
  37436. this.purgeCache(0);
  37437. };
  37438. __decorate$1L([
  37439. Autowired('gridOptionsWrapper')
  37440. ], DetailRowCompCache.prototype, "gridOptionsWrapper", void 0);
  37441. __decorate$1L([
  37442. PostConstruct
  37443. ], DetailRowCompCache.prototype, "postConstruct", null);
  37444. __decorate$1L([
  37445. PreDestroy
  37446. ], DetailRowCompCache.prototype, "destroy", null);
  37447. DetailRowCompCache = __decorate$1L([
  37448. Bean('detailRowCompCache')
  37449. ], DetailRowCompCache);
  37450. return DetailRowCompCache;
  37451. }(BeanStub));
  37452. /**
  37453. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  37454. * @version v23.2.1
  37455. * @link http://www.ag-grid.com/
  37456. * @license MIT
  37457. */
  37458. var __extends$1S = (undefined && undefined.__extends) || (function () {
  37459. var extendStatics = function (d, b) {
  37460. extendStatics = Object.setPrototypeOf ||
  37461. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  37462. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  37463. return extendStatics(d, b);
  37464. };
  37465. return function (d, b) {
  37466. extendStatics(d, b);
  37467. function __() { this.constructor = d; }
  37468. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  37469. };
  37470. })();
  37471. var __decorate$1M = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  37472. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  37473. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  37474. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  37475. return c > 3 && r && Object.defineProperty(target, key, r), r;
  37476. };
  37477. var RowPositionUtils = /** @class */ (function (_super) {
  37478. __extends$1S(RowPositionUtils, _super);
  37479. function RowPositionUtils() {
  37480. return _super !== null && _super.apply(this, arguments) || this;
  37481. }
  37482. RowPositionUtils.prototype.getFirstRow = function () {
  37483. var rowIndex = 0;
  37484. var rowPinned;
  37485. if (this.pinnedRowModel.getPinnedTopRowCount()) {
  37486. rowPinned = Constants.PINNED_TOP;
  37487. }
  37488. else if (this.rowModel.getRowCount()) {
  37489. rowPinned = null;
  37490. }
  37491. else if (this.pinnedRowModel.getPinnedBottomRowCount()) {
  37492. rowPinned = Constants.PINNED_BOTTOM;
  37493. }
  37494. return rowPinned === undefined ? null : { rowIndex: rowIndex, rowPinned: rowPinned };
  37495. };
  37496. RowPositionUtils.prototype.getRowNode = function (gridRow) {
  37497. switch (gridRow.rowPinned) {
  37498. case Constants.PINNED_TOP:
  37499. return this.pinnedRowModel.getPinnedTopRowData()[gridRow.rowIndex];
  37500. case Constants.PINNED_BOTTOM:
  37501. return this.pinnedRowModel.getPinnedBottomRowData()[gridRow.rowIndex];
  37502. default:
  37503. return this.rowModel.getRow(gridRow.rowIndex);
  37504. }
  37505. };
  37506. RowPositionUtils.prototype.sameRow = function (rowA, rowB) {
  37507. // if both missing
  37508. if (!rowA && !rowB) {
  37509. return true;
  37510. }
  37511. // if only one missing
  37512. if ((rowA && !rowB) || (!rowA && rowB)) {
  37513. return false;
  37514. }
  37515. // otherwise compare (use == to compare rowPinned because it can be null or undefined)
  37516. return rowA.rowIndex === rowB.rowIndex && rowA.rowPinned == rowB.rowPinned;
  37517. };
  37518. // tests if this row selection is before the other row selection
  37519. RowPositionUtils.prototype.before = function (rowA, rowB) {
  37520. switch (rowA.rowPinned) {
  37521. case Constants.PINNED_TOP:
  37522. // we we are floating top, and other isn't, then we are always before
  37523. if (rowB.rowPinned !== Constants.PINNED_TOP) {
  37524. return true;
  37525. }
  37526. break;
  37527. case Constants.PINNED_BOTTOM:
  37528. // if we are floating bottom, and the other isn't, then we are never before
  37529. if (rowB.rowPinned !== Constants.PINNED_BOTTOM) {
  37530. return false;
  37531. }
  37532. break;
  37533. default:
  37534. // if we are not floating, but the other one is floating...
  37535. if (_.exists(rowB.rowPinned)) {
  37536. return rowB.rowPinned !== Constants.PINNED_TOP;
  37537. }
  37538. break;
  37539. }
  37540. return rowA.rowIndex < rowB.rowIndex;
  37541. };
  37542. __decorate$1M([
  37543. Autowired('rowModel')
  37544. ], RowPositionUtils.prototype, "rowModel", void 0);
  37545. __decorate$1M([
  37546. Autowired('rowRenderer')
  37547. ], RowPositionUtils.prototype, "rowRenderer", void 0);
  37548. __decorate$1M([
  37549. Autowired('pinnedRowModel')
  37550. ], RowPositionUtils.prototype, "pinnedRowModel", void 0);
  37551. RowPositionUtils = __decorate$1M([
  37552. Bean('rowPositionUtils')
  37553. ], RowPositionUtils);
  37554. return RowPositionUtils;
  37555. }(BeanStub));
  37556. /**
  37557. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  37558. * @version v23.2.1
  37559. * @link http://www.ag-grid.com/
  37560. * @license MIT
  37561. */
  37562. var __extends$1T = (undefined && undefined.__extends) || (function () {
  37563. var extendStatics = function (d, b) {
  37564. extendStatics = Object.setPrototypeOf ||
  37565. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  37566. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  37567. return extendStatics(d, b);
  37568. };
  37569. return function (d, b) {
  37570. extendStatics(d, b);
  37571. function __() { this.constructor = d; }
  37572. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  37573. };
  37574. })();
  37575. var __decorate$1N = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  37576. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  37577. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  37578. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  37579. return c > 3 && r && Object.defineProperty(target, key, r), r;
  37580. };
  37581. var CellPositionUtils = /** @class */ (function (_super) {
  37582. __extends$1T(CellPositionUtils, _super);
  37583. function CellPositionUtils() {
  37584. return _super !== null && _super.apply(this, arguments) || this;
  37585. }
  37586. CellPositionUtils.prototype.createId = function (cellPosition) {
  37587. var rowIndex = cellPosition.rowIndex, rowPinned = cellPosition.rowPinned, column = cellPosition.column;
  37588. return this.createIdFromValues(rowIndex, column, rowPinned);
  37589. };
  37590. CellPositionUtils.prototype.createIdFromValues = function (rowIndex, column, rowPinned) {
  37591. return rowIndex + "." + (rowPinned == null ? 'null' : rowPinned) + "." + column.getId();
  37592. };
  37593. CellPositionUtils.prototype.equals = function (cellA, cellB) {
  37594. var colsMatch = cellA.column === cellB.column;
  37595. var floatingMatch = cellA.rowPinned === cellB.rowPinned;
  37596. var indexMatch = cellA.rowIndex === cellB.rowIndex;
  37597. return colsMatch && floatingMatch && indexMatch;
  37598. };
  37599. CellPositionUtils = __decorate$1N([
  37600. Bean('cellPositionUtils')
  37601. ], CellPositionUtils);
  37602. return CellPositionUtils;
  37603. }(BeanStub));
  37604. /**
  37605. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  37606. * @version v23.2.1
  37607. * @link http://www.ag-grid.com/
  37608. * @license MIT
  37609. */
  37610. var __extends$1U = (undefined && undefined.__extends) || (function () {
  37611. var extendStatics = function (d, b) {
  37612. extendStatics = Object.setPrototypeOf ||
  37613. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  37614. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  37615. return extendStatics(d, b);
  37616. };
  37617. return function (d, b) {
  37618. extendStatics(d, b);
  37619. function __() { this.constructor = d; }
  37620. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  37621. };
  37622. })();
  37623. var __decorate$1O = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  37624. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  37625. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  37626. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  37627. return c > 3 && r && Object.defineProperty(target, key, r), r;
  37628. };
  37629. var PinnedRowModel = /** @class */ (function (_super) {
  37630. __extends$1U(PinnedRowModel, _super);
  37631. function PinnedRowModel() {
  37632. return _super !== null && _super.apply(this, arguments) || this;
  37633. }
  37634. PinnedRowModel.prototype.init = function () {
  37635. this.setPinnedTopRowData(this.gridOptionsWrapper.getPinnedTopRowData());
  37636. this.setPinnedBottomRowData(this.gridOptionsWrapper.getPinnedBottomRowData());
  37637. };
  37638. PinnedRowModel.prototype.isEmpty = function (floating) {
  37639. var rows = floating === Constants.PINNED_TOP ? this.pinnedTopRows : this.pinnedBottomRows;
  37640. return _.missingOrEmpty(rows);
  37641. };
  37642. PinnedRowModel.prototype.isRowsToRender = function (floating) {
  37643. return !this.isEmpty(floating);
  37644. };
  37645. PinnedRowModel.prototype.getRowAtPixel = function (pixel, floating) {
  37646. var rows = floating === Constants.PINNED_TOP ? this.pinnedTopRows : this.pinnedBottomRows;
  37647. if (_.missingOrEmpty(rows)) {
  37648. return 0; // this should never happen, just in case, 0 is graceful failure
  37649. }
  37650. for (var i = 0; i < rows.length; i++) {
  37651. var rowNode = rows[i];
  37652. var rowTopPixel = rowNode.rowTop + rowNode.rowHeight - 1;
  37653. // only need to range check against the top pixel, as we are going through the list
  37654. // in order, first row to hit the pixel wins
  37655. if (rowTopPixel >= pixel) {
  37656. return i;
  37657. }
  37658. }
  37659. return rows.length - 1;
  37660. };
  37661. PinnedRowModel.prototype.setPinnedTopRowData = function (rowData) {
  37662. this.pinnedTopRows = this.createNodesFromData(rowData, true);
  37663. var event = {
  37664. type: Events.EVENT_PINNED_ROW_DATA_CHANGED,
  37665. api: this.gridApi,
  37666. columnApi: this.columnApi
  37667. };
  37668. this.eventService.dispatchEvent(event);
  37669. };
  37670. PinnedRowModel.prototype.setPinnedBottomRowData = function (rowData) {
  37671. this.pinnedBottomRows = this.createNodesFromData(rowData, false);
  37672. var event = {
  37673. type: Events.EVENT_PINNED_ROW_DATA_CHANGED,
  37674. api: this.gridApi,
  37675. columnApi: this.columnApi
  37676. };
  37677. this.eventService.dispatchEvent(event);
  37678. };
  37679. PinnedRowModel.prototype.createNodesFromData = function (allData, isTop) {
  37680. var _this = this;
  37681. var rowNodes = [];
  37682. if (allData) {
  37683. var nextRowTop_1 = 0;
  37684. allData.forEach(function (dataItem, index) {
  37685. var rowNode = new RowNode();
  37686. _this.context.createBean(rowNode);
  37687. rowNode.data = dataItem;
  37688. var idPrefix = isTop ? RowNode.ID_PREFIX_TOP_PINNED : RowNode.ID_PREFIX_BOTTOM_PINNED;
  37689. rowNode.id = idPrefix + index;
  37690. rowNode.rowPinned = isTop ? Constants.PINNED_TOP : Constants.PINNED_BOTTOM;
  37691. rowNode.setRowTop(nextRowTop_1);
  37692. rowNode.setRowHeight(_this.gridOptionsWrapper.getRowHeightForNode(rowNode).height);
  37693. rowNode.setRowIndex(index);
  37694. nextRowTop_1 += rowNode.rowHeight;
  37695. rowNodes.push(rowNode);
  37696. });
  37697. }
  37698. return rowNodes;
  37699. };
  37700. PinnedRowModel.prototype.getPinnedTopRowData = function () {
  37701. return this.pinnedTopRows;
  37702. };
  37703. PinnedRowModel.prototype.getPinnedBottomRowData = function () {
  37704. return this.pinnedBottomRows;
  37705. };
  37706. PinnedRowModel.prototype.getPinnedTopTotalHeight = function () {
  37707. return this.getTotalHeight(this.pinnedTopRows);
  37708. };
  37709. PinnedRowModel.prototype.getPinnedTopRowCount = function () {
  37710. return this.pinnedTopRows ? this.pinnedTopRows.length : 0;
  37711. };
  37712. PinnedRowModel.prototype.getPinnedBottomRowCount = function () {
  37713. return this.pinnedBottomRows ? this.pinnedBottomRows.length : 0;
  37714. };
  37715. PinnedRowModel.prototype.getPinnedTopRow = function (index) {
  37716. return this.pinnedTopRows[index];
  37717. };
  37718. PinnedRowModel.prototype.getPinnedBottomRow = function (index) {
  37719. return this.pinnedBottomRows[index];
  37720. };
  37721. PinnedRowModel.prototype.forEachPinnedTopRow = function (callback) {
  37722. if (_.missingOrEmpty(this.pinnedTopRows)) {
  37723. return;
  37724. }
  37725. this.pinnedTopRows.forEach(callback);
  37726. };
  37727. PinnedRowModel.prototype.forEachPinnedBottomRow = function (callback) {
  37728. if (_.missingOrEmpty(this.pinnedBottomRows)) {
  37729. return;
  37730. }
  37731. this.pinnedBottomRows.forEach(callback);
  37732. };
  37733. PinnedRowModel.prototype.getPinnedBottomTotalHeight = function () {
  37734. return this.getTotalHeight(this.pinnedBottomRows);
  37735. };
  37736. PinnedRowModel.prototype.getTotalHeight = function (rowNodes) {
  37737. if (!rowNodes || rowNodes.length === 0) {
  37738. return 0;
  37739. }
  37740. else {
  37741. var lastNode = _.last(rowNodes);
  37742. return lastNode.rowTop + lastNode.rowHeight;
  37743. }
  37744. };
  37745. __decorate$1O([
  37746. Autowired('gridOptionsWrapper')
  37747. ], PinnedRowModel.prototype, "gridOptionsWrapper", void 0);
  37748. __decorate$1O([
  37749. Autowired('columnApi')
  37750. ], PinnedRowModel.prototype, "columnApi", void 0);
  37751. __decorate$1O([
  37752. Autowired('gridApi')
  37753. ], PinnedRowModel.prototype, "gridApi", void 0);
  37754. __decorate$1O([
  37755. PostConstruct
  37756. ], PinnedRowModel.prototype, "init", null);
  37757. PinnedRowModel = __decorate$1O([
  37758. Bean('pinnedRowModel')
  37759. ], PinnedRowModel);
  37760. return PinnedRowModel;
  37761. }(BeanStub));
  37762. /**
  37763. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  37764. * @version v23.2.1
  37765. * @link http://www.ag-grid.com/
  37766. * @license MIT
  37767. */
  37768. var __extends$1V = (undefined && undefined.__extends) || (function () {
  37769. var extendStatics = function (d, b) {
  37770. extendStatics = Object.setPrototypeOf ||
  37771. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  37772. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  37773. return extendStatics(d, b);
  37774. };
  37775. return function (d, b) {
  37776. extendStatics(d, b);
  37777. function __() { this.constructor = d; }
  37778. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  37779. };
  37780. })();
  37781. var UndoRedoAction = /** @class */ (function () {
  37782. function UndoRedoAction(cellValueChanges) {
  37783. this.cellValueChanges = cellValueChanges;
  37784. }
  37785. return UndoRedoAction;
  37786. }());
  37787. var FillUndoRedoAction = /** @class */ (function (_super) {
  37788. __extends$1V(FillUndoRedoAction, _super);
  37789. function FillUndoRedoAction(cellValueChanges, initialRange, finalRange) {
  37790. var _this = _super.call(this, cellValueChanges) || this;
  37791. _this.initialRange = initialRange;
  37792. _this.finalRange = finalRange;
  37793. return _this;
  37794. }
  37795. return FillUndoRedoAction;
  37796. }(UndoRedoAction));
  37797. var UndoRedoStack = /** @class */ (function () {
  37798. function UndoRedoStack(maxStackSize) {
  37799. this.actionStack = [];
  37800. this.maxStackSize = maxStackSize ? maxStackSize : UndoRedoStack.DEFAULT_STACK_SIZE;
  37801. this.actionStack = new Array(this.maxStackSize);
  37802. }
  37803. UndoRedoStack.prototype.pop = function () {
  37804. return this.actionStack.pop();
  37805. };
  37806. UndoRedoStack.prototype.push = function (item) {
  37807. var shouldAddActions = item.cellValueChanges && item.cellValueChanges.length > 0;
  37808. if (!shouldAddActions) {
  37809. return;
  37810. }
  37811. if (this.actionStack.length === this.maxStackSize) {
  37812. this.actionStack.shift();
  37813. }
  37814. this.actionStack.push(item);
  37815. };
  37816. UndoRedoStack.prototype.clear = function () {
  37817. this.actionStack = [];
  37818. };
  37819. UndoRedoStack.DEFAULT_STACK_SIZE = 10;
  37820. return UndoRedoStack;
  37821. }());
  37822. /**
  37823. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  37824. * @version v23.2.1
  37825. * @link http://www.ag-grid.com/
  37826. * @license MIT
  37827. */
  37828. var __extends$1W = (undefined && undefined.__extends) || (function () {
  37829. var extendStatics = function (d, b) {
  37830. extendStatics = Object.setPrototypeOf ||
  37831. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  37832. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  37833. return extendStatics(d, b);
  37834. };
  37835. return function (d, b) {
  37836. extendStatics(d, b);
  37837. function __() { this.constructor = d; }
  37838. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  37839. };
  37840. })();
  37841. var __decorate$1P = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  37842. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  37843. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  37844. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  37845. return c > 3 && r && Object.defineProperty(target, key, r), r;
  37846. };
  37847. var UndoRedoService = /** @class */ (function (_super) {
  37848. __extends$1W(UndoRedoService, _super);
  37849. function UndoRedoService() {
  37850. var _this = _super !== null && _super.apply(this, arguments) || this;
  37851. _this.cellValueChanges = [];
  37852. _this.isCellEditing = false;
  37853. _this.isRowEditing = false;
  37854. _this.isPasting = false;
  37855. _this.isFilling = false;
  37856. _this.onCellValueChanged = function (event) {
  37857. var shouldCaptureAction = _this.isCellEditing || _this.isRowEditing || _this.isPasting || _this.isFilling;
  37858. if (!shouldCaptureAction) {
  37859. return;
  37860. }
  37861. var rowPinned = event.rowPinned, rowIndex = event.rowIndex, column = event.column, oldValue = event.oldValue, value = event.value;
  37862. var cellValueChange = {
  37863. rowPinned: rowPinned,
  37864. rowIndex: rowIndex,
  37865. columnId: column.getColId(),
  37866. oldValue: oldValue,
  37867. newValue: value
  37868. };
  37869. _this.cellValueChanges.push(cellValueChange);
  37870. };
  37871. _this.clearStacks = function () {
  37872. _this.undoStack.clear();
  37873. _this.redoStack.clear();
  37874. };
  37875. return _this;
  37876. }
  37877. UndoRedoService.prototype.init = function () {
  37878. if (!this.gridOptionsWrapper.isUndoRedoCellEditing()) {
  37879. return;
  37880. }
  37881. var undoRedoLimit = this.gridOptionsWrapper.getUndoRedoCellEditingLimit();
  37882. if (undoRedoLimit <= 0) {
  37883. return;
  37884. }
  37885. this.undoStack = new UndoRedoStack(undoRedoLimit);
  37886. this.redoStack = new UndoRedoStack(undoRedoLimit);
  37887. this.addRowEditingListeners();
  37888. this.addCellEditingListeners();
  37889. this.addPasteListeners();
  37890. this.addFillListeners();
  37891. this.addManagedListener(this.eventService, Events.EVENT_CELL_VALUE_CHANGED, this.onCellValueChanged);
  37892. // undo / redo is restricted to actual editing so we clear the stacks when other operations are
  37893. // performed that change the order of the row / cols.
  37894. this.addManagedListener(this.eventService, Events.EVENT_MODEL_UPDATED, this.clearStacks);
  37895. this.addManagedListener(this.eventService, Events.EVENT_COLUMN_PIVOT_MODE_CHANGED, this.clearStacks);
  37896. this.addManagedListener(this.eventService, Events.EVENT_COLUMN_EVERYTHING_CHANGED, this.clearStacks);
  37897. this.addManagedListener(this.eventService, Events.EVENT_COLUMN_GROUP_OPENED, this.clearStacks);
  37898. this.addManagedListener(this.eventService, Events.EVENT_COLUMN_ROW_GROUP_CHANGED, this.clearStacks);
  37899. this.addManagedListener(this.eventService, Events.EVENT_COLUMN_MOVED, this.clearStacks);
  37900. this.addManagedListener(this.eventService, Events.EVENT_COLUMN_PINNED, this.clearStacks);
  37901. this.addManagedListener(this.eventService, Events.EVENT_COLUMN_VISIBLE, this.clearStacks);
  37902. this.addManagedListener(this.eventService, Events.EVENT_ROW_DRAG_END, this.clearStacks);
  37903. };
  37904. UndoRedoService.prototype.undo = function () {
  37905. if (!this.undoStack) {
  37906. return;
  37907. }
  37908. var undoAction = this.undoStack.pop();
  37909. if (!undoAction || !undoAction.cellValueChanges) {
  37910. return;
  37911. }
  37912. this.processAction(undoAction, function (cellValueChange) { return cellValueChange.oldValue; });
  37913. if (undoAction instanceof FillUndoRedoAction) {
  37914. this.processRangeAndCellFocus(undoAction.cellValueChanges, undoAction.initialRange);
  37915. }
  37916. else {
  37917. this.processRangeAndCellFocus(undoAction.cellValueChanges);
  37918. }
  37919. this.redoStack.push(undoAction);
  37920. };
  37921. UndoRedoService.prototype.redo = function () {
  37922. if (!this.redoStack) {
  37923. return;
  37924. }
  37925. var redoAction = this.redoStack.pop();
  37926. if (!redoAction || !redoAction.cellValueChanges) {
  37927. return;
  37928. }
  37929. this.processAction(redoAction, function (cellValueChange) { return cellValueChange.newValue; });
  37930. if (redoAction instanceof FillUndoRedoAction) {
  37931. this.processRangeAndCellFocus(redoAction.cellValueChanges, redoAction.finalRange);
  37932. }
  37933. else {
  37934. this.processRangeAndCellFocus(redoAction.cellValueChanges);
  37935. }
  37936. this.undoStack.push(redoAction);
  37937. };
  37938. UndoRedoService.prototype.processAction = function (action, valueExtractor) {
  37939. var _this = this;
  37940. action.cellValueChanges.forEach(function (cellValueChange) {
  37941. var rowIndex = cellValueChange.rowIndex, rowPinned = cellValueChange.rowPinned, columnId = cellValueChange.columnId;
  37942. var rowPosition = { rowIndex: rowIndex, rowPinned: rowPinned };
  37943. var currentRow = _this.getRowNode(rowPosition);
  37944. // checks if the row has been filtered out
  37945. if (currentRow.rowTop == null) {
  37946. return;
  37947. }
  37948. currentRow.setDataValue(columnId, valueExtractor(cellValueChange));
  37949. });
  37950. };
  37951. UndoRedoService.prototype.processRangeAndCellFocus = function (cellValueChanges, range) {
  37952. if (range) {
  37953. var startRow = range.startRow;
  37954. var endRow = range.endRow;
  37955. var lastFocusedCell_1 = {
  37956. rowPinned: startRow.rowPinned,
  37957. rowIndex: startRow.rowIndex,
  37958. columnId: range.startColumn.getColId()
  37959. };
  37960. this.setLastFocusedCell(lastFocusedCell_1);
  37961. var cellRangeParams = {
  37962. rowStartIndex: startRow.rowIndex,
  37963. rowStartPinned: startRow.rowPinned,
  37964. rowEndIndex: endRow.rowIndex,
  37965. rowEndPinned: endRow.rowPinned,
  37966. columnStart: range.startColumn,
  37967. columns: range.columns
  37968. };
  37969. this.gridApi.addCellRange(cellRangeParams);
  37970. return;
  37971. }
  37972. var cellValueChange = cellValueChanges[0];
  37973. var rowIndex = cellValueChange.rowIndex, rowPinned = cellValueChange.rowPinned;
  37974. var rowPosition = { rowIndex: rowIndex, rowPinned: rowPinned };
  37975. var row = this.getRowNode(rowPosition);
  37976. var lastFocusedCell = {
  37977. rowPinned: cellValueChange.rowPinned,
  37978. rowIndex: row.rowIndex,
  37979. columnId: cellValueChange.columnId
  37980. };
  37981. this.setLastFocusedCell(lastFocusedCell);
  37982. };
  37983. UndoRedoService.prototype.setLastFocusedCell = function (lastFocusedCell) {
  37984. var rowIndex = lastFocusedCell.rowIndex, columnId = lastFocusedCell.columnId, rowPinned = lastFocusedCell.rowPinned;
  37985. this.gridApi.ensureIndexVisible(rowIndex);
  37986. this.gridApi.ensureColumnVisible(columnId);
  37987. if (ModuleRegistry.isRegistered(exports.ModuleNames.RangeSelectionModule)) {
  37988. this.gridApi.clearRangeSelection();
  37989. }
  37990. this.focusController.setFocusedCell(rowIndex, columnId, rowPinned, true);
  37991. };
  37992. UndoRedoService.prototype.addRowEditingListeners = function () {
  37993. var _this = this;
  37994. this.addManagedListener(this.eventService, Events.EVENT_ROW_EDITING_STARTED, function () {
  37995. _this.isRowEditing = true;
  37996. });
  37997. this.addManagedListener(this.eventService, Events.EVENT_ROW_EDITING_STOPPED, function () {
  37998. var action = new UndoRedoAction(_this.cellValueChanges);
  37999. _this.pushActionsToUndoStack(action);
  38000. _this.isRowEditing = false;
  38001. });
  38002. };
  38003. UndoRedoService.prototype.addCellEditingListeners = function () {
  38004. var _this = this;
  38005. this.addManagedListener(this.eventService, Events.EVENT_CELL_EDITING_STARTED, function () {
  38006. _this.isCellEditing = true;
  38007. });
  38008. this.addManagedListener(this.eventService, Events.EVENT_CELL_EDITING_STOPPED, function () {
  38009. _this.isCellEditing = false;
  38010. var shouldPushAction = !_this.isRowEditing && !_this.isPasting && !_this.isFilling;
  38011. if (shouldPushAction) {
  38012. var action = new UndoRedoAction(_this.cellValueChanges);
  38013. _this.pushActionsToUndoStack(action);
  38014. }
  38015. });
  38016. };
  38017. UndoRedoService.prototype.addPasteListeners = function () {
  38018. var _this = this;
  38019. this.addManagedListener(this.eventService, Events.EVENT_PASTE_START, function () {
  38020. _this.isPasting = true;
  38021. });
  38022. this.addManagedListener(this.eventService, Events.EVENT_PASTE_END, function () {
  38023. var action = new UndoRedoAction(_this.cellValueChanges);
  38024. _this.pushActionsToUndoStack(action);
  38025. _this.isPasting = false;
  38026. });
  38027. };
  38028. UndoRedoService.prototype.addFillListeners = function () {
  38029. var _this = this;
  38030. this.addManagedListener(this.eventService, Events.EVENT_FILL_START, function () {
  38031. _this.isFilling = true;
  38032. });
  38033. this.addManagedListener(this.eventService, Events.EVENT_FILL_END, function (event) {
  38034. var action = new FillUndoRedoAction(_this.cellValueChanges, event.initialRange, event.finalRange);
  38035. _this.pushActionsToUndoStack(action);
  38036. _this.isFilling = false;
  38037. });
  38038. };
  38039. UndoRedoService.prototype.pushActionsToUndoStack = function (action) {
  38040. this.undoStack.push(action);
  38041. this.cellValueChanges = [];
  38042. this.redoStack.clear();
  38043. };
  38044. UndoRedoService.prototype.getRowNode = function (gridRow) {
  38045. switch (gridRow.rowPinned) {
  38046. case Constants.PINNED_TOP:
  38047. return this.pinnedRowModel.getPinnedTopRowData()[gridRow.rowIndex];
  38048. case Constants.PINNED_BOTTOM:
  38049. return this.pinnedRowModel.getPinnedBottomRowData()[gridRow.rowIndex];
  38050. default:
  38051. return this.rowModel.getRow(gridRow.rowIndex);
  38052. }
  38053. };
  38054. __decorate$1P([
  38055. Autowired('gridOptionsWrapper')
  38056. ], UndoRedoService.prototype, "gridOptionsWrapper", void 0);
  38057. __decorate$1P([
  38058. Autowired('focusController')
  38059. ], UndoRedoService.prototype, "focusController", void 0);
  38060. __decorate$1P([
  38061. Autowired('gridApi')
  38062. ], UndoRedoService.prototype, "gridApi", void 0);
  38063. __decorate$1P([
  38064. Autowired('rowModel')
  38065. ], UndoRedoService.prototype, "rowModel", void 0);
  38066. __decorate$1P([
  38067. Autowired('pinnedRowModel')
  38068. ], UndoRedoService.prototype, "pinnedRowModel", void 0);
  38069. __decorate$1P([
  38070. PostConstruct
  38071. ], UndoRedoService.prototype, "init", null);
  38072. UndoRedoService = __decorate$1P([
  38073. Bean('undoRedoService')
  38074. ], UndoRedoService);
  38075. return UndoRedoService;
  38076. }(BeanStub));
  38077. /**
  38078. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  38079. * @version v23.2.1
  38080. * @link http://www.ag-grid.com/
  38081. * @license MIT
  38082. */
  38083. var __extends$1X = (undefined && undefined.__extends) || (function () {
  38084. var extendStatics = function (d, b) {
  38085. extendStatics = Object.setPrototypeOf ||
  38086. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  38087. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  38088. return extendStatics(d, b);
  38089. };
  38090. return function (d, b) {
  38091. extendStatics(d, b);
  38092. function __() { this.constructor = d; }
  38093. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  38094. };
  38095. })();
  38096. var __decorate$1Q = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  38097. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  38098. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  38099. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  38100. return c > 3 && r && Object.defineProperty(target, key, r), r;
  38101. };
  38102. var AgStackComponentsRegistry = /** @class */ (function (_super) {
  38103. __extends$1X(AgStackComponentsRegistry, _super);
  38104. function AgStackComponentsRegistry() {
  38105. var _this = _super !== null && _super.apply(this, arguments) || this;
  38106. _this.componentsMappedByName = {};
  38107. return _this;
  38108. }
  38109. AgStackComponentsRegistry.prototype.setupComponents = function (components) {
  38110. var _this = this;
  38111. if (components) {
  38112. components.forEach(function (componentMeta) { return _this.addComponent(componentMeta); });
  38113. }
  38114. };
  38115. AgStackComponentsRegistry.prototype.addComponent = function (componentMeta) {
  38116. // get name of the class as a string
  38117. // let className = _.getNameOfClass(ComponentClass);
  38118. // insert a dash after every capital letter
  38119. // let classEscaped = className.replace(/([A-Z])/g, "-$1").toLowerCase();
  38120. var classEscaped = componentMeta.componentName.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
  38121. // put all to upper case
  38122. var classUpperCase = classEscaped.toUpperCase();
  38123. // finally store
  38124. this.componentsMappedByName[classUpperCase] = componentMeta.componentClass;
  38125. };
  38126. AgStackComponentsRegistry.prototype.getComponentClass = function (htmlTag) {
  38127. return this.componentsMappedByName[htmlTag];
  38128. };
  38129. AgStackComponentsRegistry = __decorate$1Q([
  38130. Bean('agStackComponentsRegistry')
  38131. ], AgStackComponentsRegistry);
  38132. return AgStackComponentsRegistry;
  38133. }(BeanStub));
  38134. /**
  38135. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  38136. * @version v23.2.1
  38137. * @link http://www.ag-grid.com/
  38138. * @license MIT
  38139. */
  38140. var __extends$1Y = (undefined && undefined.__extends) || (function () {
  38141. var extendStatics = function (d, b) {
  38142. extendStatics = Object.setPrototypeOf ||
  38143. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  38144. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  38145. return extendStatics(d, b);
  38146. };
  38147. return function (d, b) {
  38148. extendStatics(d, b);
  38149. function __() { this.constructor = d; }
  38150. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  38151. };
  38152. })();
  38153. var __decorate$1R = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  38154. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  38155. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  38156. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  38157. return c > 3 && r && Object.defineProperty(target, key, r), r;
  38158. };
  38159. var HeaderPositionUtils = /** @class */ (function (_super) {
  38160. __extends$1Y(HeaderPositionUtils, _super);
  38161. function HeaderPositionUtils() {
  38162. return _super !== null && _super.apply(this, arguments) || this;
  38163. }
  38164. HeaderPositionUtils.prototype.findHeader = function (focusedHeader, direction) {
  38165. var nextColumn;
  38166. var getGroupMethod;
  38167. var getColMethod;
  38168. if (focusedHeader.column instanceof ColumnGroup) {
  38169. getGroupMethod = "getDisplayedGroup" + direction;
  38170. nextColumn = this.columnController[getGroupMethod](focusedHeader.column);
  38171. }
  38172. else {
  38173. getColMethod = "getDisplayedCol" + direction;
  38174. nextColumn = this.columnController[getColMethod](focusedHeader.column);
  38175. }
  38176. if (nextColumn) {
  38177. return {
  38178. column: nextColumn,
  38179. headerRowIndex: focusedHeader.headerRowIndex
  38180. };
  38181. }
  38182. };
  38183. HeaderPositionUtils.prototype.findColAtEdgeForHeaderRow = function (level, position) {
  38184. var displayedColumns = this.columnController.getAllDisplayedColumns();
  38185. var column = displayedColumns[position === 'start' ? 0 : displayedColumns.length - 1];
  38186. if (!column) {
  38187. return;
  38188. }
  38189. var childContainer = this.headerNavigationService.getHeaderContainer(column.getPinned());
  38190. var headerRowComp = childContainer.getRowComps()[level];
  38191. var type = headerRowComp && headerRowComp.getType();
  38192. if (type == HeaderRowType.COLUMN_GROUP) {
  38193. var columnGroup = this.columnController.getColumnGroupAtLevel(column, level);
  38194. return {
  38195. headerRowIndex: level,
  38196. column: columnGroup
  38197. };
  38198. }
  38199. return {
  38200. headerRowIndex: !headerRowComp ? -1 : level,
  38201. column: column
  38202. };
  38203. };
  38204. __decorate$1R([
  38205. Autowired('columnController')
  38206. ], HeaderPositionUtils.prototype, "columnController", void 0);
  38207. __decorate$1R([
  38208. Autowired('headerNavigationService')
  38209. ], HeaderPositionUtils.prototype, "headerNavigationService", void 0);
  38210. HeaderPositionUtils = __decorate$1R([
  38211. Bean('headerPositionUtils')
  38212. ], HeaderPositionUtils);
  38213. return HeaderPositionUtils;
  38214. }(BeanStub));
  38215. /**
  38216. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  38217. * @version v23.2.1
  38218. * @link http://www.ag-grid.com/
  38219. * @license MIT
  38220. */
  38221. var Grid = /** @class */ (function () {
  38222. function Grid(eGridDiv, gridOptions, params) {
  38223. if (!eGridDiv) {
  38224. console.error('ag-Grid: no div element provided to the grid');
  38225. return;
  38226. }
  38227. if (!gridOptions) {
  38228. console.error('ag-Grid: no gridOptions provided to the grid');
  38229. return;
  38230. }
  38231. var debug = !!gridOptions.debug;
  38232. this.gridOptions = gridOptions;
  38233. var registeredModules = this.getRegisteredModules(params);
  38234. var beanClasses = this.createBeansList(registeredModules);
  38235. var providedBeanInstances = this.createProvidedBeans(eGridDiv, params);
  38236. if (!beanClasses) {
  38237. return;
  38238. } // happens when no row model found
  38239. var contextParams = {
  38240. providedBeanInstances: providedBeanInstances,
  38241. beanClasses: beanClasses,
  38242. debug: debug
  38243. };
  38244. this.logger = new Logger('ag-Grid', function () { return gridOptions.debug; });
  38245. var contextLogger = new Logger('Context', function () { return contextParams.debug; });
  38246. this.context = new Context(contextParams, contextLogger);
  38247. this.registerModuleUserComponents(registeredModules);
  38248. this.registerStackComponents(registeredModules);
  38249. var gridCoreClass = (params && params.rootComponent) || GridCore;
  38250. var gridCore = new gridCoreClass();
  38251. this.context.createBean(gridCore);
  38252. this.setColumnsAndData();
  38253. this.dispatchGridReadyEvent(gridOptions);
  38254. var isEnterprise = ModuleRegistry.isRegistered(exports.ModuleNames.EnterpriseCoreModule);
  38255. this.logger.log("initialised successfully, enterprise = " + isEnterprise);
  38256. }
  38257. Grid.prototype.registerStackComponents = function (registeredModules) {
  38258. var agStackComponents = this.createAgStackComponentsList(registeredModules);
  38259. var agStackComponentsRegistry = this.context.getBean('agStackComponentsRegistry');
  38260. agStackComponentsRegistry.setupComponents(agStackComponents);
  38261. };
  38262. Grid.prototype.getRegisteredModules = function (params) {
  38263. var passedViaConstructor = params ? params.modules : null;
  38264. var registered = ModuleRegistry.getRegisteredModules();
  38265. var allModules = [];
  38266. var mapNames = {};
  38267. // adds to list and removes duplicates
  38268. function addModule(moduleBased, module) {
  38269. function addIndividualModule(module) {
  38270. if (!mapNames[module.moduleName]) {
  38271. mapNames[module.moduleName] = true;
  38272. allModules.push(module);
  38273. ModuleRegistry.register(module, moduleBased);
  38274. }
  38275. }
  38276. addIndividualModule(module);
  38277. if (module.dependantModules) {
  38278. module.dependantModules.forEach(addModule.bind(null, moduleBased));
  38279. }
  38280. }
  38281. if (passedViaConstructor) {
  38282. passedViaConstructor.forEach(addModule.bind(null, true));
  38283. }
  38284. if (registered) {
  38285. registered.forEach(addModule.bind(null, !ModuleRegistry.isPackageBased()));
  38286. }
  38287. return allModules;
  38288. };
  38289. Grid.prototype.registerModuleUserComponents = function (registeredModules) {
  38290. var userComponentRegistry = this.context.getBean('userComponentRegistry');
  38291. var moduleUserComps = this.extractModuleEntity(registeredModules, function (module) { return module.userComponents ? module.userComponents : []; });
  38292. moduleUserComps.forEach(function (compMeta) {
  38293. userComponentRegistry.registerDefaultComponent(compMeta.componentName, compMeta.componentClass);
  38294. });
  38295. };
  38296. Grid.prototype.createProvidedBeans = function (eGridDiv, params) {
  38297. var frameworkOverrides = params ? params.frameworkOverrides : null;
  38298. if (_.missing(frameworkOverrides)) {
  38299. frameworkOverrides = new VanillaFrameworkOverrides();
  38300. }
  38301. var seed = {
  38302. gridOptions: this.gridOptions,
  38303. eGridDiv: eGridDiv,
  38304. $scope: params ? params.$scope : null,
  38305. $compile: params ? params.$compile : null,
  38306. quickFilterOnScope: params ? params.quickFilterOnScope : null,
  38307. globalEventListener: params ? params.globalEventListener : null,
  38308. frameworkOverrides: frameworkOverrides
  38309. };
  38310. if (params && params.providedBeanInstances) {
  38311. _.assign(seed, params.providedBeanInstances);
  38312. }
  38313. return seed;
  38314. };
  38315. Grid.prototype.createAgStackComponentsList = function (registeredModules) {
  38316. var components = [
  38317. { componentName: 'AgCheckbox', componentClass: AgCheckbox },
  38318. { componentName: 'AgRadioButton', componentClass: AgRadioButton },
  38319. { componentName: 'AgToggleButton', componentClass: AgToggleButton },
  38320. { componentName: 'AgInputTextField', componentClass: AgInputTextField },
  38321. { componentName: 'AgInputTextArea', componentClass: AgInputTextArea },
  38322. { componentName: 'AgInputNumberField', componentClass: AgInputNumberField },
  38323. { componentName: 'AgInputRange', componentClass: AgInputRange },
  38324. { componentName: 'AgSelect', componentClass: AgSelect },
  38325. { componentName: 'AgSlider', componentClass: AgSlider },
  38326. { componentName: 'AgAngleSelect', componentClass: AgAngleSelect },
  38327. { componentName: 'AgColorPicker', componentClass: AgColorPicker },
  38328. { componentName: 'AgGridComp', componentClass: GridPanel },
  38329. { componentName: 'AgHeaderRoot', componentClass: HeaderRootComp },
  38330. { componentName: 'AgPagination', componentClass: PaginationComp },
  38331. { componentName: 'AgOverlayWrapper', componentClass: OverlayWrapperComponent },
  38332. { componentName: 'AgGroupComponent', componentClass: AgGroupComponent },
  38333. { componentName: 'AgPanel', componentClass: AgPanel },
  38334. { componentName: 'AgDialog', componentClass: AgDialog }
  38335. ];
  38336. var moduleAgStackComps = this.extractModuleEntity(registeredModules, function (module) { return module.agStackComponents ? module.agStackComponents : []; });
  38337. components = components.concat(moduleAgStackComps);
  38338. return components;
  38339. };
  38340. Grid.prototype.createBeansList = function (registeredModules) {
  38341. var rowModelClass = this.getRowModelClass(registeredModules);
  38342. if (!rowModelClass) {
  38343. return undefined;
  38344. }
  38345. // beans should only contain SERVICES, it should NEVER contain COMPONENTS
  38346. var beans = [
  38347. rowModelClass, Beans, RowPositionUtils, CellPositionUtils, HeaderPositionUtils,
  38348. PaginationAutoPageSizeService, GridApi, UserComponentRegistry, AgComponentUtils,
  38349. ComponentMetadataProvider, ResizeObserverService, UserComponentFactory,
  38350. MaxDivHeightScaler, AutoHeightCalculator, CellRendererFactory, HorizontalResizeService,
  38351. PinnedRowModel, DragService, DisplayedGroupCreator, EventService, GridOptionsWrapper,
  38352. PopupService, SelectionController, FilterManager, ColumnController, HeaderNavigationService,
  38353. PaginationProxy, RowRenderer, ExpressionService, ColumnFactory, TemplateService,
  38354. AlignedGridsService, NavigationService, ValueCache, ValueService, LoggerFactory,
  38355. ColumnUtils, AutoWidthCalculator, StandardMenuFactory, DragAndDropService, ColumnApi,
  38356. FocusController, MouseEventService, Environment, CellNavigationService, ValueFormatterService,
  38357. StylingService, ScrollVisibleService, SortController, ColumnHoverService, ColumnAnimationService,
  38358. SelectableService, AutoGroupColService, ChangeDetectionService, AnimationFrameService,
  38359. DetailRowCompCache, UndoRedoService, AgStackComponentsRegistry
  38360. ];
  38361. var moduleBeans = this.extractModuleEntity(registeredModules, function (module) { return module.beans ? module.beans : []; });
  38362. beans.push.apply(beans, moduleBeans);
  38363. // check for duplicates, as different modules could include the same beans that
  38364. // they depend on, eg ClientSideRowModel in enterprise, and ClientSideRowModel in community
  38365. var beansNoDuplicates = [];
  38366. beans.forEach(function (bean) {
  38367. if (beansNoDuplicates.indexOf(bean) < 0) {
  38368. beansNoDuplicates.push(bean);
  38369. }
  38370. });
  38371. return beansNoDuplicates;
  38372. };
  38373. Grid.prototype.extractModuleEntity = function (moduleEntities, extractor) {
  38374. return [].concat.apply([], moduleEntities.map(extractor));
  38375. };
  38376. Grid.prototype.setColumnsAndData = function () {
  38377. var gridOptionsWrapper = this.context.getBean('gridOptionsWrapper');
  38378. var columnController = this.context.getBean('columnController');
  38379. var columnDefs = gridOptionsWrapper.getColumnDefs();
  38380. if (_.exists(columnDefs)) {
  38381. columnController.setColumnDefs(columnDefs, "gridInitializing");
  38382. }
  38383. var rowModel = this.context.getBean('rowModel');
  38384. rowModel.start();
  38385. };
  38386. Grid.prototype.dispatchGridReadyEvent = function (gridOptions) {
  38387. var eventService = this.context.getBean('eventService');
  38388. var readyEvent = {
  38389. type: Events.EVENT_GRID_READY,
  38390. api: gridOptions.api,
  38391. columnApi: gridOptions.columnApi
  38392. };
  38393. eventService.dispatchEvent(readyEvent);
  38394. };
  38395. Grid.prototype.getRowModelClass = function (registeredModules) {
  38396. var rowModelType = this.gridOptions.rowModelType;
  38397. //TODO: temporary measure before 'enterprise' is completely removed (similar handling in gridOptionsWrapper is also required)
  38398. if (rowModelType === 'enterprise') {
  38399. console.warn("ag-Grid: enterprise rowModel deprecated. Should now be called server side row model instead.");
  38400. rowModelType = Constants.ROW_MODEL_TYPE_SERVER_SIDE;
  38401. }
  38402. if (rowModelType === 'normal') {
  38403. console.warn("ag-Grid: normal rowModel deprecated. Should now be called client side row model instead.");
  38404. rowModelType = Constants.ROW_MODEL_TYPE_CLIENT_SIDE;
  38405. }
  38406. // default to client side
  38407. if (!rowModelType) {
  38408. rowModelType = Constants.ROW_MODEL_TYPE_CLIENT_SIDE;
  38409. }
  38410. var rowModelClasses = {};
  38411. registeredModules.forEach(function (module) {
  38412. _.iterateObject(module.rowModels, function (key, value) {
  38413. rowModelClasses[key] = value;
  38414. });
  38415. });
  38416. var rowModelClass = rowModelClasses[rowModelType];
  38417. if (_.exists(rowModelClass)) {
  38418. return rowModelClass;
  38419. }
  38420. else {
  38421. if (rowModelType === Constants.ROW_MODEL_TYPE_INFINITE) {
  38422. console.error("ag-Grid: Row Model \"Infinite\" not found. Please ensure the " + exports.ModuleNames.InfiniteRowModelModule + " is registered.';");
  38423. }
  38424. console.error('ag-Grid: could not find matching row model for rowModelType ' + rowModelType);
  38425. if (rowModelType === Constants.ROW_MODEL_TYPE_VIEWPORT) {
  38426. console.error("ag-Grid: Row Model \"Viewport\" not found. Please ensure the ag-Grid Enterprise Module " + exports.ModuleNames.ViewportRowModelModule + " is registered.';");
  38427. }
  38428. if (rowModelType === Constants.ROW_MODEL_TYPE_SERVER_SIDE) {
  38429. console.error("ag-Grid: Row Model \"Server Side\" not found. Please ensure the ag-Grid Enterprise Module " + exports.ModuleNames.ServerSideRowModelModule + " is registered.';");
  38430. }
  38431. if (rowModelType === Constants.ROW_MODEL_TYPE_CLIENT_SIDE) {
  38432. console.error("ag-Grid: Row Model \"Client Side\" not found. Please ensure the " + exports.ModuleNames.ClientSideRowModelModule + " is registered.';");
  38433. }
  38434. return undefined;
  38435. }
  38436. };
  38437. Grid.prototype.destroy = function () {
  38438. this.gridOptions.api.destroy();
  38439. };
  38440. return Grid;
  38441. }());
  38442. /**
  38443. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  38444. * @version v23.2.1
  38445. * @link http://www.ag-grid.com/
  38446. * @license MIT
  38447. */
  38448. function initialiseAgGridWithAngular1(angular) {
  38449. var angularModule = angular.module("agGrid", []);
  38450. angularModule.directive("agGrid", function () {
  38451. return {
  38452. restrict: "A",
  38453. controller: ['$element', '$scope', '$compile', '$attrs', AngularDirectiveController],
  38454. scope: true
  38455. };
  38456. });
  38457. }
  38458. function AngularDirectiveController($element, $scope, $compile, $attrs) {
  38459. var gridOptions;
  38460. var quickFilterOnScope;
  38461. var keyOfGridInScope = $attrs.agGrid;
  38462. quickFilterOnScope = keyOfGridInScope + '.quickFilterText';
  38463. gridOptions = $scope.$eval(keyOfGridInScope);
  38464. if (!gridOptions) {
  38465. console.warn("WARNING - grid options for ag-Grid not found. Please ensure the attribute ag-grid points to a valid object on the scope");
  38466. return;
  38467. }
  38468. var eGridDiv = $element[0];
  38469. var gridParams = {
  38470. $scope: $scope,
  38471. $compile: $compile,
  38472. quickFilterOnScope: quickFilterOnScope
  38473. };
  38474. var grid = new Grid(eGridDiv, gridOptions, gridParams);
  38475. $scope.$on("$destroy", function () {
  38476. grid.destroy();
  38477. grid = null;
  38478. });
  38479. }
  38480. /**
  38481. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  38482. * @version v23.2.1
  38483. * @link http://www.ag-grid.com/
  38484. * @license MIT
  38485. */
  38486. var registered = false;
  38487. function initialiseAgGridWithWebComponents() {
  38488. console.warn('ag-grid: initialiseAgGridWithWebComponents is deprecated. Please use the ag-grid-webcomponent dependency instead. ');
  38489. // only register to WebComponents once
  38490. if (registered) {
  38491. return;
  38492. }
  38493. registered = true;
  38494. if (typeof document === 'undefined' || !document.registerElement) {
  38495. console.error('ag-Grid: unable to find document.registerElement() function, unable to initialise ag-Grid as a Web Component');
  38496. }
  38497. // i don't think this type of extension is possible in TypeScript, so back to
  38498. // plain Javascript to create this object
  38499. var AgileGridProto = Object.create(HTMLElement.prototype);
  38500. // wrap each property with a get and set method, so we can track when changes are done
  38501. ComponentUtil.ALL_PROPERTIES.forEach(function (key) {
  38502. Object.defineProperty(AgileGridProto, key, {
  38503. set: function (v) {
  38504. this.__agGridSetProperty(key, v);
  38505. },
  38506. get: function () {
  38507. return this.__agGridGetProperty(key);
  38508. },
  38509. enumerable: true,
  38510. configurable: true
  38511. });
  38512. });
  38513. var agGridProtoNoType = AgileGridProto;
  38514. agGridProtoNoType.__agGridSetProperty = function (key, value) {
  38515. if (!this.__attributes) {
  38516. this.__attributes = {};
  38517. }
  38518. this.__attributes[key] = value;
  38519. // keeping this consistent with the ng2 onChange, so I can reuse the handling code
  38520. var changeObject = {};
  38521. changeObject[key] = { currentValue: value };
  38522. this.onChange(changeObject);
  38523. };
  38524. agGridProtoNoType.onChange = function (changes) {
  38525. if (this._initialised) {
  38526. ComponentUtil.processOnChange(changes, this._gridOptions, this.api, this.columnApi);
  38527. }
  38528. };
  38529. agGridProtoNoType.__agGridGetProperty = function (key) {
  38530. if (!this.__attributes) {
  38531. this.__attributes = {};
  38532. }
  38533. return this.__attributes[key];
  38534. };
  38535. agGridProtoNoType.setGridOptions = function (options) {
  38536. var globalEventListener = this.globalEventListener.bind(this);
  38537. this._gridOptions = ComponentUtil.copyAttributesToGridOptions(options, this);
  38538. var gridParams = {
  38539. globalEventListener: globalEventListener
  38540. };
  38541. this._agGrid = new Grid(this, this._gridOptions, gridParams);
  38542. this.api = options.api;
  38543. this.columnApi = options.columnApi;
  38544. this._initialised = true;
  38545. };
  38546. // copies all the attributes into this object
  38547. agGridProtoNoType.createdCallback = function () {
  38548. for (var i = 0; i < this.attributes.length; i++) {
  38549. var attribute = this.attributes[i];
  38550. this.setPropertyFromAttribute(attribute);
  38551. }
  38552. };
  38553. agGridProtoNoType.setPropertyFromAttribute = function (attribute) {
  38554. var name = toCamelCase(attribute.nodeName);
  38555. var value = attribute.nodeValue;
  38556. if (ComponentUtil.ALL_PROPERTIES.indexOf(name) >= 0) {
  38557. this[name] = value;
  38558. }
  38559. };
  38560. agGridProtoNoType.attachedCallback = function (params) { };
  38561. agGridProtoNoType.detachedCallback = function (params) { };
  38562. agGridProtoNoType.attributeChangedCallback = function (attributeName) {
  38563. var attribute = this.attributes[attributeName];
  38564. this.setPropertyFromAttribute(attribute);
  38565. };
  38566. agGridProtoNoType.globalEventListener = function (eventType, event) {
  38567. var eventLowerCase = eventType.toLowerCase();
  38568. var browserEvent = new Event(eventLowerCase);
  38569. var browserEventNoType = browserEvent;
  38570. browserEventNoType.agGridDetails = event;
  38571. this.dispatchEvent(browserEvent);
  38572. var callbackMethod = 'on' + eventLowerCase;
  38573. if (typeof this[callbackMethod] === 'function') {
  38574. this[callbackMethod](browserEvent);
  38575. }
  38576. };
  38577. // finally, register
  38578. document.registerElement('ag-grid', { prototype: AgileGridProto });
  38579. }
  38580. function toCamelCase(myString) {
  38581. if (typeof myString === 'string') {
  38582. var result = myString.replace(/-([a-z])/g, function (g) {
  38583. return g[1].toUpperCase();
  38584. });
  38585. return result;
  38586. }
  38587. else {
  38588. return myString;
  38589. }
  38590. }
  38591. /**
  38592. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  38593. * @version v23.2.1
  38594. * @link http://www.ag-grid.com/
  38595. * @license MIT
  38596. */
  38597. var __extends$1Z = (undefined && undefined.__extends) || (function () {
  38598. var extendStatics = function (d, b) {
  38599. extendStatics = Object.setPrototypeOf ||
  38600. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  38601. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  38602. return extendStatics(d, b);
  38603. };
  38604. return function (d, b) {
  38605. extendStatics(d, b);
  38606. function __() { this.constructor = d; }
  38607. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  38608. };
  38609. })();
  38610. var __decorate$1S = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  38611. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  38612. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  38613. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  38614. return c > 3 && r && Object.defineProperty(target, key, r), r;
  38615. };
  38616. var TabbedLayout = /** @class */ (function (_super) {
  38617. __extends$1Z(TabbedLayout, _super);
  38618. function TabbedLayout(params) {
  38619. var _this = _super.call(this, TabbedLayout.getTemplate(params.cssClass)) || this;
  38620. _this.items = [];
  38621. _this.params = params;
  38622. if (params.items) {
  38623. params.items.forEach(function (item) { return _this.addItem(item); });
  38624. }
  38625. return _this;
  38626. }
  38627. TabbedLayout.getTemplate = function (cssClass) {
  38628. return /* html */ "<div class=\"ag-tabs " + cssClass + "\">\n <div ref=\"eHeader\" class=\"ag-tabs-header " + (cssClass ? cssClass + "-header" : '') + "\"></div>\n <div ref=\"eBody\" class=\"ag-tabs-body " + (cssClass ? cssClass + "-body" : '') + "\"></div>\n </div>";
  38629. };
  38630. TabbedLayout.prototype.handleKeyDown = function (e) {
  38631. switch (e.keyCode) {
  38632. case Constants.KEY_RIGHT:
  38633. case Constants.KEY_LEFT:
  38634. if (!this.eHeader.contains(document.activeElement)) {
  38635. return;
  38636. }
  38637. var currentPosition = this.items.indexOf(this.activeItem);
  38638. var nextPosition = e.keyCode === Constants.KEY_RIGHT ? Math.min(currentPosition + 1, this.items.length - 1) : Math.max(currentPosition - 1, 0);
  38639. if (currentPosition === nextPosition) {
  38640. return;
  38641. }
  38642. e.preventDefault();
  38643. var nextItem = this.items[nextPosition];
  38644. this.showItemWrapper(nextItem);
  38645. nextItem.eHeaderButton.focus();
  38646. break;
  38647. case Constants.KEY_UP:
  38648. case Constants.KEY_DOWN:
  38649. e.stopPropagation();
  38650. break;
  38651. }
  38652. };
  38653. TabbedLayout.prototype.onTabKeyDown = function (e) {
  38654. var _a = this, focusController = _a.focusController, eHeader = _a.eHeader, eBody = _a.eBody, activeItem = _a.activeItem;
  38655. var activeElement = document.activeElement;
  38656. var focusInHeader = eHeader.contains(activeElement);
  38657. e.preventDefault();
  38658. if (focusInHeader) {
  38659. if (e.shiftKey) {
  38660. focusController.focusLastFocusableElement(eBody);
  38661. }
  38662. else {
  38663. focusController.focusFirstFocusableElement(eBody);
  38664. }
  38665. }
  38666. else {
  38667. var isFocusManaged = focusController.isFocusUnderManagedComponent(eBody);
  38668. if (isFocusManaged) {
  38669. activeItem.eHeaderButton.focus();
  38670. }
  38671. else {
  38672. var nextEl = focusController.findNextFocusableElement(eBody, false, e.shiftKey);
  38673. if (nextEl) {
  38674. nextEl.focus();
  38675. }
  38676. else {
  38677. activeItem.eHeaderButton.focus();
  38678. }
  38679. }
  38680. }
  38681. };
  38682. TabbedLayout.prototype.setAfterAttachedParams = function (params) {
  38683. this.afterAttachedParams = params;
  38684. };
  38685. TabbedLayout.prototype.getMinDimensions = function () {
  38686. var eDummyContainer = this.getGui().cloneNode(true);
  38687. var eDummyBody = eDummyContainer.querySelector('[ref="eBody"]');
  38688. // position fixed, so it isn't restricted to the boundaries of the parent
  38689. eDummyContainer.style.position = 'fixed';
  38690. // we put the dummy into the body container, so it will inherit all the
  38691. // css styles that the real cells are inheriting
  38692. this.getGui().appendChild(eDummyContainer);
  38693. var minWidth = 0;
  38694. var minHeight = 0;
  38695. this.items.forEach(function (itemWrapper) {
  38696. _.clearElement(eDummyBody);
  38697. var eClone = itemWrapper.tabbedItem.bodyPromise.resolveNow(null, function (body) { return body.cloneNode(true); });
  38698. if (eClone == null) {
  38699. return;
  38700. }
  38701. eDummyBody.appendChild(eClone);
  38702. if (minWidth < eDummyContainer.offsetWidth) {
  38703. minWidth = eDummyContainer.offsetWidth;
  38704. }
  38705. if (minHeight < eDummyContainer.offsetHeight) {
  38706. minHeight = eDummyContainer.offsetHeight;
  38707. }
  38708. });
  38709. this.getGui().removeChild(eDummyContainer);
  38710. return { height: minHeight, width: minWidth };
  38711. };
  38712. TabbedLayout.prototype.showFirstItem = function () {
  38713. if (this.items.length > 0) {
  38714. this.showItemWrapper(this.items[0]);
  38715. }
  38716. };
  38717. TabbedLayout.prototype.addItem = function (item) {
  38718. var eHeaderButton = document.createElement('span');
  38719. eHeaderButton.tabIndex = -1;
  38720. eHeaderButton.appendChild(item.title);
  38721. _.addCssClass(eHeaderButton, 'ag-tab');
  38722. this.eHeader.appendChild(eHeaderButton);
  38723. eHeaderButton.setAttribute('aria-label', item.titleLabel);
  38724. var wrapper = {
  38725. tabbedItem: item,
  38726. eHeaderButton: eHeaderButton
  38727. };
  38728. this.items.push(wrapper);
  38729. eHeaderButton.addEventListener('click', this.showItemWrapper.bind(this, wrapper));
  38730. };
  38731. TabbedLayout.prototype.showItem = function (tabbedItem) {
  38732. var itemWrapper = _.find(this.items, function (wrapper) {
  38733. return wrapper.tabbedItem === tabbedItem;
  38734. });
  38735. if (itemWrapper) {
  38736. this.showItemWrapper(itemWrapper);
  38737. }
  38738. };
  38739. TabbedLayout.prototype.showItemWrapper = function (wrapper) {
  38740. var _this = this;
  38741. if (this.params.onItemClicked) {
  38742. this.params.onItemClicked({ item: wrapper.tabbedItem });
  38743. }
  38744. if (this.activeItem === wrapper) {
  38745. _.callIfPresent(this.params.onActiveItemClicked);
  38746. return;
  38747. }
  38748. _.clearElement(this.eBody);
  38749. wrapper.tabbedItem.bodyPromise.then(function (body) {
  38750. _this.eBody.appendChild(body);
  38751. var onlyUnmanaged = !_this.focusController.isKeyboardFocus();
  38752. _this.focusController.focusFirstFocusableElement(_this.eBody, onlyUnmanaged);
  38753. });
  38754. if (this.activeItem) {
  38755. _.removeCssClass(this.activeItem.eHeaderButton, 'ag-tab-selected');
  38756. }
  38757. _.addCssClass(wrapper.eHeaderButton, 'ag-tab-selected');
  38758. this.activeItem = wrapper;
  38759. if (wrapper.tabbedItem.afterAttachedCallback) {
  38760. wrapper.tabbedItem.afterAttachedCallback(this.afterAttachedParams);
  38761. }
  38762. };
  38763. __decorate$1S([
  38764. RefSelector('eHeader')
  38765. ], TabbedLayout.prototype, "eHeader", void 0);
  38766. __decorate$1S([
  38767. RefSelector('eBody')
  38768. ], TabbedLayout.prototype, "eBody", void 0);
  38769. return TabbedLayout;
  38770. }(ManagedFocusComponent));
  38771. /**
  38772. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  38773. * @version v23.2.1
  38774. * @link http://www.ag-grid.com/
  38775. * @license MIT
  38776. */
  38777. function simpleHttpRequest(params) {
  38778. return new Promise(function (resolve) {
  38779. var httpRequest = new XMLHttpRequest();
  38780. httpRequest.open('GET', params.url);
  38781. httpRequest.send();
  38782. httpRequest.onreadystatechange = function () {
  38783. if (httpRequest.readyState === 4 && httpRequest.status === 200) {
  38784. resolve(JSON.parse(httpRequest.responseText));
  38785. }
  38786. };
  38787. });
  38788. }
  38789. /**
  38790. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  38791. * @version v23.2.1
  38792. * @link http://www.ag-grid.com/
  38793. * @license MIT
  38794. */
  38795. var __extends$1_ = (undefined && undefined.__extends) || (function () {
  38796. var extendStatics = function (d, b) {
  38797. extendStatics = Object.setPrototypeOf ||
  38798. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  38799. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  38800. return extendStatics(d, b);
  38801. };
  38802. return function (d, b) {
  38803. extendStatics(d, b);
  38804. function __() { this.constructor = d; }
  38805. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  38806. };
  38807. })();
  38808. var __decorate$1T = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  38809. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  38810. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  38811. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  38812. return c > 3 && r && Object.defineProperty(target, key, r), r;
  38813. };
  38814. var RowNodeBlock = /** @class */ (function (_super) {
  38815. __extends$1_(RowNodeBlock, _super);
  38816. function RowNodeBlock(blockNumber, rowNodeCacheParams) {
  38817. var _this = _super.call(this) || this;
  38818. _this.version = 0;
  38819. _this.state = RowNodeBlock.STATE_DIRTY;
  38820. _this.rowNodeCacheParams = rowNodeCacheParams;
  38821. _this.blockNumber = blockNumber;
  38822. // we don't need to calculate these now, as the inputs don't change,
  38823. // however it makes the code easier to read if we work them out up front
  38824. _this.startRow = blockNumber * rowNodeCacheParams.blockSize;
  38825. _this.endRow = _this.startRow + rowNodeCacheParams.blockSize;
  38826. return _this;
  38827. }
  38828. RowNodeBlock.prototype.isAnyNodeOpen = function (rowCount) {
  38829. var result = false;
  38830. this.forEachNodeCallback(function (rowNode) {
  38831. if (rowNode.expanded) {
  38832. result = true;
  38833. }
  38834. }, rowCount);
  38835. return result;
  38836. };
  38837. RowNodeBlock.prototype.forEachNodeCallback = function (callback, rowCount) {
  38838. for (var rowIndex = this.startRow; rowIndex < this.endRow; rowIndex++) {
  38839. // we check against rowCount as this page may be the last one, and if it is, then
  38840. // the last rows are not part of the set
  38841. if (rowIndex < rowCount) {
  38842. var rowNode = this.getRowUsingLocalIndex(rowIndex);
  38843. callback(rowNode, rowIndex);
  38844. }
  38845. }
  38846. };
  38847. RowNodeBlock.prototype.forEachNode = function (callback, sequence, rowCount, deep) {
  38848. this.forEachNodeCallback(function (rowNode) {
  38849. callback(rowNode, sequence.next());
  38850. // this will only every happen for server side row model, as infinite
  38851. // row model doesn't have groups
  38852. if (deep && rowNode.childrenCache) {
  38853. rowNode.childrenCache.forEachNodeDeep(callback, sequence);
  38854. }
  38855. }, rowCount);
  38856. };
  38857. RowNodeBlock.prototype.forEachNodeDeep = function (callback, sequence, rowCount) {
  38858. this.forEachNode(callback, sequence, rowCount, true);
  38859. };
  38860. RowNodeBlock.prototype.forEachNodeShallow = function (callback, sequence, rowCount) {
  38861. this.forEachNode(callback, sequence, rowCount, false);
  38862. };
  38863. RowNodeBlock.prototype.getVersion = function () {
  38864. return this.version;
  38865. };
  38866. RowNodeBlock.prototype.getLastAccessed = function () {
  38867. return this.lastAccessed;
  38868. };
  38869. RowNodeBlock.prototype.getRowUsingLocalIndex = function (rowIndex, dontTouchLastAccessed) {
  38870. if (dontTouchLastAccessed === void 0) { dontTouchLastAccessed = false; }
  38871. if (!dontTouchLastAccessed) {
  38872. this.lastAccessed = this.rowNodeCacheParams.lastAccessedSequence.next();
  38873. }
  38874. var localIndex = rowIndex - this.startRow;
  38875. return this.rowNodes[localIndex];
  38876. };
  38877. RowNodeBlock.prototype.init = function (beans) {
  38878. this.beans = beans;
  38879. this.createRowNodes();
  38880. };
  38881. RowNodeBlock.prototype.getStartRow = function () {
  38882. return this.startRow;
  38883. };
  38884. RowNodeBlock.prototype.getEndRow = function () {
  38885. return this.endRow;
  38886. };
  38887. RowNodeBlock.prototype.getBlockNumber = function () {
  38888. return this.blockNumber;
  38889. };
  38890. RowNodeBlock.prototype.setDirty = function () {
  38891. // in case any current loads in progress, this will have their results ignored
  38892. this.version++;
  38893. this.state = RowNodeBlock.STATE_DIRTY;
  38894. };
  38895. RowNodeBlock.prototype.setDirtyAndPurge = function () {
  38896. this.setDirty();
  38897. this.rowNodes.forEach(function (rowNode) {
  38898. rowNode.setData(null);
  38899. });
  38900. };
  38901. RowNodeBlock.prototype.getState = function () {
  38902. return this.state;
  38903. };
  38904. RowNodeBlock.prototype.setRowNode = function (rowIndex, rowNode) {
  38905. var localIndex = rowIndex - this.startRow;
  38906. this.rowNodes[localIndex] = rowNode;
  38907. };
  38908. RowNodeBlock.prototype.setBlankRowNode = function (rowIndex) {
  38909. var localIndex = rowIndex - this.startRow;
  38910. var newRowNode = this.createBlankRowNode(rowIndex);
  38911. this.rowNodes[localIndex] = newRowNode;
  38912. return newRowNode;
  38913. };
  38914. RowNodeBlock.prototype.setNewData = function (rowIndex, dataItem) {
  38915. var newRowNode = this.setBlankRowNode(rowIndex);
  38916. this.setDataAndId(newRowNode, dataItem, this.startRow + rowIndex);
  38917. return newRowNode;
  38918. };
  38919. RowNodeBlock.prototype.createBlankRowNode = function (rowIndex) {
  38920. var rowNode = new RowNode();
  38921. this.beans.context.createBean(rowNode);
  38922. rowNode.setRowHeight(this.rowNodeCacheParams.rowHeight);
  38923. return rowNode;
  38924. };
  38925. // creates empty row nodes, data is missing as not loaded yet
  38926. RowNodeBlock.prototype.createRowNodes = function () {
  38927. this.rowNodes = [];
  38928. for (var i = 0; i < this.rowNodeCacheParams.blockSize; i++) {
  38929. var rowIndex = this.startRow + i;
  38930. var rowNode = this.createBlankRowNode(rowIndex);
  38931. this.rowNodes.push(rowNode);
  38932. }
  38933. };
  38934. RowNodeBlock.prototype.load = function () {
  38935. this.state = RowNodeBlock.STATE_LOADING;
  38936. this.loadFromDatasource();
  38937. };
  38938. RowNodeBlock.prototype.pageLoadFailed = function () {
  38939. this.state = RowNodeBlock.STATE_FAILED;
  38940. var event = {
  38941. type: RowNodeBlock.EVENT_LOAD_COMPLETE,
  38942. success: false,
  38943. page: this,
  38944. lastRow: null
  38945. };
  38946. this.dispatchEvent(event);
  38947. };
  38948. RowNodeBlock.prototype.populateWithRowData = function (rows) {
  38949. var _this = this;
  38950. var rowNodesToRefresh = [];
  38951. this.rowNodes.forEach(function (rowNode, index) {
  38952. var data = rows[index];
  38953. if (rowNode.stub) {
  38954. rowNodesToRefresh.push(rowNode);
  38955. }
  38956. _this.setDataAndId(rowNode, data, _this.startRow + index);
  38957. });
  38958. if (rowNodesToRefresh.length > 0) {
  38959. this.beans.rowRenderer.redrawRows(rowNodesToRefresh);
  38960. }
  38961. };
  38962. RowNodeBlock.prototype.destroyRowNodes = function () {
  38963. var _this = this;
  38964. this.rowNodes.forEach(function (rowNode) {
  38965. if (rowNode.childrenCache) {
  38966. _this.destroyBean(rowNode.childrenCache);
  38967. rowNode.childrenCache = null;
  38968. }
  38969. // this is needed, so row render knows to fade out the row, otherwise it
  38970. // sees row top is present, and thinks the row should be shown. maybe
  38971. // rowNode should have a flag on whether it is visible???
  38972. rowNode.clearRowTop();
  38973. });
  38974. };
  38975. RowNodeBlock.prototype.pageLoaded = function (version, rows, lastRow) {
  38976. // we need to check the version, in case there was an old request
  38977. // from the server that was sent before we refreshed the cache,
  38978. // if the load was done as a result of a cache refresh
  38979. if (version === this.version) {
  38980. this.state = RowNodeBlock.STATE_LOADED;
  38981. this.populateWithRowData(rows);
  38982. }
  38983. lastRow = _.cleanNumber(lastRow);
  38984. // check here if lastRow should be set
  38985. var event = {
  38986. type: RowNodeBlock.EVENT_LOAD_COMPLETE,
  38987. success: true,
  38988. page: this,
  38989. lastRow: lastRow
  38990. };
  38991. this.dispatchEvent(event);
  38992. };
  38993. RowNodeBlock.EVENT_LOAD_COMPLETE = 'loadComplete';
  38994. RowNodeBlock.STATE_DIRTY = 'dirty';
  38995. RowNodeBlock.STATE_LOADING = 'loading';
  38996. RowNodeBlock.STATE_LOADED = 'loaded';
  38997. RowNodeBlock.STATE_FAILED = 'failed';
  38998. __decorate$1T([
  38999. PreDestroy
  39000. ], RowNodeBlock.prototype, "destroyRowNodes", null);
  39001. return RowNodeBlock;
  39002. }(BeanStub));
  39003. /**
  39004. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  39005. * @version v23.2.1
  39006. * @link http://www.ag-grid.com/
  39007. * @license MIT
  39008. */
  39009. var __extends$1$ = (undefined && undefined.__extends) || (function () {
  39010. var extendStatics = function (d, b) {
  39011. extendStatics = Object.setPrototypeOf ||
  39012. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  39013. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  39014. return extendStatics(d, b);
  39015. };
  39016. return function (d, b) {
  39017. extendStatics(d, b);
  39018. function __() { this.constructor = d; }
  39019. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  39020. };
  39021. })();
  39022. var __decorate$1U = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  39023. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  39024. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  39025. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  39026. return c > 3 && r && Object.defineProperty(target, key, r), r;
  39027. };
  39028. var __param$9 = (undefined && undefined.__param) || function (paramIndex, decorator) {
  39029. return function (target, key) { decorator(target, key, paramIndex); }
  39030. };
  39031. var RowNodeBlockLoader = /** @class */ (function (_super) {
  39032. __extends$1$(RowNodeBlockLoader, _super);
  39033. function RowNodeBlockLoader(maxConcurrentRequests, blockLoadDebounceMillis) {
  39034. var _this = _super.call(this) || this;
  39035. _this.activeBlockLoadsCount = 0;
  39036. _this.blocks = [];
  39037. _this.active = true;
  39038. _this.maxConcurrentRequests = maxConcurrentRequests;
  39039. if (blockLoadDebounceMillis && blockLoadDebounceMillis > 0) {
  39040. _this.checkBlockToLoadDebounce = _.debounce(_this.performCheckBlocksToLoad.bind(_this), blockLoadDebounceMillis);
  39041. }
  39042. return _this;
  39043. }
  39044. RowNodeBlockLoader.prototype.setBeans = function (loggerFactory) {
  39045. this.logger = loggerFactory.create('RowNodeBlockLoader');
  39046. };
  39047. RowNodeBlockLoader.prototype.addBlock = function (block) {
  39048. this.blocks.push(block);
  39049. };
  39050. RowNodeBlockLoader.prototype.removeBlock = function (block) {
  39051. _.removeFromArray(this.blocks, block);
  39052. };
  39053. RowNodeBlockLoader.prototype.destroy = function () {
  39054. _super.prototype.destroy.call(this);
  39055. this.active = false;
  39056. };
  39057. RowNodeBlockLoader.prototype.loadComplete = function () {
  39058. this.activeBlockLoadsCount--;
  39059. };
  39060. RowNodeBlockLoader.prototype.checkBlockToLoad = function () {
  39061. if (this.checkBlockToLoadDebounce) {
  39062. this.checkBlockToLoadDebounce();
  39063. }
  39064. else {
  39065. this.performCheckBlocksToLoad();
  39066. }
  39067. };
  39068. RowNodeBlockLoader.prototype.performCheckBlocksToLoad = function () {
  39069. if (!this.active) {
  39070. return;
  39071. }
  39072. this.printCacheStatus();
  39073. if (this.activeBlockLoadsCount >= this.maxConcurrentRequests) {
  39074. this.logger.log("checkBlockToLoad: max loads exceeded");
  39075. return;
  39076. }
  39077. var blockToLoad = null;
  39078. this.blocks.forEach(function (block) {
  39079. if (block.getState() === RowNodeBlock.STATE_DIRTY) {
  39080. blockToLoad = block;
  39081. }
  39082. });
  39083. if (blockToLoad) {
  39084. blockToLoad.load();
  39085. this.activeBlockLoadsCount++;
  39086. this.logger.log("checkBlockToLoad: loading page " + blockToLoad.getBlockNumber());
  39087. this.printCacheStatus();
  39088. }
  39089. else {
  39090. this.logger.log("checkBlockToLoad: no pages to load");
  39091. }
  39092. };
  39093. RowNodeBlockLoader.prototype.getBlockState = function () {
  39094. var result = {};
  39095. this.blocks.forEach(function (block) {
  39096. var nodeIdPrefix = block.getNodeIdPrefix();
  39097. var stateItem = {
  39098. blockNumber: block.getBlockNumber(),
  39099. startRow: block.getStartRow(),
  39100. endRow: block.getEndRow(),
  39101. pageStatus: block.getState()
  39102. };
  39103. if (_.exists(nodeIdPrefix)) {
  39104. result[nodeIdPrefix + block.getBlockNumber()] = stateItem;
  39105. }
  39106. else {
  39107. result[block.getBlockNumber()] = stateItem;
  39108. }
  39109. });
  39110. return result;
  39111. };
  39112. RowNodeBlockLoader.prototype.printCacheStatus = function () {
  39113. if (this.logger.isLogging()) {
  39114. this.logger.log("printCacheStatus: activePageLoadsCount = " + this.activeBlockLoadsCount + ","
  39115. + (" blocks = " + JSON.stringify(this.getBlockState())));
  39116. }
  39117. };
  39118. RowNodeBlockLoader.prototype.isLoading = function () {
  39119. return this.activeBlockLoadsCount > 0;
  39120. };
  39121. __decorate$1U([
  39122. __param$9(0, Qualifier('loggerFactory'))
  39123. ], RowNodeBlockLoader.prototype, "setBeans", null);
  39124. return RowNodeBlockLoader;
  39125. }(BeanStub));
  39126. /**
  39127. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  39128. * @version v23.2.1
  39129. * @link http://www.ag-grid.com/
  39130. * @license MIT
  39131. */
  39132. var __extends$20 = (undefined && undefined.__extends) || (function () {
  39133. var extendStatics = function (d, b) {
  39134. extendStatics = Object.setPrototypeOf ||
  39135. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  39136. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  39137. return extendStatics(d, b);
  39138. };
  39139. return function (d, b) {
  39140. extendStatics(d, b);
  39141. function __() { this.constructor = d; }
  39142. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  39143. };
  39144. })();
  39145. var __decorate$1V = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  39146. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  39147. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  39148. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  39149. return c > 3 && r && Object.defineProperty(target, key, r), r;
  39150. };
  39151. var RowNodeCache = /** @class */ (function (_super) {
  39152. __extends$20(RowNodeCache, _super);
  39153. function RowNodeCache(cacheParams) {
  39154. var _this = _super.call(this) || this;
  39155. _this.maxRowFound = false;
  39156. _this.blocks = {};
  39157. _this.blockCount = 0;
  39158. _this.virtualRowCount = cacheParams.initialRowCount;
  39159. _this.cacheParams = cacheParams;
  39160. return _this;
  39161. }
  39162. RowNodeCache.prototype.destroyAllBlocks = function () {
  39163. var _this = this;
  39164. this.forEachBlockInOrder(function (block) { return _this.destroyBlock(block); });
  39165. };
  39166. RowNodeCache.prototype.init = function () {
  39167. var _this = this;
  39168. this.active = true;
  39169. this.addDestroyFunc(function () { return _this.active = false; });
  39170. };
  39171. RowNodeCache.prototype.isActive = function () {
  39172. return this.active;
  39173. };
  39174. RowNodeCache.prototype.getVirtualRowCount = function () {
  39175. return this.virtualRowCount;
  39176. };
  39177. RowNodeCache.prototype.hack_setVirtualRowCount = function (virtualRowCount) {
  39178. this.virtualRowCount = virtualRowCount;
  39179. };
  39180. RowNodeCache.prototype.isMaxRowFound = function () {
  39181. return this.maxRowFound;
  39182. };
  39183. // listener on EVENT_LOAD_COMPLETE
  39184. RowNodeCache.prototype.onPageLoaded = function (event) {
  39185. this.cacheParams.rowNodeBlockLoader.loadComplete();
  39186. this.checkBlockToLoad();
  39187. // if we are not active, then we ignore all events, otherwise we could end up getting the
  39188. // grid to refresh even though we are no longer the active cache
  39189. if (!this.isActive()) {
  39190. return;
  39191. }
  39192. this.logger.log("onPageLoaded: page = " + event.page.getBlockNumber() + ", lastRow = " + event.lastRow);
  39193. if (event.success) {
  39194. this.checkVirtualRowCount(event.page, event.lastRow);
  39195. }
  39196. };
  39197. RowNodeCache.prototype.purgeBlocksIfNeeded = function (blockToExclude) {
  39198. var _this = this;
  39199. // put all candidate blocks into a list for sorting
  39200. var blocksForPurging = [];
  39201. this.forEachBlockInOrder(function (block) {
  39202. // we exclude checking for the page just created, as this has yet to be accessed and hence
  39203. // the lastAccessed stamp will not be updated for the first time yet
  39204. if (block === blockToExclude) {
  39205. return;
  39206. }
  39207. blocksForPurging.push(block);
  39208. });
  39209. // note: need to verify that this sorts items in the right order
  39210. blocksForPurging.sort(function (a, b) { return b.getLastAccessed() - a.getLastAccessed(); });
  39211. // we remove (maxBlocksInCache - 1) as we already excluded the 'just created' page.
  39212. // in other words, after the splice operation below, we have taken out the blocks
  39213. // we want to keep, which means we are left with blocks that we can potentially purge
  39214. var maxBlocksProvided = this.cacheParams.maxBlocksInCache > 0;
  39215. var blocksToKeep = maxBlocksProvided ? this.cacheParams.maxBlocksInCache - 1 : null;
  39216. var emptyBlocksToKeep = RowNodeCache.MAX_EMPTY_BLOCKS_TO_KEEP - 1;
  39217. blocksForPurging.forEach(function (block, index) {
  39218. var purgeBecauseBlockEmpty = block.getState() === RowNodeBlock.STATE_DIRTY && index >= emptyBlocksToKeep;
  39219. var purgeBecauseCacheFull = maxBlocksProvided ? index >= blocksToKeep : false;
  39220. if (purgeBecauseBlockEmpty || purgeBecauseCacheFull) {
  39221. // we never purge blocks if they are open, as purging them would mess up with
  39222. // our indexes, it would be very messy to restore the purged block to it's
  39223. // previous state if it had open children (and what if open children of open
  39224. // children, jeeeesus, just thinking about it freaks me out) so best is have a
  39225. // rule, if block is open, we never purge.
  39226. if (block.isAnyNodeOpen(_this.virtualRowCount)) {
  39227. return;
  39228. }
  39229. // if the block currently has rows been displayed, then don't remove it either.
  39230. // this can happen if user has maxBlocks=2, and blockSize=5 (thus 10 max rows in cache)
  39231. // but the screen is showing 20 rows, so at least 4 blocks are needed.
  39232. if (_this.isBlockCurrentlyDisplayed(block)) {
  39233. return;
  39234. }
  39235. // at this point, block is not needed, and no open nodes, so burn baby burn
  39236. _this.removeBlockFromCache(block);
  39237. }
  39238. });
  39239. };
  39240. RowNodeCache.prototype.isBlockCurrentlyDisplayed = function (block) {
  39241. var firstViewportRow = this.rowRenderer.getFirstVirtualRenderedRow();
  39242. var lastViewportRow = this.rowRenderer.getLastVirtualRenderedRow();
  39243. var firstRowIndex = block.getDisplayIndexStart();
  39244. var lastRowIndex = block.getDisplayIndexEnd() - 1;
  39245. // parent closed means the parent node is not expanded, thus these blocks are not visible
  39246. var parentClosed = firstRowIndex == null || lastRowIndex == null;
  39247. if (parentClosed) {
  39248. return false;
  39249. }
  39250. var blockBeforeViewport = firstRowIndex > lastViewportRow;
  39251. var blockAfterViewport = lastRowIndex < firstViewportRow;
  39252. var blockInsideViewport = !blockBeforeViewport && !blockAfterViewport;
  39253. return blockInsideViewport;
  39254. };
  39255. RowNodeCache.prototype.postCreateBlock = function (newBlock) {
  39256. newBlock.addEventListener(RowNodeBlock.EVENT_LOAD_COMPLETE, this.onPageLoaded.bind(this));
  39257. this.setBlock(newBlock.getBlockNumber(), newBlock);
  39258. this.purgeBlocksIfNeeded(newBlock);
  39259. this.checkBlockToLoad();
  39260. };
  39261. RowNodeCache.prototype.removeBlockFromCache = function (blockToRemove) {
  39262. if (!blockToRemove) {
  39263. return;
  39264. }
  39265. this.destroyBlock(blockToRemove);
  39266. // we do not want to remove the 'loaded' event listener, as the
  39267. // concurrent loads count needs to be updated when the load is complete
  39268. // if the purged page is in loading state
  39269. };
  39270. // gets called after: 1) block loaded 2) block created 3) cache refresh
  39271. RowNodeCache.prototype.checkBlockToLoad = function () {
  39272. this.cacheParams.rowNodeBlockLoader.checkBlockToLoad();
  39273. };
  39274. RowNodeCache.prototype.checkVirtualRowCount = function (block, lastRow) {
  39275. // if client provided a last row, we always use it, as it could change between server calls
  39276. // if user deleted data and then called refresh on the grid.
  39277. if (typeof lastRow === 'number' && lastRow >= 0) {
  39278. this.virtualRowCount = lastRow;
  39279. this.maxRowFound = true;
  39280. this.onCacheUpdated();
  39281. }
  39282. else if (!this.maxRowFound) {
  39283. // otherwise, see if we need to add some virtual rows
  39284. var lastRowIndex = (block.getBlockNumber() + 1) * this.cacheParams.blockSize;
  39285. var lastRowIndexPlusOverflow = lastRowIndex + this.cacheParams.overflowSize;
  39286. if (this.virtualRowCount < lastRowIndexPlusOverflow) {
  39287. this.virtualRowCount = lastRowIndexPlusOverflow;
  39288. this.onCacheUpdated();
  39289. }
  39290. else if (this.cacheParams.dynamicRowHeight) {
  39291. // the only other time is if dynamic row height, as loading rows
  39292. // will change the height of the block, given the height of the rows
  39293. // is only known after the row is loaded.
  39294. this.onCacheUpdated();
  39295. }
  39296. }
  39297. };
  39298. RowNodeCache.prototype.setVirtualRowCount = function (rowCount, maxRowFound) {
  39299. this.virtualRowCount = rowCount;
  39300. // if undefined is passed, we do not set this value, if one of {true,false}
  39301. // is passed, we do set the value.
  39302. if (_.exists(maxRowFound)) {
  39303. this.maxRowFound = maxRowFound;
  39304. }
  39305. // if we are still searching, then the row count must not end at the end
  39306. // of a particular page, otherwise the searching will not pop into the
  39307. // next page
  39308. if (!this.maxRowFound) {
  39309. if (this.virtualRowCount % this.cacheParams.blockSize === 0) {
  39310. this.virtualRowCount++;
  39311. }
  39312. }
  39313. this.onCacheUpdated();
  39314. };
  39315. RowNodeCache.prototype.forEachNodeDeep = function (callback, sequence) {
  39316. var _this = this;
  39317. if (sequence === void 0) { sequence = new NumberSequence(); }
  39318. this.forEachBlockInOrder(function (block) {
  39319. block.forEachNodeDeep(callback, sequence, _this.virtualRowCount);
  39320. });
  39321. };
  39322. RowNodeCache.prototype.forEachBlockInOrder = function (callback) {
  39323. var ids = this.getBlockIdsSorted();
  39324. this.forEachBlockId(ids, callback);
  39325. };
  39326. RowNodeCache.prototype.forEachBlockInReverseOrder = function (callback) {
  39327. var ids = this.getBlockIdsSorted().reverse();
  39328. this.forEachBlockId(ids, callback);
  39329. };
  39330. RowNodeCache.prototype.forEachBlockId = function (ids, callback) {
  39331. var _this = this;
  39332. ids.forEach(function (id) {
  39333. var block = _this.blocks[id];
  39334. callback(block, id);
  39335. });
  39336. };
  39337. RowNodeCache.prototype.getBlockIdsSorted = function () {
  39338. // get all page id's as NUMBERS (not strings, as we need to sort as numbers) and in descending order
  39339. var numberComparator = function (a, b) { return a - b; }; // default comparator for array is string comparison
  39340. var blockIds = Object.keys(this.blocks).map(function (idStr) { return parseInt(idStr, 10); }).sort(numberComparator);
  39341. return blockIds;
  39342. };
  39343. RowNodeCache.prototype.getBlock = function (blockId) {
  39344. return this.blocks[blockId];
  39345. };
  39346. RowNodeCache.prototype.setBlock = function (id, block) {
  39347. this.blocks[id] = block;
  39348. this.blockCount++;
  39349. this.cacheParams.rowNodeBlockLoader.addBlock(block);
  39350. };
  39351. RowNodeCache.prototype.destroyBlock = function (block) {
  39352. delete this.blocks[block.getBlockNumber()];
  39353. this.destroyBean(block);
  39354. this.blockCount--;
  39355. this.cacheParams.rowNodeBlockLoader.removeBlock(block);
  39356. };
  39357. // gets called 1) row count changed 2) cache purged 3) items inserted
  39358. RowNodeCache.prototype.onCacheUpdated = function () {
  39359. if (this.isActive()) {
  39360. // if the virtualRowCount is shortened, then it's possible blocks exist that are no longer
  39361. // in the valid range. so we must remove these. this can happen if user explicitly sets
  39362. // the virtual row count, or the datasource returns a result and sets lastRow to something
  39363. // less than virtualRowCount (can happen if user scrolls down, server reduces dataset size).
  39364. this.destroyAllBlocksPastVirtualRowCount();
  39365. // this results in both row models (infinite and server side) firing ModelUpdated,
  39366. // however server side row model also updates the row indexes first
  39367. var event_1 = {
  39368. type: RowNodeCache.EVENT_CACHE_UPDATED
  39369. };
  39370. this.dispatchEvent(event_1);
  39371. }
  39372. };
  39373. RowNodeCache.prototype.destroyAllBlocksPastVirtualRowCount = function () {
  39374. var _this = this;
  39375. var blocksToDestroy = [];
  39376. this.forEachBlockInOrder(function (block, id) {
  39377. var startRow = id * _this.cacheParams.blockSize;
  39378. if (startRow >= _this.virtualRowCount) {
  39379. blocksToDestroy.push(block);
  39380. }
  39381. });
  39382. if (blocksToDestroy.length > 0) {
  39383. blocksToDestroy.forEach(function (block) { return _this.destroyBlock(block); });
  39384. }
  39385. };
  39386. RowNodeCache.prototype.purgeCache = function () {
  39387. var _this = this;
  39388. this.forEachBlockInOrder(function (block) { return _this.removeBlockFromCache(block); });
  39389. this.maxRowFound = false;
  39390. // if zero rows in the cache, we need to get the SSRM to start asking for rows again.
  39391. // otherwise if set to zero rows last time, and we don't update the row count, then after
  39392. // the purge there will still be zero rows, meaning the SRRM won't request any rows.
  39393. // to kick things off, at lest one row needs to be asked for.
  39394. if (this.virtualRowCount === 0) {
  39395. this.virtualRowCount = this.cacheParams.initialRowCount;
  39396. }
  39397. this.onCacheUpdated();
  39398. };
  39399. RowNodeCache.prototype.getRowNodesInRange = function (firstInRange, lastInRange) {
  39400. var _this = this;
  39401. var result = [];
  39402. var lastBlockId = -1;
  39403. var inActiveRange = false;
  39404. var numberSequence = new NumberSequence();
  39405. // if only one node passed, we start the selection at the top
  39406. if (_.missing(firstInRange)) {
  39407. inActiveRange = true;
  39408. }
  39409. var foundGapInSelection = false;
  39410. this.forEachBlockInOrder(function (block, id) {
  39411. if (foundGapInSelection) {
  39412. return;
  39413. }
  39414. if (inActiveRange && (lastBlockId + 1 !== id)) {
  39415. foundGapInSelection = true;
  39416. return;
  39417. }
  39418. lastBlockId = id;
  39419. block.forEachNodeShallow(function (rowNode) {
  39420. var hitFirstOrLast = rowNode === firstInRange || rowNode === lastInRange;
  39421. if (inActiveRange || hitFirstOrLast) {
  39422. result.push(rowNode);
  39423. }
  39424. if (hitFirstOrLast) {
  39425. inActiveRange = !inActiveRange;
  39426. }
  39427. }, numberSequence, _this.virtualRowCount);
  39428. });
  39429. // inActiveRange will be still true if we never hit the second rowNode
  39430. var invalidRange = foundGapInSelection || inActiveRange;
  39431. return invalidRange ? [] : result;
  39432. };
  39433. RowNodeCache.EVENT_CACHE_UPDATED = 'cacheUpdated';
  39434. // this property says how many empty blocks should be in a cache, eg if scrolls down fast and creates 10
  39435. // blocks all for loading, the grid will only load the last 2 - it will assume the blocks the user quickly
  39436. // scrolled over are not needed to be loaded.
  39437. RowNodeCache.MAX_EMPTY_BLOCKS_TO_KEEP = 2;
  39438. __decorate$1V([
  39439. Autowired('rowRenderer')
  39440. ], RowNodeCache.prototype, "rowRenderer", void 0);
  39441. __decorate$1V([
  39442. PreDestroy
  39443. ], RowNodeCache.prototype, "destroyAllBlocks", null);
  39444. __decorate$1V([
  39445. PostConstruct
  39446. ], RowNodeCache.prototype, "init", null);
  39447. return RowNodeCache;
  39448. }(BeanStub));
  39449. /**
  39450. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  39451. * @version v23.2.1
  39452. * @link http://www.ag-grid.com/
  39453. * @license MIT
  39454. */
  39455. var __extends$21 = (undefined && undefined.__extends) || (function () {
  39456. var extendStatics = function (d, b) {
  39457. extendStatics = Object.setPrototypeOf ||
  39458. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  39459. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  39460. return extendStatics(d, b);
  39461. };
  39462. return function (d, b) {
  39463. extendStatics(d, b);
  39464. function __() { this.constructor = d; }
  39465. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  39466. };
  39467. })();
  39468. var __decorate$1W = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  39469. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  39470. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  39471. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  39472. return c > 3 && r && Object.defineProperty(target, key, r), r;
  39473. };
  39474. var VirtualList = /** @class */ (function (_super) {
  39475. __extends$21(VirtualList, _super);
  39476. function VirtualList(cssIdentifier) {
  39477. if (cssIdentifier === void 0) { cssIdentifier = 'default'; }
  39478. var _this = _super.call(this, VirtualList.getTemplate(cssIdentifier)) || this;
  39479. _this.cssIdentifier = cssIdentifier;
  39480. _this.renderedRows = new Map();
  39481. _this.rowHeight = 20;
  39482. return _this;
  39483. }
  39484. VirtualList.prototype.postConstruct = function () {
  39485. this.addScrollListener();
  39486. this.rowHeight = this.getItemHeight();
  39487. _super.prototype.postConstruct.call(this);
  39488. };
  39489. VirtualList.prototype.isFocusableContainer = function () {
  39490. return true;
  39491. };
  39492. VirtualList.prototype.focusInnerElement = function (fromBottom) {
  39493. var rowCount = this.model.getRowCount();
  39494. this.focusRow(fromBottom ? rowCount - 1 : 0);
  39495. };
  39496. VirtualList.prototype.onFocusIn = function (e) {
  39497. _super.prototype.onFocusIn.call(this, e);
  39498. var target = e.target;
  39499. if (_.containsClass(target, 'ag-virtual-list-item')) {
  39500. this.lastFocusedRow = parseInt(target.getAttribute('aria-rowindex'), 10) - 1;
  39501. }
  39502. };
  39503. VirtualList.prototype.onFocusOut = function (e) {
  39504. _super.prototype.onFocusOut.call(this, e);
  39505. if (!this.getFocusableElement().contains(e.relatedTarget)) {
  39506. this.lastFocusedRow = null;
  39507. }
  39508. };
  39509. VirtualList.prototype.handleKeyDown = function (e) {
  39510. switch (e.keyCode) {
  39511. case Constants.KEY_UP:
  39512. case Constants.KEY_DOWN:
  39513. case Constants.KEY_TAB:
  39514. if (this.navigate(e.keyCode === Constants.KEY_UP ||
  39515. (e.keyCode === Constants.KEY_TAB && e.shiftKey))) {
  39516. e.preventDefault();
  39517. }
  39518. break;
  39519. }
  39520. };
  39521. VirtualList.prototype.navigate = function (up) {
  39522. if (!_.exists(this.lastFocusedRow)) {
  39523. return false;
  39524. }
  39525. var nextRow = this.lastFocusedRow + (up ? -1 : 1);
  39526. if (nextRow < 0 || nextRow >= this.model.getRowCount()) {
  39527. return false;
  39528. }
  39529. this.focusRow(nextRow);
  39530. return true;
  39531. };
  39532. VirtualList.prototype.getLastFocusedRow = function () {
  39533. return this.lastFocusedRow;
  39534. };
  39535. VirtualList.prototype.focusRow = function (rowNumber) {
  39536. var _this = this;
  39537. this.ensureIndexVisible(rowNumber);
  39538. window.setTimeout(function () {
  39539. var renderedRow = _this.renderedRows.get(rowNumber);
  39540. if (renderedRow) {
  39541. renderedRow.eDiv.focus();
  39542. }
  39543. }, 10);
  39544. };
  39545. VirtualList.prototype.getComponentAt = function (rowIndex) {
  39546. var comp = this.renderedRows.get(rowIndex);
  39547. return comp && comp.rowComponent;
  39548. };
  39549. VirtualList.getTemplate = function (cssIdentifier) {
  39550. return /* html */ "\n <div class=\"ag-virtual-list-viewport ag-" + cssIdentifier + "-virtual-list-viewport\">\n <div class=\"ag-virtual-list-container ag-" + cssIdentifier + "-virtual-list-container\" ref=\"eContainer\"></div>\n </div>";
  39551. };
  39552. VirtualList.prototype.getItemHeight = function () {
  39553. return this.gridOptionsWrapper.getListItemHeight();
  39554. };
  39555. VirtualList.prototype.ensureIndexVisible = function (index) {
  39556. var lastRow = this.model.getRowCount();
  39557. if (typeof index !== 'number' || index < 0 || index >= lastRow) {
  39558. console.warn('invalid row index for ensureIndexVisible: ' + index);
  39559. return;
  39560. }
  39561. var rowTopPixel = index * this.rowHeight;
  39562. var rowBottomPixel = rowTopPixel + this.rowHeight;
  39563. var eGui = this.getGui();
  39564. var viewportTopPixel = eGui.scrollTop;
  39565. var viewportHeight = eGui.offsetHeight;
  39566. var viewportBottomPixel = viewportTopPixel + viewportHeight;
  39567. var viewportScrolledPastRow = viewportTopPixel > rowTopPixel;
  39568. var viewportScrolledBeforeRow = viewportBottomPixel < rowBottomPixel;
  39569. if (viewportScrolledPastRow) {
  39570. // if row is before, scroll up with row at top
  39571. eGui.scrollTop = rowTopPixel;
  39572. }
  39573. else if (viewportScrolledBeforeRow) {
  39574. // if row is below, scroll down with row at bottom
  39575. var newScrollPosition = rowBottomPixel - viewportHeight;
  39576. eGui.scrollTop = newScrollPosition;
  39577. }
  39578. };
  39579. VirtualList.prototype.setComponentCreator = function (componentCreator) {
  39580. this.componentCreator = componentCreator;
  39581. };
  39582. VirtualList.prototype.getRowHeight = function () {
  39583. return this.rowHeight;
  39584. };
  39585. VirtualList.prototype.getScrollTop = function () {
  39586. return this.getGui().scrollTop;
  39587. };
  39588. VirtualList.prototype.setRowHeight = function (rowHeight) {
  39589. this.rowHeight = rowHeight;
  39590. this.refresh();
  39591. };
  39592. VirtualList.prototype.refresh = function () {
  39593. var _this = this;
  39594. if (this.model == null) {
  39595. return;
  39596. }
  39597. var rowCount = this.model.getRowCount();
  39598. this.eContainer.style.height = rowCount * this.rowHeight + "px";
  39599. this.eContainer.setAttribute('aria-rowcount', rowCount.toString());
  39600. // ensure height is applied before attempting to redraw rows
  39601. setTimeout(function () {
  39602. _this.clearVirtualRows();
  39603. _this.drawVirtualRows();
  39604. }, 0);
  39605. };
  39606. VirtualList.prototype.clearVirtualRows = function () {
  39607. var _this = this;
  39608. this.renderedRows.forEach(function (_, rowIndex) { return _this.removeRow(rowIndex); });
  39609. };
  39610. VirtualList.prototype.drawVirtualRows = function () {
  39611. var gui = this.getGui();
  39612. var topPixel = gui.scrollTop;
  39613. var bottomPixel = topPixel + gui.offsetHeight;
  39614. var firstRow = Math.floor(topPixel / this.rowHeight);
  39615. var lastRow = Math.floor(bottomPixel / this.rowHeight);
  39616. this.ensureRowsRendered(firstRow, lastRow);
  39617. };
  39618. VirtualList.prototype.ensureRowsRendered = function (start, finish) {
  39619. var _this = this;
  39620. // remove any rows that are no longer required
  39621. this.renderedRows.forEach(function (_, rowIndex) {
  39622. if ((rowIndex < start || rowIndex > finish) && rowIndex !== _this.lastFocusedRow) {
  39623. _this.removeRow(rowIndex);
  39624. }
  39625. });
  39626. // insert any required new rows
  39627. for (var rowIndex = start; rowIndex <= finish; rowIndex++) {
  39628. if (this.renderedRows.has(rowIndex)) {
  39629. continue;
  39630. }
  39631. // check this row actually exists (in case overflow buffer window exceeds real data)
  39632. if (rowIndex < this.model.getRowCount()) {
  39633. var value = this.model.getRow(rowIndex);
  39634. this.insertRow(value, rowIndex);
  39635. }
  39636. }
  39637. };
  39638. VirtualList.prototype.insertRow = function (value, rowIndex) {
  39639. var eDiv = document.createElement('div');
  39640. _.addCssClass(eDiv, 'ag-virtual-list-item');
  39641. _.addCssClass(eDiv, "ag-" + this.cssIdentifier + "-virtual-list-item");
  39642. eDiv.setAttribute('aria-rowindex', (rowIndex + 1).toString());
  39643. eDiv.setAttribute('tabindex', '-1');
  39644. eDiv.style.height = this.rowHeight + "px";
  39645. eDiv.style.top = this.rowHeight * rowIndex + "px";
  39646. var rowComponent = this.componentCreator(value);
  39647. eDiv.appendChild(rowComponent.getGui());
  39648. this.eContainer.appendChild(eDiv);
  39649. this.renderedRows.set(rowIndex, { rowComponent: rowComponent, eDiv: eDiv });
  39650. };
  39651. VirtualList.prototype.removeRow = function (rowIndex) {
  39652. var component = this.renderedRows.get(rowIndex);
  39653. this.eContainer.removeChild(component.eDiv);
  39654. this.destroyBean(component.rowComponent);
  39655. this.renderedRows.delete(rowIndex);
  39656. };
  39657. VirtualList.prototype.addScrollListener = function () {
  39658. var _this = this;
  39659. this.addGuiEventListener('scroll', function () { return _this.drawVirtualRows(); });
  39660. };
  39661. VirtualList.prototype.setModel = function (model) {
  39662. this.model = model;
  39663. };
  39664. __decorate$1W([
  39665. Autowired('gridOptionsWrapper')
  39666. ], VirtualList.prototype, "gridOptionsWrapper", void 0);
  39667. __decorate$1W([
  39668. RefSelector('eContainer')
  39669. ], VirtualList.prototype, "eContainer", void 0);
  39670. return VirtualList;
  39671. }(ManagedFocusComponent));
  39672. /**
  39673. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  39674. * @version v23.2.1
  39675. * @link http://www.ag-grid.com/
  39676. * @license MIT
  39677. */
  39678. function defaultGroupComparator(valueA, valueB, nodeA, nodeB, accentedCompare) {
  39679. if (accentedCompare === void 0) { accentedCompare = false; }
  39680. console.warn('ag-Grid: Since ag-grid 11.0.0 defaultGroupComparator is not necessary. You can remove this from your colDef');
  39681. var nodeAIsGroup = _.exists(nodeA) && nodeA.group;
  39682. var nodeBIsGroup = _.exists(nodeB) && nodeB.group;
  39683. var bothAreGroups = nodeAIsGroup && nodeBIsGroup;
  39684. var bothAreNormal = !nodeAIsGroup && !nodeBIsGroup;
  39685. if (bothAreGroups) {
  39686. return _.defaultComparator(nodeA.key, nodeB.key, accentedCompare);
  39687. }
  39688. if (bothAreNormal) {
  39689. return _.defaultComparator(valueA, valueB, accentedCompare);
  39690. }
  39691. if (nodeAIsGroup) {
  39692. return 1;
  39693. }
  39694. return -1;
  39695. }
  39696. /**
  39697. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  39698. * @version v23.2.1
  39699. * @link http://www.ag-grid.com/
  39700. * @license MIT
  39701. */
  39702. var BaseComponentWrapper = /** @class */ (function () {
  39703. function BaseComponentWrapper() {
  39704. }
  39705. BaseComponentWrapper.prototype.wrap = function (OriginalConstructor, mandatoryMethodList, optionalMethodList, componentType, componentName) {
  39706. var _this = this;
  39707. if (optionalMethodList === void 0) { optionalMethodList = []; }
  39708. var wrapper = this.createWrapper(OriginalConstructor, componentType, componentName);
  39709. mandatoryMethodList.forEach((function (methodName) {
  39710. _this.createMethod(wrapper, methodName, true);
  39711. }));
  39712. optionalMethodList.forEach((function (methodName) {
  39713. _this.createMethod(wrapper, methodName, false);
  39714. }));
  39715. return wrapper;
  39716. };
  39717. BaseComponentWrapper.prototype.createMethod = function (wrapper, methodName, mandatory) {
  39718. wrapper.addMethod(methodName, this.createMethodProxy(wrapper, methodName, mandatory));
  39719. };
  39720. BaseComponentWrapper.prototype.createMethodProxy = function (wrapper, methodName, mandatory) {
  39721. return function () {
  39722. if (wrapper.hasMethod(methodName)) {
  39723. return wrapper.callMethod(methodName, arguments);
  39724. }
  39725. if (mandatory) {
  39726. console.warn('ag-Grid: Framework component is missing the method ' + methodName + '()');
  39727. }
  39728. return null;
  39729. };
  39730. };
  39731. return BaseComponentWrapper;
  39732. }());
  39733. /**
  39734. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  39735. * @version v23.2.1
  39736. * @link http://www.ag-grid.com/
  39737. * @license MIT
  39738. */
  39739. (function (ChartType) {
  39740. ChartType["GroupedColumn"] = "groupedColumn";
  39741. ChartType["StackedColumn"] = "stackedColumn";
  39742. ChartType["NormalizedColumn"] = "normalizedColumn";
  39743. ChartType["GroupedBar"] = "groupedBar";
  39744. ChartType["StackedBar"] = "stackedBar";
  39745. ChartType["NormalizedBar"] = "normalizedBar";
  39746. ChartType["Line"] = "line";
  39747. ChartType["Scatter"] = "scatter";
  39748. ChartType["Bubble"] = "bubble";
  39749. ChartType["Pie"] = "pie";
  39750. ChartType["Doughnut"] = "doughnut";
  39751. ChartType["Area"] = "area";
  39752. ChartType["StackedArea"] = "stackedArea";
  39753. ChartType["NormalizedArea"] = "normalizedArea";
  39754. ChartType["Histogram"] = "histogram";
  39755. })(exports.ChartType || (exports.ChartType = {}));
  39756. (function (LegendPosition) {
  39757. LegendPosition["Top"] = "top";
  39758. LegendPosition["Right"] = "right";
  39759. LegendPosition["Bottom"] = "bottom";
  39760. LegendPosition["Left"] = "left";
  39761. })(exports.LegendPosition || (exports.LegendPosition = {}));
  39762. /**
  39763. * @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
  39764. * @version v23.2.1
  39765. * @link http://www.ag-grid.com/
  39766. * @license MIT
  39767. */
  39768. var globalObj = typeof global === 'undefined' ? {} : global;
  39769. globalObj.HTMLElement = typeof HTMLElement === 'undefined' ? {} : HTMLElement;
  39770. globalObj.HTMLButtonElement = typeof HTMLButtonElement === 'undefined' ? {} : HTMLButtonElement;
  39771. globalObj.HTMLSelectElement = typeof HTMLSelectElement === 'undefined' ? {} : HTMLSelectElement;
  39772. globalObj.HTMLInputElement = typeof HTMLInputElement === 'undefined' ? {} : HTMLInputElement;
  39773. globalObj.Node = typeof Node === 'undefined' ? {} : Node;
  39774. globalObj.MouseEvent = typeof MouseEvent === 'undefined' ? {} : MouseEvent;
  39775. var ClientSideNodeManager = /** @class */ (function () {
  39776. function ClientSideNodeManager(rootNode, gridOptionsWrapper, context, eventService, columnController, gridApi, columnApi, selectionController) {
  39777. this.nextId = 0;
  39778. // when user is provide the id's, we also keep a map of ids to row nodes for convenience
  39779. this.allNodesMap = {};
  39780. this.rootNode = rootNode;
  39781. this.gridOptionsWrapper = gridOptionsWrapper;
  39782. this.context = context;
  39783. this.eventService = eventService;
  39784. this.columnController = columnController;
  39785. this.gridApi = gridApi;
  39786. this.columnApi = columnApi;
  39787. this.selectionController = selectionController;
  39788. this.rootNode.group = true;
  39789. this.rootNode.level = -1;
  39790. this.rootNode.id = ClientSideNodeManager.ROOT_NODE_ID;
  39791. this.rootNode.allLeafChildren = [];
  39792. this.rootNode.childrenAfterGroup = [];
  39793. this.rootNode.childrenAfterSort = [];
  39794. this.rootNode.childrenAfterFilter = [];
  39795. // if we make this class a bean, then can annotate postConstruct
  39796. this.postConstruct();
  39797. }
  39798. // @PostConstruct - this is not a bean, so postConstruct called by constructor
  39799. ClientSideNodeManager.prototype.postConstruct = function () {
  39800. // func below doesn't have 'this' pointer, so need to pull out these bits
  39801. this.getNodeChildDetails = this.gridOptionsWrapper.getNodeChildDetailsFunc();
  39802. this.suppressParentsInRowNodes = this.gridOptionsWrapper.isSuppressParentsInRowNodes();
  39803. this.doesDataFlower = this.gridOptionsWrapper.getDoesDataFlowerFunc();
  39804. this.isRowMasterFunc = this.gridOptionsWrapper.getIsRowMasterFunc();
  39805. this.doingTreeData = this.gridOptionsWrapper.isTreeData();
  39806. this.doingLegacyTreeData = !this.doingTreeData && _.exists(this.getNodeChildDetails);
  39807. this.doingMasterDetail = this.gridOptionsWrapper.isMasterDetail();
  39808. if (this.getNodeChildDetails) {
  39809. console.warn("ag-Grid: the callback nodeChildDetailsFunc() is now deprecated. The new way of doing\n tree data in ag-Grid was introduced in v14 (released November 2017). In the next\n major release of ag-Grid we will be dropping support for the old version of\n tree data. If you are reading this message, please go to the docs to see how\n to implement Tree Data without using nodeChildDetailsFunc().");
  39810. }
  39811. };
  39812. ClientSideNodeManager.prototype.getCopyOfNodesMap = function () {
  39813. var result = _.cloneObject(this.allNodesMap);
  39814. return result;
  39815. };
  39816. ClientSideNodeManager.prototype.getRowNode = function (id) {
  39817. return this.allNodesMap[id];
  39818. };
  39819. ClientSideNodeManager.prototype.setRowData = function (rowData) {
  39820. this.rootNode.childrenAfterFilter = null;
  39821. this.rootNode.childrenAfterGroup = null;
  39822. this.rootNode.childrenAfterSort = null;
  39823. this.rootNode.childrenMapped = null;
  39824. this.nextId = 0;
  39825. this.allNodesMap = {};
  39826. if (!rowData) {
  39827. this.rootNode.allLeafChildren = [];
  39828. this.rootNode.childrenAfterGroup = [];
  39829. return;
  39830. }
  39831. // kick off recursion
  39832. // we add rootNode as the parent, however if using ag-grid-enterprise, the grouping stage
  39833. // sets the parent node on each row (even if we are not grouping). so setting parent node
  39834. // here is for benefit of ag-grid-community users
  39835. var result = this.recursiveFunction(rowData, this.rootNode, ClientSideNodeManager.TOP_LEVEL);
  39836. if (this.doingLegacyTreeData) {
  39837. this.rootNode.childrenAfterGroup = result;
  39838. this.setLeafChildren(this.rootNode);
  39839. }
  39840. else {
  39841. this.rootNode.allLeafChildren = result;
  39842. }
  39843. };
  39844. ClientSideNodeManager.prototype.updateRowData = function (rowDataTran, rowNodeOrder) {
  39845. if (this.isLegacyTreeData()) {
  39846. return null;
  39847. }
  39848. var rowNodeTransaction = {
  39849. remove: [],
  39850. update: [],
  39851. add: []
  39852. };
  39853. var nodesToUnselect = [];
  39854. this.executeAdd(rowDataTran, rowNodeTransaction);
  39855. this.executeRemove(rowDataTran, rowNodeTransaction, nodesToUnselect);
  39856. this.executeUpdate(rowDataTran, rowNodeTransaction, nodesToUnselect);
  39857. this.updateSelection(nodesToUnselect);
  39858. if (rowNodeOrder) {
  39859. _.sortRowNodesByOrder(this.rootNode.allLeafChildren, rowNodeOrder);
  39860. }
  39861. return rowNodeTransaction;
  39862. };
  39863. ClientSideNodeManager.prototype.updateSelection = function (nodesToUnselect) {
  39864. var selectionChanged = nodesToUnselect.length > 0;
  39865. if (selectionChanged) {
  39866. nodesToUnselect.forEach(function (rowNode) {
  39867. rowNode.setSelected(false, false, true);
  39868. });
  39869. }
  39870. // we do this regardless of nodes to unselect or not, as it's possible
  39871. // a new node was inserted, so a parent that was previously selected (as all
  39872. // children were selected) should not be tri-state (as new one unselected against
  39873. // all other selected children).
  39874. this.selectionController.updateGroupsFromChildrenSelections();
  39875. if (selectionChanged) {
  39876. var event_1 = {
  39877. type: Events.EVENT_SELECTION_CHANGED,
  39878. api: this.gridApi,
  39879. columnApi: this.columnApi
  39880. };
  39881. this.eventService.dispatchEvent(event_1);
  39882. }
  39883. };
  39884. ClientSideNodeManager.prototype.executeAdd = function (rowDataTran, rowNodeTransaction) {
  39885. var _this = this;
  39886. var add = rowDataTran.add, addIndex = rowDataTran.addIndex;
  39887. if (!add) {
  39888. return;
  39889. }
  39890. var useIndex = typeof addIndex === 'number' && addIndex >= 0;
  39891. if (useIndex) {
  39892. // items get inserted in reverse order for index insertion
  39893. add.reverse().forEach(function (item) {
  39894. var newRowNode = _this.addRowNode(item, addIndex);
  39895. rowNodeTransaction.add.push(newRowNode);
  39896. });
  39897. }
  39898. else {
  39899. add.forEach(function (item) {
  39900. var newRowNode = _this.addRowNode(item);
  39901. rowNodeTransaction.add.push(newRowNode);
  39902. });
  39903. }
  39904. };
  39905. ClientSideNodeManager.prototype.executeRemove = function (rowDataTran, rowNodeTransaction, nodesToUnselect) {
  39906. var _this = this;
  39907. var remove = rowDataTran.remove;
  39908. if (!remove) {
  39909. return;
  39910. }
  39911. var rowIdsRemoved = {};
  39912. remove.forEach(function (item) {
  39913. var rowNode = _this.lookupRowNode(item);
  39914. if (!rowNode) {
  39915. return;
  39916. }
  39917. // do delete - setting 'suppressFinishActions = true' to ensure EVENT_SELECTION_CHANGED is not raised for
  39918. // each row node updated, instead it is raised once by the calling code if any selected nodes exist.
  39919. if (rowNode.isSelected()) {
  39920. nodesToUnselect.push(rowNode);
  39921. }
  39922. // so row renderer knows to fade row out (and not reposition it)
  39923. rowNode.clearRowTop();
  39924. // NOTE: were we could remove from allLeaveChildren, however _.removeFromArray() is expensive, especially
  39925. // if called multiple times (eg deleting lots of rows) and if allLeafChildren is a large list
  39926. rowIdsRemoved[rowNode.id] = true;
  39927. // _.removeFromArray(this.rootNode.allLeafChildren, rowNode);
  39928. delete _this.allNodesMap[rowNode.id];
  39929. rowNodeTransaction.remove.push(rowNode);
  39930. });
  39931. this.rootNode.allLeafChildren = this.rootNode.allLeafChildren.filter(function (rowNode) { return !rowIdsRemoved[rowNode.id]; });
  39932. };
  39933. ClientSideNodeManager.prototype.executeUpdate = function (rowDataTran, rowNodeTransaction, nodesToUnselect) {
  39934. var _this = this;
  39935. var update = rowDataTran.update;
  39936. if (!update) {
  39937. return;
  39938. }
  39939. update.forEach(function (item) {
  39940. var rowNode = _this.lookupRowNode(item);
  39941. if (!rowNode) {
  39942. return;
  39943. }
  39944. rowNode.updateData(item);
  39945. if (!rowNode.selectable && rowNode.isSelected()) {
  39946. nodesToUnselect.push(rowNode);
  39947. }
  39948. _this.setMasterForRow(rowNode, item, ClientSideNodeManager.TOP_LEVEL, false);
  39949. rowNodeTransaction.update.push(rowNode);
  39950. });
  39951. };
  39952. ClientSideNodeManager.prototype.addRowNode = function (data, index) {
  39953. var newNode = this.createNode(data, this.rootNode, ClientSideNodeManager.TOP_LEVEL);
  39954. if (_.exists(index)) {
  39955. _.insertIntoArray(this.rootNode.allLeafChildren, newNode, index);
  39956. }
  39957. else {
  39958. this.rootNode.allLeafChildren.push(newNode);
  39959. }
  39960. return newNode;
  39961. };
  39962. ClientSideNodeManager.prototype.lookupRowNode = function (data) {
  39963. var rowNodeIdFunc = this.gridOptionsWrapper.getRowNodeIdFunc();
  39964. var rowNode;
  39965. if (_.exists(rowNodeIdFunc)) {
  39966. // find rowNode using id
  39967. var id = rowNodeIdFunc(data);
  39968. rowNode = this.allNodesMap[id];
  39969. if (!rowNode) {
  39970. console.error("ag-Grid: could not find row id=" + id + ", data item was not found for this id");
  39971. return null;
  39972. }
  39973. }
  39974. else {
  39975. // find rowNode using object references
  39976. rowNode = _.find(this.rootNode.allLeafChildren, function (rowNode) { return rowNode.data === data; });
  39977. if (!rowNode) {
  39978. console.error("ag-Grid: could not find data item as object was not found", data);
  39979. return null;
  39980. }
  39981. }
  39982. return rowNode;
  39983. };
  39984. ClientSideNodeManager.prototype.recursiveFunction = function (rowData, parent, level) {
  39985. var _this = this;
  39986. // make sure the rowData is an array and not a string of json - this was a commonly reported problem on the forum
  39987. if (typeof rowData === 'string') {
  39988. console.warn('ag-Grid: rowData must be an array, however you passed in a string. If you are loading JSON, make sure you convert the JSON string to JavaScript objects first');
  39989. return;
  39990. }
  39991. var rowNodes = [];
  39992. rowData.forEach(function (dataItem) {
  39993. var node = _this.createNode(dataItem, parent, level);
  39994. rowNodes.push(node);
  39995. });
  39996. return rowNodes;
  39997. };
  39998. ClientSideNodeManager.prototype.createNode = function (dataItem, parent, level) {
  39999. var node = new RowNode();
  40000. this.context.createBean(node);
  40001. var nodeChildDetails = this.doingLegacyTreeData ? this.getNodeChildDetails(dataItem) : null;
  40002. if (nodeChildDetails && nodeChildDetails.group) {
  40003. node.group = true;
  40004. node.childrenAfterGroup = this.recursiveFunction(nodeChildDetails.children, node, level + 1);
  40005. node.expanded = nodeChildDetails.expanded === true;
  40006. node.field = nodeChildDetails.field;
  40007. node.key = nodeChildDetails.key;
  40008. // pull out all the leaf children and add to our node
  40009. this.setLeafChildren(node);
  40010. }
  40011. else {
  40012. node.group = false;
  40013. this.setMasterForRow(node, dataItem, level, true);
  40014. }
  40015. // support for backwards compatibility, canFlow is now called 'master'
  40016. /** @deprecated is now 'master' */
  40017. node.canFlower = node.master;
  40018. if (parent && !this.suppressParentsInRowNodes) {
  40019. node.parent = parent;
  40020. }
  40021. node.level = level;
  40022. node.setDataAndId(dataItem, this.nextId.toString());
  40023. if (this.allNodesMap[node.id]) {
  40024. console.warn("ag-grid: duplicate node id '" + node.id + "' detected from getRowNodeId callback, this could cause issues in your grid.");
  40025. }
  40026. this.allNodesMap[node.id] = node;
  40027. this.nextId++;
  40028. return node;
  40029. };
  40030. ClientSideNodeManager.prototype.setMasterForRow = function (rowNode, data, level, setExpanded) {
  40031. if (this.doingTreeData) {
  40032. rowNode.setMaster(false);
  40033. if (setExpanded) {
  40034. rowNode.expanded = false;
  40035. }
  40036. }
  40037. else {
  40038. // this is the default, for when doing grid data
  40039. if (this.doesDataFlower) {
  40040. rowNode.setMaster(this.doesDataFlower(data));
  40041. }
  40042. else if (this.doingMasterDetail) {
  40043. // if we are doing master detail, then the
  40044. // default is that everything can be a Master Row.
  40045. if (this.isRowMasterFunc) {
  40046. rowNode.setMaster(this.isRowMasterFunc(data));
  40047. }
  40048. else {
  40049. rowNode.setMaster(true);
  40050. }
  40051. }
  40052. else {
  40053. rowNode.setMaster(false);
  40054. }
  40055. if (setExpanded) {
  40056. var rowGroupColumns = this.columnController.getRowGroupColumns();
  40057. var numRowGroupColumns = rowGroupColumns ? rowGroupColumns.length : 0;
  40058. // need to take row group into account when determining level
  40059. var masterRowLevel = level + numRowGroupColumns;
  40060. rowNode.expanded = rowNode.master ? this.isExpanded(masterRowLevel) : false;
  40061. }
  40062. }
  40063. };
  40064. ClientSideNodeManager.prototype.isExpanded = function (level) {
  40065. var expandByDefault = this.gridOptionsWrapper.getGroupDefaultExpanded();
  40066. if (expandByDefault === -1) {
  40067. return true;
  40068. }
  40069. else {
  40070. return level < expandByDefault;
  40071. }
  40072. };
  40073. // this is only used for doing legacy tree data
  40074. ClientSideNodeManager.prototype.setLeafChildren = function (node) {
  40075. node.allLeafChildren = [];
  40076. if (node.childrenAfterGroup) {
  40077. node.childrenAfterGroup.forEach(function (childAfterGroup) {
  40078. if (childAfterGroup.group) {
  40079. if (childAfterGroup.allLeafChildren) {
  40080. childAfterGroup.allLeafChildren.forEach(function (leafChild) { return node.allLeafChildren.push(leafChild); });
  40081. }
  40082. }
  40083. else {
  40084. node.allLeafChildren.push(childAfterGroup);
  40085. }
  40086. });
  40087. }
  40088. };
  40089. ClientSideNodeManager.prototype.isLegacyTreeData = function () {
  40090. var rowsAlreadyGrouped = _.exists(this.gridOptionsWrapper.getNodeChildDetailsFunc());
  40091. if (rowsAlreadyGrouped) {
  40092. console.warn('ag-Grid: adding and removing rows is not supported when using nodeChildDetailsFunc, ie it is not ' +
  40093. 'supported for legacy tree data. Please see the docs on the new preferred way of providing tree data that works with delta updates.');
  40094. return true;
  40095. }
  40096. else {
  40097. return false;
  40098. }
  40099. };
  40100. ClientSideNodeManager.TOP_LEVEL = 0;
  40101. ClientSideNodeManager.ROOT_NODE_ID = 'ROOT_NODE_ID';
  40102. return ClientSideNodeManager;
  40103. }());
  40104. var __extends$22 = (undefined && undefined.__extends) || (function () {
  40105. var extendStatics = function (d, b) {
  40106. extendStatics = Object.setPrototypeOf ||
  40107. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  40108. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  40109. return extendStatics(d, b);
  40110. };
  40111. return function (d, b) {
  40112. extendStatics(d, b);
  40113. function __() { this.constructor = d; }
  40114. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  40115. };
  40116. })();
  40117. var __decorate$1X = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  40118. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  40119. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  40120. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  40121. return c > 3 && r && Object.defineProperty(target, key, r), r;
  40122. };
  40123. var RecursionType;
  40124. (function (RecursionType) {
  40125. RecursionType[RecursionType["Normal"] = 0] = "Normal";
  40126. RecursionType[RecursionType["AfterFilter"] = 1] = "AfterFilter";
  40127. RecursionType[RecursionType["AfterFilterAndSort"] = 2] = "AfterFilterAndSort";
  40128. RecursionType[RecursionType["PivotNodes"] = 3] = "PivotNodes";
  40129. })(RecursionType || (RecursionType = {}));
  40130. var ClientSideRowModel = /** @class */ (function (_super) {
  40131. __extends$22(ClientSideRowModel, _super);
  40132. function ClientSideRowModel() {
  40133. return _super !== null && _super.apply(this, arguments) || this;
  40134. }
  40135. ClientSideRowModel.prototype.init = function () {
  40136. var refreshEverythingFunc = this.refreshModel.bind(this, { step: Constants.STEP_EVERYTHING });
  40137. var refreshEverythingAfterColsChangedFunc = this.refreshModel.bind(this, { step: Constants.STEP_EVERYTHING, afterColumnsChanged: true, keepRenderedRows: true });
  40138. this.addManagedListener(this.eventService, Events.EVENT_COLUMN_EVERYTHING_CHANGED, refreshEverythingAfterColsChangedFunc);
  40139. this.addManagedListener(this.eventService, Events.EVENT_COLUMN_ROW_GROUP_CHANGED, refreshEverythingFunc);
  40140. this.addManagedListener(this.eventService, Events.EVENT_COLUMN_VALUE_CHANGED, this.onValueChanged.bind(this));
  40141. this.addManagedListener(this.eventService, Events.EVENT_COLUMN_PIVOT_CHANGED, this.refreshModel.bind(this, { step: Constants.STEP_PIVOT }));
  40142. this.addManagedListener(this.eventService, Events.EVENT_ROW_GROUP_OPENED, this.onRowGroupOpened.bind(this));
  40143. this.addManagedListener(this.eventService, Events.EVENT_FILTER_CHANGED, this.onFilterChanged.bind(this));
  40144. this.addManagedListener(this.eventService, Events.EVENT_SORT_CHANGED, this.onSortChanged.bind(this));
  40145. this.addManagedListener(this.eventService, Events.EVENT_COLUMN_PIVOT_MODE_CHANGED, refreshEverythingFunc);
  40146. var refreshMapListener = this.refreshModel.bind(this, {
  40147. step: Constants.STEP_MAP,
  40148. keepRenderedRows: true,
  40149. animate: true
  40150. });
  40151. this.addManagedListener(this.gridOptionsWrapper, GridOptionsWrapper.PROP_GROUP_REMOVE_SINGLE_CHILDREN, refreshMapListener);
  40152. this.addManagedListener(this.gridOptionsWrapper, GridOptionsWrapper.PROP_GROUP_REMOVE_LOWEST_SINGLE_CHILDREN, refreshMapListener);
  40153. this.rootNode = new RowNode();
  40154. this.nodeManager = new ClientSideNodeManager(this.rootNode, this.gridOptionsWrapper, this.getContext(), this.eventService, this.columnController, this.gridApi, this.columnApi, this.selectionController);
  40155. this.createBean(this.rootNode);
  40156. };
  40157. ClientSideRowModel.prototype.start = function () {
  40158. var rowData = this.gridOptionsWrapper.getRowData();
  40159. if (rowData) {
  40160. this.setRowData(rowData);
  40161. }
  40162. };
  40163. ClientSideRowModel.prototype.ensureRowHeightsValid = function (startPixel, endPixel, startLimitIndex, endLimitIndex) {
  40164. var atLeastOneChange;
  40165. var res = false;
  40166. // we do this multiple times as changing the row heights can also change the first and last rows,
  40167. // so the first pass can make lots of rows smaller, which means the second pass we end up changing
  40168. // more rows.
  40169. do {
  40170. atLeastOneChange = false;
  40171. var rowAtStartPixel = this.getRowIndexAtPixel(startPixel);
  40172. var rowAtEndPixel = this.getRowIndexAtPixel(endPixel);
  40173. // keep check to current page if doing pagination
  40174. var firstRow = Math.max(rowAtStartPixel, startLimitIndex);
  40175. var lastRow = Math.min(rowAtEndPixel, endLimitIndex);
  40176. for (var rowIndex = firstRow; rowIndex <= lastRow; rowIndex++) {
  40177. var rowNode = this.getRow(rowIndex);
  40178. if (rowNode.rowHeightEstimated) {
  40179. var rowHeight = this.gridOptionsWrapper.getRowHeightForNode(rowNode);
  40180. rowNode.setRowHeight(rowHeight.height);
  40181. atLeastOneChange = true;
  40182. res = true;
  40183. }
  40184. }
  40185. if (atLeastOneChange) {
  40186. this.setRowTops();
  40187. }
  40188. } while (atLeastOneChange);
  40189. return res;
  40190. };
  40191. ClientSideRowModel.prototype.setRowTops = function () {
  40192. var nextRowTop = 0;
  40193. for (var i = 0; i < this.rowsToDisplay.length; i++) {
  40194. // we don't estimate if doing fullHeight or autoHeight, as all rows get rendered all the time
  40195. // with these two layouts.
  40196. var allowEstimate = this.gridOptionsWrapper.getDomLayout() === Constants.DOM_LAYOUT_NORMAL;
  40197. var rowNode = this.rowsToDisplay[i];
  40198. if (_.missing(rowNode.rowHeight)) {
  40199. var rowHeight = this.gridOptionsWrapper.getRowHeightForNode(rowNode, allowEstimate);
  40200. rowNode.setRowHeight(rowHeight.height, rowHeight.estimated);
  40201. }
  40202. rowNode.setRowTop(nextRowTop);
  40203. rowNode.setRowIndex(i);
  40204. nextRowTop += rowNode.rowHeight;
  40205. }
  40206. };
  40207. ClientSideRowModel.prototype.resetRowTops = function (rowNode, changedPath) {
  40208. rowNode.clearRowTop();
  40209. if (rowNode.hasChildren()) {
  40210. if (rowNode.childrenAfterGroup) {
  40211. // if a changedPath is active, it means we are here because of a transaction update or
  40212. // a change detection. neither of these impacts the open/closed state of groups. so if
  40213. // a group is not open this time, it was not open last time. so we know all closed groups
  40214. // already have their top positions cleared. so there is no need to traverse all the way
  40215. // when changedPath is active and the rowNode is not expanded.
  40216. var skipChildren = changedPath.isActive() && !rowNode.expanded;
  40217. if (!skipChildren) {
  40218. for (var i = 0; i < rowNode.childrenAfterGroup.length; i++) {
  40219. this.resetRowTops(rowNode.childrenAfterGroup[i], changedPath);
  40220. }
  40221. }
  40222. }
  40223. if (rowNode.sibling) {
  40224. rowNode.sibling.clearRowTop();
  40225. }
  40226. }
  40227. if (rowNode.detailNode) {
  40228. rowNode.detailNode.clearRowTop();
  40229. }
  40230. };
  40231. // returns false if row was moved, otherwise true
  40232. ClientSideRowModel.prototype.ensureRowsAtPixel = function (rowNodes, pixel, increment) {
  40233. var _this = this;
  40234. if (increment === void 0) { increment = 0; }
  40235. var indexAtPixelNow = this.getRowIndexAtPixel(pixel);
  40236. var rowNodeAtPixelNow = this.getRow(indexAtPixelNow);
  40237. if (rowNodeAtPixelNow === rowNodes[0]) {
  40238. return false;
  40239. }
  40240. rowNodes.forEach(function (rowNode) {
  40241. _.removeFromArray(_this.rootNode.allLeafChildren, rowNode);
  40242. });
  40243. rowNodes.forEach(function (rowNode, idx) {
  40244. _.insertIntoArray(_this.rootNode.allLeafChildren, rowNode, indexAtPixelNow + increment + idx);
  40245. });
  40246. this.refreshModel({
  40247. step: Constants.STEP_EVERYTHING,
  40248. keepRenderedRows: true,
  40249. animate: true,
  40250. keepEditingRows: true
  40251. });
  40252. return true;
  40253. };
  40254. ClientSideRowModel.prototype.highlightRowAtPixel = function (rowNode, pixel) {
  40255. var indexAtPixelNow = pixel != null ? this.getRowIndexAtPixel(pixel) : null;
  40256. var rowNodeAtPixelNow = indexAtPixelNow != null ? this.getRow(indexAtPixelNow) : null;
  40257. if (!rowNodeAtPixelNow || !rowNode || rowNodeAtPixelNow === rowNode || pixel == null) {
  40258. if (this.lastHighlightedRow) {
  40259. this.lastHighlightedRow.setHighlighted(null);
  40260. this.lastHighlightedRow = null;
  40261. }
  40262. return;
  40263. }
  40264. var highlight = this.getHighlightPosition(pixel, rowNodeAtPixelNow);
  40265. if (this.lastHighlightedRow && this.lastHighlightedRow !== rowNodeAtPixelNow) {
  40266. this.lastHighlightedRow.setHighlighted(null);
  40267. this.lastHighlightedRow = null;
  40268. }
  40269. rowNodeAtPixelNow.setHighlighted(highlight);
  40270. this.lastHighlightedRow = rowNodeAtPixelNow;
  40271. };
  40272. ClientSideRowModel.prototype.getHighlightPosition = function (pixel, rowNode) {
  40273. if (!rowNode) {
  40274. var index = this.getRowIndexAtPixel(pixel);
  40275. rowNode = this.getRow(index || 0);
  40276. if (!rowNode) {
  40277. return 'below';
  40278. }
  40279. }
  40280. var rowTop = rowNode.rowTop, rowHeight = rowNode.rowHeight;
  40281. return pixel - rowTop < rowHeight / 2 ? 'above' : 'below';
  40282. };
  40283. ClientSideRowModel.prototype.getLastHighlightedRowNode = function () {
  40284. return this.lastHighlightedRow;
  40285. };
  40286. ClientSideRowModel.prototype.isLastRowFound = function () {
  40287. return true;
  40288. };
  40289. ClientSideRowModel.prototype.getRowCount = function () {
  40290. if (this.rowsToDisplay) {
  40291. return this.rowsToDisplay.length;
  40292. }
  40293. return 0;
  40294. };
  40295. ClientSideRowModel.prototype.getTopLevelRowCount = function () {
  40296. var showingRootNode = this.rowsToDisplay && this.rowsToDisplay[0] === this.rootNode;
  40297. if (showingRootNode) {
  40298. return 1;
  40299. }
  40300. return this.rootNode.childrenAfterFilter ? this.rootNode.childrenAfterFilter.length : 0;
  40301. };
  40302. ClientSideRowModel.prototype.getTopLevelRowDisplayedIndex = function (topLevelIndex) {
  40303. var showingRootNode = this.rowsToDisplay && this.rowsToDisplay[0] === this.rootNode;
  40304. if (showingRootNode) {
  40305. return topLevelIndex;
  40306. }
  40307. var rowNode = this.rootNode.childrenAfterSort[topLevelIndex];
  40308. if (this.gridOptionsWrapper.isGroupHideOpenParents()) {
  40309. // if hideOpenParents, and this row open, then this row is now displayed at this index, first child is
  40310. while (rowNode.expanded && rowNode.childrenAfterSort && rowNode.childrenAfterSort.length > 0) {
  40311. rowNode = rowNode.childrenAfterSort[0];
  40312. }
  40313. }
  40314. return rowNode.rowIndex;
  40315. };
  40316. ClientSideRowModel.prototype.getRowBounds = function (index) {
  40317. if (_.missing(this.rowsToDisplay)) {
  40318. return null;
  40319. }
  40320. var rowNode = this.rowsToDisplay[index];
  40321. if (rowNode) {
  40322. return {
  40323. rowTop: rowNode.rowTop,
  40324. rowHeight: rowNode.rowHeight
  40325. };
  40326. }
  40327. return null;
  40328. };
  40329. ClientSideRowModel.prototype.onRowGroupOpened = function () {
  40330. var animate = this.gridOptionsWrapper.isAnimateRows();
  40331. this.refreshModel({ step: Constants.STEP_MAP, keepRenderedRows: true, animate: animate });
  40332. };
  40333. ClientSideRowModel.prototype.onFilterChanged = function (event) {
  40334. if (event.afterDataChange) {
  40335. return;
  40336. }
  40337. var animate = this.gridOptionsWrapper.isAnimateRows();
  40338. this.refreshModel({ step: Constants.STEP_FILTER, keepRenderedRows: true, animate: animate });
  40339. };
  40340. ClientSideRowModel.prototype.onSortChanged = function () {
  40341. var animate = this.gridOptionsWrapper.isAnimateRows();
  40342. this.refreshModel({ step: Constants.STEP_SORT, keepRenderedRows: true, animate: animate, keepEditingRows: true });
  40343. };
  40344. ClientSideRowModel.prototype.getType = function () {
  40345. return Constants.ROW_MODEL_TYPE_CLIENT_SIDE;
  40346. };
  40347. ClientSideRowModel.prototype.onValueChanged = function () {
  40348. if (this.columnController.isPivotActive()) {
  40349. this.refreshModel({ step: Constants.STEP_PIVOT });
  40350. }
  40351. else {
  40352. this.refreshModel({ step: Constants.STEP_AGGREGATE });
  40353. }
  40354. };
  40355. ClientSideRowModel.prototype.createChangePath = function (rowNodeTransactions) {
  40356. // for updates, if the row is updated at all, then we re-calc all the values
  40357. // in that row. we could compare each value to each old value, however if we
  40358. // did this, we would be calling the valueService twice, once on the old value
  40359. // and once on the new value. so it's less valueGetter calls if we just assume
  40360. // each column is different. that way the changedPath is used so that only
  40361. // the impacted parent rows are recalculated, parents who's children have
  40362. // not changed are not impacted.
  40363. var noTransactions = _.missingOrEmpty(rowNodeTransactions);
  40364. var changedPath = new ChangedPath(false, this.rootNode);
  40365. if (noTransactions || this.gridOptionsWrapper.isTreeData()) {
  40366. changedPath.setInactive();
  40367. }
  40368. return changedPath;
  40369. };
  40370. ClientSideRowModel.prototype.refreshModel = function (params) {
  40371. // this goes through the pipeline of stages. what's in my head is similar
  40372. // to the diagram on this page:
  40373. // http://commons.apache.org/sandbox/commons-pipeline/pipeline_basics.html
  40374. // however we want to keep the results of each stage, hence we manually call
  40375. // each step rather than have them chain each other.
  40376. var _this = this;
  40377. // fallthrough in below switch is on purpose,
  40378. // eg if STEP_FILTER, then all steps below this
  40379. // step get done
  40380. // let start: number;
  40381. // console.log('======= start =======');
  40382. var changedPath = this.createChangePath(params.rowNodeTransactions);
  40383. switch (params.step) {
  40384. case Constants.STEP_EVERYTHING:
  40385. // start = new Date().getTime();
  40386. this.doRowGrouping(params.groupState, params.rowNodeTransactions, params.rowNodeOrder, changedPath, params.afterColumnsChanged);
  40387. // console.log('rowGrouping = ' + (new Date().getTime() - start));
  40388. case Constants.STEP_FILTER:
  40389. // start = new Date().getTime();
  40390. this.doFilter(changedPath);
  40391. // console.log('filter = ' + (new Date().getTime() - start));
  40392. case Constants.STEP_PIVOT:
  40393. this.doPivot(changedPath);
  40394. case Constants.STEP_AGGREGATE: // depends on agg fields
  40395. // start = new Date().getTime();
  40396. this.doAggregate(changedPath);
  40397. // console.log('aggregation = ' + (new Date().getTime() - start));
  40398. case Constants.STEP_SORT:
  40399. // start = new Date().getTime();
  40400. this.doSort(params.rowNodeTransactions, changedPath);
  40401. // console.log('sort = ' + (new Date().getTime() - start));
  40402. case Constants.STEP_MAP:
  40403. // start = new Date().getTime();
  40404. this.doRowsToDisplay();
  40405. // console.log('rowsToDisplay = ' + (new Date().getTime() - start));
  40406. }
  40407. // set all row tops to null, then set row tops on all visible rows. if we don't
  40408. // do this, then the algorithm below only sets row tops, old row tops from old rows
  40409. // will still lie around
  40410. this.resetRowTops(this.rootNode, changedPath);
  40411. this.setRowTops();
  40412. var event = {
  40413. type: Events.EVENT_MODEL_UPDATED,
  40414. api: this.gridApi,
  40415. columnApi: this.columnApi,
  40416. animate: params.animate,
  40417. keepRenderedRows: params.keepRenderedRows,
  40418. newData: params.newData,
  40419. newPage: false
  40420. };
  40421. this.eventService.dispatchEvent(event);
  40422. if (this.$scope) {
  40423. window.setTimeout(function () {
  40424. _this.$scope.$apply();
  40425. }, 0);
  40426. }
  40427. };
  40428. ClientSideRowModel.prototype.isEmpty = function () {
  40429. var rowsMissing;
  40430. var doingLegacyTreeData = _.exists(this.gridOptionsWrapper.getNodeChildDetailsFunc());
  40431. if (doingLegacyTreeData) {
  40432. rowsMissing = _.missing(this.rootNode.childrenAfterGroup) || this.rootNode.childrenAfterGroup.length === 0;
  40433. }
  40434. else {
  40435. rowsMissing = _.missing(this.rootNode.allLeafChildren) || this.rootNode.allLeafChildren.length === 0;
  40436. }
  40437. var empty = _.missing(this.rootNode) || rowsMissing || !this.columnController.isReady();
  40438. return empty;
  40439. };
  40440. ClientSideRowModel.prototype.isRowsToRender = function () {
  40441. return _.exists(this.rowsToDisplay) && this.rowsToDisplay.length > 0;
  40442. };
  40443. ClientSideRowModel.prototype.getNodesInRangeForSelection = function (firstInRange, lastInRange) {
  40444. // if lastSelectedNode is missing, we start at the first row
  40445. var firstRowHit = !lastInRange;
  40446. var lastRowHit = false;
  40447. var lastRow;
  40448. var result = [];
  40449. var groupsSelectChildren = this.gridOptionsWrapper.isGroupSelectsChildren();
  40450. this.forEachNodeAfterFilterAndSort(function (rowNode) {
  40451. var lookingForLastRow = firstRowHit && !lastRowHit;
  40452. // check if we need to flip the select switch
  40453. if (!firstRowHit) {
  40454. if (rowNode === lastInRange || rowNode === firstInRange) {
  40455. firstRowHit = true;
  40456. }
  40457. }
  40458. var skipThisGroupNode = rowNode.group && groupsSelectChildren;
  40459. if (!skipThisGroupNode) {
  40460. var inRange = firstRowHit && !lastRowHit;
  40461. var childOfLastRow = rowNode.isParentOfNode(lastRow);
  40462. if (inRange || childOfLastRow) {
  40463. result.push(rowNode);
  40464. }
  40465. }
  40466. if (lookingForLastRow) {
  40467. if (rowNode === lastInRange || rowNode === firstInRange) {
  40468. lastRowHit = true;
  40469. if (rowNode === lastInRange) {
  40470. lastRow = lastInRange;
  40471. }
  40472. else {
  40473. lastRow = firstInRange;
  40474. }
  40475. }
  40476. }
  40477. });
  40478. return result;
  40479. };
  40480. ClientSideRowModel.prototype.setDatasource = function (datasource) {
  40481. console.error('ag-Grid: should never call setDatasource on clientSideRowController');
  40482. };
  40483. ClientSideRowModel.prototype.getTopLevelNodes = function () {
  40484. return this.rootNode ? this.rootNode.childrenAfterGroup : null;
  40485. };
  40486. ClientSideRowModel.prototype.getRootNode = function () {
  40487. return this.rootNode;
  40488. };
  40489. ClientSideRowModel.prototype.getRow = function (index) {
  40490. return this.rowsToDisplay[index];
  40491. };
  40492. ClientSideRowModel.prototype.isRowPresent = function (rowNode) {
  40493. return this.rowsToDisplay.indexOf(rowNode) >= 0;
  40494. };
  40495. ClientSideRowModel.prototype.getRowIndexAtPixel = function (pixelToMatch) {
  40496. if (this.isEmpty()) {
  40497. return -1;
  40498. }
  40499. // do binary search of tree
  40500. // http://oli.me.uk/2013/06/08/searching-javascript-arrays-with-a-binary-search/
  40501. var bottomPointer = 0;
  40502. var topPointer = this.rowsToDisplay.length - 1;
  40503. // quick check, if the pixel is out of bounds, then return last row
  40504. if (pixelToMatch <= 0) {
  40505. // if pixel is less than or equal zero, it's always the first row
  40506. return 0;
  40507. }
  40508. var lastNode = _.last(this.rowsToDisplay);
  40509. if (lastNode.rowTop <= pixelToMatch) {
  40510. return this.rowsToDisplay.length - 1;
  40511. }
  40512. while (true) {
  40513. var midPointer = Math.floor((bottomPointer + topPointer) / 2);
  40514. var currentRowNode = this.rowsToDisplay[midPointer];
  40515. if (this.isRowInPixel(currentRowNode, pixelToMatch)) {
  40516. return midPointer;
  40517. }
  40518. if (currentRowNode.rowTop < pixelToMatch) {
  40519. bottomPointer = midPointer + 1;
  40520. }
  40521. else if (currentRowNode.rowTop > pixelToMatch) {
  40522. topPointer = midPointer - 1;
  40523. }
  40524. }
  40525. };
  40526. ClientSideRowModel.prototype.isRowInPixel = function (rowNode, pixelToMatch) {
  40527. var topPixel = rowNode.rowTop;
  40528. var bottomPixel = rowNode.rowTop + rowNode.rowHeight;
  40529. var pixelInRow = topPixel <= pixelToMatch && bottomPixel > pixelToMatch;
  40530. return pixelInRow;
  40531. };
  40532. ClientSideRowModel.prototype.getCurrentPageHeight = function () {
  40533. if (this.rowsToDisplay && this.rowsToDisplay.length > 0) {
  40534. var lastRow = _.last(this.rowsToDisplay);
  40535. var lastPixel = lastRow.rowTop + lastRow.rowHeight;
  40536. return lastPixel;
  40537. }
  40538. return 0;
  40539. };
  40540. ClientSideRowModel.prototype.forEachLeafNode = function (callback) {
  40541. if (this.rootNode.allLeafChildren) {
  40542. this.rootNode.allLeafChildren.forEach(function (rowNode, index) { return callback(rowNode, index); });
  40543. }
  40544. };
  40545. ClientSideRowModel.prototype.forEachNode = function (callback) {
  40546. this.recursivelyWalkNodesAndCallback(this.rootNode.childrenAfterGroup, callback, RecursionType.Normal, 0);
  40547. };
  40548. ClientSideRowModel.prototype.forEachNodeAfterFilter = function (callback) {
  40549. this.recursivelyWalkNodesAndCallback(this.rootNode.childrenAfterFilter, callback, RecursionType.AfterFilter, 0);
  40550. };
  40551. ClientSideRowModel.prototype.forEachNodeAfterFilterAndSort = function (callback) {
  40552. this.recursivelyWalkNodesAndCallback(this.rootNode.childrenAfterSort, callback, RecursionType.AfterFilterAndSort, 0);
  40553. };
  40554. ClientSideRowModel.prototype.forEachPivotNode = function (callback) {
  40555. this.recursivelyWalkNodesAndCallback([this.rootNode], callback, RecursionType.PivotNodes, 0);
  40556. };
  40557. // iterates through each item in memory, and calls the callback function
  40558. // nodes - the rowNodes to traverse
  40559. // callback - the user provided callback
  40560. // recursion type - need this to know what child nodes to recurse, eg if looking at all nodes, or filtered notes etc
  40561. // index - works similar to the index in forEach in javascript's array function
  40562. ClientSideRowModel.prototype.recursivelyWalkNodesAndCallback = function (nodes, callback, recursionType, index) {
  40563. if (!nodes) {
  40564. return index;
  40565. }
  40566. for (var i = 0; i < nodes.length; i++) {
  40567. var node = nodes[i];
  40568. callback(node, index++);
  40569. // go to the next level if it is a group
  40570. if (node.hasChildren()) {
  40571. // depending on the recursion type, we pick a difference set of children
  40572. var nodeChildren = null;
  40573. switch (recursionType) {
  40574. case RecursionType.Normal:
  40575. nodeChildren = node.childrenAfterGroup;
  40576. break;
  40577. case RecursionType.AfterFilter:
  40578. nodeChildren = node.childrenAfterFilter;
  40579. break;
  40580. case RecursionType.AfterFilterAndSort:
  40581. nodeChildren = node.childrenAfterSort;
  40582. break;
  40583. case RecursionType.PivotNodes:
  40584. // for pivot, we don't go below leafGroup levels
  40585. nodeChildren = !node.leafGroup ? node.childrenAfterSort : null;
  40586. break;
  40587. }
  40588. if (nodeChildren) {
  40589. index = this.recursivelyWalkNodesAndCallback(nodeChildren, callback, recursionType, index);
  40590. }
  40591. }
  40592. }
  40593. return index;
  40594. };
  40595. // it's possible to recompute the aggregate without doing the other parts
  40596. // + gridApi.recomputeAggregates()
  40597. ClientSideRowModel.prototype.doAggregate = function (changedPath) {
  40598. if (this.aggregationStage) {
  40599. this.aggregationStage.execute({ rowNode: this.rootNode, changedPath: changedPath });
  40600. }
  40601. };
  40602. // + gridApi.expandAll()
  40603. // + gridApi.collapseAll()
  40604. ClientSideRowModel.prototype.expandOrCollapseAll = function (expand) {
  40605. var usingTreeData = this.gridOptionsWrapper.isTreeData();
  40606. if (this.rootNode) {
  40607. recursiveExpandOrCollapse(this.rootNode.childrenAfterGroup);
  40608. }
  40609. function recursiveExpandOrCollapse(rowNodes) {
  40610. if (!rowNodes) {
  40611. return;
  40612. }
  40613. rowNodes.forEach(function (rowNode) {
  40614. var shouldExpandOrCollapse = usingTreeData ? _.exists(rowNode.childrenAfterGroup) : rowNode.group;
  40615. if (shouldExpandOrCollapse) {
  40616. rowNode.expanded = expand;
  40617. recursiveExpandOrCollapse(rowNode.childrenAfterGroup);
  40618. }
  40619. });
  40620. }
  40621. this.refreshModel({ step: Constants.STEP_MAP });
  40622. var eventSource = expand ? 'expandAll' : 'collapseAll';
  40623. var event = {
  40624. api: this.gridApi,
  40625. columnApi: this.columnApi,
  40626. type: Events.EVENT_EXPAND_COLLAPSE_ALL,
  40627. source: eventSource
  40628. };
  40629. this.eventService.dispatchEvent(event);
  40630. };
  40631. ClientSideRowModel.prototype.doSort = function (rowNodeTransactions, changedPath) {
  40632. this.sortStage.execute({
  40633. rowNode: this.rootNode,
  40634. rowNodeTransactions: rowNodeTransactions,
  40635. changedPath: changedPath
  40636. });
  40637. };
  40638. ClientSideRowModel.prototype.doRowGrouping = function (groupState, rowNodeTransactions, rowNodeOrder, changedPath, afterColumnsChanged) {
  40639. // grouping is enterprise only, so if service missing, skip the step
  40640. var doingLegacyTreeData = _.exists(this.gridOptionsWrapper.getNodeChildDetailsFunc());
  40641. if (doingLegacyTreeData) {
  40642. return;
  40643. }
  40644. if (this.groupStage) {
  40645. if (rowNodeTransactions) {
  40646. this.groupStage.execute({
  40647. rowNode: this.rootNode,
  40648. rowNodeTransactions: rowNodeTransactions,
  40649. rowNodeOrder: rowNodeOrder,
  40650. changedPath: changedPath
  40651. });
  40652. }
  40653. else {
  40654. // groups are about to get disposed, so need to deselect any that are selected
  40655. this.selectionController.removeGroupsFromSelection();
  40656. this.groupStage.execute({
  40657. rowNode: this.rootNode,
  40658. changedPath: changedPath,
  40659. afterColumnsChanged: afterColumnsChanged
  40660. });
  40661. // set open/closed state on groups
  40662. this.restoreGroupState(groupState);
  40663. }
  40664. if (this.gridOptionsWrapper.isGroupSelectsChildren()) {
  40665. this.selectionController.updateGroupsFromChildrenSelections(changedPath);
  40666. }
  40667. }
  40668. else {
  40669. this.rootNode.childrenAfterGroup = this.rootNode.allLeafChildren;
  40670. }
  40671. };
  40672. ClientSideRowModel.prototype.restoreGroupState = function (groupState) {
  40673. if (!groupState) {
  40674. return;
  40675. }
  40676. _.traverseNodesWithKey(this.rootNode.childrenAfterGroup, function (node, key) {
  40677. // if the group was open last time, then open it this time. however
  40678. // if was not open last time, then don't touch the group, so the 'groupDefaultExpanded'
  40679. // setting will take effect.
  40680. if (typeof groupState[key] === 'boolean') {
  40681. node.expanded = groupState[key];
  40682. }
  40683. });
  40684. };
  40685. ClientSideRowModel.prototype.doFilter = function (changedPath) {
  40686. this.filterStage.execute({ rowNode: this.rootNode, changedPath: changedPath });
  40687. };
  40688. ClientSideRowModel.prototype.doPivot = function (changedPath) {
  40689. if (this.pivotStage) {
  40690. this.pivotStage.execute({ rowNode: this.rootNode, changedPath: changedPath });
  40691. }
  40692. };
  40693. ClientSideRowModel.prototype.getGroupState = function () {
  40694. if (!this.rootNode.childrenAfterGroup || !this.gridOptionsWrapper.isRememberGroupStateWhenNewData()) {
  40695. return null;
  40696. }
  40697. var result = {};
  40698. _.traverseNodesWithKey(this.rootNode.childrenAfterGroup, function (node, key) { return result[key] = node.expanded; });
  40699. return result;
  40700. };
  40701. ClientSideRowModel.prototype.getCopyOfNodesMap = function () {
  40702. return this.nodeManager.getCopyOfNodesMap();
  40703. };
  40704. ClientSideRowModel.prototype.getRowNode = function (id) {
  40705. return this.nodeManager.getRowNode(id);
  40706. };
  40707. // rows: the rows to put into the model
  40708. ClientSideRowModel.prototype.setRowData = function (rowData) {
  40709. // no need to invalidate cache, as the cache is stored on the rowNode,
  40710. // so new rowNodes means the cache is wiped anyway.
  40711. // remember group state, so we can expand groups that should be expanded
  40712. var groupState = this.getGroupState();
  40713. this.nodeManager.setRowData(rowData);
  40714. // this event kicks off:
  40715. // - clears selection
  40716. // - updates filters
  40717. // - shows 'no rows' overlay if needed
  40718. var rowDataChangedEvent = {
  40719. type: Events.EVENT_ROW_DATA_CHANGED,
  40720. api: this.gridApi,
  40721. columnApi: this.columnApi
  40722. };
  40723. this.eventService.dispatchEvent(rowDataChangedEvent);
  40724. this.refreshModel({
  40725. step: Constants.STEP_EVERYTHING,
  40726. groupState: groupState,
  40727. newData: true
  40728. });
  40729. };
  40730. ClientSideRowModel.prototype.batchUpdateRowData = function (rowDataTransaction, callback) {
  40731. var _this = this;
  40732. if (!this.rowDataTransactionBatch) {
  40733. this.rowDataTransactionBatch = [];
  40734. var waitMillis = this.gridOptionsWrapper.getAsyncTransactionWaitMillis();
  40735. window.setTimeout(function () {
  40736. _this.executeBatchUpdateRowData();
  40737. _this.rowDataTransactionBatch = null;
  40738. }, waitMillis);
  40739. }
  40740. this.rowDataTransactionBatch.push({ rowDataTransaction: rowDataTransaction, callback: callback });
  40741. };
  40742. ClientSideRowModel.prototype.executeBatchUpdateRowData = function () {
  40743. var _this = this;
  40744. this.valueCache.onDataChanged();
  40745. var callbackFuncsBound = [];
  40746. var rowNodeTrans = [];
  40747. if (this.rowDataTransactionBatch) {
  40748. this.rowDataTransactionBatch.forEach(function (tranItem) {
  40749. var rowNodeTran = _this.nodeManager.updateRowData(tranItem.rowDataTransaction, null);
  40750. rowNodeTrans.push(rowNodeTran);
  40751. if (tranItem.callback) {
  40752. callbackFuncsBound.push(tranItem.callback.bind(null, rowNodeTran));
  40753. }
  40754. });
  40755. }
  40756. this.commonUpdateRowData(rowNodeTrans);
  40757. // do callbacks in next VM turn so it's async
  40758. if (callbackFuncsBound.length > 0) {
  40759. window.setTimeout(function () {
  40760. callbackFuncsBound.forEach(function (func) { return func(); });
  40761. }, 0);
  40762. }
  40763. };
  40764. ClientSideRowModel.prototype.updateRowData = function (rowDataTran, rowNodeOrder) {
  40765. this.valueCache.onDataChanged();
  40766. var rowNodeTran = this.nodeManager.updateRowData(rowDataTran, rowNodeOrder);
  40767. this.commonUpdateRowData([rowNodeTran], rowNodeOrder);
  40768. return rowNodeTran;
  40769. };
  40770. // common to updateRowData and batchUpdateRowData
  40771. ClientSideRowModel.prototype.commonUpdateRowData = function (rowNodeTrans, rowNodeOrder) {
  40772. this.refreshModel({
  40773. step: Constants.STEP_EVERYTHING,
  40774. rowNodeTransactions: rowNodeTrans,
  40775. rowNodeOrder: rowNodeOrder,
  40776. keepRenderedRows: true,
  40777. animate: true,
  40778. keepEditingRows: true
  40779. });
  40780. var event = {
  40781. type: Events.EVENT_ROW_DATA_UPDATED,
  40782. api: this.gridApi,
  40783. columnApi: this.columnApi
  40784. };
  40785. this.eventService.dispatchEvent(event);
  40786. };
  40787. ClientSideRowModel.prototype.doRowsToDisplay = function () {
  40788. this.rowsToDisplay = this.flattenStage.execute({ rowNode: this.rootNode });
  40789. };
  40790. ClientSideRowModel.prototype.onRowHeightChanged = function () {
  40791. this.refreshModel({ step: Constants.STEP_MAP, keepRenderedRows: true, keepEditingRows: true });
  40792. };
  40793. ClientSideRowModel.prototype.resetRowHeights = function () {
  40794. this.forEachNode(function (rowNode) {
  40795. rowNode.setRowHeight(null);
  40796. // forEachNode doesn't go through detail rows, so need to check
  40797. // for detail nodes explicitly.
  40798. if (rowNode.detailNode) {
  40799. rowNode.detailNode.setRowHeight(null);
  40800. }
  40801. });
  40802. this.onRowHeightChanged();
  40803. };
  40804. __decorate$1X([
  40805. Autowired('gridOptionsWrapper')
  40806. ], ClientSideRowModel.prototype, "gridOptionsWrapper", void 0);
  40807. __decorate$1X([
  40808. Autowired('columnController')
  40809. ], ClientSideRowModel.prototype, "columnController", void 0);
  40810. __decorate$1X([
  40811. Autowired('filterManager')
  40812. ], ClientSideRowModel.prototype, "filterManager", void 0);
  40813. __decorate$1X([
  40814. Autowired('$scope')
  40815. ], ClientSideRowModel.prototype, "$scope", void 0);
  40816. __decorate$1X([
  40817. Autowired('selectionController')
  40818. ], ClientSideRowModel.prototype, "selectionController", void 0);
  40819. __decorate$1X([
  40820. Autowired('valueService')
  40821. ], ClientSideRowModel.prototype, "valueService", void 0);
  40822. __decorate$1X([
  40823. Autowired('valueCache')
  40824. ], ClientSideRowModel.prototype, "valueCache", void 0);
  40825. __decorate$1X([
  40826. Autowired('columnApi')
  40827. ], ClientSideRowModel.prototype, "columnApi", void 0);
  40828. __decorate$1X([
  40829. Autowired('gridApi')
  40830. ], ClientSideRowModel.prototype, "gridApi", void 0);
  40831. __decorate$1X([
  40832. Autowired('filterStage')
  40833. ], ClientSideRowModel.prototype, "filterStage", void 0);
  40834. __decorate$1X([
  40835. Autowired('sortStage')
  40836. ], ClientSideRowModel.prototype, "sortStage", void 0);
  40837. __decorate$1X([
  40838. Autowired('flattenStage')
  40839. ], ClientSideRowModel.prototype, "flattenStage", void 0);
  40840. __decorate$1X([
  40841. Optional('groupStage')
  40842. ], ClientSideRowModel.prototype, "groupStage", void 0);
  40843. __decorate$1X([
  40844. Optional('aggregationStage')
  40845. ], ClientSideRowModel.prototype, "aggregationStage", void 0);
  40846. __decorate$1X([
  40847. Optional('pivotStage')
  40848. ], ClientSideRowModel.prototype, "pivotStage", void 0);
  40849. __decorate$1X([
  40850. PostConstruct
  40851. ], ClientSideRowModel.prototype, "init", null);
  40852. ClientSideRowModel = __decorate$1X([
  40853. Bean('rowModel')
  40854. ], ClientSideRowModel);
  40855. return ClientSideRowModel;
  40856. }(BeanStub));
  40857. var __extends$23 = (undefined && undefined.__extends) || (function () {
  40858. var extendStatics = function (d, b) {
  40859. extendStatics = Object.setPrototypeOf ||
  40860. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  40861. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  40862. return extendStatics(d, b);
  40863. };
  40864. return function (d, b) {
  40865. extendStatics(d, b);
  40866. function __() { this.constructor = d; }
  40867. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  40868. };
  40869. })();
  40870. var __decorate$1Y = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  40871. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  40872. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  40873. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  40874. return c > 3 && r && Object.defineProperty(target, key, r), r;
  40875. };
  40876. var FilterStage = /** @class */ (function (_super) {
  40877. __extends$23(FilterStage, _super);
  40878. function FilterStage() {
  40879. return _super !== null && _super.apply(this, arguments) || this;
  40880. }
  40881. FilterStage.prototype.execute = function (params) {
  40882. var rowNode = params.rowNode, changedPath = params.changedPath;
  40883. this.filterService.filter(changedPath);
  40884. this.selectableService.updateSelectableAfterFiltering(rowNode);
  40885. };
  40886. __decorate$1Y([
  40887. Autowired('gridOptionsWrapper')
  40888. ], FilterStage.prototype, "gridOptionsWrapper", void 0);
  40889. __decorate$1Y([
  40890. Autowired('selectableService')
  40891. ], FilterStage.prototype, "selectableService", void 0);
  40892. __decorate$1Y([
  40893. Autowired('filterService')
  40894. ], FilterStage.prototype, "filterService", void 0);
  40895. FilterStage = __decorate$1Y([
  40896. Bean('filterStage')
  40897. ], FilterStage);
  40898. return FilterStage;
  40899. }(BeanStub));
  40900. var __extends$24 = (undefined && undefined.__extends) || (function () {
  40901. var extendStatics = function (d, b) {
  40902. extendStatics = Object.setPrototypeOf ||
  40903. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  40904. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  40905. return extendStatics(d, b);
  40906. };
  40907. return function (d, b) {
  40908. extendStatics(d, b);
  40909. function __() { this.constructor = d; }
  40910. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  40911. };
  40912. })();
  40913. var __decorate$1Z = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  40914. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  40915. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  40916. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  40917. return c > 3 && r && Object.defineProperty(target, key, r), r;
  40918. };
  40919. var SortStage = /** @class */ (function (_super) {
  40920. __extends$24(SortStage, _super);
  40921. function SortStage() {
  40922. return _super !== null && _super.apply(this, arguments) || this;
  40923. }
  40924. SortStage.prototype.execute = function (params) {
  40925. var sortOptions = this.sortController.getSortForRowController();
  40926. var sortActive = _.exists(sortOptions) && sortOptions.length > 0;
  40927. var deltaSort = sortActive
  40928. && _.exists(params.rowNodeTransactions)
  40929. // in time we can remove this check, so that delta sort is always
  40930. // on if transactions are present. it's off for now so that we can
  40931. // selectively turn it on and test it with some select users before
  40932. // rolling out to everyone.
  40933. && this.gridOptionsWrapper.isDeltaSort();
  40934. // we only need dirty nodes if doing delta sort
  40935. var dirtyLeafNodes = deltaSort ? this.calculateDirtyNodes(params.rowNodeTransactions) : null;
  40936. var valueColumns = this.columnController.getValueColumns();
  40937. var noAggregations = _.missingOrEmpty(valueColumns);
  40938. this.sortService.sort(sortOptions, sortActive, deltaSort, dirtyLeafNodes, params.changedPath, noAggregations);
  40939. };
  40940. SortStage.prototype.calculateDirtyNodes = function (rowNodeTransactions) {
  40941. var dirtyNodes = {};
  40942. var addNodesFunc = function (rowNodes) {
  40943. if (rowNodes) {
  40944. rowNodes.forEach(function (rowNode) { return dirtyNodes[rowNode.id] = true; });
  40945. }
  40946. };
  40947. // all leaf level nodes in the transaction were impacted
  40948. rowNodeTransactions.forEach(function (tran) {
  40949. addNodesFunc(tran.add);
  40950. addNodesFunc(tran.update);
  40951. addNodesFunc(tran.remove);
  40952. });
  40953. return dirtyNodes;
  40954. };
  40955. __decorate$1Z([
  40956. Autowired('gridOptionsWrapper')
  40957. ], SortStage.prototype, "gridOptionsWrapper", void 0);
  40958. __decorate$1Z([
  40959. Autowired('sortService')
  40960. ], SortStage.prototype, "sortService", void 0);
  40961. __decorate$1Z([
  40962. Autowired('sortController')
  40963. ], SortStage.prototype, "sortController", void 0);
  40964. __decorate$1Z([
  40965. Autowired('columnController')
  40966. ], SortStage.prototype, "columnController", void 0);
  40967. SortStage = __decorate$1Z([
  40968. Bean('sortStage')
  40969. ], SortStage);
  40970. return SortStage;
  40971. }(BeanStub));
  40972. var __extends$25 = (undefined && undefined.__extends) || (function () {
  40973. var extendStatics = function (d, b) {
  40974. extendStatics = Object.setPrototypeOf ||
  40975. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  40976. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  40977. return extendStatics(d, b);
  40978. };
  40979. return function (d, b) {
  40980. extendStatics(d, b);
  40981. function __() { this.constructor = d; }
  40982. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  40983. };
  40984. })();
  40985. var __decorate$1_ = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  40986. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  40987. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  40988. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  40989. return c > 3 && r && Object.defineProperty(target, key, r), r;
  40990. };
  40991. var FlattenStage = /** @class */ (function (_super) {
  40992. __extends$25(FlattenStage, _super);
  40993. function FlattenStage() {
  40994. return _super !== null && _super.apply(this, arguments) || this;
  40995. }
  40996. FlattenStage.prototype.execute = function (params) {
  40997. var rootNode = params.rowNode;
  40998. // even if not doing grouping, we do the mapping, as the client might
  40999. // of passed in data that already has a grouping in it somewhere
  41000. var result = [];
  41001. // putting value into a wrapper so it's passed by reference
  41002. var nextRowTop = { value: 0 };
  41003. var skipLeafNodes = this.columnController.isPivotMode();
  41004. // if we are reducing, and not grouping, then we want to show the root node, as that
  41005. // is where the pivot values are
  41006. var showRootNode = skipLeafNodes && rootNode.leafGroup;
  41007. var topList = showRootNode ? [rootNode] : rootNode.childrenAfterSort;
  41008. this.recursivelyAddToRowsToDisplay(topList, result, nextRowTop, skipLeafNodes, 0);
  41009. // we do not want the footer total if the gris is empty
  41010. var atLeastOneRowPresent = result.length > 0;
  41011. var includeGroupTotalFooter = !showRootNode
  41012. // don't show total footer when showRootNode is true (i.e. in pivot mode and no groups)
  41013. && atLeastOneRowPresent
  41014. && this.gridOptionsWrapper.isGroupIncludeTotalFooter();
  41015. if (includeGroupTotalFooter) {
  41016. this.ensureFooterNodeExists(rootNode);
  41017. this.addRowNodeToRowsToDisplay(rootNode.sibling, result, nextRowTop, 0);
  41018. }
  41019. return result;
  41020. };
  41021. FlattenStage.prototype.recursivelyAddToRowsToDisplay = function (rowsToFlatten, result, nextRowTop, skipLeafNodes, uiLevel) {
  41022. if (_.missingOrEmpty(rowsToFlatten)) {
  41023. return;
  41024. }
  41025. var groupSuppressRow = this.gridOptionsWrapper.isGroupSuppressRow();
  41026. var hideOpenParents = this.gridOptionsWrapper.isGroupHideOpenParents();
  41027. // these two are mutually exclusive, so if first set, we don't set the second
  41028. var groupRemoveSingleChildren = this.gridOptionsWrapper.isGroupRemoveSingleChildren();
  41029. var groupRemoveLowestSingleChildren = !groupRemoveSingleChildren && this.gridOptionsWrapper.isGroupRemoveLowestSingleChildren();
  41030. for (var i = 0; i < rowsToFlatten.length; i++) {
  41031. var rowNode = rowsToFlatten[i];
  41032. // check all these cases, for working out if this row should be included in the final mapped list
  41033. var isParent = rowNode.hasChildren();
  41034. var isGroupSuppressedNode = groupSuppressRow && isParent;
  41035. var isSkippedLeafNode = skipLeafNodes && !isParent;
  41036. var isRemovedSingleChildrenGroup = groupRemoveSingleChildren &&
  41037. isParent &&
  41038. rowNode.childrenAfterGroup.length === 1;
  41039. var isRemovedLowestSingleChildrenGroup = groupRemoveLowestSingleChildren &&
  41040. isParent &&
  41041. rowNode.leafGroup &&
  41042. rowNode.childrenAfterGroup.length === 1;
  41043. // hide open parents means when group is open, we don't show it. we also need to make sure the
  41044. // group is expandable in the first place (as leaf groups are not expandable if pivot mode is on).
  41045. // the UI will never allow expanding leaf groups, however the user might via the API (or menu option 'expand all')
  41046. var neverAllowToExpand = skipLeafNodes && rowNode.leafGroup;
  41047. var isHiddenOpenParent = hideOpenParents && rowNode.expanded && (!neverAllowToExpand);
  41048. var thisRowShouldBeRendered = !isSkippedLeafNode &&
  41049. !isGroupSuppressedNode &&
  41050. !isHiddenOpenParent &&
  41051. !isRemovedSingleChildrenGroup &&
  41052. !isRemovedLowestSingleChildrenGroup;
  41053. if (thisRowShouldBeRendered) {
  41054. this.addRowNodeToRowsToDisplay(rowNode, result, nextRowTop, uiLevel);
  41055. }
  41056. // if we are pivoting, we never map below the leaf group
  41057. if (skipLeafNodes && rowNode.leafGroup) {
  41058. continue;
  41059. }
  41060. if (isParent) {
  41061. var excludedParent = isRemovedSingleChildrenGroup || isRemovedLowestSingleChildrenGroup;
  41062. // we traverse the group if it is expended, however we always traverse if the parent node
  41063. // was removed (as the group will never be opened if it is not displayed, we show the children instead)
  41064. if (rowNode.expanded || excludedParent) {
  41065. // if the parent was excluded, then ui level is that of the parent
  41066. var uiLevelForChildren = excludedParent ? uiLevel : uiLevel + 1;
  41067. this.recursivelyAddToRowsToDisplay(rowNode.childrenAfterSort, result, nextRowTop, skipLeafNodes, uiLevelForChildren);
  41068. // put a footer in if user is looking for it
  41069. if (this.gridOptionsWrapper.isGroupIncludeFooter()) {
  41070. this.ensureFooterNodeExists(rowNode);
  41071. this.addRowNodeToRowsToDisplay(rowNode.sibling, result, nextRowTop, uiLevel);
  41072. }
  41073. }
  41074. }
  41075. else if (rowNode.master && rowNode.expanded) {
  41076. var detailNode = this.createDetailNode(rowNode);
  41077. this.addRowNodeToRowsToDisplay(detailNode, result, nextRowTop, uiLevel);
  41078. }
  41079. }
  41080. };
  41081. // duplicated method, it's also in floatingRowModel
  41082. FlattenStage.prototype.addRowNodeToRowsToDisplay = function (rowNode, result, nextRowTop, uiLevel) {
  41083. var isGroupMultiAutoColumn = this.gridOptionsWrapper.isGroupMultiAutoColumn();
  41084. result.push(rowNode);
  41085. rowNode.setUiLevel(isGroupMultiAutoColumn ? 0 : uiLevel);
  41086. };
  41087. FlattenStage.prototype.ensureFooterNodeExists = function (groupNode) {
  41088. // only create footer node once, otherwise we have daemons and
  41089. // the animate screws up with the daemons hanging around
  41090. if (_.exists(groupNode.sibling)) {
  41091. return;
  41092. }
  41093. var footerNode = new RowNode();
  41094. this.context.createBean(footerNode);
  41095. Object.keys(groupNode).forEach(function (key) {
  41096. footerNode[key] = groupNode[key];
  41097. });
  41098. footerNode.footer = true;
  41099. footerNode.rowTop = null;
  41100. footerNode.oldRowTop = null;
  41101. if (_.exists(footerNode.id)) {
  41102. footerNode.id = 'rowGroupFooter_' + footerNode.id;
  41103. }
  41104. // get both header and footer to reference each other as siblings. this is never undone,
  41105. // only overwritten. so if a group is expanded, then contracted, it will have a ghost
  41106. // sibling - but that's fine, as we can ignore this if the header is contracted.
  41107. footerNode.sibling = groupNode;
  41108. groupNode.sibling = footerNode;
  41109. };
  41110. FlattenStage.prototype.createDetailNode = function (masterNode) {
  41111. if (_.exists(masterNode.detailNode)) {
  41112. return masterNode.detailNode;
  41113. }
  41114. var detailNode = new RowNode();
  41115. this.context.createBean(detailNode);
  41116. detailNode.detail = true;
  41117. detailNode.selectable = false;
  41118. // flower was renamed to 'detail', but keeping for backwards compatibility
  41119. detailNode.flower = detailNode.detail;
  41120. detailNode.parent = masterNode;
  41121. if (_.exists(masterNode.id)) {
  41122. detailNode.id = 'detail_' + masterNode.id;
  41123. }
  41124. detailNode.data = masterNode.data;
  41125. detailNode.level = masterNode.level + 1;
  41126. masterNode.detailNode = detailNode;
  41127. masterNode.childFlower = masterNode.detailNode; // for backwards compatibility
  41128. return detailNode;
  41129. };
  41130. __decorate$1_([
  41131. Autowired('gridOptionsWrapper')
  41132. ], FlattenStage.prototype, "gridOptionsWrapper", void 0);
  41133. __decorate$1_([
  41134. Autowired('selectionController')
  41135. ], FlattenStage.prototype, "selectionController", void 0);
  41136. __decorate$1_([
  41137. Autowired('columnController')
  41138. ], FlattenStage.prototype, "columnController", void 0);
  41139. FlattenStage = __decorate$1_([
  41140. Bean('flattenStage')
  41141. ], FlattenStage);
  41142. return FlattenStage;
  41143. }(BeanStub));
  41144. var __extends$26 = (undefined && undefined.__extends) || (function () {
  41145. var extendStatics = function (d, b) {
  41146. extendStatics = Object.setPrototypeOf ||
  41147. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  41148. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  41149. return extendStatics(d, b);
  41150. };
  41151. return function (d, b) {
  41152. extendStatics(d, b);
  41153. function __() { this.constructor = d; }
  41154. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  41155. };
  41156. })();
  41157. var __decorate$1$ = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  41158. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  41159. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  41160. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  41161. return c > 3 && r && Object.defineProperty(target, key, r), r;
  41162. };
  41163. var SortService = /** @class */ (function (_super) {
  41164. __extends$26(SortService, _super);
  41165. function SortService() {
  41166. return _super !== null && _super.apply(this, arguments) || this;
  41167. }
  41168. SortService.prototype.init = function () {
  41169. this.postSortFunc = this.gridOptionsWrapper.getPostSortFunc();
  41170. };
  41171. SortService.prototype.sort = function (sortOptions, sortActive, deltaSort, dirtyLeafNodes, changedPath, noAggregations) {
  41172. var _this = this;
  41173. var callback = function (rowNode) {
  41174. // we clear out the 'pull down open parents' first, as the values mix up the sorting
  41175. _this.pullDownGroupDataForHideOpenParents(rowNode.childrenAfterFilter, true);
  41176. // Javascript sort is non deterministic when all the array items are equals, ie Comparator always returns 0,
  41177. // so to ensure the array keeps its order, add an additional sorting condition manually, in this case we
  41178. // are going to inspect the original array position. This is what sortedRowNodes is for.
  41179. if (sortActive) {
  41180. var sortedRowNodes = deltaSort ?
  41181. _this.doDeltaSort(rowNode, sortOptions, dirtyLeafNodes, changedPath, noAggregations)
  41182. : _this.doFullSort(rowNode, sortOptions);
  41183. rowNode.childrenAfterSort = sortedRowNodes.map(function (sorted) { return sorted.rowNode; });
  41184. }
  41185. else {
  41186. rowNode.childrenAfterSort = rowNode.childrenAfterFilter.slice(0);
  41187. }
  41188. _this.updateChildIndexes(rowNode);
  41189. if (_this.postSortFunc) {
  41190. _this.postSortFunc(rowNode.childrenAfterSort);
  41191. }
  41192. };
  41193. changedPath.forEachChangedNodeDepthFirst(callback);
  41194. this.updateGroupDataForHiddenOpenParents(changedPath);
  41195. };
  41196. SortService.prototype.doFullSort = function (rowNode, sortOptions) {
  41197. var sortedRowNodes = rowNode.childrenAfterFilter
  41198. .map(this.mapNodeToSortedNode.bind(this));
  41199. sortedRowNodes.sort(this.compareRowNodes.bind(this, sortOptions));
  41200. return sortedRowNodes;
  41201. };
  41202. SortService.prototype.mapNodeToSortedNode = function (rowNode, pos) {
  41203. return { currentPos: pos, rowNode: rowNode };
  41204. };
  41205. SortService.prototype.doDeltaSort = function (rowNode, sortOptions, dirtyLeafNodes, changedPath, noAggregations) {
  41206. // clean nodes will be a list of all row nodes that remain in the set
  41207. // and ordered. we start with the old sorted set and take out any nodes
  41208. // that were removed or changed (but not added, added doesn't make sense,
  41209. // if a node was added, there is no way it could be here from last time).
  41210. var cleanNodes = rowNode.childrenAfterSort
  41211. .filter(function (rowNode) {
  41212. // take out all nodes that were changed as part of the current transaction.
  41213. // a changed node could a) be in a different sort position or b) may
  41214. // no longer be in this set as the changed node may not pass filtering,
  41215. // or be in a different group.
  41216. var passesDirtyNodesCheck = !dirtyLeafNodes[rowNode.id];
  41217. // also remove group nodes in the changed path, as they can have different aggregate
  41218. // values which could impact the sort order.
  41219. // note: changed path is not active if a) no value columns or b) no transactions. it is never
  41220. // (b) in deltaSort as we only do deltaSort for transactions. for (a) if no value columns, then
  41221. // there is no value in the group that could of changed (ie no aggregate values)
  41222. var passesChangedPathCheck = noAggregations || changedPath.canSkip(rowNode);
  41223. return passesDirtyNodesCheck && passesChangedPathCheck;
  41224. })
  41225. .map(this.mapNodeToSortedNode.bind(this));
  41226. // for fast access below, we map them
  41227. var cleanNodesMapped = {};
  41228. cleanNodes.forEach(function (sortedRowNode) { return cleanNodesMapped[sortedRowNode.rowNode.id] = sortedRowNode.rowNode; });
  41229. // these are all nodes that need to be placed
  41230. var changedNodes = rowNode.childrenAfterFilter
  41231. // ignore nodes in the clean list
  41232. .filter(function (rowNode) { return !cleanNodesMapped[rowNode.id]; })
  41233. .map(this.mapNodeToSortedNode.bind(this));
  41234. // sort changed nodes. note that we don't need to sort cleanNodes as they are
  41235. // already sorted from last time.
  41236. changedNodes.sort(this.compareRowNodes.bind(this, sortOptions));
  41237. if (changedNodes.length === 0) {
  41238. return cleanNodes;
  41239. }
  41240. else if (cleanNodes.length === 0) {
  41241. return changedNodes;
  41242. }
  41243. else {
  41244. return this.mergeSortedArrays(sortOptions, cleanNodes, changedNodes);
  41245. }
  41246. };
  41247. // Merge two sorted arrays into each other
  41248. SortService.prototype.mergeSortedArrays = function (sortOptions, arr1, arr2) {
  41249. var res = [];
  41250. var i = 0;
  41251. var j = 0;
  41252. // Traverse both array, adding them in order
  41253. while (i < arr1.length && j < arr2.length) {
  41254. // Check if current element of first
  41255. // array is smaller than current element
  41256. // of second array. If yes, store first
  41257. // array element and increment first array
  41258. // index. Otherwise do same with second array
  41259. var compareResult = this.compareRowNodes(sortOptions, arr1[i], arr2[j]);
  41260. if (compareResult < 0) {
  41261. res.push(arr1[i++]);
  41262. }
  41263. else {
  41264. res.push(arr2[j++]);
  41265. }
  41266. }
  41267. // add remaining from arr1
  41268. while (i < arr1.length) {
  41269. res.push(arr1[i++]);
  41270. }
  41271. // add remaining from arr2
  41272. while (j < arr2.length) {
  41273. res.push(arr2[j++]);
  41274. }
  41275. return res;
  41276. };
  41277. SortService.prototype.compareRowNodes = function (sortOptions, sortedNodeA, sortedNodeB) {
  41278. var nodeA = sortedNodeA.rowNode;
  41279. var nodeB = sortedNodeB.rowNode;
  41280. // Iterate columns, return the first that doesn't match
  41281. for (var i = 0, len = sortOptions.length; i < len; i++) {
  41282. var sortOption = sortOptions[i];
  41283. // let compared = compare(nodeA, nodeB, sortOption.column, sortOption.inverter === -1);
  41284. var isInverted = sortOption.inverter === -1;
  41285. var valueA = this.getValue(nodeA, sortOption.column);
  41286. var valueB = this.getValue(nodeB, sortOption.column);
  41287. var comparatorResult = void 0;
  41288. if (sortOption.column.getColDef().comparator) {
  41289. //if comparator provided, use it
  41290. comparatorResult = sortOption.column.getColDef().comparator(valueA, valueB, nodeA, nodeB, isInverted);
  41291. }
  41292. else {
  41293. //otherwise do our own comparison
  41294. comparatorResult = _.defaultComparator(valueA, valueB, this.gridOptionsWrapper.isAccentedSort());
  41295. }
  41296. if (comparatorResult !== 0) {
  41297. return comparatorResult * sortOption.inverter;
  41298. }
  41299. }
  41300. // All matched, we make is so that the original sort order is kept:
  41301. return sortedNodeA.currentPos - sortedNodeB.currentPos;
  41302. };
  41303. SortService.prototype.getValue = function (nodeA, column) {
  41304. return this.valueService.getValue(column, nodeA);
  41305. };
  41306. SortService.prototype.updateChildIndexes = function (rowNode) {
  41307. if (_.missing(rowNode.childrenAfterSort)) {
  41308. return;
  41309. }
  41310. var listToSort = rowNode.childrenAfterSort;
  41311. for (var i = 0; i < listToSort.length; i++) {
  41312. var child = listToSort[i];
  41313. var firstChild = i === 0;
  41314. var lastChild = i === rowNode.childrenAfterSort.length - 1;
  41315. child.setFirstChild(firstChild);
  41316. child.setLastChild(lastChild);
  41317. child.setChildIndex(i);
  41318. }
  41319. };
  41320. SortService.prototype.updateGroupDataForHiddenOpenParents = function (changedPath) {
  41321. var _this = this;
  41322. if (!this.gridOptionsWrapper.isGroupHideOpenParents()) {
  41323. return;
  41324. }
  41325. // recurse breadth first over group nodes after sort to 'pull down' group data to child groups
  41326. var callback = function (rowNode) {
  41327. _this.pullDownGroupDataForHideOpenParents(rowNode.childrenAfterSort, false);
  41328. rowNode.childrenAfterSort.forEach(function (child) {
  41329. if (child.hasChildren()) {
  41330. callback(child);
  41331. }
  41332. });
  41333. };
  41334. changedPath.executeFromRootNode(function (rowNode) { return callback(rowNode); });
  41335. };
  41336. SortService.prototype.pullDownGroupDataForHideOpenParents = function (rowNodes, clearOperation) {
  41337. var _this = this;
  41338. if (_.missing(rowNodes)) {
  41339. return;
  41340. }
  41341. if (!this.gridOptionsWrapper.isGroupHideOpenParents()) {
  41342. return;
  41343. }
  41344. rowNodes.forEach(function (childRowNode) {
  41345. var groupDisplayCols = _this.columnController.getGroupDisplayColumns();
  41346. groupDisplayCols.forEach(function (groupDisplayCol) {
  41347. var showRowGroup = groupDisplayCol.getColDef().showRowGroup;
  41348. if (typeof showRowGroup !== 'string') {
  41349. console.error('ag-Grid: groupHideOpenParents only works when specifying specific columns for colDef.showRowGroup');
  41350. return;
  41351. }
  41352. var displayingGroupKey = showRowGroup;
  41353. var rowGroupColumn = _this.columnController.getPrimaryColumn(displayingGroupKey);
  41354. var thisRowNodeMatches = rowGroupColumn === childRowNode.rowGroupColumn;
  41355. if (thisRowNodeMatches) {
  41356. return;
  41357. }
  41358. if (clearOperation) {
  41359. // if doing a clear operation, we clear down the value for every possible group column
  41360. childRowNode.setGroupValue(groupDisplayCol.getId(), null);
  41361. }
  41362. else {
  41363. // if doing a set operation, we set only where the pull down is to occur
  41364. var parentToStealFrom = childRowNode.getFirstChildOfFirstChild(rowGroupColumn);
  41365. if (parentToStealFrom) {
  41366. childRowNode.setGroupValue(groupDisplayCol.getId(), parentToStealFrom.key);
  41367. }
  41368. }
  41369. });
  41370. });
  41371. };
  41372. __decorate$1$([
  41373. Autowired('sortController')
  41374. ], SortService.prototype, "sortController", void 0);
  41375. __decorate$1$([
  41376. Autowired('columnController')
  41377. ], SortService.prototype, "columnController", void 0);
  41378. __decorate$1$([
  41379. Autowired('valueService')
  41380. ], SortService.prototype, "valueService", void 0);
  41381. __decorate$1$([
  41382. Autowired('gridOptionsWrapper')
  41383. ], SortService.prototype, "gridOptionsWrapper", void 0);
  41384. __decorate$1$([
  41385. PostConstruct
  41386. ], SortService.prototype, "init", null);
  41387. SortService = __decorate$1$([
  41388. Bean('sortService')
  41389. ], SortService);
  41390. return SortService;
  41391. }(BeanStub));
  41392. var __extends$27 = (undefined && undefined.__extends) || (function () {
  41393. var extendStatics = function (d, b) {
  41394. extendStatics = Object.setPrototypeOf ||
  41395. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  41396. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  41397. return extendStatics(d, b);
  41398. };
  41399. return function (d, b) {
  41400. extendStatics(d, b);
  41401. function __() { this.constructor = d; }
  41402. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  41403. };
  41404. })();
  41405. var __decorate$20 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  41406. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  41407. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  41408. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  41409. return c > 3 && r && Object.defineProperty(target, key, r), r;
  41410. };
  41411. var FilterService = /** @class */ (function (_super) {
  41412. __extends$27(FilterService, _super);
  41413. function FilterService() {
  41414. return _super !== null && _super.apply(this, arguments) || this;
  41415. }
  41416. FilterService.prototype.postConstruct = function () {
  41417. this.doingTreeData = this.gridOptionsWrapper.isTreeData();
  41418. };
  41419. FilterService.prototype.filter = function (changedPath) {
  41420. var filterActive = this.filterManager.isAnyFilterPresent();
  41421. this.filterNodes(filterActive, changedPath);
  41422. };
  41423. FilterService.prototype.filterNodes = function (filterActive, changedPath) {
  41424. var _this = this;
  41425. var filterCallback = function (rowNode, includeChildNodes) {
  41426. // recursively get all children that are groups to also filter
  41427. if (rowNode.hasChildren()) {
  41428. // result of filter for this node. when filtering tree data, includeChildNodes = true when parent passes
  41429. if (filterActive && !includeChildNodes) {
  41430. rowNode.childrenAfterFilter = rowNode.childrenAfterGroup.filter(function (childNode) {
  41431. // a group is included in the result if it has any children of it's own.
  41432. // by this stage, the child groups are already filtered
  41433. var passBecauseChildren = childNode.childrenAfterFilter && childNode.childrenAfterFilter.length > 0;
  41434. // both leaf level nodes and tree data nodes have data. these get added if
  41435. // the data passes the filter
  41436. var passBecauseDataPasses = childNode.data && _this.filterManager.doesRowPassFilter(childNode);
  41437. // note - tree data nodes pass either if a) they pass themselves or b) any children of that node pass
  41438. return passBecauseChildren || passBecauseDataPasses;
  41439. });
  41440. }
  41441. else {
  41442. // if not filtering, the result is the original list
  41443. rowNode.childrenAfterFilter = rowNode.childrenAfterGroup;
  41444. }
  41445. _this.setAllChildrenCount(rowNode);
  41446. }
  41447. else {
  41448. rowNode.childrenAfterFilter = rowNode.childrenAfterGroup;
  41449. rowNode.setAllChildrenCount(null);
  41450. }
  41451. };
  41452. if (this.doingTreeDataFiltering()) {
  41453. var treeDataDepthFirstFilter_1 = function (rowNode, alreadyFoundInParent) {
  41454. // tree data filter traverses the hierarchy depth first and includes child nodes if parent passes
  41455. // filter, and parent nodes will be include if any children exist.
  41456. if (rowNode.childrenAfterGroup) {
  41457. for (var i = 0; i < rowNode.childrenAfterGroup.length; i++) {
  41458. var childNode = rowNode.childrenAfterGroup[i];
  41459. // first check if current node passes filter before invoking child nodes
  41460. var foundInParent = alreadyFoundInParent || _this.filterManager.doesRowPassFilter(childNode);
  41461. if (childNode.childrenAfterGroup) {
  41462. treeDataDepthFirstFilter_1(rowNode.childrenAfterGroup[i], foundInParent);
  41463. }
  41464. else {
  41465. filterCallback(childNode, foundInParent);
  41466. }
  41467. }
  41468. }
  41469. filterCallback(rowNode, alreadyFoundInParent);
  41470. };
  41471. var treeDataFilterCallback = function (rowNode) { return treeDataDepthFirstFilter_1(rowNode, false); };
  41472. changedPath.executeFromRootNode(treeDataFilterCallback);
  41473. }
  41474. else {
  41475. var defaultFilterCallback = function (rowNode) { return filterCallback(rowNode, false); };
  41476. changedPath.forEachChangedNodeDepthFirst(defaultFilterCallback, true);
  41477. }
  41478. };
  41479. FilterService.prototype.setAllChildrenCountTreeData = function (rowNode) {
  41480. // for tree data, we include all children, groups and leafs
  41481. var allChildrenCount = 0;
  41482. rowNode.childrenAfterFilter.forEach(function (child) {
  41483. // include child itself
  41484. allChildrenCount++;
  41485. // include children of children
  41486. allChildrenCount += child.allChildrenCount;
  41487. });
  41488. rowNode.setAllChildrenCount(allChildrenCount);
  41489. };
  41490. FilterService.prototype.setAllChildrenCountGridGrouping = function (rowNode) {
  41491. // for grid data, we only count the leafs
  41492. var allChildrenCount = 0;
  41493. rowNode.childrenAfterFilter.forEach(function (child) {
  41494. if (child.group) {
  41495. allChildrenCount += child.allChildrenCount;
  41496. }
  41497. else {
  41498. allChildrenCount++;
  41499. }
  41500. });
  41501. rowNode.setAllChildrenCount(allChildrenCount);
  41502. };
  41503. FilterService.prototype.setAllChildrenCount = function (rowNode) {
  41504. if (this.doingTreeData) {
  41505. this.setAllChildrenCountTreeData(rowNode);
  41506. }
  41507. else {
  41508. this.setAllChildrenCountGridGrouping(rowNode);
  41509. }
  41510. };
  41511. FilterService.prototype.doingTreeDataFiltering = function () {
  41512. return this.gridOptionsWrapper.isTreeData() && !this.gridOptionsWrapper.isExcludeChildrenWhenTreeDataFiltering();
  41513. };
  41514. __decorate$20([
  41515. Autowired('filterManager')
  41516. ], FilterService.prototype, "filterManager", void 0);
  41517. __decorate$20([
  41518. Autowired('gridOptionsWrapper')
  41519. ], FilterService.prototype, "gridOptionsWrapper", void 0);
  41520. __decorate$20([
  41521. PostConstruct
  41522. ], FilterService.prototype, "postConstruct", null);
  41523. FilterService = __decorate$20([
  41524. Bean("filterService")
  41525. ], FilterService);
  41526. return FilterService;
  41527. }(BeanStub));
  41528. var __extends$28 = (undefined && undefined.__extends) || (function () {
  41529. var extendStatics = function (d, b) {
  41530. extendStatics = Object.setPrototypeOf ||
  41531. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  41532. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  41533. return extendStatics(d, b);
  41534. };
  41535. return function (d, b) {
  41536. extendStatics(d, b);
  41537. function __() { this.constructor = d; }
  41538. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  41539. };
  41540. })();
  41541. var __decorate$21 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  41542. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  41543. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  41544. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  41545. return c > 3 && r && Object.defineProperty(target, key, r), r;
  41546. };
  41547. var ImmutableService = /** @class */ (function (_super) {
  41548. __extends$28(ImmutableService, _super);
  41549. function ImmutableService() {
  41550. return _super !== null && _super.apply(this, arguments) || this;
  41551. }
  41552. ImmutableService.prototype.postConstruct = function () {
  41553. if (this.rowModel.getType() === Constants.ROW_MODEL_TYPE_CLIENT_SIDE) {
  41554. this.clientSideRowModel = this.rowModel;
  41555. }
  41556. };
  41557. // converts the setRowData() command to a transaction
  41558. ImmutableService.prototype.createTransactionForRowData = function (data) {
  41559. if (_.missing(this.clientSideRowModel)) {
  41560. console.error('ag-Grid: ImmutableService only works with ClientSideRowModel');
  41561. return;
  41562. }
  41563. var getRowNodeIdFunc = this.gridOptionsWrapper.getRowNodeIdFunc();
  41564. if (!getRowNodeIdFunc || _.missing(getRowNodeIdFunc)) {
  41565. console.error('ag-Grid: ImmutableService requires getRowNodeId() callback to be implemented, your row data need IDs!');
  41566. return;
  41567. }
  41568. // convert the data into a transaction object by working out adds, removes and updates
  41569. var transaction = {
  41570. remove: [],
  41571. update: [],
  41572. add: []
  41573. };
  41574. var existingNodesMap = this.clientSideRowModel.getCopyOfNodesMap();
  41575. var suppressSortOrder = this.gridOptionsWrapper.isSuppressMaintainUnsortedOrder();
  41576. var orderMap = suppressSortOrder ? null : {};
  41577. if (_.exists(data)) {
  41578. // split all the new data in the following:
  41579. // if new, push to 'add'
  41580. // if update, push to 'update'
  41581. // if not changed, do not include in the transaction
  41582. data.forEach(function (dataItem, index) {
  41583. var id = getRowNodeIdFunc(dataItem);
  41584. var existingNode = existingNodesMap[id];
  41585. if (orderMap) {
  41586. orderMap[id] = index;
  41587. }
  41588. if (existingNode) {
  41589. var dataHasChanged = existingNode.data !== dataItem;
  41590. if (dataHasChanged) {
  41591. transaction.update.push(dataItem);
  41592. }
  41593. // otherwise, if data not changed, we just don't include it anywhere, as it's not a delta
  41594. // remove from list, so we know the item is not to be removed
  41595. existingNodesMap[id] = undefined;
  41596. }
  41597. else {
  41598. transaction.add.push(dataItem);
  41599. }
  41600. });
  41601. }
  41602. // at this point, all rows that are left, should be removed
  41603. _.iterateObject(existingNodesMap, function (id, rowNode) {
  41604. if (rowNode) {
  41605. transaction.remove.push(rowNode.data);
  41606. }
  41607. });
  41608. return [transaction, orderMap];
  41609. };
  41610. __decorate$21([
  41611. Autowired('rowModel')
  41612. ], ImmutableService.prototype, "rowModel", void 0);
  41613. __decorate$21([
  41614. Autowired('gridOptionsWrapper')
  41615. ], ImmutableService.prototype, "gridOptionsWrapper", void 0);
  41616. __decorate$21([
  41617. PostConstruct
  41618. ], ImmutableService.prototype, "postConstruct", null);
  41619. ImmutableService = __decorate$21([
  41620. Bean('immutableService')
  41621. ], ImmutableService);
  41622. return ImmutableService;
  41623. }(BeanStub));
  41624. var ClientSideRowModelModule = {
  41625. moduleName: exports.ModuleNames.ClientSideRowModelModule,
  41626. beans: [FilterStage, SortStage, FlattenStage, SortService, FilterService, ImmutableService],
  41627. rowModels: { clientSide: ClientSideRowModel }
  41628. };
  41629. var __extends$29 = (undefined && undefined.__extends) || (function () {
  41630. var extendStatics = function (d, b) {
  41631. extendStatics = Object.setPrototypeOf ||
  41632. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  41633. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  41634. return extendStatics(d, b);
  41635. };
  41636. return function (d, b) {
  41637. extendStatics(d, b);
  41638. function __() { this.constructor = d; }
  41639. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  41640. };
  41641. })();
  41642. var __decorate$22 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  41643. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  41644. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  41645. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  41646. return c > 3 && r && Object.defineProperty(target, key, r), r;
  41647. };
  41648. var InfiniteBlock = /** @class */ (function (_super) {
  41649. __extends$29(InfiniteBlock, _super);
  41650. function InfiniteBlock(pageNumber, params) {
  41651. var _this = _super.call(this, pageNumber, params) || this;
  41652. _this.cacheParams = params;
  41653. return _this;
  41654. }
  41655. InfiniteBlock.prototype.getDisplayIndexStart = function () {
  41656. return this.getBlockNumber() * this.cacheParams.blockSize;
  41657. };
  41658. // this is an estimate, as the last block will probably only be partially full. however
  41659. // this method is used to know if this block is been rendered, before destroying, so
  41660. // and this estimate works in that use case.
  41661. InfiniteBlock.prototype.getDisplayIndexEnd = function () {
  41662. return this.getDisplayIndexStart() + this.cacheParams.blockSize;
  41663. };
  41664. InfiniteBlock.prototype.createBlankRowNode = function (rowIndex) {
  41665. var rowNode = _super.prototype.createBlankRowNode.call(this, rowIndex);
  41666. rowNode.uiLevel = 0;
  41667. this.setIndexAndTopOnRowNode(rowNode, rowIndex);
  41668. return rowNode;
  41669. };
  41670. InfiniteBlock.prototype.setDataAndId = function (rowNode, data, index) {
  41671. if (_.exists(data)) {
  41672. // this means if the user is not providing id's we just use the
  41673. // index for the row. this will allow selection to work (that is based
  41674. // on index) as long user is not inserting or deleting rows,
  41675. // or wanting to keep selection between server side sorting or filtering
  41676. rowNode.setDataAndId(data, index.toString());
  41677. }
  41678. else {
  41679. rowNode.setDataAndId(undefined, undefined);
  41680. }
  41681. };
  41682. InfiniteBlock.prototype.setRowNode = function (rowIndex, rowNode) {
  41683. _super.prototype.setRowNode.call(this, rowIndex, rowNode);
  41684. this.setIndexAndTopOnRowNode(rowNode, rowIndex);
  41685. };
  41686. InfiniteBlock.prototype.init = function () {
  41687. _super.prototype.init.call(this, {
  41688. context: this.getContext(),
  41689. rowRenderer: this.rowRenderer
  41690. });
  41691. };
  41692. InfiniteBlock.prototype.getNodeIdPrefix = function () {
  41693. return null;
  41694. };
  41695. InfiniteBlock.prototype.getRow = function (displayIndex) {
  41696. return this.getRowUsingLocalIndex(displayIndex);
  41697. };
  41698. InfiniteBlock.prototype.setIndexAndTopOnRowNode = function (rowNode, rowIndex) {
  41699. rowNode.setRowIndex(rowIndex);
  41700. rowNode.rowTop = this.cacheParams.rowHeight * rowIndex;
  41701. };
  41702. InfiniteBlock.prototype.loadFromDatasource = function () {
  41703. var _this = this;
  41704. // PROBLEM . . . . when the user sets sort via colDef.sort, then this code
  41705. // is executing before the sort is set up, so server is not getting the sort
  41706. // model. need to change with regards order - so the server side request is
  41707. // AFTER thus it gets the right sort model.
  41708. var params = {
  41709. startRow: this.getStartRow(),
  41710. endRow: this.getEndRow(),
  41711. successCallback: this.pageLoaded.bind(this, this.getVersion()),
  41712. failCallback: this.pageLoadFailed.bind(this),
  41713. sortModel: this.cacheParams.sortModel,
  41714. filterModel: this.cacheParams.filterModel,
  41715. context: this.gridOptionsWrapper.getContext()
  41716. };
  41717. if (_.missing(this.cacheParams.datasource.getRows)) {
  41718. console.warn("ag-Grid: datasource is missing getRows method");
  41719. return;
  41720. }
  41721. // put in timeout, to force result to be async
  41722. window.setTimeout(function () {
  41723. _this.cacheParams.datasource.getRows(params);
  41724. }, 0);
  41725. };
  41726. __decorate$22([
  41727. Autowired('gridOptionsWrapper')
  41728. ], InfiniteBlock.prototype, "gridOptionsWrapper", void 0);
  41729. __decorate$22([
  41730. Autowired('rowRenderer')
  41731. ], InfiniteBlock.prototype, "rowRenderer", void 0);
  41732. __decorate$22([
  41733. PostConstruct
  41734. ], InfiniteBlock.prototype, "init", null);
  41735. return InfiniteBlock;
  41736. }(RowNodeBlock));
  41737. var __extends$2a = (undefined && undefined.__extends) || (function () {
  41738. var extendStatics = function (d, b) {
  41739. extendStatics = Object.setPrototypeOf ||
  41740. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  41741. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  41742. return extendStatics(d, b);
  41743. };
  41744. return function (d, b) {
  41745. extendStatics(d, b);
  41746. function __() { this.constructor = d; }
  41747. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  41748. };
  41749. })();
  41750. var __decorate$23 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  41751. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  41752. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  41753. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  41754. return c > 3 && r && Object.defineProperty(target, key, r), r;
  41755. };
  41756. var __param$a = (undefined && undefined.__param) || function (paramIndex, decorator) {
  41757. return function (target, key) { decorator(target, key, paramIndex); }
  41758. };
  41759. var InfiniteCache = /** @class */ (function (_super) {
  41760. __extends$2a(InfiniteCache, _super);
  41761. function InfiniteCache(params) {
  41762. return _super.call(this, params) || this;
  41763. }
  41764. InfiniteCache.prototype.setBeans = function (loggerFactory) {
  41765. this.logger = loggerFactory.create('InfiniteCache');
  41766. };
  41767. InfiniteCache.prototype.moveItemsDown = function (block, moveFromIndex, moveCount) {
  41768. var startRow = block.getStartRow();
  41769. var endRow = block.getEndRow();
  41770. var indexOfLastRowToMove = moveFromIndex + moveCount;
  41771. // all rows need to be moved down below the insertion index
  41772. for (var currentRowIndex = endRow - 1; currentRowIndex >= startRow; currentRowIndex--) {
  41773. // don't move rows at or before the insertion index
  41774. if (currentRowIndex < indexOfLastRowToMove) {
  41775. continue;
  41776. }
  41777. var indexOfNodeWeWant = currentRowIndex - moveCount;
  41778. var nodeForThisIndex = this.getRow(indexOfNodeWeWant, true);
  41779. if (nodeForThisIndex) {
  41780. block.setRowNode(currentRowIndex, nodeForThisIndex);
  41781. }
  41782. else {
  41783. block.setBlankRowNode(currentRowIndex);
  41784. block.setDirty();
  41785. }
  41786. }
  41787. };
  41788. InfiniteCache.prototype.insertItems = function (block, indexToInsert, items) {
  41789. var pageStartRow = block.getStartRow();
  41790. var pageEndRow = block.getEndRow();
  41791. var newRowNodes = [];
  41792. // next stage is insert the rows into this page, if applicable
  41793. for (var index = 0; index < items.length; index++) {
  41794. var rowIndex = indexToInsert + index;
  41795. var currentRowInThisPage = rowIndex >= pageStartRow && rowIndex < pageEndRow;
  41796. if (currentRowInThisPage) {
  41797. var dataItem = items[index];
  41798. var newRowNode = block.setNewData(rowIndex, dataItem);
  41799. newRowNodes.push(newRowNode);
  41800. }
  41801. }
  41802. return newRowNodes;
  41803. };
  41804. InfiniteCache.prototype.insertItemsAtIndex = function (indexToInsert, items) {
  41805. // get all page id's as NUMBERS (not strings, as we need to sort as numbers) and in descending order
  41806. var _this = this;
  41807. var newNodes = [];
  41808. this.forEachBlockInReverseOrder(function (block) {
  41809. var pageEndRow = block.getEndRow();
  41810. // if the insertion is after this page, then this page is not impacted
  41811. if (pageEndRow <= indexToInsert) {
  41812. return;
  41813. }
  41814. _this.moveItemsDown(block, indexToInsert, items.length);
  41815. var newNodesThisPage = _this.insertItems(block, indexToInsert, items);
  41816. newNodesThisPage.forEach(function (rowNode) { return newNodes.push(rowNode); });
  41817. });
  41818. if (this.isMaxRowFound()) {
  41819. this.hack_setVirtualRowCount(this.getVirtualRowCount() + items.length);
  41820. }
  41821. this.onCacheUpdated();
  41822. var event = {
  41823. type: Events.EVENT_ROW_DATA_UPDATED,
  41824. api: this.gridApi,
  41825. columnApi: this.columnApi
  41826. };
  41827. this.eventService.dispatchEvent(event);
  41828. };
  41829. // the rowRenderer will not pass dontCreatePage, meaning when rendering the grid,
  41830. // it will want new pages in the cache as it asks for rows. only when we are inserting /
  41831. // removing rows via the api is dontCreatePage set, where we move rows between the pages.
  41832. InfiniteCache.prototype.getRow = function (rowIndex, dontCreatePage) {
  41833. if (dontCreatePage === void 0) { dontCreatePage = false; }
  41834. var blockId = Math.floor(rowIndex / this.cacheParams.blockSize);
  41835. var block = this.getBlock(blockId);
  41836. if (!block) {
  41837. if (dontCreatePage) {
  41838. return null;
  41839. }
  41840. else {
  41841. block = this.createBlock(blockId);
  41842. }
  41843. }
  41844. return block.getRow(rowIndex);
  41845. };
  41846. InfiniteCache.prototype.createBlock = function (blockNumber) {
  41847. var newBlock = new InfiniteBlock(blockNumber, this.cacheParams);
  41848. this.getContext().createBean(newBlock);
  41849. this.postCreateBlock(newBlock);
  41850. return newBlock;
  41851. };
  41852. // we have this on infinite row model only, not server side row model,
  41853. // because for server side, it would leave the children in inconsistent
  41854. // state - eg if a node had children, but after the refresh it had data
  41855. // for a different row, then the children would be with the wrong row node.
  41856. InfiniteCache.prototype.refreshCache = function () {
  41857. this.forEachBlockInOrder(function (block) { return block.setDirty(); });
  41858. this.checkBlockToLoad();
  41859. };
  41860. __decorate$23([
  41861. Autowired('columnApi')
  41862. ], InfiniteCache.prototype, "columnApi", void 0);
  41863. __decorate$23([
  41864. Autowired('gridApi')
  41865. ], InfiniteCache.prototype, "gridApi", void 0);
  41866. __decorate$23([
  41867. __param$a(0, Qualifier('loggerFactory'))
  41868. ], InfiniteCache.prototype, "setBeans", null);
  41869. return InfiniteCache;
  41870. }(RowNodeCache));
  41871. var __extends$2b = (undefined && undefined.__extends) || (function () {
  41872. var extendStatics = function (d, b) {
  41873. extendStatics = Object.setPrototypeOf ||
  41874. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  41875. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  41876. return extendStatics(d, b);
  41877. };
  41878. return function (d, b) {
  41879. extendStatics(d, b);
  41880. function __() { this.constructor = d; }
  41881. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  41882. };
  41883. })();
  41884. var __decorate$24 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  41885. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  41886. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  41887. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  41888. return c > 3 && r && Object.defineProperty(target, key, r), r;
  41889. };
  41890. var InfiniteRowModel = /** @class */ (function (_super) {
  41891. __extends$2b(InfiniteRowModel, _super);
  41892. function InfiniteRowModel() {
  41893. return _super !== null && _super.apply(this, arguments) || this;
  41894. }
  41895. InfiniteRowModel.prototype.getRowBounds = function (index) {
  41896. return {
  41897. rowHeight: this.rowHeight,
  41898. rowTop: this.rowHeight * index
  41899. };
  41900. };
  41901. // we don't implement as lazy row heights is not supported in this row model
  41902. InfiniteRowModel.prototype.ensureRowHeightsValid = function (startPixel, endPixel, startLimitIndex, endLimitIndex) {
  41903. return false;
  41904. };
  41905. InfiniteRowModel.prototype.init = function () {
  41906. var _this = this;
  41907. if (!this.gridOptionsWrapper.isRowModelInfinite()) {
  41908. return;
  41909. }
  41910. this.rowHeight = this.gridOptionsWrapper.getRowHeightAsNumber();
  41911. this.addEventListeners();
  41912. this.addDestroyFunc(function () { return _this.destroyCache(); });
  41913. };
  41914. InfiniteRowModel.prototype.start = function () {
  41915. this.setDatasource(this.gridOptionsWrapper.getDatasource());
  41916. };
  41917. InfiniteRowModel.prototype.destroyDatasource = function () {
  41918. if (this.datasource) {
  41919. this.getContext().destroyBean(this.datasource);
  41920. this.rowRenderer.datasourceChanged();
  41921. this.datasource = null;
  41922. }
  41923. };
  41924. InfiniteRowModel.prototype.isLastRowFound = function () {
  41925. return this.infiniteCache ? this.infiniteCache.isMaxRowFound() : false;
  41926. };
  41927. InfiniteRowModel.prototype.addEventListeners = function () {
  41928. this.addManagedListener(this.eventService, Events.EVENT_FILTER_CHANGED, this.onFilterChanged.bind(this));
  41929. this.addManagedListener(this.eventService, Events.EVENT_SORT_CHANGED, this.onSortChanged.bind(this));
  41930. this.addManagedListener(this.eventService, Events.EVENT_COLUMN_EVERYTHING_CHANGED, this.onColumnEverything.bind(this));
  41931. };
  41932. InfiniteRowModel.prototype.onFilterChanged = function () {
  41933. this.reset();
  41934. };
  41935. InfiniteRowModel.prototype.onSortChanged = function () {
  41936. this.reset();
  41937. };
  41938. InfiniteRowModel.prototype.onColumnEverything = function () {
  41939. var resetRequired;
  41940. // if cache params, we require reset only if sort model has changed. we don't need to check
  41941. // for filter model, as the filter manager will fire an event when columns change that result
  41942. // in the filter changing.
  41943. if (this.cacheParams) {
  41944. resetRequired = this.isSortModelDifferent();
  41945. }
  41946. else {
  41947. // if no cacheParams, means first time creating the cache, so always create one
  41948. resetRequired = true;
  41949. }
  41950. if (resetRequired) {
  41951. this.reset();
  41952. }
  41953. };
  41954. InfiniteRowModel.prototype.isSortModelDifferent = function () {
  41955. return !_.jsonEquals(this.cacheParams.sortModel, this.sortController.getSortModel());
  41956. };
  41957. InfiniteRowModel.prototype.getType = function () {
  41958. return Constants.ROW_MODEL_TYPE_INFINITE;
  41959. };
  41960. InfiniteRowModel.prototype.setDatasource = function (datasource) {
  41961. this.destroyDatasource();
  41962. this.datasource = datasource;
  41963. // only reset if we have a valid datasource to working with
  41964. if (datasource) {
  41965. this.checkForDeprecated();
  41966. this.reset();
  41967. }
  41968. };
  41969. InfiniteRowModel.prototype.checkForDeprecated = function () {
  41970. var ds = this.datasource;
  41971. // the number of concurrent loads we are allowed to the server
  41972. if (_.exists(ds.maxConcurrentRequests)) {
  41973. console.error('ag-Grid: since version 5.1.x, maxConcurrentRequests is replaced with grid property maxConcurrentDatasourceRequests');
  41974. }
  41975. if (_.exists(ds.maxPagesInCache)) {
  41976. console.error('ag-Grid: since version 5.1.x, maxPagesInCache is replaced with grid property maxPagesInPaginationCache');
  41977. }
  41978. if (_.exists(ds.overflowSize)) {
  41979. console.error('ag-Grid: since version 5.1.x, overflowSize is replaced with grid property paginationOverflowSize');
  41980. }
  41981. if (_.exists(ds.blockSize)) {
  41982. console.error('ag-Grid: since version 5.1.x, pageSize/blockSize is replaced with grid property infinitePageSize');
  41983. }
  41984. };
  41985. InfiniteRowModel.prototype.isEmpty = function () {
  41986. return _.missing(this.infiniteCache);
  41987. };
  41988. InfiniteRowModel.prototype.isRowsToRender = function () {
  41989. return _.exists(this.infiniteCache);
  41990. };
  41991. InfiniteRowModel.prototype.getNodesInRangeForSelection = function (firstInRange, lastInRange) {
  41992. return this.infiniteCache ? this.infiniteCache.getRowNodesInRange(firstInRange, lastInRange) : [];
  41993. };
  41994. InfiniteRowModel.prototype.reset = function () {
  41995. // important to return here, as the user could be setting filter or sort before
  41996. // data-source is set
  41997. if (_.missing(this.datasource)) {
  41998. return;
  41999. }
  42000. // if user is providing id's, then this means we can keep the selection between datasource hits,
  42001. // as the rows will keep their unique id's even if, for example, server side sorting or filtering
  42002. // is done.
  42003. var userGeneratingIds = _.exists(this.gridOptionsWrapper.getRowNodeIdFunc());
  42004. if (!userGeneratingIds) {
  42005. this.selectionController.reset();
  42006. }
  42007. this.resetCache();
  42008. var event = this.createModelUpdatedEvent();
  42009. this.eventService.dispatchEvent(event);
  42010. };
  42011. InfiniteRowModel.prototype.createModelUpdatedEvent = function () {
  42012. return {
  42013. type: Events.EVENT_MODEL_UPDATED,
  42014. api: this.gridApi,
  42015. columnApi: this.columnApi,
  42016. // not sure if these should all be false - noticed if after implementing,
  42017. // maybe they should be true?
  42018. newPage: false,
  42019. newData: false,
  42020. keepRenderedRows: false,
  42021. animate: false
  42022. };
  42023. };
  42024. InfiniteRowModel.prototype.resetCache = function () {
  42025. // if not first time creating a cache, need to destroy the old one
  42026. this.destroyCache();
  42027. var maxConcurrentRequests = this.gridOptionsWrapper.getMaxConcurrentDatasourceRequests();
  42028. var blockLoadDebounceMillis = this.gridOptionsWrapper.getBlockLoadDebounceMillis();
  42029. // there is a bi-directional dependency between the loader and the cache,
  42030. // so we create loader here, and then pass dependencies in setDependencies() method later
  42031. this.rowNodeBlockLoader = new RowNodeBlockLoader(maxConcurrentRequests, blockLoadDebounceMillis);
  42032. this.getContext().createBean(this.rowNodeBlockLoader);
  42033. this.cacheParams = {
  42034. // the user provided datasource
  42035. datasource: this.datasource,
  42036. // sort and filter model
  42037. filterModel: this.filterManager.getFilterModel(),
  42038. sortModel: this.sortController.getSortModel(),
  42039. rowNodeBlockLoader: this.rowNodeBlockLoader,
  42040. // properties - this way we take a snapshot of them, so if user changes any, they will be
  42041. // used next time we create a new cache, which is generally after a filter or sort change,
  42042. // or a new datasource is set
  42043. maxConcurrentRequests: maxConcurrentRequests,
  42044. overflowSize: this.gridOptionsWrapper.getCacheOverflowSize(),
  42045. initialRowCount: this.gridOptionsWrapper.getInfiniteInitialRowCount(),
  42046. maxBlocksInCache: this.gridOptionsWrapper.getMaxBlocksInCache(),
  42047. blockSize: this.gridOptionsWrapper.getCacheBlockSize(),
  42048. rowHeight: this.gridOptionsWrapper.getRowHeightAsNumber(),
  42049. // the cache could create this, however it is also used by the pages, so handy to create it
  42050. // here as the settings are also passed to the pages
  42051. lastAccessedSequence: new NumberSequence()
  42052. };
  42053. // set defaults
  42054. if (!this.cacheParams.maxConcurrentRequests || !(this.cacheParams.maxConcurrentRequests >= 1)) {
  42055. this.cacheParams.maxConcurrentRequests = 2;
  42056. }
  42057. // page size needs to be 1 or greater. having it at 1 would be silly, as you would be hitting the
  42058. // server for one page at a time. so the default if not specified is 100.
  42059. if (!this.cacheParams.blockSize || !(this.cacheParams.blockSize >= 1)) {
  42060. this.cacheParams.blockSize = 100;
  42061. }
  42062. // if user doesn't give initial rows to display, we assume one
  42063. if (!(this.cacheParams.initialRowCount >= 1)) {
  42064. this.cacheParams.initialRowCount = 1;
  42065. }
  42066. // if user doesn't provide overflow, we use default overflow of 1, so user can scroll past
  42067. // the current page and request first row of next page
  42068. if (!(this.cacheParams.overflowSize >= 1)) {
  42069. this.cacheParams.overflowSize = 1;
  42070. }
  42071. this.infiniteCache = new InfiniteCache(this.cacheParams);
  42072. this.getContext().createBean(this.infiniteCache);
  42073. this.infiniteCache.addEventListener(RowNodeCache.EVENT_CACHE_UPDATED, this.onCacheUpdated.bind(this));
  42074. };
  42075. InfiniteRowModel.prototype.destroyCache = function () {
  42076. if (this.infiniteCache) {
  42077. this.infiniteCache = this.destroyBean(this.infiniteCache);
  42078. }
  42079. if (this.rowNodeBlockLoader) {
  42080. this.rowNodeBlockLoader = this.destroyBean(this.rowNodeBlockLoader);
  42081. }
  42082. };
  42083. InfiniteRowModel.prototype.onCacheUpdated = function () {
  42084. var event = this.createModelUpdatedEvent();
  42085. this.eventService.dispatchEvent(event);
  42086. };
  42087. InfiniteRowModel.prototype.getRow = function (rowIndex) {
  42088. return this.infiniteCache ? this.infiniteCache.getRow(rowIndex) : null;
  42089. };
  42090. InfiniteRowModel.prototype.getRowNode = function (id) {
  42091. var result = null;
  42092. this.forEachNode(function (rowNode) {
  42093. if (rowNode.id === id) {
  42094. result = rowNode;
  42095. }
  42096. });
  42097. return result;
  42098. };
  42099. InfiniteRowModel.prototype.forEachNode = function (callback) {
  42100. if (this.infiniteCache) {
  42101. this.infiniteCache.forEachNodeDeep(callback, new NumberSequence());
  42102. }
  42103. };
  42104. InfiniteRowModel.prototype.getCurrentPageHeight = function () {
  42105. return this.getRowCount() * this.rowHeight;
  42106. };
  42107. InfiniteRowModel.prototype.getTopLevelRowCount = function () {
  42108. return this.getRowCount();
  42109. };
  42110. InfiniteRowModel.prototype.getTopLevelRowDisplayedIndex = function (topLevelIndex) {
  42111. return topLevelIndex;
  42112. };
  42113. InfiniteRowModel.prototype.getRowIndexAtPixel = function (pixel) {
  42114. if (this.rowHeight !== 0) { // avoid divide by zero error
  42115. var rowIndexForPixel = Math.floor(pixel / this.rowHeight);
  42116. var lastRowIndex = this.getRowCount() - 1;
  42117. if (rowIndexForPixel > lastRowIndex) {
  42118. return lastRowIndex;
  42119. }
  42120. else {
  42121. return rowIndexForPixel;
  42122. }
  42123. }
  42124. else {
  42125. return 0;
  42126. }
  42127. };
  42128. InfiniteRowModel.prototype.getRowCount = function () {
  42129. return this.infiniteCache ? this.infiniteCache.getVirtualRowCount() : 0;
  42130. };
  42131. InfiniteRowModel.prototype.updateRowData = function (transaction) {
  42132. if (_.exists(transaction.remove) || _.exists(transaction.update)) {
  42133. console.warn('ag-Grid: updateRowData for InfiniteRowModel does not support remove or update, only add');
  42134. return;
  42135. }
  42136. if (_.missing(transaction.addIndex)) {
  42137. console.warn('ag-Grid: updateRowData for InfiniteRowModel requires add and addIndex to be set');
  42138. return;
  42139. }
  42140. if (this.infiniteCache) {
  42141. this.infiniteCache.insertItemsAtIndex(transaction.addIndex, transaction.add);
  42142. }
  42143. };
  42144. InfiniteRowModel.prototype.isRowPresent = function (rowNode) {
  42145. return false;
  42146. };
  42147. InfiniteRowModel.prototype.refreshCache = function () {
  42148. if (this.infiniteCache) {
  42149. this.infiniteCache.refreshCache();
  42150. }
  42151. };
  42152. InfiniteRowModel.prototype.purgeCache = function () {
  42153. if (this.infiniteCache) {
  42154. this.infiniteCache.purgeCache();
  42155. }
  42156. };
  42157. InfiniteRowModel.prototype.getVirtualRowCount = function () {
  42158. if (this.infiniteCache) {
  42159. return this.infiniteCache.getVirtualRowCount();
  42160. }
  42161. else {
  42162. return null;
  42163. }
  42164. };
  42165. InfiniteRowModel.prototype.isMaxRowFound = function () {
  42166. if (this.infiniteCache) {
  42167. return this.infiniteCache.isMaxRowFound();
  42168. }
  42169. };
  42170. InfiniteRowModel.prototype.setVirtualRowCount = function (rowCount, maxRowFound) {
  42171. if (this.infiniteCache) {
  42172. this.infiniteCache.setVirtualRowCount(rowCount, maxRowFound);
  42173. }
  42174. };
  42175. InfiniteRowModel.prototype.getBlockState = function () {
  42176. if (this.rowNodeBlockLoader) {
  42177. return this.rowNodeBlockLoader.getBlockState();
  42178. }
  42179. else {
  42180. return null;
  42181. }
  42182. };
  42183. __decorate$24([
  42184. Autowired('gridOptionsWrapper')
  42185. ], InfiniteRowModel.prototype, "gridOptionsWrapper", void 0);
  42186. __decorate$24([
  42187. Autowired('filterManager')
  42188. ], InfiniteRowModel.prototype, "filterManager", void 0);
  42189. __decorate$24([
  42190. Autowired('sortController')
  42191. ], InfiniteRowModel.prototype, "sortController", void 0);
  42192. __decorate$24([
  42193. Autowired('selectionController')
  42194. ], InfiniteRowModel.prototype, "selectionController", void 0);
  42195. __decorate$24([
  42196. Autowired('gridApi')
  42197. ], InfiniteRowModel.prototype, "gridApi", void 0);
  42198. __decorate$24([
  42199. Autowired('columnApi')
  42200. ], InfiniteRowModel.prototype, "columnApi", void 0);
  42201. __decorate$24([
  42202. Autowired('rowRenderer')
  42203. ], InfiniteRowModel.prototype, "rowRenderer", void 0);
  42204. __decorate$24([
  42205. PostConstruct
  42206. ], InfiniteRowModel.prototype, "init", null);
  42207. __decorate$24([
  42208. PreDestroy
  42209. ], InfiniteRowModel.prototype, "destroyDatasource", null);
  42210. InfiniteRowModel = __decorate$24([
  42211. Bean('rowModel')
  42212. ], InfiniteRowModel);
  42213. return InfiniteRowModel;
  42214. }(BeanStub));
  42215. var InfiniteRowModelModule = {
  42216. moduleName: exports.ModuleNames.InfiniteRowModelModule,
  42217. rowModels: { 'infinite': InfiniteRowModel }
  42218. };
  42219. var __extends$2c = (undefined && undefined.__extends) || (function () {
  42220. var extendStatics = function (d, b) {
  42221. extendStatics = Object.setPrototypeOf ||
  42222. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  42223. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  42224. return extendStatics(d, b);
  42225. };
  42226. return function (d, b) {
  42227. extendStatics(d, b);
  42228. function __() { this.constructor = d; }
  42229. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  42230. };
  42231. })();
  42232. var __decorate$25 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  42233. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  42234. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  42235. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  42236. return c > 3 && r && Object.defineProperty(target, key, r), r;
  42237. };
  42238. var BaseGridSerializingSession = /** @class */ (function () {
  42239. function BaseGridSerializingSession(config) {
  42240. var columnController = config.columnController, valueService = config.valueService, gridOptionsWrapper = config.gridOptionsWrapper, processCellCallback = config.processCellCallback, processHeaderCallback = config.processHeaderCallback, processGroupHeaderCallback = config.processGroupHeaderCallback, processRowGroupCallback = config.processRowGroupCallback;
  42241. this.columnController = columnController;
  42242. this.valueService = valueService;
  42243. this.gridOptionsWrapper = gridOptionsWrapper;
  42244. this.processCellCallback = processCellCallback;
  42245. this.processHeaderCallback = processHeaderCallback;
  42246. this.processGroupHeaderCallback = processGroupHeaderCallback;
  42247. this.processRowGroupCallback = processRowGroupCallback;
  42248. }
  42249. BaseGridSerializingSession.prototype.prepare = function (columnsToExport) {
  42250. this.firstGroupColumn = _.find(columnsToExport, function (col) { return !!col.getColDef().showRowGroup; });
  42251. };
  42252. BaseGridSerializingSession.prototype.extractHeaderValue = function (column) {
  42253. var value = this.getHeaderName(this.processHeaderCallback, column);
  42254. return value != null ? value : '';
  42255. };
  42256. BaseGridSerializingSession.prototype.extractRowCellValue = function (column, index, type, node) {
  42257. // we render the group summary text e.g. "-> Parent -> Child"...
  42258. var renderGroupSummaryCell =
  42259. // on group rows
  42260. node && node.group
  42261. && (
  42262. // in the first group column if groups appear in regular grid cells
  42263. column === this.firstGroupColumn
  42264. // or the first cell in the row, if we're doing full width rows
  42265. || (index === 0 && this.gridOptionsWrapper.isGroupUseEntireRow(this.columnController.isPivotMode())));
  42266. var valueForCell;
  42267. if (renderGroupSummaryCell) {
  42268. valueForCell = this.createValueForGroupNode(node);
  42269. }
  42270. else {
  42271. valueForCell = this.valueService.getValue(column, node);
  42272. }
  42273. var value = this.processCell(node, column, valueForCell, this.processCellCallback, type);
  42274. return value != null ? value : '';
  42275. };
  42276. BaseGridSerializingSession.prototype.getHeaderName = function (callback, column) {
  42277. if (callback) {
  42278. return callback({
  42279. column: column,
  42280. api: this.gridOptionsWrapper.getApi(),
  42281. columnApi: this.gridOptionsWrapper.getColumnApi(),
  42282. context: this.gridOptionsWrapper.getContext()
  42283. });
  42284. }
  42285. else {
  42286. return this.columnController.getDisplayNameForColumn(column, 'csv', true);
  42287. }
  42288. };
  42289. BaseGridSerializingSession.prototype.createValueForGroupNode = function (node) {
  42290. if (this.processRowGroupCallback) {
  42291. return this.processRowGroupCallback({
  42292. node: node,
  42293. api: this.gridOptionsWrapper.getApi(),
  42294. columnApi: this.gridOptionsWrapper.getColumnApi(),
  42295. context: this.gridOptionsWrapper.getContext(),
  42296. });
  42297. }
  42298. var keys = [node.key];
  42299. while (node.parent) {
  42300. node = node.parent;
  42301. keys.push(node.key);
  42302. }
  42303. return keys.reverse().join(' -> ');
  42304. };
  42305. BaseGridSerializingSession.prototype.processCell = function (rowNode, column, value, processCellCallback, type) {
  42306. if (processCellCallback) {
  42307. return processCellCallback({
  42308. column: column,
  42309. node: rowNode,
  42310. value: value,
  42311. api: this.gridOptionsWrapper.getApi(),
  42312. columnApi: this.gridOptionsWrapper.getColumnApi(),
  42313. context: this.gridOptionsWrapper.getContext(),
  42314. type: type
  42315. });
  42316. }
  42317. else {
  42318. return value;
  42319. }
  42320. };
  42321. return BaseGridSerializingSession;
  42322. }());
  42323. var GridSerializer = /** @class */ (function (_super) {
  42324. __extends$2c(GridSerializer, _super);
  42325. function GridSerializer() {
  42326. return _super !== null && _super.apply(this, arguments) || this;
  42327. }
  42328. GridSerializer.prototype.serialize = function (gridSerializingSession, params) {
  42329. if (params === void 0) { params = {}; }
  42330. var rowSkipper = params.shouldRowBeSkipped || (function () { return false; });
  42331. var api = this.gridOptionsWrapper.getApi();
  42332. var columnApi = this.gridOptionsWrapper.getColumnApi();
  42333. var skipSingleChildrenGroup = this.gridOptionsWrapper.isGroupRemoveSingleChildren();
  42334. var skipLowestSingleChildrenGroup = this.gridOptionsWrapper.isGroupRemoveLowestSingleChildren();
  42335. var context = this.gridOptionsWrapper.getContext();
  42336. // when in pivot mode, we always render cols on screen, never 'all columns'
  42337. var isPivotMode = this.columnController.isPivotMode();
  42338. var rowModelNormal = this.rowModel.getType() === Constants.ROW_MODEL_TYPE_CLIENT_SIDE;
  42339. var onlySelectedNonStandardModel = !rowModelNormal && params.onlySelected;
  42340. var columnsToExport = [];
  42341. if (_.existsAndNotEmpty(params.columnKeys)) {
  42342. columnsToExport = this.columnController.getGridColumns(params.columnKeys);
  42343. }
  42344. else if (params.allColumns && !isPivotMode) {
  42345. // add auto group column for tree data
  42346. columnsToExport = this.gridOptionsWrapper.isTreeData() ?
  42347. this.columnController.getGridColumns([Constants.GROUP_AUTO_COLUMN_ID]) : [];
  42348. columnsToExport = columnsToExport.concat(this.columnController.getAllPrimaryColumns() || []);
  42349. }
  42350. else {
  42351. columnsToExport = this.columnController.getAllDisplayedColumns();
  42352. }
  42353. if (params.customHeader) {
  42354. gridSerializingSession.addCustomContent(params.customHeader);
  42355. }
  42356. gridSerializingSession.prepare(columnsToExport);
  42357. // first pass, put in the header names of the cols
  42358. if (params.columnGroups) {
  42359. var groupInstanceIdCreator = new GroupInstanceIdCreator();
  42360. var displayedGroups = this.displayedGroupCreator.createDisplayedGroups(columnsToExport, this.columnController.getGridBalancedTree(), groupInstanceIdCreator, null);
  42361. this.recursivelyAddHeaderGroups(displayedGroups, gridSerializingSession, params.processGroupHeaderCallback);
  42362. }
  42363. if (!params.skipHeader) {
  42364. var gridRowIterator_1 = gridSerializingSession.onNewHeaderRow();
  42365. columnsToExport.forEach(function (column, index) {
  42366. gridRowIterator_1.onColumn(column, index, undefined);
  42367. });
  42368. }
  42369. this.pinnedRowModel.forEachPinnedTopRow(processRow);
  42370. if (isPivotMode) {
  42371. if (this.rowModel.forEachPivotNode) {
  42372. this.rowModel.forEachPivotNode(processRow);
  42373. }
  42374. else {
  42375. //Must be enterprise, so we can just loop through all the nodes
  42376. this.rowModel.forEachNode(processRow);
  42377. }
  42378. }
  42379. else {
  42380. // onlySelectedAllPages: user doing pagination and wants selected items from
  42381. // other pages, so cannot use the standard row model as it won't have rows from
  42382. // other pages.
  42383. // onlySelectedNonStandardModel: if user wants selected in non standard row model
  42384. // (eg viewport) then again rowmodel cannot be used, so need to use selected instead.
  42385. if (params.onlySelectedAllPages || onlySelectedNonStandardModel) {
  42386. var selectedNodes = this.selectionController.getSelectedNodes();
  42387. selectedNodes.forEach(function (node) {
  42388. processRow(node);
  42389. });
  42390. }
  42391. else {
  42392. // here is everything else - including standard row model and selected. we don't use
  42393. // the selection model even when just using selected, so that the result is the order
  42394. // of the rows appearing on the screen.
  42395. if (rowModelNormal) {
  42396. this.rowModel.forEachNodeAfterFilterAndSort(processRow);
  42397. }
  42398. else {
  42399. this.rowModel.forEachNode(processRow);
  42400. }
  42401. }
  42402. }
  42403. this.pinnedRowModel.forEachPinnedBottomRow(processRow);
  42404. if (params.customFooter) {
  42405. gridSerializingSession.addCustomContent(params.customFooter);
  42406. }
  42407. function processRow(node) {
  42408. var shouldSkipLowestGroup = skipLowestSingleChildrenGroup && node.leafGroup;
  42409. var shouldSkipCurrentGroup = node.allChildrenCount === 1 && (skipSingleChildrenGroup || shouldSkipLowestGroup);
  42410. if (node.group && (params.skipGroups || shouldSkipCurrentGroup)) {
  42411. return;
  42412. }
  42413. if (params.skipFooters && node.footer) {
  42414. return;
  42415. }
  42416. if (params.onlySelected && !node.isSelected()) {
  42417. return;
  42418. }
  42419. if (params.skipPinnedTop && node.rowPinned === 'top') {
  42420. return;
  42421. }
  42422. if (params.skipPinnedBottom && node.rowPinned === 'bottom') {
  42423. return;
  42424. }
  42425. // if we are in pivotMode, then the grid will show the root node only
  42426. // if it's not a leaf group
  42427. var nodeIsRootNode = node.level === -1;
  42428. if (nodeIsRootNode && !node.leafGroup) {
  42429. return;
  42430. }
  42431. var shouldRowBeSkipped = rowSkipper({ node: node, api: api, context: context });
  42432. if (shouldRowBeSkipped) {
  42433. return;
  42434. }
  42435. var rowAccumulator = gridSerializingSession.onNewBodyRow();
  42436. columnsToExport.forEach(function (column, index) {
  42437. rowAccumulator.onColumn(column, index, node);
  42438. });
  42439. if (params.getCustomContentBelowRow) {
  42440. var content = params.getCustomContentBelowRow({ node: node, api: api, columnApi: columnApi, context: context });
  42441. if (content) {
  42442. gridSerializingSession.addCustomContent(content);
  42443. }
  42444. }
  42445. }
  42446. return gridSerializingSession.parse();
  42447. };
  42448. GridSerializer.prototype.recursivelyAddHeaderGroups = function (displayedGroups, gridSerializingSession, processGroupHeaderCallback) {
  42449. var directChildrenHeaderGroups = [];
  42450. displayedGroups.forEach(function (columnGroupChild) {
  42451. var columnGroup = columnGroupChild;
  42452. if (!columnGroup.getChildren) {
  42453. return;
  42454. }
  42455. columnGroup.getChildren().forEach(function (it) { return directChildrenHeaderGroups.push(it); });
  42456. });
  42457. if (displayedGroups.length > 0 && displayedGroups[0] instanceof ColumnGroup) {
  42458. this.doAddHeaderHeader(gridSerializingSession, displayedGroups, processGroupHeaderCallback);
  42459. }
  42460. if (directChildrenHeaderGroups && directChildrenHeaderGroups.length > 0) {
  42461. this.recursivelyAddHeaderGroups(directChildrenHeaderGroups, gridSerializingSession, processGroupHeaderCallback);
  42462. }
  42463. };
  42464. GridSerializer.prototype.doAddHeaderHeader = function (gridSerializingSession, displayedGroups, processGroupHeaderCallback) {
  42465. var _this = this;
  42466. var gridRowIterator = gridSerializingSession.onNewHeaderGroupingRow();
  42467. var columnIndex = 0;
  42468. displayedGroups.forEach(function (columnGroupChild) {
  42469. var columnGroup = columnGroupChild;
  42470. var name;
  42471. if (processGroupHeaderCallback) {
  42472. name = processGroupHeaderCallback({
  42473. columnGroup: columnGroup,
  42474. api: _this.gridOptionsWrapper.getApi(),
  42475. columnApi: _this.gridOptionsWrapper.getColumnApi(),
  42476. context: _this.gridOptionsWrapper.getContext()
  42477. });
  42478. }
  42479. else {
  42480. name = _this.columnController.getDisplayNameForColumnGroup(columnGroup, 'header');
  42481. }
  42482. gridRowIterator.onColumn(name || '', columnIndex++, columnGroup.getLeafColumns().length - 1);
  42483. });
  42484. };
  42485. __decorate$25([
  42486. Autowired('displayedGroupCreator')
  42487. ], GridSerializer.prototype, "displayedGroupCreator", void 0);
  42488. __decorate$25([
  42489. Autowired('columnController')
  42490. ], GridSerializer.prototype, "columnController", void 0);
  42491. __decorate$25([
  42492. Autowired('rowModel')
  42493. ], GridSerializer.prototype, "rowModel", void 0);
  42494. __decorate$25([
  42495. Autowired('pinnedRowModel')
  42496. ], GridSerializer.prototype, "pinnedRowModel", void 0);
  42497. __decorate$25([
  42498. Autowired('selectionController')
  42499. ], GridSerializer.prototype, "selectionController", void 0);
  42500. __decorate$25([
  42501. Autowired('columnFactory')
  42502. ], GridSerializer.prototype, "columnFactory", void 0);
  42503. __decorate$25([
  42504. Autowired('gridOptionsWrapper')
  42505. ], GridSerializer.prototype, "gridOptionsWrapper", void 0);
  42506. GridSerializer = __decorate$25([
  42507. Bean("gridSerializer")
  42508. ], GridSerializer);
  42509. return GridSerializer;
  42510. }(BeanStub));
  42511. var RowType;
  42512. (function (RowType) {
  42513. RowType[RowType["HEADER_GROUPING"] = 0] = "HEADER_GROUPING";
  42514. RowType[RowType["HEADER"] = 1] = "HEADER";
  42515. RowType[RowType["BODY"] = 2] = "BODY";
  42516. })(RowType || (RowType = {}));
  42517. var __extends$2d = (undefined && undefined.__extends) || (function () {
  42518. var extendStatics = function (d, b) {
  42519. extendStatics = Object.setPrototypeOf ||
  42520. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  42521. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  42522. return extendStatics(d, b);
  42523. };
  42524. return function (d, b) {
  42525. extendStatics(d, b);
  42526. function __() { this.constructor = d; }
  42527. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  42528. };
  42529. })();
  42530. var __decorate$26 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  42531. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  42532. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  42533. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  42534. return c > 3 && r && Object.defineProperty(target, key, r), r;
  42535. };
  42536. var LINE_SEPARATOR = '\r\n';
  42537. var CsvSerializingSession = /** @class */ (function (_super) {
  42538. __extends$2d(CsvSerializingSession, _super);
  42539. function CsvSerializingSession(config) {
  42540. var _this = _super.call(this, config) || this;
  42541. _this.isFirstLine = true;
  42542. _this.result = '';
  42543. var suppressQuotes = config.suppressQuotes, columnSeparator = config.columnSeparator;
  42544. _this.suppressQuotes = suppressQuotes;
  42545. _this.columnSeparator = columnSeparator;
  42546. return _this;
  42547. }
  42548. CsvSerializingSession.prototype.addCustomContent = function (content) {
  42549. var _this = this;
  42550. if (!content) {
  42551. return;
  42552. }
  42553. if (typeof content === 'string') {
  42554. // we used to require the customFooter to be prefixed with a newline but no longer do,
  42555. // so only add the newline if the user has not supplied one
  42556. if (!/^\s*\n/.test(content)) {
  42557. this.beginNewLine();
  42558. }
  42559. // replace whatever newlines are supplied with the style we're using
  42560. content = content.replace(/\r?\n/g, LINE_SEPARATOR);
  42561. this.result += content;
  42562. }
  42563. else {
  42564. content.forEach(function (row) {
  42565. _this.beginNewLine();
  42566. row.forEach(function (cell, index) {
  42567. if (index !== 0) {
  42568. _this.result += _this.columnSeparator;
  42569. }
  42570. _this.result += _this.putInQuotes(cell.data.value || '');
  42571. if (cell.mergeAcross) {
  42572. _this.appendEmptyCells(cell.mergeAcross);
  42573. }
  42574. });
  42575. });
  42576. }
  42577. };
  42578. CsvSerializingSession.prototype.onNewHeaderGroupingRow = function () {
  42579. this.beginNewLine();
  42580. return {
  42581. onColumn: this.onNewHeaderGroupingRowColumn.bind(this)
  42582. };
  42583. };
  42584. CsvSerializingSession.prototype.onNewHeaderGroupingRowColumn = function (header, index, span) {
  42585. if (index != 0) {
  42586. this.result += this.columnSeparator;
  42587. }
  42588. this.result += this.putInQuotes(header);
  42589. this.appendEmptyCells(span);
  42590. };
  42591. CsvSerializingSession.prototype.appendEmptyCells = function (count) {
  42592. for (var i = 1; i <= count; i++) {
  42593. this.result += this.columnSeparator + this.putInQuotes("");
  42594. }
  42595. };
  42596. CsvSerializingSession.prototype.onNewHeaderRow = function () {
  42597. this.beginNewLine();
  42598. return {
  42599. onColumn: this.onNewHeaderRowColumn.bind(this)
  42600. };
  42601. };
  42602. CsvSerializingSession.prototype.onNewHeaderRowColumn = function (column, index, node) {
  42603. if (index != 0) {
  42604. this.result += this.columnSeparator;
  42605. }
  42606. this.result += this.putInQuotes(this.extractHeaderValue(column));
  42607. };
  42608. CsvSerializingSession.prototype.onNewBodyRow = function () {
  42609. this.beginNewLine();
  42610. return {
  42611. onColumn: this.onNewBodyRowColumn.bind(this)
  42612. };
  42613. };
  42614. CsvSerializingSession.prototype.onNewBodyRowColumn = function (column, index, node) {
  42615. if (index != 0) {
  42616. this.result += this.columnSeparator;
  42617. }
  42618. this.result += this.putInQuotes(this.extractRowCellValue(column, index, Constants.EXPORT_TYPE_CSV, node));
  42619. };
  42620. CsvSerializingSession.prototype.putInQuotes = function (value) {
  42621. if (this.suppressQuotes) {
  42622. return value;
  42623. }
  42624. if (value === null || value === undefined) {
  42625. return '""';
  42626. }
  42627. var stringValue;
  42628. if (typeof value === 'string') {
  42629. stringValue = value;
  42630. }
  42631. else if (typeof value.toString === 'function') {
  42632. stringValue = value.toString();
  42633. }
  42634. else {
  42635. console.warn('unknown value type during csv conversion');
  42636. stringValue = '';
  42637. }
  42638. // replace each " with "" (ie two sets of double quotes is how to do double quotes in csv)
  42639. var valueEscaped = stringValue.replace(/"/g, "\"\"");
  42640. return '"' + valueEscaped + '"';
  42641. };
  42642. CsvSerializingSession.prototype.parse = function () {
  42643. return this.result;
  42644. };
  42645. CsvSerializingSession.prototype.beginNewLine = function () {
  42646. if (!this.isFirstLine) {
  42647. this.result += LINE_SEPARATOR;
  42648. }
  42649. this.isFirstLine = false;
  42650. };
  42651. return CsvSerializingSession;
  42652. }(BaseGridSerializingSession));
  42653. var BaseCreator = /** @class */ (function () {
  42654. function BaseCreator() {
  42655. }
  42656. BaseCreator.prototype.setBeans = function (beans) {
  42657. this.beans = beans;
  42658. };
  42659. BaseCreator.prototype.export = function (userParams) {
  42660. if (this.isExportSuppressed()) {
  42661. console.warn("ag-grid: Export cancelled. Export is not allowed as per your configuration.");
  42662. return '';
  42663. }
  42664. var _a = this.getMergedParamsAndData(userParams), mergedParams = _a.mergedParams, data = _a.data;
  42665. var fileNamePresent = mergedParams && mergedParams.fileName && mergedParams.fileName.length !== 0;
  42666. var fileName = fileNamePresent ? mergedParams.fileName : this.getDefaultFileName();
  42667. if (fileName.indexOf(".") === -1) {
  42668. fileName = fileName + "." + this.getDefaultFileExtension();
  42669. }
  42670. this.beans.downloader.download(fileName, this.packageFile(data));
  42671. return data;
  42672. };
  42673. BaseCreator.prototype.getData = function (params) {
  42674. return this.getMergedParamsAndData(params).data;
  42675. };
  42676. BaseCreator.prototype.getMergedParamsAndData = function (userParams) {
  42677. var mergedParams = this.mergeDefaultParams(userParams);
  42678. var data = this.beans.gridSerializer.serialize(this.createSerializingSession(mergedParams), mergedParams);
  42679. return { mergedParams: mergedParams, data: data };
  42680. };
  42681. BaseCreator.prototype.mergeDefaultParams = function (userParams) {
  42682. var baseParams = this.beans.gridOptionsWrapper.getDefaultExportParams();
  42683. var params = {};
  42684. _.assign(params, baseParams);
  42685. _.assign(params, userParams);
  42686. return params;
  42687. };
  42688. BaseCreator.prototype.packageFile = function (data) {
  42689. return new Blob(["\ufeff", data], {
  42690. type: window.navigator.msSaveOrOpenBlob ? this.getMimeType() : 'octet/stream'
  42691. });
  42692. };
  42693. return BaseCreator;
  42694. }());
  42695. var CsvCreator = /** @class */ (function (_super) {
  42696. __extends$2d(CsvCreator, _super);
  42697. function CsvCreator() {
  42698. return _super !== null && _super.apply(this, arguments) || this;
  42699. }
  42700. CsvCreator.prototype.postConstruct = function () {
  42701. this.setBeans({
  42702. downloader: this.downloader,
  42703. gridSerializer: this.gridSerializer,
  42704. gridOptionsWrapper: this.gridOptionsWrapper
  42705. });
  42706. };
  42707. CsvCreator.prototype.exportDataAsCsv = function (params) {
  42708. return this.export(params);
  42709. };
  42710. CsvCreator.prototype.getDataAsCsv = function (params) {
  42711. return this.getData(params);
  42712. };
  42713. CsvCreator.prototype.getMimeType = function () {
  42714. return 'text/csv;charset=utf-8;';
  42715. };
  42716. CsvCreator.prototype.getDefaultFileName = function () {
  42717. return 'export.csv';
  42718. };
  42719. CsvCreator.prototype.getDefaultFileExtension = function () {
  42720. return 'csv';
  42721. };
  42722. CsvCreator.prototype.createSerializingSession = function (params) {
  42723. var _a = this, columnController = _a.columnController, valueService = _a.valueService, gridOptionsWrapper = _a.gridOptionsWrapper;
  42724. var processCellCallback = params.processCellCallback, processHeaderCallback = params.processHeaderCallback, processGroupHeaderCallback = params.processGroupHeaderCallback, processRowGroupCallback = params.processRowGroupCallback, suppressQuotes = params.suppressQuotes, columnSeparator = params.columnSeparator;
  42725. return new CsvSerializingSession({
  42726. columnController: columnController,
  42727. valueService: valueService,
  42728. gridOptionsWrapper: gridOptionsWrapper,
  42729. processCellCallback: processCellCallback || undefined,
  42730. processHeaderCallback: processHeaderCallback || undefined,
  42731. processGroupHeaderCallback: processGroupHeaderCallback || undefined,
  42732. processRowGroupCallback: processRowGroupCallback || undefined,
  42733. suppressQuotes: suppressQuotes || false,
  42734. columnSeparator: columnSeparator || ','
  42735. });
  42736. };
  42737. CsvCreator.prototype.isExportSuppressed = function () {
  42738. return this.gridOptionsWrapper.isSuppressCsvExport();
  42739. };
  42740. __decorate$26([
  42741. Autowired('columnController')
  42742. ], CsvCreator.prototype, "columnController", void 0);
  42743. __decorate$26([
  42744. Autowired('valueService')
  42745. ], CsvCreator.prototype, "valueService", void 0);
  42746. __decorate$26([
  42747. Autowired('downloader')
  42748. ], CsvCreator.prototype, "downloader", void 0);
  42749. __decorate$26([
  42750. Autowired('gridSerializer')
  42751. ], CsvCreator.prototype, "gridSerializer", void 0);
  42752. __decorate$26([
  42753. Autowired('gridOptionsWrapper')
  42754. ], CsvCreator.prototype, "gridOptionsWrapper", void 0);
  42755. __decorate$26([
  42756. PostConstruct
  42757. ], CsvCreator.prototype, "postConstruct", null);
  42758. CsvCreator = __decorate$26([
  42759. Bean('csvCreator')
  42760. ], CsvCreator);
  42761. return CsvCreator;
  42762. }(BaseCreator));
  42763. var __decorate$27 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  42764. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  42765. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  42766. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  42767. return c > 3 && r && Object.defineProperty(target, key, r), r;
  42768. };
  42769. var Downloader = /** @class */ (function () {
  42770. function Downloader() {
  42771. }
  42772. Downloader.prototype.download = function (fileName, content) {
  42773. // Internet Explorer
  42774. if (window.navigator.msSaveOrOpenBlob) {
  42775. window.navigator.msSaveOrOpenBlob(content, fileName);
  42776. }
  42777. else {
  42778. // Other Browsers
  42779. var element = document.createElement("a");
  42780. var url_1 = window.URL.createObjectURL(content);
  42781. element.setAttribute("href", url_1);
  42782. element.setAttribute("download", fileName);
  42783. element.style.display = "none";
  42784. document.body.appendChild(element);
  42785. element.dispatchEvent(new MouseEvent('click', {
  42786. bubbles: false,
  42787. cancelable: true,
  42788. view: window
  42789. }));
  42790. document.body.removeChild(element);
  42791. window.setTimeout(function () {
  42792. window.URL.revokeObjectURL(url_1);
  42793. }, 0);
  42794. }
  42795. };
  42796. Downloader = __decorate$27([
  42797. Bean("downloader")
  42798. ], Downloader);
  42799. return Downloader;
  42800. }());
  42801. var __extends$2e = (undefined && undefined.__extends) || (function () {
  42802. var extendStatics = function (d, b) {
  42803. extendStatics = Object.setPrototypeOf ||
  42804. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  42805. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  42806. return extendStatics(d, b);
  42807. };
  42808. return function (d, b) {
  42809. extendStatics(d, b);
  42810. function __() { this.constructor = d; }
  42811. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  42812. };
  42813. })();
  42814. var __decorate$28 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  42815. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  42816. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  42817. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  42818. return c > 3 && r && Object.defineProperty(target, key, r), r;
  42819. };
  42820. var LINE_SEPARATOR$1 = '\r\n';
  42821. var XmlFactory = /** @class */ (function (_super) {
  42822. __extends$2e(XmlFactory, _super);
  42823. function XmlFactory() {
  42824. return _super !== null && _super.apply(this, arguments) || this;
  42825. }
  42826. XmlFactory.prototype.createHeader = function (headerElement) {
  42827. if (headerElement === void 0) { headerElement = {}; }
  42828. var headerStart = '<?';
  42829. var headerEnd = '?>';
  42830. var keys = ['version'];
  42831. if (!headerElement.version) {
  42832. headerElement.version = "1.0";
  42833. }
  42834. if (headerElement.encoding) {
  42835. keys.push('encoding');
  42836. }
  42837. if (headerElement.standalone) {
  42838. keys.push('standalone');
  42839. }
  42840. var att = keys.map(function (key) { return key + "=\"" + headerElement[key] + "\""; }).join(' ');
  42841. return headerStart + "xml " + att + " " + headerEnd;
  42842. };
  42843. XmlFactory.prototype.createXml = function (xmlElement, booleanTransformer) {
  42844. var _this = this;
  42845. var props = '';
  42846. if (xmlElement.properties) {
  42847. if (xmlElement.properties.prefixedAttributes) {
  42848. xmlElement.properties.prefixedAttributes.forEach(function (prefixedSet) {
  42849. Object.keys(prefixedSet.map).forEach(function (key) {
  42850. props += _this.returnAttributeIfPopulated(prefixedSet.prefix + key, prefixedSet.map[key], booleanTransformer);
  42851. });
  42852. });
  42853. }
  42854. if (xmlElement.properties.rawMap) {
  42855. Object.keys(xmlElement.properties.rawMap).forEach(function (key) {
  42856. props += _this.returnAttributeIfPopulated(key, xmlElement.properties.rawMap[key], booleanTransformer);
  42857. });
  42858. }
  42859. }
  42860. var result = '<' + xmlElement.name + props;
  42861. if (!xmlElement.children && xmlElement.textNode == null) {
  42862. return result + '/>' + LINE_SEPARATOR$1;
  42863. }
  42864. if (xmlElement.textNode != null) {
  42865. return result + '>' + xmlElement.textNode + '</' + xmlElement.name + '>' + LINE_SEPARATOR$1;
  42866. }
  42867. result += '>' + LINE_SEPARATOR$1;
  42868. if (xmlElement.children) {
  42869. xmlElement.children.forEach(function (it) {
  42870. result += _this.createXml(it, booleanTransformer);
  42871. });
  42872. }
  42873. return result + '</' + xmlElement.name + '>' + LINE_SEPARATOR$1;
  42874. };
  42875. XmlFactory.prototype.returnAttributeIfPopulated = function (key, value, booleanTransformer) {
  42876. if (!value && value !== '' && value !== 0) {
  42877. return '';
  42878. }
  42879. var xmlValue = value;
  42880. if ((typeof (value) === 'boolean')) {
  42881. if (booleanTransformer) {
  42882. xmlValue = booleanTransformer(value);
  42883. }
  42884. }
  42885. return " " + key + "=\"" + xmlValue + "\"";
  42886. };
  42887. XmlFactory = __decorate$28([
  42888. Bean('xmlFactory')
  42889. ], XmlFactory);
  42890. return XmlFactory;
  42891. }(BeanStub));
  42892. var __extends$2f = (undefined && undefined.__extends) || (function () {
  42893. var extendStatics = function (d, b) {
  42894. extendStatics = Object.setPrototypeOf ||
  42895. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  42896. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  42897. return extendStatics(d, b);
  42898. };
  42899. return function (d, b) {
  42900. extendStatics(d, b);
  42901. function __() { this.constructor = d; }
  42902. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  42903. };
  42904. })();
  42905. var __decorate$29 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  42906. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  42907. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  42908. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  42909. return c > 3 && r && Object.defineProperty(target, key, r), r;
  42910. };
  42911. // table for crc calculation
  42912. // from: https://referencesource.microsoft.com/#System/sys/System/IO/compression/Crc32Helper.cs,3b31978c7d7f7246,references
  42913. var crcTable = [
  42914. 0, 1996959894, -301047508, -1727442502, 124634137, 1886057615, -379345611, -1637575261, 249268274,
  42915. 2044508324, -522852066, -1747789432, 162941995, 2125561021, -407360249, -1866523247, 498536548,
  42916. 1789927666, -205950648, -2067906082, 450548861, 1843258603, -187386543, -2083289657, 325883990,
  42917. 1684777152, -43845254, -1973040660, 335633487, 1661365465, -99664541, -1928851979, 997073096,
  42918. 1281953886, -715111964, -1570279054, 1006888145, 1258607687, -770865667, -1526024853, 901097722,
  42919. 1119000684, -608450090, -1396901568, 853044451, 1172266101, -589951537, -1412350631, 651767980,
  42920. 1373503546, -925412992, -1076862698, 565507253, 1454621731, -809855591, -1195530993, 671266974,
  42921. 1594198024, -972236366, -1324619484, 795835527, 1483230225, -1050600021, -1234817731, 1994146192,
  42922. 31158534, -1731059524, -271249366, 1907459465, 112637215, -1614814043, -390540237, 2013776290,
  42923. 251722036, -1777751922, -519137256, 2137656763, 141376813, -1855689577, -429695999, 1802195444,
  42924. 476864866, -2056965928, -228458418, 1812370925, 453092731, -2113342271, -183516073, 1706088902,
  42925. 314042704, -1950435094, -54949764, 1658658271, 366619977, -1932296973, -69972891, 1303535960,
  42926. 984961486, -1547960204, -725929758, 1256170817, 1037604311, -1529756563, -740887301, 1131014506,
  42927. 879679996, -1385723834, -631195440, 1141124467, 855842277, -1442165665, -586318647, 1342533948,
  42928. 654459306, -1106571248, -921952122, 1466479909, 544179635, -1184443383, -832445281, 1591671054,
  42929. 702138776, -1328506846, -942167884, 1504918807, 783551873, -1212326853, -1061524307, -306674912,
  42930. -1698712650, 62317068, 1957810842, -355121351, -1647151185, 81470997, 1943803523, -480048366,
  42931. -1805370492, 225274430, 2053790376, -468791541, -1828061283, 167816743, 2097651377, -267414716,
  42932. -2029476910, 503444072, 1762050814, -144550051, -2140837941, 426522225, 1852507879, -19653770,
  42933. -1982649376, 282753626, 1742555852, -105259153, -1900089351, 397917763, 1622183637, -690576408,
  42934. -1580100738, 953729732, 1340076626, -776247311, -1497606297, 1068828381, 1219638859, -670225446,
  42935. -1358292148, 906185462, 1090812512, -547295293, -1469587627, 829329135, 1181335161, -882789492,
  42936. -1134132454, 628085408, 1382605366, -871598187, -1156888829, 570562233, 1426400815, -977650754,
  42937. -1296233688, 733239954, 1555261956, -1026031705, -1244606671, 752459403, 1541320221, -1687895376,
  42938. -328994266, 1969922972, 40735498, -1677130071, -351390145, 1913087877, 83908371, -1782625662,
  42939. -491226604, 2075208622, 213261112, -1831694693, -438977011, 2094854071, 198958881, -2032938284,
  42940. -237706686, 1759359992, 534414190, -2118248755, -155638181, 1873836001, 414664567, -2012718362,
  42941. -15766928, 1711684554, 285281116, -1889165569, -127750551, 1634467795, 376229701, -1609899400,
  42942. -686959890, 1308918612, 956543938, -1486412191, -799009033, 1231636301, 1047427035, -1362007478,
  42943. -640263460, 1088359270, 936918000, -1447252397, -558129467, 1202900863, 817233897, -1111625188,
  42944. -893730166, 1404277552, 615818150, -1160759803, -841546093, 1423857449, 601450431, -1285129682,
  42945. -1000256840, 1567103746, 711928724, -1274298825, -1022587231, 1510334235, 755167117
  42946. ];
  42947. var ZipContainer = /** @class */ (function (_super) {
  42948. __extends$2f(ZipContainer, _super);
  42949. function ZipContainer() {
  42950. var _this = _super !== null && _super.apply(this, arguments) || this;
  42951. _this.folders = [];
  42952. _this.files = [];
  42953. _this.addFolder = function (path) {
  42954. _this.folders.push({
  42955. path: path,
  42956. created: new Date()
  42957. });
  42958. };
  42959. return _this;
  42960. }
  42961. ZipContainer.prototype.addFolders = function (paths) {
  42962. paths.forEach(this.addFolder);
  42963. };
  42964. ZipContainer.prototype.addFile = function (path, content) {
  42965. this.files.push({
  42966. path: path,
  42967. created: new Date(),
  42968. content: content
  42969. });
  42970. };
  42971. ZipContainer.prototype.clearStream = function () {
  42972. this.folders = [];
  42973. this.files = [];
  42974. };
  42975. ZipContainer.prototype.getContent = function (mimeType) {
  42976. if (mimeType === void 0) { mimeType = 'application/zip'; }
  42977. var textOutput = this.buildFileStream();
  42978. var uInt8Output = this.buildUint8Array(textOutput);
  42979. this.clearStream();
  42980. return new Blob([uInt8Output], { type: mimeType });
  42981. };
  42982. ZipContainer.prototype.buildFileStream = function (fData) {
  42983. if (fData === void 0) { fData = ''; }
  42984. var totalFiles = this.folders.concat(this.files);
  42985. var len = totalFiles.length;
  42986. var foData = '';
  42987. var lL = 0;
  42988. var cL = 0;
  42989. for (var _i = 0, totalFiles_1 = totalFiles; _i < totalFiles_1.length; _i++) {
  42990. var currentFile = totalFiles_1[_i];
  42991. var _a = this.getHeader(currentFile, lL), fileHeader = _a.fileHeader, folderHeader = _a.folderHeader, content = _a.content;
  42992. lL += fileHeader.length + content.length;
  42993. cL += folderHeader.length;
  42994. fData += fileHeader + content;
  42995. foData += folderHeader;
  42996. }
  42997. var foEnd = this.buildFolderEnd(len, cL, lL);
  42998. return fData + foData + foEnd;
  42999. };
  43000. ZipContainer.prototype.getHeader = function (currentFile, offset) {
  43001. var content = currentFile.content, path = currentFile.path, created = currentFile.created;
  43002. var utf8_encode = _.utf8_encode, decToHex = _.decToHex;
  43003. var utfPath = utf8_encode(path);
  43004. var isUTF8 = utfPath !== path;
  43005. var time = this.convertTime(created);
  43006. var dt = this.convertDate(created);
  43007. var extraFields = '';
  43008. if (isUTF8) {
  43009. var uExtraFieldPath = decToHex(1, 1) + decToHex(this.getFromCrc32Table(utfPath), 4) + utfPath;
  43010. extraFields = "\x75\x70" + decToHex(uExtraFieldPath.length, 2) + uExtraFieldPath;
  43011. }
  43012. var header = '\x0A\x00' +
  43013. (isUTF8 ? '\x00\x08' : '\x00\x00') +
  43014. '\x00\x00' +
  43015. decToHex(time, 2) + // last modified time
  43016. decToHex(dt, 2) + // last modified date
  43017. decToHex(content ? this.getFromCrc32Table(content) : 0, 4) +
  43018. decToHex(content ? content.length : 0, 4) + // compressed size
  43019. decToHex(content ? content.length : 0, 4) + // uncompressed size
  43020. decToHex(utfPath.length, 2) + // file name length
  43021. decToHex(extraFields.length, 2); // extra field length
  43022. var fileHeader = 'PK\x03\x04' + header + utfPath + extraFields;
  43023. var folderHeader = 'PK\x01\x02' + // central header
  43024. '\x14\x00' +
  43025. header + // file header
  43026. '\x00\x00' +
  43027. '\x00\x00' +
  43028. '\x00\x00' +
  43029. (content ? '\x00\x00\x00\x00' : '\x10\x00\x00\x00') + // external file attributes
  43030. decToHex(offset, 4) + // relative offset of local header
  43031. utfPath + // file name
  43032. extraFields; // extra field
  43033. return { fileHeader: fileHeader, folderHeader: folderHeader, content: content || '' };
  43034. };
  43035. ZipContainer.prototype.buildFolderEnd = function (tLen, cLen, lLen) {
  43036. var decToHex = _.decToHex;
  43037. return 'PK\x05\x06' + // central folder end
  43038. '\x00\x00' +
  43039. '\x00\x00' +
  43040. decToHex(tLen, 2) + // total number of entries in the central folder
  43041. decToHex(tLen, 2) + // total number of entries in the central folder
  43042. decToHex(cLen, 4) + // size of the central folder
  43043. decToHex(lLen, 4) + // central folder start offset
  43044. '\x00\x00';
  43045. };
  43046. ZipContainer.prototype.buildUint8Array = function (content) {
  43047. var uint8 = new Uint8Array(content.length);
  43048. for (var i = 0; i < uint8.length; i++) {
  43049. uint8[i] = content.charCodeAt(i);
  43050. }
  43051. return uint8;
  43052. };
  43053. ZipContainer.prototype.getFromCrc32Table = function (content, crc) {
  43054. if (crc === void 0) { crc = 0; }
  43055. if (!content.length) {
  43056. return 0;
  43057. }
  43058. crc ^= (-1);
  43059. var j = 0;
  43060. var k = 0;
  43061. var l = 0;
  43062. for (var i = 0; i < content.length; i++) {
  43063. j = content.charCodeAt(i);
  43064. k = (crc ^ j) & 0xFF;
  43065. l = crcTable[k];
  43066. crc = (crc >>> 8) ^ l;
  43067. }
  43068. return crc ^ (-1);
  43069. };
  43070. ZipContainer.prototype.convertTime = function (date) {
  43071. var time = date.getHours();
  43072. time <<= 6;
  43073. time = time | date.getMinutes();
  43074. time <<= 5;
  43075. time = time | date.getSeconds() / 2;
  43076. return time;
  43077. };
  43078. ZipContainer.prototype.convertDate = function (date) {
  43079. var dt = date.getFullYear() - 1980;
  43080. dt <<= 4;
  43081. dt = dt | (date.getMonth() + 1);
  43082. dt <<= 5;
  43083. dt = dt | date.getDate();
  43084. return dt;
  43085. };
  43086. ZipContainer = __decorate$29([
  43087. Bean('zipContainer')
  43088. ], ZipContainer);
  43089. return ZipContainer;
  43090. }(BeanStub));
  43091. var CsvExportModule = {
  43092. moduleName: exports.ModuleNames.CsvExportModule,
  43093. beans: [CsvCreator, Downloader, XmlFactory, GridSerializer, ZipContainer]
  43094. };
  43095. ModuleRegistry.register(ClientSideRowModelModule, false);
  43096. ModuleRegistry.register(InfiniteRowModelModule, false);
  43097. ModuleRegistry.register(CsvExportModule, false);
  43098. exports.AgAbstractField = AgAbstractField;
  43099. exports.AgAngleSelect = AgAngleSelect;
  43100. exports.AgCheckbox = AgCheckbox;
  43101. exports.AgColorPicker = AgColorPicker;
  43102. exports.AgDialog = AgDialog;
  43103. exports.AgGroupComponent = AgGroupComponent;
  43104. exports.AgInputNumberField = AgInputNumberField;
  43105. exports.AgInputRange = AgInputRange;
  43106. exports.AgInputTextArea = AgInputTextArea;
  43107. exports.AgInputTextField = AgInputTextField;
  43108. exports.AgPanel = AgPanel;
  43109. exports.AgRadioButton = AgRadioButton;
  43110. exports.AgSelect = AgSelect;
  43111. exports.AgSlider = AgSlider;
  43112. exports.AgToggleButton = AgToggleButton;
  43113. exports.AlignedGridsService = AlignedGridsService;
  43114. exports.AnimateShowChangeCellRenderer = AnimateShowChangeCellRenderer;
  43115. exports.AnimateSlideCellRenderer = AnimateSlideCellRenderer;
  43116. exports.AutoWidthCalculator = AutoWidthCalculator;
  43117. exports.Autowired = Autowired;
  43118. exports.BaseComponentWrapper = BaseComponentWrapper;
  43119. exports.Bean = Bean;
  43120. exports.BeanStub = BeanStub;
  43121. exports.BodyDropPivotTarget = BodyDropPivotTarget;
  43122. exports.BodyDropTarget = BodyDropTarget;
  43123. exports.CellComp = CellComp;
  43124. exports.CellNavigationService = CellNavigationService;
  43125. exports.CellPositionUtils = CellPositionUtils;
  43126. exports.CellRendererFactory = CellRendererFactory;
  43127. exports.ChangedPath = ChangedPath;
  43128. exports.CheckboxSelectionComponent = CheckboxSelectionComponent;
  43129. exports.ColDefUtil = ColDefUtil;
  43130. exports.Color = Color;
  43131. exports.Column = Column;
  43132. exports.ColumnApi = ColumnApi;
  43133. exports.ColumnController = ColumnController;
  43134. exports.ColumnFactory = ColumnFactory;
  43135. exports.ColumnGroup = ColumnGroup;
  43136. exports.ColumnKeyCreator = ColumnKeyCreator;
  43137. exports.ColumnUtils = ColumnUtils;
  43138. exports.Component = Component;
  43139. exports.ComponentUtil = ComponentUtil;
  43140. exports.Constants = Constants;
  43141. exports.Context = Context;
  43142. exports.CssClassApplier = CssClassApplier;
  43143. exports.DateFilter = DateFilter;
  43144. exports.DisplayedGroupCreator = DisplayedGroupCreator;
  43145. exports.DragAndDropService = DragAndDropService;
  43146. exports.DragService = DragService;
  43147. exports.Environment = Environment;
  43148. exports.EventService = EventService;
  43149. exports.Events = Events;
  43150. exports.ExpressionService = ExpressionService;
  43151. exports.FilterManager = FilterManager;
  43152. exports.FocusController = FocusController;
  43153. exports.Grid = Grid;
  43154. exports.GridApi = GridApi;
  43155. exports.GridCore = GridCore;
  43156. exports.GridListener = GridListener;
  43157. exports.GridOptionsWrapper = GridOptionsWrapper;
  43158. exports.GridPanel = GridPanel;
  43159. exports.GroupCellRenderer = GroupCellRenderer;
  43160. exports.GroupInstanceIdCreator = GroupInstanceIdCreator;
  43161. exports.GuiListener = GuiListener;
  43162. exports.HeaderContainer = HeaderContainer;
  43163. exports.HeaderNavigationService = HeaderNavigationService;
  43164. exports.HeaderPositionUtils = HeaderPositionUtils;
  43165. exports.HeaderRootComp = HeaderRootComp;
  43166. exports.HeaderRowComp = HeaderRowComp;
  43167. exports.HorizontalResizeService = HorizontalResizeService;
  43168. exports.LargeTextCellEditor = LargeTextCellEditor;
  43169. exports.Logger = Logger;
  43170. exports.LoggerFactory = LoggerFactory;
  43171. exports.ManagedFocusComponent = ManagedFocusComponent;
  43172. exports.ModuleRegistry = ModuleRegistry;
  43173. exports.MouseEventService = MouseEventService;
  43174. exports.MoveColumnController = MoveColumnController;
  43175. exports.NumberFilter = NumberFilter;
  43176. exports.NumberSequence = NumberSequence;
  43177. exports.Optional = Optional;
  43178. exports.OriginalColumnGroup = OriginalColumnGroup;
  43179. exports.PaginationProxy = PaginationProxy;
  43180. exports.PinnedRowModel = PinnedRowModel;
  43181. exports.PopupComponent = PopupComponent;
  43182. exports.PopupEditorWrapper = PopupEditorWrapper;
  43183. exports.PopupSelectCellEditor = PopupSelectCellEditor;
  43184. exports.PopupService = PopupService;
  43185. exports.PopupTextCellEditor = PopupTextCellEditor;
  43186. exports.PostConstruct = PostConstruct;
  43187. exports.PreConstruct = PreConstruct;
  43188. exports.PreDestroy = PreDestroy;
  43189. exports.Promise = Promise;
  43190. exports.PropertyKeys = PropertyKeys;
  43191. exports.ProvidedFilter = ProvidedFilter;
  43192. exports.Qualifier = Qualifier;
  43193. exports.QuerySelector = QuerySelector;
  43194. exports.RefSelector = RefSelector;
  43195. exports.ResizeObserverService = ResizeObserverService;
  43196. exports.RowComp = RowComp;
  43197. exports.RowNode = RowNode;
  43198. exports.RowNodeBlock = RowNodeBlock;
  43199. exports.RowNodeBlockLoader = RowNodeBlockLoader;
  43200. exports.RowNodeCache = RowNodeCache;
  43201. exports.RowPositionUtils = RowPositionUtils;
  43202. exports.RowRenderer = RowRenderer;
  43203. exports.ScalarFilter = ScalarFilter;
  43204. exports.ScrollVisibleService = ScrollVisibleService;
  43205. exports.SelectCellEditor = SelectCellEditor;
  43206. exports.SelectableService = SelectableService;
  43207. exports.SelectionController = SelectionController;
  43208. exports.SetLeftFeature = SetLeftFeature;
  43209. exports.SimpleFilter = SimpleFilter;
  43210. exports.SortController = SortController;
  43211. exports.StandardMenuFactory = StandardMenuFactory;
  43212. exports.StylingService = StylingService;
  43213. exports.TabbedLayout = TabbedLayout;
  43214. exports.TemplateService = TemplateService;
  43215. exports.TextCellEditor = TextCellEditor;
  43216. exports.TextFilter = TextFilter;
  43217. exports.Timer = Timer;
  43218. exports.TooltipFeature = TooltipFeature;
  43219. exports.TouchListener = TouchListener;
  43220. exports.UserComponentFactory = UserComponentFactory;
  43221. exports.UserComponentRegistry = UserComponentRegistry;
  43222. exports.ValueCache = ValueCache;
  43223. exports.ValueFormatterService = ValueFormatterService;
  43224. exports.ValueService = ValueService;
  43225. exports.VanillaFrameworkOverrides = VanillaFrameworkOverrides;
  43226. exports.VirtualList = VirtualList;
  43227. exports._ = _;
  43228. exports.defaultGroupComparator = defaultGroupComparator;
  43229. exports.initialiseAgGridWithAngular1 = initialiseAgGridWithAngular1;
  43230. exports.initialiseAgGridWithWebComponents = initialiseAgGridWithWebComponents;
  43231. exports.simpleHttpRequest = simpleHttpRequest;
  43232. exports.stringToArray = stringToArray;