swimlane-ngx-datatable.js 315 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780
  1. import { Injectable, Inject, Directive, TemplateRef, EventEmitter, ElementRef, NgZone, HostBinding, Output, Input, Renderer2, HostListener, KeyValueDiffers, ContentChildren, Component, ChangeDetectionStrategy, ContentChild, ChangeDetectorRef, ViewChild, ViewEncapsulation, SkipSelf, Optional, ViewContainerRef, NgModule } from '@angular/core';
  2. import { DOCUMENT, CommonModule } from '@angular/common';
  3. import { Subject, fromEvent, BehaviorSubject } from 'rxjs';
  4. import { takeUntil } from 'rxjs/operators';
  5. import { __values, __spread, __assign, __decorate, __metadata } from 'tslib';
  6. /**
  7. * @fileoverview added by tsickle
  8. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  9. */
  10. /**
  11. * Gets the width of the scrollbar. Nesc for windows
  12. * http://stackoverflow.com/a/13382873/888165
  13. */
  14. var ScrollbarHelper = /** @class */ (function () {
  15. function ScrollbarHelper(document) {
  16. this.document = document;
  17. this.width = this.getWidth();
  18. }
  19. /**
  20. * @return {?}
  21. */
  22. ScrollbarHelper.prototype.getWidth = /**
  23. * @return {?}
  24. */
  25. function () {
  26. /** @type {?} */
  27. var outer = this.document.createElement('div');
  28. outer.style.visibility = 'hidden';
  29. outer.style.width = '100px';
  30. outer.style.msOverflowStyle = 'scrollbar';
  31. this.document.body.appendChild(outer);
  32. /** @type {?} */
  33. var widthNoScroll = outer.offsetWidth;
  34. outer.style.overflow = 'scroll';
  35. /** @type {?} */
  36. var inner = this.document.createElement('div');
  37. inner.style.width = '100%';
  38. outer.appendChild(inner);
  39. /** @type {?} */
  40. var widthWithScroll = inner.offsetWidth;
  41. outer.parentNode.removeChild(outer);
  42. return widthNoScroll - widthWithScroll;
  43. };
  44. ScrollbarHelper.decorators = [
  45. { type: Injectable }
  46. ];
  47. /** @nocollapse */
  48. ScrollbarHelper.ctorParameters = function () { return [
  49. { type: undefined, decorators: [{ type: Inject, args: [DOCUMENT,] }] }
  50. ]; };
  51. return ScrollbarHelper;
  52. }());
  53. if (false) {
  54. /** @type {?} */
  55. ScrollbarHelper.prototype.width;
  56. /**
  57. * @type {?}
  58. * @private
  59. */
  60. ScrollbarHelper.prototype.document;
  61. }
  62. /**
  63. * @fileoverview added by tsickle
  64. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  65. */
  66. /**
  67. * Gets the width of the scrollbar. Nesc for windows
  68. * http://stackoverflow.com/a/13382873/888165
  69. */
  70. var DimensionsHelper = /** @class */ (function () {
  71. function DimensionsHelper() {
  72. }
  73. /**
  74. * @param {?} element
  75. * @return {?}
  76. */
  77. DimensionsHelper.prototype.getDimensions = /**
  78. * @param {?} element
  79. * @return {?}
  80. */
  81. function (element) {
  82. return element.getBoundingClientRect();
  83. };
  84. DimensionsHelper.decorators = [
  85. { type: Injectable }
  86. ];
  87. return DimensionsHelper;
  88. }());
  89. /**
  90. * @fileoverview added by tsickle
  91. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  92. */
  93. /**
  94. * service to make DatatableComponent aware of changes to
  95. * input bindings of DataTableColumnDirective
  96. */
  97. var ColumnChangesService = /** @class */ (function () {
  98. function ColumnChangesService() {
  99. this.columnInputChanges = new Subject();
  100. }
  101. Object.defineProperty(ColumnChangesService.prototype, "columnInputChanges$", {
  102. get: /**
  103. * @return {?}
  104. */
  105. function () {
  106. return this.columnInputChanges.asObservable();
  107. },
  108. enumerable: true,
  109. configurable: true
  110. });
  111. /**
  112. * @return {?}
  113. */
  114. ColumnChangesService.prototype.onInputChange = /**
  115. * @return {?}
  116. */
  117. function () {
  118. this.columnInputChanges.next();
  119. };
  120. ColumnChangesService.decorators = [
  121. { type: Injectable }
  122. ];
  123. return ColumnChangesService;
  124. }());
  125. if (false) {
  126. /**
  127. * @type {?}
  128. * @private
  129. */
  130. ColumnChangesService.prototype.columnInputChanges;
  131. }
  132. /**
  133. * @fileoverview added by tsickle
  134. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  135. */
  136. var DataTableFooterTemplateDirective = /** @class */ (function () {
  137. function DataTableFooterTemplateDirective(template) {
  138. this.template = template;
  139. }
  140. DataTableFooterTemplateDirective.decorators = [
  141. { type: Directive, args: [{ selector: '[ngx-datatable-footer-template]' },] }
  142. ];
  143. /** @nocollapse */
  144. DataTableFooterTemplateDirective.ctorParameters = function () { return [
  145. { type: TemplateRef }
  146. ]; };
  147. return DataTableFooterTemplateDirective;
  148. }());
  149. if (false) {
  150. /** @type {?} */
  151. DataTableFooterTemplateDirective.prototype.template;
  152. }
  153. /**
  154. * @fileoverview added by tsickle
  155. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  156. */
  157. /**
  158. * Visibility Observer Directive
  159. *
  160. * Usage:
  161. *
  162. * <div
  163. * visibilityObserver
  164. * (visible)="onVisible($event)">
  165. * </div>
  166. *
  167. */
  168. var VisibilityDirective = /** @class */ (function () {
  169. function VisibilityDirective(element, zone) {
  170. this.element = element;
  171. this.zone = zone;
  172. this.isVisible = false;
  173. this.visible = new EventEmitter();
  174. }
  175. /**
  176. * @return {?}
  177. */
  178. VisibilityDirective.prototype.ngOnInit = /**
  179. * @return {?}
  180. */
  181. function () {
  182. this.runCheck();
  183. };
  184. /**
  185. * @return {?}
  186. */
  187. VisibilityDirective.prototype.ngOnDestroy = /**
  188. * @return {?}
  189. */
  190. function () {
  191. clearTimeout(this.timeout);
  192. };
  193. /**
  194. * @return {?}
  195. */
  196. VisibilityDirective.prototype.onVisibilityChange = /**
  197. * @return {?}
  198. */
  199. function () {
  200. var _this = this;
  201. // trigger zone recalc for columns
  202. this.zone.run((/**
  203. * @return {?}
  204. */
  205. function () {
  206. _this.isVisible = true;
  207. _this.visible.emit(true);
  208. }));
  209. };
  210. /**
  211. * @return {?}
  212. */
  213. VisibilityDirective.prototype.runCheck = /**
  214. * @return {?}
  215. */
  216. function () {
  217. var _this = this;
  218. /** @type {?} */
  219. var check = (/**
  220. * @return {?}
  221. */
  222. function () {
  223. // https://davidwalsh.name/offsetheight-visibility
  224. var _a = _this.element.nativeElement, offsetHeight = _a.offsetHeight, offsetWidth = _a.offsetWidth;
  225. if (offsetHeight && offsetWidth) {
  226. clearTimeout(_this.timeout);
  227. _this.onVisibilityChange();
  228. }
  229. else {
  230. clearTimeout(_this.timeout);
  231. _this.zone.runOutsideAngular((/**
  232. * @return {?}
  233. */
  234. function () {
  235. _this.timeout = setTimeout((/**
  236. * @return {?}
  237. */
  238. function () { return check(); }), 50);
  239. }));
  240. }
  241. });
  242. this.timeout = setTimeout((/**
  243. * @return {?}
  244. */
  245. function () { return check(); }));
  246. };
  247. VisibilityDirective.decorators = [
  248. { type: Directive, args: [{ selector: '[visibilityObserver]' },] }
  249. ];
  250. /** @nocollapse */
  251. VisibilityDirective.ctorParameters = function () { return [
  252. { type: ElementRef },
  253. { type: NgZone }
  254. ]; };
  255. VisibilityDirective.propDecorators = {
  256. isVisible: [{ type: HostBinding, args: ['class.visible',] }],
  257. visible: [{ type: Output }]
  258. };
  259. return VisibilityDirective;
  260. }());
  261. if (false) {
  262. /** @type {?} */
  263. VisibilityDirective.prototype.isVisible;
  264. /** @type {?} */
  265. VisibilityDirective.prototype.visible;
  266. /** @type {?} */
  267. VisibilityDirective.prototype.timeout;
  268. /**
  269. * @type {?}
  270. * @private
  271. */
  272. VisibilityDirective.prototype.element;
  273. /**
  274. * @type {?}
  275. * @private
  276. */
  277. VisibilityDirective.prototype.zone;
  278. }
  279. /**
  280. * @fileoverview added by tsickle
  281. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  282. */
  283. /**
  284. * Draggable Directive for Angular2
  285. *
  286. * Inspiration:
  287. * https://github.com/AngularClass/angular2-examples/blob/master/rx-draggable/directives/draggable.ts
  288. * http://stackoverflow.com/questions/35662530/how-to-implement-drag-and-drop-in-angular2
  289. *
  290. */
  291. var DraggableDirective = /** @class */ (function () {
  292. function DraggableDirective(element) {
  293. this.dragX = true;
  294. this.dragY = true;
  295. this.dragStart = new EventEmitter();
  296. this.dragging = new EventEmitter();
  297. this.dragEnd = new EventEmitter();
  298. this.isDragging = false;
  299. this.element = element.nativeElement;
  300. }
  301. /**
  302. * @param {?} changes
  303. * @return {?}
  304. */
  305. DraggableDirective.prototype.ngOnChanges = /**
  306. * @param {?} changes
  307. * @return {?}
  308. */
  309. function (changes) {
  310. if (changes['dragEventTarget'] && changes['dragEventTarget'].currentValue && this.dragModel.dragging) {
  311. this.onMousedown(changes['dragEventTarget'].currentValue);
  312. }
  313. };
  314. /**
  315. * @return {?}
  316. */
  317. DraggableDirective.prototype.ngOnDestroy = /**
  318. * @return {?}
  319. */
  320. function () {
  321. this._destroySubscription();
  322. };
  323. /**
  324. * @param {?} event
  325. * @return {?}
  326. */
  327. DraggableDirective.prototype.onMouseup = /**
  328. * @param {?} event
  329. * @return {?}
  330. */
  331. function (event) {
  332. if (!this.isDragging)
  333. return;
  334. this.isDragging = false;
  335. this.element.classList.remove('dragging');
  336. if (this.subscription) {
  337. this._destroySubscription();
  338. this.dragEnd.emit({
  339. event: event,
  340. element: this.element,
  341. model: this.dragModel
  342. });
  343. }
  344. };
  345. /**
  346. * @param {?} event
  347. * @return {?}
  348. */
  349. DraggableDirective.prototype.onMousedown = /**
  350. * @param {?} event
  351. * @return {?}
  352. */
  353. function (event) {
  354. var _this = this;
  355. // we only want to drag the inner header text
  356. /** @type {?} */
  357. var isDragElm = ((/** @type {?} */ (event.target))).classList.contains('draggable');
  358. if (isDragElm && (this.dragX || this.dragY)) {
  359. event.preventDefault();
  360. this.isDragging = true;
  361. /** @type {?} */
  362. var mouseDownPos_1 = { x: event.clientX, y: event.clientY };
  363. /** @type {?} */
  364. var mouseup = fromEvent(document, 'mouseup');
  365. this.subscription = mouseup.subscribe((/**
  366. * @param {?} ev
  367. * @return {?}
  368. */
  369. function (ev) { return _this.onMouseup(ev); }));
  370. /** @type {?} */
  371. var mouseMoveSub = fromEvent(document, 'mousemove')
  372. .pipe(takeUntil(mouseup))
  373. .subscribe((/**
  374. * @param {?} ev
  375. * @return {?}
  376. */
  377. function (ev) { return _this.move(ev, mouseDownPos_1); }));
  378. this.subscription.add(mouseMoveSub);
  379. this.dragStart.emit({
  380. event: event,
  381. element: this.element,
  382. model: this.dragModel
  383. });
  384. }
  385. };
  386. /**
  387. * @param {?} event
  388. * @param {?} mouseDownPos
  389. * @return {?}
  390. */
  391. DraggableDirective.prototype.move = /**
  392. * @param {?} event
  393. * @param {?} mouseDownPos
  394. * @return {?}
  395. */
  396. function (event, mouseDownPos) {
  397. if (!this.isDragging)
  398. return;
  399. /** @type {?} */
  400. var x = event.clientX - mouseDownPos.x;
  401. /** @type {?} */
  402. var y = event.clientY - mouseDownPos.y;
  403. if (this.dragX)
  404. this.element.style.left = x + "px";
  405. if (this.dragY)
  406. this.element.style.top = y + "px";
  407. this.element.classList.add('dragging');
  408. this.dragging.emit({
  409. event: event,
  410. element: this.element,
  411. model: this.dragModel
  412. });
  413. };
  414. /**
  415. * @private
  416. * @return {?}
  417. */
  418. DraggableDirective.prototype._destroySubscription = /**
  419. * @private
  420. * @return {?}
  421. */
  422. function () {
  423. if (this.subscription) {
  424. this.subscription.unsubscribe();
  425. this.subscription = undefined;
  426. }
  427. };
  428. DraggableDirective.decorators = [
  429. { type: Directive, args: [{ selector: '[draggable]' },] }
  430. ];
  431. /** @nocollapse */
  432. DraggableDirective.ctorParameters = function () { return [
  433. { type: ElementRef }
  434. ]; };
  435. DraggableDirective.propDecorators = {
  436. dragEventTarget: [{ type: Input }],
  437. dragModel: [{ type: Input }],
  438. dragX: [{ type: Input }],
  439. dragY: [{ type: Input }],
  440. dragStart: [{ type: Output }],
  441. dragging: [{ type: Output }],
  442. dragEnd: [{ type: Output }]
  443. };
  444. return DraggableDirective;
  445. }());
  446. if (false) {
  447. /** @type {?} */
  448. DraggableDirective.prototype.dragEventTarget;
  449. /** @type {?} */
  450. DraggableDirective.prototype.dragModel;
  451. /** @type {?} */
  452. DraggableDirective.prototype.dragX;
  453. /** @type {?} */
  454. DraggableDirective.prototype.dragY;
  455. /** @type {?} */
  456. DraggableDirective.prototype.dragStart;
  457. /** @type {?} */
  458. DraggableDirective.prototype.dragging;
  459. /** @type {?} */
  460. DraggableDirective.prototype.dragEnd;
  461. /** @type {?} */
  462. DraggableDirective.prototype.element;
  463. /** @type {?} */
  464. DraggableDirective.prototype.isDragging;
  465. /** @type {?} */
  466. DraggableDirective.prototype.subscription;
  467. }
  468. /**
  469. * @fileoverview added by tsickle
  470. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  471. */
  472. /* tslint:disable */
  473. /** @type {?} */
  474. var MouseEvent = (/** @type {?} */ ((((/** @type {?} */ ((typeof window !== 'undefined' && window)))) || ((/** @type {?} */ (global))))
  475. .MouseEvent));
  476. /** @type {?} */
  477. var KeyboardEvent = (/** @type {?} */ ((((/** @type {?} */ ((typeof window !== 'undefined' && window)))) || ((/** @type {?} */ (global))))
  478. .KeyboardEvent));
  479. /** @type {?} */
  480. var Event = (/** @type {?} */ ((((/** @type {?} */ ((typeof window !== 'undefined' && window)))) || ((/** @type {?} */ (global)))).Event));
  481. /**
  482. * @fileoverview added by tsickle
  483. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  484. */
  485. var ResizeableDirective = /** @class */ (function () {
  486. function ResizeableDirective(element, renderer) {
  487. this.renderer = renderer;
  488. this.resizeEnabled = true;
  489. this.resize = new EventEmitter();
  490. this.resizing = false;
  491. this.element = element.nativeElement;
  492. }
  493. /**
  494. * @return {?}
  495. */
  496. ResizeableDirective.prototype.ngAfterViewInit = /**
  497. * @return {?}
  498. */
  499. function () {
  500. /** @type {?} */
  501. var renderer2 = this.renderer;
  502. this.resizeHandle = renderer2.createElement('span');
  503. if (this.resizeEnabled) {
  504. renderer2.addClass(this.resizeHandle, 'resize-handle');
  505. }
  506. else {
  507. renderer2.addClass(this.resizeHandle, 'resize-handle--not-resizable');
  508. }
  509. renderer2.appendChild(this.element, this.resizeHandle);
  510. };
  511. /**
  512. * @return {?}
  513. */
  514. ResizeableDirective.prototype.ngOnDestroy = /**
  515. * @return {?}
  516. */
  517. function () {
  518. this._destroySubscription();
  519. if (this.renderer.destroyNode) {
  520. this.renderer.destroyNode(this.resizeHandle);
  521. }
  522. else {
  523. this.renderer.removeChild(this.renderer.parentNode(this.resizeHandle), this.resizeHandle);
  524. }
  525. };
  526. /**
  527. * @return {?}
  528. */
  529. ResizeableDirective.prototype.onMouseup = /**
  530. * @return {?}
  531. */
  532. function () {
  533. this.resizing = false;
  534. if (this.subscription && !this.subscription.closed) {
  535. this._destroySubscription();
  536. this.resize.emit(this.element.clientWidth);
  537. }
  538. };
  539. /**
  540. * @param {?} event
  541. * @return {?}
  542. */
  543. ResizeableDirective.prototype.onMousedown = /**
  544. * @param {?} event
  545. * @return {?}
  546. */
  547. function (event) {
  548. var _this = this;
  549. /** @type {?} */
  550. var isHandle = ((/** @type {?} */ (event.target))).classList.contains('resize-handle');
  551. /** @type {?} */
  552. var initialWidth = this.element.clientWidth;
  553. /** @type {?} */
  554. var mouseDownScreenX = event.screenX;
  555. if (isHandle) {
  556. event.stopPropagation();
  557. this.resizing = true;
  558. /** @type {?} */
  559. var mouseup = fromEvent(document, 'mouseup');
  560. this.subscription = mouseup.subscribe((/**
  561. * @param {?} ev
  562. * @return {?}
  563. */
  564. function (ev) { return _this.onMouseup(); }));
  565. /** @type {?} */
  566. var mouseMoveSub = fromEvent(document, 'mousemove')
  567. .pipe(takeUntil(mouseup))
  568. .subscribe((/**
  569. * @param {?} e
  570. * @return {?}
  571. */
  572. function (e) { return _this.move(e, initialWidth, mouseDownScreenX); }));
  573. this.subscription.add(mouseMoveSub);
  574. }
  575. };
  576. /**
  577. * @param {?} event
  578. * @param {?} initialWidth
  579. * @param {?} mouseDownScreenX
  580. * @return {?}
  581. */
  582. ResizeableDirective.prototype.move = /**
  583. * @param {?} event
  584. * @param {?} initialWidth
  585. * @param {?} mouseDownScreenX
  586. * @return {?}
  587. */
  588. function (event, initialWidth, mouseDownScreenX) {
  589. /** @type {?} */
  590. var movementX = event.screenX - mouseDownScreenX;
  591. /** @type {?} */
  592. var newWidth = initialWidth + movementX;
  593. /** @type {?} */
  594. var overMinWidth = !this.minWidth || newWidth >= this.minWidth;
  595. /** @type {?} */
  596. var underMaxWidth = !this.maxWidth || newWidth <= this.maxWidth;
  597. if (overMinWidth && underMaxWidth) {
  598. this.element.style.width = newWidth + "px";
  599. }
  600. };
  601. /**
  602. * @private
  603. * @return {?}
  604. */
  605. ResizeableDirective.prototype._destroySubscription = /**
  606. * @private
  607. * @return {?}
  608. */
  609. function () {
  610. if (this.subscription) {
  611. this.subscription.unsubscribe();
  612. this.subscription = undefined;
  613. }
  614. };
  615. ResizeableDirective.decorators = [
  616. { type: Directive, args: [{
  617. selector: '[resizeable]',
  618. host: {
  619. '[class.resizeable]': 'resizeEnabled'
  620. }
  621. },] }
  622. ];
  623. /** @nocollapse */
  624. ResizeableDirective.ctorParameters = function () { return [
  625. { type: ElementRef },
  626. { type: Renderer2 }
  627. ]; };
  628. ResizeableDirective.propDecorators = {
  629. resizeEnabled: [{ type: Input }],
  630. minWidth: [{ type: Input }],
  631. maxWidth: [{ type: Input }],
  632. resize: [{ type: Output }],
  633. onMousedown: [{ type: HostListener, args: ['mousedown', ['$event'],] }]
  634. };
  635. return ResizeableDirective;
  636. }());
  637. if (false) {
  638. /** @type {?} */
  639. ResizeableDirective.prototype.resizeEnabled;
  640. /** @type {?} */
  641. ResizeableDirective.prototype.minWidth;
  642. /** @type {?} */
  643. ResizeableDirective.prototype.maxWidth;
  644. /** @type {?} */
  645. ResizeableDirective.prototype.resize;
  646. /** @type {?} */
  647. ResizeableDirective.prototype.element;
  648. /** @type {?} */
  649. ResizeableDirective.prototype.subscription;
  650. /** @type {?} */
  651. ResizeableDirective.prototype.resizing;
  652. /**
  653. * @type {?}
  654. * @private
  655. */
  656. ResizeableDirective.prototype.resizeHandle;
  657. /**
  658. * @type {?}
  659. * @private
  660. */
  661. ResizeableDirective.prototype.renderer;
  662. }
  663. /**
  664. * @fileoverview added by tsickle
  665. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  666. */
  667. var OrderableDirective = /** @class */ (function () {
  668. function OrderableDirective(differs, document) {
  669. this.document = document;
  670. this.reorder = new EventEmitter();
  671. this.targetChanged = new EventEmitter();
  672. this.differ = differs.find({}).create();
  673. }
  674. /**
  675. * @return {?}
  676. */
  677. OrderableDirective.prototype.ngAfterContentInit = /**
  678. * @return {?}
  679. */
  680. function () {
  681. // HACK: Investigate Better Way
  682. this.updateSubscriptions();
  683. this.draggables.changes.subscribe(this.updateSubscriptions.bind(this));
  684. };
  685. /**
  686. * @return {?}
  687. */
  688. OrderableDirective.prototype.ngOnDestroy = /**
  689. * @return {?}
  690. */
  691. function () {
  692. this.draggables.forEach((/**
  693. * @param {?} d
  694. * @return {?}
  695. */
  696. function (d) {
  697. d.dragStart.unsubscribe();
  698. d.dragging.unsubscribe();
  699. d.dragEnd.unsubscribe();
  700. }));
  701. };
  702. /**
  703. * @return {?}
  704. */
  705. OrderableDirective.prototype.updateSubscriptions = /**
  706. * @return {?}
  707. */
  708. function () {
  709. var _this = this;
  710. /** @type {?} */
  711. var diffs = this.differ.diff(this.createMapDiffs());
  712. if (diffs) {
  713. /** @type {?} */
  714. var subscribe = (/**
  715. * @param {?} __0
  716. * @return {?}
  717. */
  718. function (_a) {
  719. var currentValue = _a.currentValue, previousValue = _a.previousValue;
  720. unsubscribe_1({ previousValue: previousValue });
  721. if (currentValue) {
  722. currentValue.dragStart.subscribe(_this.onDragStart.bind(_this));
  723. currentValue.dragging.subscribe(_this.onDragging.bind(_this));
  724. currentValue.dragEnd.subscribe(_this.onDragEnd.bind(_this));
  725. }
  726. });
  727. /** @type {?} */
  728. var unsubscribe_1 = (/**
  729. * @param {?} __0
  730. * @return {?}
  731. */
  732. function (_a) {
  733. var previousValue = _a.previousValue;
  734. if (previousValue) {
  735. previousValue.dragStart.unsubscribe();
  736. previousValue.dragging.unsubscribe();
  737. previousValue.dragEnd.unsubscribe();
  738. }
  739. });
  740. diffs.forEachAddedItem(subscribe);
  741. // diffs.forEachChangedItem(subscribe.bind(this));
  742. diffs.forEachRemovedItem(unsubscribe_1);
  743. }
  744. };
  745. /**
  746. * @return {?}
  747. */
  748. OrderableDirective.prototype.onDragStart = /**
  749. * @return {?}
  750. */
  751. function () {
  752. var e_1, _a;
  753. this.positions = {};
  754. /** @type {?} */
  755. var i = 0;
  756. try {
  757. for (var _b = __values(this.draggables.toArray()), _c = _b.next(); !_c.done; _c = _b.next()) {
  758. var dragger = _c.value;
  759. /** @type {?} */
  760. var elm = dragger.element;
  761. /** @type {?} */
  762. var left = parseInt(elm.offsetLeft.toString(), 0);
  763. this.positions[dragger.dragModel.prop] = {
  764. left: left,
  765. right: left + parseInt(elm.offsetWidth.toString(), 0),
  766. index: i++,
  767. element: elm
  768. };
  769. }
  770. }
  771. catch (e_1_1) { e_1 = { error: e_1_1 }; }
  772. finally {
  773. try {
  774. if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
  775. }
  776. finally { if (e_1) throw e_1.error; }
  777. }
  778. };
  779. /**
  780. * @param {?} __0
  781. * @return {?}
  782. */
  783. OrderableDirective.prototype.onDragging = /**
  784. * @param {?} __0
  785. * @return {?}
  786. */
  787. function (_a) {
  788. var element = _a.element, model = _a.model, event = _a.event;
  789. /** @type {?} */
  790. var prevPos = this.positions[model.prop];
  791. /** @type {?} */
  792. var target = this.isTarget(model, event);
  793. if (target) {
  794. if (this.lastDraggingIndex !== target.i) {
  795. this.targetChanged.emit({
  796. prevIndex: this.lastDraggingIndex,
  797. newIndex: target.i,
  798. initialIndex: prevPos.index
  799. });
  800. this.lastDraggingIndex = target.i;
  801. }
  802. }
  803. else if (this.lastDraggingIndex !== prevPos.index) {
  804. this.targetChanged.emit({
  805. prevIndex: this.lastDraggingIndex,
  806. initialIndex: prevPos.index
  807. });
  808. this.lastDraggingIndex = prevPos.index;
  809. }
  810. };
  811. /**
  812. * @param {?} __0
  813. * @return {?}
  814. */
  815. OrderableDirective.prototype.onDragEnd = /**
  816. * @param {?} __0
  817. * @return {?}
  818. */
  819. function (_a) {
  820. var element = _a.element, model = _a.model, event = _a.event;
  821. /** @type {?} */
  822. var prevPos = this.positions[model.prop];
  823. /** @type {?} */
  824. var target = this.isTarget(model, event);
  825. if (target) {
  826. this.reorder.emit({
  827. prevIndex: prevPos.index,
  828. newIndex: target.i,
  829. model: model
  830. });
  831. }
  832. this.lastDraggingIndex = undefined;
  833. element.style.left = 'auto';
  834. };
  835. /**
  836. * @param {?} model
  837. * @param {?} event
  838. * @return {?}
  839. */
  840. OrderableDirective.prototype.isTarget = /**
  841. * @param {?} model
  842. * @param {?} event
  843. * @return {?}
  844. */
  845. function (model, event) {
  846. /** @type {?} */
  847. var i = 0;
  848. /** @type {?} */
  849. var x = event.x || event.clientX;
  850. /** @type {?} */
  851. var y = event.y || event.clientY;
  852. /** @type {?} */
  853. var targets = this.document.elementsFromPoint(x, y);
  854. var _loop_1 = function (prop) {
  855. // current column position which throws event.
  856. /** @type {?} */
  857. var pos = this_1.positions[prop];
  858. // since we drag the inner span, we need to find it in the elements at the cursor
  859. if (model.prop !== prop && targets.find((/**
  860. * @param {?} el
  861. * @return {?}
  862. */
  863. function (el) { return el === pos.element; }))) {
  864. return { value: {
  865. pos: pos,
  866. i: i
  867. } };
  868. }
  869. i++;
  870. };
  871. var this_1 = this;
  872. for (var prop in this.positions) {
  873. var state_1 = _loop_1(prop);
  874. if (typeof state_1 === "object")
  875. return state_1.value;
  876. }
  877. };
  878. /**
  879. * @private
  880. * @return {?}
  881. */
  882. OrderableDirective.prototype.createMapDiffs = /**
  883. * @private
  884. * @return {?}
  885. */
  886. function () {
  887. return this.draggables.toArray().reduce((/**
  888. * @param {?} acc
  889. * @param {?} curr
  890. * @return {?}
  891. */
  892. function (acc, curr) {
  893. acc[curr.dragModel.$$id] = curr;
  894. return acc;
  895. }), {});
  896. };
  897. OrderableDirective.decorators = [
  898. { type: Directive, args: [{ selector: '[orderable]' },] }
  899. ];
  900. /** @nocollapse */
  901. OrderableDirective.ctorParameters = function () { return [
  902. { type: KeyValueDiffers },
  903. { type: undefined, decorators: [{ type: Inject, args: [DOCUMENT,] }] }
  904. ]; };
  905. OrderableDirective.propDecorators = {
  906. reorder: [{ type: Output }],
  907. targetChanged: [{ type: Output }],
  908. draggables: [{ type: ContentChildren, args: [DraggableDirective, { descendants: true },] }]
  909. };
  910. return OrderableDirective;
  911. }());
  912. if (false) {
  913. /** @type {?} */
  914. OrderableDirective.prototype.reorder;
  915. /** @type {?} */
  916. OrderableDirective.prototype.targetChanged;
  917. /** @type {?} */
  918. OrderableDirective.prototype.draggables;
  919. /** @type {?} */
  920. OrderableDirective.prototype.positions;
  921. /** @type {?} */
  922. OrderableDirective.prototype.differ;
  923. /** @type {?} */
  924. OrderableDirective.prototype.lastDraggingIndex;
  925. /**
  926. * @type {?}
  927. * @private
  928. */
  929. OrderableDirective.prototype.document;
  930. }
  931. /**
  932. * @fileoverview added by tsickle
  933. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  934. */
  935. var LongPressDirective = /** @class */ (function () {
  936. function LongPressDirective() {
  937. this.pressEnabled = true;
  938. this.duration = 500;
  939. this.longPressStart = new EventEmitter();
  940. this.longPressing = new EventEmitter();
  941. this.longPressEnd = new EventEmitter();
  942. this.mouseX = 0;
  943. this.mouseY = 0;
  944. }
  945. Object.defineProperty(LongPressDirective.prototype, "press", {
  946. get: /**
  947. * @return {?}
  948. */
  949. function () {
  950. return this.pressing;
  951. },
  952. enumerable: true,
  953. configurable: true
  954. });
  955. Object.defineProperty(LongPressDirective.prototype, "isLongPress", {
  956. get: /**
  957. * @return {?}
  958. */
  959. function () {
  960. return this.isLongPressing;
  961. },
  962. enumerable: true,
  963. configurable: true
  964. });
  965. /**
  966. * @param {?} event
  967. * @return {?}
  968. */
  969. LongPressDirective.prototype.onMouseDown = /**
  970. * @param {?} event
  971. * @return {?}
  972. */
  973. function (event) {
  974. var _this = this;
  975. // don't do right/middle clicks
  976. if (event.which !== 1 || !this.pressEnabled)
  977. return;
  978. // don't start drag if its on resize handle
  979. /** @type {?} */
  980. var target = (/** @type {?} */ (event.target));
  981. if (target.classList.contains('resize-handle'))
  982. return;
  983. this.mouseX = event.clientX;
  984. this.mouseY = event.clientY;
  985. this.pressing = true;
  986. this.isLongPressing = false;
  987. /** @type {?} */
  988. var mouseup = fromEvent(document, 'mouseup');
  989. this.subscription = mouseup.subscribe((/**
  990. * @param {?} ev
  991. * @return {?}
  992. */
  993. function (ev) { return _this.onMouseup(); }));
  994. this.timeout = setTimeout((/**
  995. * @return {?}
  996. */
  997. function () {
  998. _this.isLongPressing = true;
  999. _this.longPressStart.emit({
  1000. event: event,
  1001. model: _this.pressModel
  1002. });
  1003. _this.subscription.add(fromEvent(document, 'mousemove')
  1004. .pipe(takeUntil(mouseup))
  1005. .subscribe((/**
  1006. * @param {?} mouseEvent
  1007. * @return {?}
  1008. */
  1009. function (mouseEvent) { return _this.onMouseMove(mouseEvent); })));
  1010. _this.loop(event);
  1011. }), this.duration);
  1012. this.loop(event);
  1013. };
  1014. /**
  1015. * @param {?} event
  1016. * @return {?}
  1017. */
  1018. LongPressDirective.prototype.onMouseMove = /**
  1019. * @param {?} event
  1020. * @return {?}
  1021. */
  1022. function (event) {
  1023. if (this.pressing && !this.isLongPressing) {
  1024. /** @type {?} */
  1025. var xThres = Math.abs(event.clientX - this.mouseX) > 10;
  1026. /** @type {?} */
  1027. var yThres = Math.abs(event.clientY - this.mouseY) > 10;
  1028. if (xThres || yThres) {
  1029. this.endPress();
  1030. }
  1031. }
  1032. };
  1033. /**
  1034. * @param {?} event
  1035. * @return {?}
  1036. */
  1037. LongPressDirective.prototype.loop = /**
  1038. * @param {?} event
  1039. * @return {?}
  1040. */
  1041. function (event) {
  1042. var _this = this;
  1043. if (this.isLongPressing) {
  1044. this.timeout = setTimeout((/**
  1045. * @return {?}
  1046. */
  1047. function () {
  1048. _this.longPressing.emit({
  1049. event: event,
  1050. model: _this.pressModel
  1051. });
  1052. _this.loop(event);
  1053. }), 50);
  1054. }
  1055. };
  1056. /**
  1057. * @return {?}
  1058. */
  1059. LongPressDirective.prototype.endPress = /**
  1060. * @return {?}
  1061. */
  1062. function () {
  1063. clearTimeout(this.timeout);
  1064. this.isLongPressing = false;
  1065. this.pressing = false;
  1066. this._destroySubscription();
  1067. this.longPressEnd.emit({
  1068. model: this.pressModel
  1069. });
  1070. };
  1071. /**
  1072. * @return {?}
  1073. */
  1074. LongPressDirective.prototype.onMouseup = /**
  1075. * @return {?}
  1076. */
  1077. function () {
  1078. this.endPress();
  1079. };
  1080. /**
  1081. * @return {?}
  1082. */
  1083. LongPressDirective.prototype.ngOnDestroy = /**
  1084. * @return {?}
  1085. */
  1086. function () {
  1087. this._destroySubscription();
  1088. };
  1089. /**
  1090. * @private
  1091. * @return {?}
  1092. */
  1093. LongPressDirective.prototype._destroySubscription = /**
  1094. * @private
  1095. * @return {?}
  1096. */
  1097. function () {
  1098. if (this.subscription) {
  1099. this.subscription.unsubscribe();
  1100. this.subscription = undefined;
  1101. }
  1102. };
  1103. LongPressDirective.decorators = [
  1104. { type: Directive, args: [{ selector: '[long-press]' },] }
  1105. ];
  1106. LongPressDirective.propDecorators = {
  1107. pressEnabled: [{ type: Input }],
  1108. pressModel: [{ type: Input }],
  1109. duration: [{ type: Input }],
  1110. longPressStart: [{ type: Output }],
  1111. longPressing: [{ type: Output }],
  1112. longPressEnd: [{ type: Output }],
  1113. press: [{ type: HostBinding, args: ['class.press',] }],
  1114. isLongPress: [{ type: HostBinding, args: ['class.longpress',] }],
  1115. onMouseDown: [{ type: HostListener, args: ['mousedown', ['$event'],] }]
  1116. };
  1117. return LongPressDirective;
  1118. }());
  1119. if (false) {
  1120. /** @type {?} */
  1121. LongPressDirective.prototype.pressEnabled;
  1122. /** @type {?} */
  1123. LongPressDirective.prototype.pressModel;
  1124. /** @type {?} */
  1125. LongPressDirective.prototype.duration;
  1126. /** @type {?} */
  1127. LongPressDirective.prototype.longPressStart;
  1128. /** @type {?} */
  1129. LongPressDirective.prototype.longPressing;
  1130. /** @type {?} */
  1131. LongPressDirective.prototype.longPressEnd;
  1132. /** @type {?} */
  1133. LongPressDirective.prototype.pressing;
  1134. /** @type {?} */
  1135. LongPressDirective.prototype.isLongPressing;
  1136. /** @type {?} */
  1137. LongPressDirective.prototype.timeout;
  1138. /** @type {?} */
  1139. LongPressDirective.prototype.mouseX;
  1140. /** @type {?} */
  1141. LongPressDirective.prototype.mouseY;
  1142. /** @type {?} */
  1143. LongPressDirective.prototype.subscription;
  1144. }
  1145. /**
  1146. * @fileoverview added by tsickle
  1147. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  1148. */
  1149. var ScrollerComponent = /** @class */ (function () {
  1150. function ScrollerComponent(ngZone, element, renderer) {
  1151. this.ngZone = ngZone;
  1152. this.renderer = renderer;
  1153. this.scrollbarV = false;
  1154. this.scrollbarH = false;
  1155. this.scroll = new EventEmitter();
  1156. this.scrollYPos = 0;
  1157. this.scrollXPos = 0;
  1158. this.prevScrollYPos = 0;
  1159. this.prevScrollXPos = 0;
  1160. this._scrollEventListener = null;
  1161. this.element = element.nativeElement;
  1162. }
  1163. /**
  1164. * @return {?}
  1165. */
  1166. ScrollerComponent.prototype.ngOnInit = /**
  1167. * @return {?}
  1168. */
  1169. function () {
  1170. // manual bind so we don't always listen
  1171. if (this.scrollbarV || this.scrollbarH) {
  1172. /** @type {?} */
  1173. var renderer = this.renderer;
  1174. this.parentElement = renderer.parentNode(renderer.parentNode(this.element));
  1175. this._scrollEventListener = this.onScrolled.bind(this);
  1176. this.parentElement.addEventListener('scroll', this._scrollEventListener);
  1177. }
  1178. };
  1179. /**
  1180. * @return {?}
  1181. */
  1182. ScrollerComponent.prototype.ngOnDestroy = /**
  1183. * @return {?}
  1184. */
  1185. function () {
  1186. if (this._scrollEventListener) {
  1187. this.parentElement.removeEventListener('scroll', this._scrollEventListener);
  1188. this._scrollEventListener = null;
  1189. }
  1190. };
  1191. /**
  1192. * @param {?} offsetY
  1193. * @return {?}
  1194. */
  1195. ScrollerComponent.prototype.setOffset = /**
  1196. * @param {?} offsetY
  1197. * @return {?}
  1198. */
  1199. function (offsetY) {
  1200. if (this.parentElement) {
  1201. this.parentElement.scrollTop = offsetY;
  1202. }
  1203. };
  1204. /**
  1205. * @param {?} event
  1206. * @return {?}
  1207. */
  1208. ScrollerComponent.prototype.onScrolled = /**
  1209. * @param {?} event
  1210. * @return {?}
  1211. */
  1212. function (event) {
  1213. var _this = this;
  1214. /** @type {?} */
  1215. var dom = (/** @type {?} */ (event.currentTarget));
  1216. requestAnimationFrame((/**
  1217. * @return {?}
  1218. */
  1219. function () {
  1220. _this.scrollYPos = dom.scrollTop;
  1221. _this.scrollXPos = dom.scrollLeft;
  1222. _this.updateOffset();
  1223. }));
  1224. };
  1225. /**
  1226. * @return {?}
  1227. */
  1228. ScrollerComponent.prototype.updateOffset = /**
  1229. * @return {?}
  1230. */
  1231. function () {
  1232. /** @type {?} */
  1233. var direction;
  1234. if (this.scrollYPos < this.prevScrollYPos) {
  1235. direction = 'down';
  1236. }
  1237. else if (this.scrollYPos > this.prevScrollYPos) {
  1238. direction = 'up';
  1239. }
  1240. this.scroll.emit({
  1241. direction: direction,
  1242. scrollYPos: this.scrollYPos,
  1243. scrollXPos: this.scrollXPos
  1244. });
  1245. this.prevScrollYPos = this.scrollYPos;
  1246. this.prevScrollXPos = this.scrollXPos;
  1247. };
  1248. ScrollerComponent.decorators = [
  1249. { type: Component, args: [{
  1250. selector: 'datatable-scroller',
  1251. template: "\n <ng-content></ng-content>\n ",
  1252. host: {
  1253. class: 'datatable-scroll'
  1254. },
  1255. changeDetection: ChangeDetectionStrategy.OnPush
  1256. }] }
  1257. ];
  1258. /** @nocollapse */
  1259. ScrollerComponent.ctorParameters = function () { return [
  1260. { type: NgZone },
  1261. { type: ElementRef },
  1262. { type: Renderer2 }
  1263. ]; };
  1264. ScrollerComponent.propDecorators = {
  1265. scrollbarV: [{ type: Input }],
  1266. scrollbarH: [{ type: Input }],
  1267. scrollHeight: [{ type: HostBinding, args: ['style.height.px',] }, { type: Input }],
  1268. scrollWidth: [{ type: HostBinding, args: ['style.width.px',] }, { type: Input }],
  1269. scroll: [{ type: Output }]
  1270. };
  1271. return ScrollerComponent;
  1272. }());
  1273. if (false) {
  1274. /** @type {?} */
  1275. ScrollerComponent.prototype.scrollbarV;
  1276. /** @type {?} */
  1277. ScrollerComponent.prototype.scrollbarH;
  1278. /** @type {?} */
  1279. ScrollerComponent.prototype.scrollHeight;
  1280. /** @type {?} */
  1281. ScrollerComponent.prototype.scrollWidth;
  1282. /** @type {?} */
  1283. ScrollerComponent.prototype.scroll;
  1284. /** @type {?} */
  1285. ScrollerComponent.prototype.scrollYPos;
  1286. /** @type {?} */
  1287. ScrollerComponent.prototype.scrollXPos;
  1288. /** @type {?} */
  1289. ScrollerComponent.prototype.prevScrollYPos;
  1290. /** @type {?} */
  1291. ScrollerComponent.prototype.prevScrollXPos;
  1292. /** @type {?} */
  1293. ScrollerComponent.prototype.element;
  1294. /** @type {?} */
  1295. ScrollerComponent.prototype.parentElement;
  1296. /** @type {?} */
  1297. ScrollerComponent.prototype.onScrollListener;
  1298. /**
  1299. * @type {?}
  1300. * @private
  1301. */
  1302. ScrollerComponent.prototype._scrollEventListener;
  1303. /**
  1304. * @type {?}
  1305. * @private
  1306. */
  1307. ScrollerComponent.prototype.ngZone;
  1308. /**
  1309. * @type {?}
  1310. * @private
  1311. */
  1312. ScrollerComponent.prototype.renderer;
  1313. }
  1314. /**
  1315. * @fileoverview added by tsickle
  1316. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  1317. */
  1318. var DatatableGroupHeaderTemplateDirective = /** @class */ (function () {
  1319. function DatatableGroupHeaderTemplateDirective(template) {
  1320. this.template = template;
  1321. }
  1322. DatatableGroupHeaderTemplateDirective.decorators = [
  1323. { type: Directive, args: [{
  1324. selector: '[ngx-datatable-group-header-template]'
  1325. },] }
  1326. ];
  1327. /** @nocollapse */
  1328. DatatableGroupHeaderTemplateDirective.ctorParameters = function () { return [
  1329. { type: TemplateRef }
  1330. ]; };
  1331. return DatatableGroupHeaderTemplateDirective;
  1332. }());
  1333. if (false) {
  1334. /** @type {?} */
  1335. DatatableGroupHeaderTemplateDirective.prototype.template;
  1336. }
  1337. /**
  1338. * @fileoverview added by tsickle
  1339. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  1340. */
  1341. var DatatableGroupHeaderDirective = /** @class */ (function () {
  1342. function DatatableGroupHeaderDirective() {
  1343. /**
  1344. * Row height is required when virtual scroll is enabled.
  1345. */
  1346. this.rowHeight = 0;
  1347. /**
  1348. * Track toggling of group visibility
  1349. */
  1350. this.toggle = new EventEmitter();
  1351. }
  1352. Object.defineProperty(DatatableGroupHeaderDirective.prototype, "template", {
  1353. get: /**
  1354. * @return {?}
  1355. */
  1356. function () {
  1357. return this._templateInput || this._templateQuery;
  1358. },
  1359. enumerable: true,
  1360. configurable: true
  1361. });
  1362. /**
  1363. * Toggle the expansion of a group
  1364. */
  1365. /**
  1366. * Toggle the expansion of a group
  1367. * @param {?} group
  1368. * @return {?}
  1369. */
  1370. DatatableGroupHeaderDirective.prototype.toggleExpandGroup = /**
  1371. * Toggle the expansion of a group
  1372. * @param {?} group
  1373. * @return {?}
  1374. */
  1375. function (group) {
  1376. this.toggle.emit({
  1377. type: 'group',
  1378. value: group
  1379. });
  1380. };
  1381. /**
  1382. * Expand all groups
  1383. */
  1384. /**
  1385. * Expand all groups
  1386. * @return {?}
  1387. */
  1388. DatatableGroupHeaderDirective.prototype.expandAllGroups = /**
  1389. * Expand all groups
  1390. * @return {?}
  1391. */
  1392. function () {
  1393. this.toggle.emit({
  1394. type: 'all',
  1395. value: true
  1396. });
  1397. };
  1398. /**
  1399. * Collapse all groups
  1400. */
  1401. /**
  1402. * Collapse all groups
  1403. * @return {?}
  1404. */
  1405. DatatableGroupHeaderDirective.prototype.collapseAllGroups = /**
  1406. * Collapse all groups
  1407. * @return {?}
  1408. */
  1409. function () {
  1410. this.toggle.emit({
  1411. type: 'all',
  1412. value: false
  1413. });
  1414. };
  1415. DatatableGroupHeaderDirective.decorators = [
  1416. { type: Directive, args: [{ selector: 'ngx-datatable-group-header' },] }
  1417. ];
  1418. DatatableGroupHeaderDirective.propDecorators = {
  1419. rowHeight: [{ type: Input }],
  1420. _templateInput: [{ type: Input, args: ['template',] }],
  1421. _templateQuery: [{ type: ContentChild, args: [DatatableGroupHeaderTemplateDirective, { read: TemplateRef, static: true },] }],
  1422. toggle: [{ type: Output }]
  1423. };
  1424. return DatatableGroupHeaderDirective;
  1425. }());
  1426. if (false) {
  1427. /**
  1428. * Row height is required when virtual scroll is enabled.
  1429. * @type {?}
  1430. */
  1431. DatatableGroupHeaderDirective.prototype.rowHeight;
  1432. /** @type {?} */
  1433. DatatableGroupHeaderDirective.prototype._templateInput;
  1434. /** @type {?} */
  1435. DatatableGroupHeaderDirective.prototype._templateQuery;
  1436. /**
  1437. * Track toggling of group visibility
  1438. * @type {?}
  1439. */
  1440. DatatableGroupHeaderDirective.prototype.toggle;
  1441. }
  1442. /**
  1443. * @fileoverview added by tsickle
  1444. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  1445. */
  1446. /**
  1447. * Always returns the empty string ''
  1448. * @return {?}
  1449. */
  1450. function emptyStringGetter() {
  1451. return '';
  1452. }
  1453. /**
  1454. * Returns the appropriate getter function for this kind of prop.
  1455. * If prop == null, returns the emptyStringGetter.
  1456. * @param {?} prop
  1457. * @return {?}
  1458. */
  1459. function getterForProp(prop) {
  1460. if (prop == null) {
  1461. return emptyStringGetter;
  1462. }
  1463. if (typeof prop === 'number') {
  1464. return numericIndexGetter;
  1465. }
  1466. else {
  1467. // deep or simple
  1468. if (prop.indexOf('.') !== -1) {
  1469. return deepValueGetter;
  1470. }
  1471. else {
  1472. return shallowValueGetter;
  1473. }
  1474. }
  1475. }
  1476. /**
  1477. * Returns the value at this numeric index.
  1478. * @param {?} row array of values
  1479. * @param {?} index numeric index
  1480. * @return {?} any or '' if invalid index
  1481. */
  1482. function numericIndexGetter(row, index) {
  1483. if (row == null) {
  1484. return '';
  1485. }
  1486. // mimic behavior of deepValueGetter
  1487. if (!row || index == null) {
  1488. return row;
  1489. }
  1490. /** @type {?} */
  1491. var value = row[index];
  1492. if (value == null) {
  1493. return '';
  1494. }
  1495. return value;
  1496. }
  1497. /**
  1498. * Returns the value of a field.
  1499. * (more efficient than deepValueGetter)
  1500. * @param {?} obj object containing the field
  1501. * @param {?} fieldName field name string
  1502. * @return {?}
  1503. */
  1504. function shallowValueGetter(obj, fieldName) {
  1505. if (obj == null) {
  1506. return '';
  1507. }
  1508. if (!obj || !fieldName) {
  1509. return obj;
  1510. }
  1511. /** @type {?} */
  1512. var value = obj[fieldName];
  1513. if (value == null) {
  1514. return '';
  1515. }
  1516. return value;
  1517. }
  1518. /**
  1519. * Returns a deep object given a string. zoo['animal.type']
  1520. * @param {?} obj
  1521. * @param {?} path
  1522. * @return {?}
  1523. */
  1524. function deepValueGetter(obj, path) {
  1525. if (obj == null) {
  1526. return '';
  1527. }
  1528. if (!obj || !path) {
  1529. return obj;
  1530. }
  1531. // check if path matches a root-level field
  1532. // { "a.b.c": 123 }
  1533. /** @type {?} */
  1534. var current = obj[path];
  1535. if (current !== undefined) {
  1536. return current;
  1537. }
  1538. current = obj;
  1539. /** @type {?} */
  1540. var split = path.split('.');
  1541. if (split.length) {
  1542. for (var i = 0; i < split.length; i++) {
  1543. current = current[split[i]];
  1544. // if found undefined, return empty string
  1545. if (current === undefined || current === null) {
  1546. return '';
  1547. }
  1548. }
  1549. }
  1550. return current;
  1551. }
  1552. /**
  1553. * @fileoverview added by tsickle
  1554. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  1555. */
  1556. /**
  1557. * @param {?} prop
  1558. * @return {?}
  1559. */
  1560. function optionalGetterForProp(prop) {
  1561. return prop && ((/**
  1562. * @param {?} row
  1563. * @return {?}
  1564. */
  1565. function (row) { return getterForProp(prop)(row, prop); }));
  1566. }
  1567. /**
  1568. * This functions rearrange items by their parents
  1569. * Also sets the level value to each of the items
  1570. *
  1571. * Note: Expecting each item has a property called parentId
  1572. * Note: This algorithm will fail if a list has two or more items with same ID
  1573. * NOTE: This algorithm will fail if there is a deadlock of relationship
  1574. *
  1575. * For example,
  1576. *
  1577. * Input
  1578. *
  1579. * id -> parent
  1580. * 1 -> 0
  1581. * 2 -> 0
  1582. * 3 -> 1
  1583. * 4 -> 1
  1584. * 5 -> 2
  1585. * 7 -> 8
  1586. * 6 -> 3
  1587. *
  1588. *
  1589. * Output
  1590. * id -> level
  1591. * 1 -> 0
  1592. * --3 -> 1
  1593. * ----6 -> 2
  1594. * --4 -> 1
  1595. * 2 -> 0
  1596. * --5 -> 1
  1597. * 7 -> 8
  1598. *
  1599. *
  1600. * @param {?} rows
  1601. *
  1602. * @param {?=} from
  1603. * @param {?=} to
  1604. * @return {?}
  1605. */
  1606. function groupRowsByParents(rows, from, to) {
  1607. if (from && to) {
  1608. /** @type {?} */
  1609. var nodeById = {};
  1610. /** @type {?} */
  1611. var l = rows.length;
  1612. /** @type {?} */
  1613. var node = null;
  1614. nodeById[0] = new TreeNode(); // that's the root node
  1615. // that's the root node
  1616. /** @type {?} */
  1617. var uniqIDs = rows.reduce((/**
  1618. * @param {?} arr
  1619. * @param {?} item
  1620. * @return {?}
  1621. */
  1622. function (arr, item) {
  1623. /** @type {?} */
  1624. var toValue = to(item);
  1625. if (arr.indexOf(toValue) === -1) {
  1626. arr.push(toValue);
  1627. }
  1628. return arr;
  1629. }), []);
  1630. for (var i = 0; i < l; i++) {
  1631. // make TreeNode objects for each item
  1632. nodeById[to(rows[i])] = new TreeNode(rows[i]);
  1633. }
  1634. for (var i = 0; i < l; i++) {
  1635. // link all TreeNode objects
  1636. node = nodeById[to(rows[i])];
  1637. /** @type {?} */
  1638. var parent_1 = 0;
  1639. /** @type {?} */
  1640. var fromValue = from(node.row);
  1641. if (!!fromValue && uniqIDs.indexOf(fromValue) > -1) {
  1642. parent_1 = fromValue;
  1643. }
  1644. node.parent = nodeById[parent_1];
  1645. node.row['level'] = node.parent.row['level'] + 1;
  1646. node.parent.children.push(node);
  1647. }
  1648. /** @type {?} */
  1649. var resolvedRows_1 = [];
  1650. nodeById[0].flatten((/**
  1651. * @return {?}
  1652. */
  1653. function () {
  1654. resolvedRows_1 = __spread(resolvedRows_1, [this.row]);
  1655. }), true);
  1656. return resolvedRows_1;
  1657. }
  1658. else {
  1659. return rows;
  1660. }
  1661. }
  1662. var TreeNode = /** @class */ (function () {
  1663. function TreeNode(row) {
  1664. if (row === void 0) { row = null; }
  1665. if (!row) {
  1666. row = {
  1667. level: -1,
  1668. treeStatus: 'expanded'
  1669. };
  1670. }
  1671. this.row = row;
  1672. this.parent = null;
  1673. this.children = [];
  1674. }
  1675. /**
  1676. * @param {?} f
  1677. * @param {?} recursive
  1678. * @return {?}
  1679. */
  1680. TreeNode.prototype.flatten = /**
  1681. * @param {?} f
  1682. * @param {?} recursive
  1683. * @return {?}
  1684. */
  1685. function (f, recursive) {
  1686. if (this.row['treeStatus'] === 'expanded') {
  1687. for (var i = 0, l = this.children.length; i < l; i++) {
  1688. /** @type {?} */
  1689. var child = this.children[i];
  1690. f.apply(child, Array.prototype.slice.call(arguments, 2));
  1691. if (recursive)
  1692. child.flatten.apply(child, arguments);
  1693. }
  1694. }
  1695. };
  1696. return TreeNode;
  1697. }());
  1698. if (false) {
  1699. /** @type {?} */
  1700. TreeNode.prototype.row;
  1701. /** @type {?} */
  1702. TreeNode.prototype.parent;
  1703. /** @type {?} */
  1704. TreeNode.prototype.children;
  1705. }
  1706. /**
  1707. * @fileoverview added by tsickle
  1708. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  1709. */
  1710. /**
  1711. * Converts strings from something to camel case
  1712. * http://stackoverflow.com/questions/10425287/convert-dash-separated-string-to-camelcase
  1713. * @param {?} str
  1714. * @return {?}
  1715. */
  1716. function camelCase(str) {
  1717. // Replace special characters with a space
  1718. str = str.replace(/[^a-zA-Z0-9 ]/g, ' ');
  1719. // put a space before an uppercase letter
  1720. str = str.replace(/([a-z](?=[A-Z]))/g, '$1 ');
  1721. // Lower case first character and some other stuff
  1722. str = str
  1723. .replace(/([^a-zA-Z0-9 ])|^[0-9]+/g, '')
  1724. .trim()
  1725. .toLowerCase();
  1726. // uppercase characters preceded by a space or number
  1727. str = str.replace(/([ 0-9]+)([a-zA-Z])/g, (/**
  1728. * @param {?} a
  1729. * @param {?} b
  1730. * @param {?} c
  1731. * @return {?}
  1732. */
  1733. function (a, b, c) {
  1734. return b.trim() + c.toUpperCase();
  1735. }));
  1736. return str;
  1737. }
  1738. /**
  1739. * Converts strings from camel case to words
  1740. * http://stackoverflow.com/questions/7225407/convert-camelcasetext-to-camel-case-text
  1741. * @param {?} str
  1742. * @return {?}
  1743. */
  1744. function deCamelCase(str) {
  1745. return str.replace(/([A-Z])/g, (/**
  1746. * @param {?} match
  1747. * @return {?}
  1748. */
  1749. function (match) { return " " + match; })).replace(/^./, (/**
  1750. * @param {?} match
  1751. * @return {?}
  1752. */
  1753. function (match) { return match.toUpperCase(); }));
  1754. }
  1755. /**
  1756. * @fileoverview added by tsickle
  1757. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  1758. */
  1759. /**
  1760. * Creates a unique object id.
  1761. * http://stackoverflow.com/questions/6248666/how-to-generate-short-uid-like-ax4j9z-in-js
  1762. * @return {?}
  1763. */
  1764. function id() {
  1765. return ('0000' + ((Math.random() * Math.pow(36, 4)) << 0).toString(36)).slice(-4);
  1766. }
  1767. /**
  1768. * @fileoverview added by tsickle
  1769. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  1770. */
  1771. /**
  1772. * Sets the column defaults
  1773. * @param {?} columns
  1774. * @return {?}
  1775. */
  1776. function setColumnDefaults(columns) {
  1777. var e_1, _a;
  1778. if (!columns)
  1779. return;
  1780. // Only one column should hold the tree view
  1781. // Thus if multiple columns are provided with
  1782. // isTreeColumn as true we take only the first one
  1783. /** @type {?} */
  1784. var treeColumnFound = false;
  1785. try {
  1786. for (var columns_1 = __values(columns), columns_1_1 = columns_1.next(); !columns_1_1.done; columns_1_1 = columns_1.next()) {
  1787. var column = columns_1_1.value;
  1788. if (!column.$$id) {
  1789. column.$$id = id();
  1790. }
  1791. // prop can be numeric; zero is valid not a missing prop
  1792. // translate name => prop
  1793. if (isNullOrUndefined(column.prop) && column.name) {
  1794. column.prop = camelCase(column.name);
  1795. }
  1796. if (!column.$$valueGetter) {
  1797. column.$$valueGetter = getterForProp(column.prop);
  1798. }
  1799. // format props if no name passed
  1800. if (!isNullOrUndefined(column.prop) && isNullOrUndefined(column.name)) {
  1801. column.name = deCamelCase(String(column.prop));
  1802. }
  1803. if (isNullOrUndefined(column.prop) && isNullOrUndefined(column.name)) {
  1804. column.name = ''; // Fixes IE and Edge displaying `null`
  1805. }
  1806. if (!column.hasOwnProperty('resizeable')) {
  1807. column.resizeable = true;
  1808. }
  1809. if (!column.hasOwnProperty('sortable')) {
  1810. column.sortable = true;
  1811. }
  1812. if (!column.hasOwnProperty('draggable')) {
  1813. column.draggable = true;
  1814. }
  1815. if (!column.hasOwnProperty('canAutoResize')) {
  1816. column.canAutoResize = true;
  1817. }
  1818. if (!column.hasOwnProperty('width')) {
  1819. column.width = 150;
  1820. }
  1821. if (!column.hasOwnProperty('isTreeColumn')) {
  1822. column.isTreeColumn = false;
  1823. }
  1824. else {
  1825. if (column.isTreeColumn && !treeColumnFound) {
  1826. // If the first column with isTreeColumn is true found
  1827. // we mark that treeCoulmn is found
  1828. treeColumnFound = true;
  1829. }
  1830. else {
  1831. // After that isTreeColumn property for any other column
  1832. // will be set as false
  1833. column.isTreeColumn = false;
  1834. }
  1835. }
  1836. }
  1837. }
  1838. catch (e_1_1) { e_1 = { error: e_1_1 }; }
  1839. finally {
  1840. try {
  1841. if (columns_1_1 && !columns_1_1.done && (_a = columns_1.return)) _a.call(columns_1);
  1842. }
  1843. finally { if (e_1) throw e_1.error; }
  1844. }
  1845. }
  1846. /**
  1847. * @template T
  1848. * @param {?} value
  1849. * @return {?}
  1850. */
  1851. function isNullOrUndefined(value) {
  1852. return value === null || value === undefined;
  1853. }
  1854. /**
  1855. * Translates templates definitions to objects
  1856. * @param {?} templates
  1857. * @return {?}
  1858. */
  1859. function translateTemplates(templates) {
  1860. var e_2, _a, e_3, _b;
  1861. /** @type {?} */
  1862. var result = [];
  1863. try {
  1864. for (var templates_1 = __values(templates), templates_1_1 = templates_1.next(); !templates_1_1.done; templates_1_1 = templates_1.next()) {
  1865. var temp = templates_1_1.value;
  1866. /** @type {?} */
  1867. var col = {};
  1868. /** @type {?} */
  1869. var props = Object.getOwnPropertyNames(temp);
  1870. try {
  1871. for (var props_1 = (e_3 = void 0, __values(props)), props_1_1 = props_1.next(); !props_1_1.done; props_1_1 = props_1.next()) {
  1872. var prop = props_1_1.value;
  1873. col[prop] = temp[prop];
  1874. }
  1875. }
  1876. catch (e_3_1) { e_3 = { error: e_3_1 }; }
  1877. finally {
  1878. try {
  1879. if (props_1_1 && !props_1_1.done && (_b = props_1.return)) _b.call(props_1);
  1880. }
  1881. finally { if (e_3) throw e_3.error; }
  1882. }
  1883. if (temp.headerTemplate) {
  1884. col.headerTemplate = temp.headerTemplate;
  1885. }
  1886. if (temp.cellTemplate) {
  1887. col.cellTemplate = temp.cellTemplate;
  1888. }
  1889. if (temp.summaryFunc) {
  1890. col.summaryFunc = temp.summaryFunc;
  1891. }
  1892. if (temp.summaryTemplate) {
  1893. col.summaryTemplate = temp.summaryTemplate;
  1894. }
  1895. result.push(col);
  1896. }
  1897. }
  1898. catch (e_2_1) { e_2 = { error: e_2_1 }; }
  1899. finally {
  1900. try {
  1901. if (templates_1_1 && !templates_1_1.done && (_a = templates_1.return)) _a.call(templates_1);
  1902. }
  1903. finally { if (e_2) throw e_2.error; }
  1904. }
  1905. return result;
  1906. }
  1907. /**
  1908. * @fileoverview added by tsickle
  1909. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  1910. */
  1911. /** @enum {string} */
  1912. var ColumnMode = {
  1913. standard: 'standard',
  1914. flex: 'flex',
  1915. force: 'force',
  1916. };
  1917. /**
  1918. * @fileoverview added by tsickle
  1919. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  1920. */
  1921. /** @enum {string} */
  1922. var SelectionType = {
  1923. single: 'single',
  1924. multi: 'multi',
  1925. multiClick: 'multiClick',
  1926. cell: 'cell',
  1927. checkbox: 'checkbox',
  1928. };
  1929. /**
  1930. * @fileoverview added by tsickle
  1931. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  1932. */
  1933. /** @enum {string} */
  1934. var SortType = {
  1935. single: 'single',
  1936. multi: 'multi',
  1937. };
  1938. /**
  1939. * @fileoverview added by tsickle
  1940. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  1941. */
  1942. /** @enum {string} */
  1943. var ContextmenuType = {
  1944. header: 'header',
  1945. body: 'body',
  1946. };
  1947. /**
  1948. * @fileoverview added by tsickle
  1949. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  1950. */
  1951. var DataTableColumnHeaderDirective = /** @class */ (function () {
  1952. function DataTableColumnHeaderDirective(template) {
  1953. this.template = template;
  1954. }
  1955. DataTableColumnHeaderDirective.decorators = [
  1956. { type: Directive, args: [{ selector: '[ngx-datatable-header-template]' },] }
  1957. ];
  1958. /** @nocollapse */
  1959. DataTableColumnHeaderDirective.ctorParameters = function () { return [
  1960. { type: TemplateRef }
  1961. ]; };
  1962. return DataTableColumnHeaderDirective;
  1963. }());
  1964. if (false) {
  1965. /** @type {?} */
  1966. DataTableColumnHeaderDirective.prototype.template;
  1967. }
  1968. /**
  1969. * @fileoverview added by tsickle
  1970. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  1971. */
  1972. var DataTableColumnCellDirective = /** @class */ (function () {
  1973. function DataTableColumnCellDirective(template) {
  1974. this.template = template;
  1975. }
  1976. DataTableColumnCellDirective.decorators = [
  1977. { type: Directive, args: [{ selector: '[ngx-datatable-cell-template]' },] }
  1978. ];
  1979. /** @nocollapse */
  1980. DataTableColumnCellDirective.ctorParameters = function () { return [
  1981. { type: TemplateRef }
  1982. ]; };
  1983. return DataTableColumnCellDirective;
  1984. }());
  1985. if (false) {
  1986. /** @type {?} */
  1987. DataTableColumnCellDirective.prototype.template;
  1988. }
  1989. /**
  1990. * @fileoverview added by tsickle
  1991. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  1992. */
  1993. var DataTableColumnCellTreeToggle = /** @class */ (function () {
  1994. function DataTableColumnCellTreeToggle(template) {
  1995. this.template = template;
  1996. }
  1997. DataTableColumnCellTreeToggle.decorators = [
  1998. { type: Directive, args: [{ selector: '[ngx-datatable-tree-toggle]' },] }
  1999. ];
  2000. /** @nocollapse */
  2001. DataTableColumnCellTreeToggle.ctorParameters = function () { return [
  2002. { type: TemplateRef }
  2003. ]; };
  2004. return DataTableColumnCellTreeToggle;
  2005. }());
  2006. if (false) {
  2007. /** @type {?} */
  2008. DataTableColumnCellTreeToggle.prototype.template;
  2009. }
  2010. /**
  2011. * @fileoverview added by tsickle
  2012. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  2013. */
  2014. var DataTableColumnDirective = /** @class */ (function () {
  2015. function DataTableColumnDirective(columnChangesService) {
  2016. this.columnChangesService = columnChangesService;
  2017. this.isFirstChange = true;
  2018. }
  2019. Object.defineProperty(DataTableColumnDirective.prototype, "cellTemplate", {
  2020. get: /**
  2021. * @return {?}
  2022. */
  2023. function () {
  2024. return this._cellTemplateInput || this._cellTemplateQuery;
  2025. },
  2026. enumerable: true,
  2027. configurable: true
  2028. });
  2029. Object.defineProperty(DataTableColumnDirective.prototype, "headerTemplate", {
  2030. get: /**
  2031. * @return {?}
  2032. */
  2033. function () {
  2034. return this._headerTemplateInput || this._headerTemplateQuery;
  2035. },
  2036. enumerable: true,
  2037. configurable: true
  2038. });
  2039. Object.defineProperty(DataTableColumnDirective.prototype, "treeToggleTemplate", {
  2040. get: /**
  2041. * @return {?}
  2042. */
  2043. function () {
  2044. return this._treeToggleTemplateInput || this._treeToggleTemplateQuery;
  2045. },
  2046. enumerable: true,
  2047. configurable: true
  2048. });
  2049. /**
  2050. * @return {?}
  2051. */
  2052. DataTableColumnDirective.prototype.ngOnChanges = /**
  2053. * @return {?}
  2054. */
  2055. function () {
  2056. if (this.isFirstChange) {
  2057. this.isFirstChange = false;
  2058. }
  2059. else {
  2060. this.columnChangesService.onInputChange();
  2061. }
  2062. };
  2063. DataTableColumnDirective.decorators = [
  2064. { type: Directive, args: [{ selector: 'ngx-datatable-column' },] }
  2065. ];
  2066. /** @nocollapse */
  2067. DataTableColumnDirective.ctorParameters = function () { return [
  2068. { type: ColumnChangesService }
  2069. ]; };
  2070. DataTableColumnDirective.propDecorators = {
  2071. name: [{ type: Input }],
  2072. prop: [{ type: Input }],
  2073. frozenLeft: [{ type: Input }],
  2074. frozenRight: [{ type: Input }],
  2075. flexGrow: [{ type: Input }],
  2076. resizeable: [{ type: Input }],
  2077. comparator: [{ type: Input }],
  2078. pipe: [{ type: Input }],
  2079. sortable: [{ type: Input }],
  2080. draggable: [{ type: Input }],
  2081. canAutoResize: [{ type: Input }],
  2082. minWidth: [{ type: Input }],
  2083. width: [{ type: Input }],
  2084. maxWidth: [{ type: Input }],
  2085. checkboxable: [{ type: Input }],
  2086. headerCheckboxable: [{ type: Input }],
  2087. headerClass: [{ type: Input }],
  2088. cellClass: [{ type: Input }],
  2089. isTreeColumn: [{ type: Input }],
  2090. treeLevelIndent: [{ type: Input }],
  2091. summaryFunc: [{ type: Input }],
  2092. summaryTemplate: [{ type: Input }],
  2093. _cellTemplateInput: [{ type: Input, args: ['cellTemplate',] }],
  2094. _cellTemplateQuery: [{ type: ContentChild, args: [DataTableColumnCellDirective, { read: TemplateRef, static: true },] }],
  2095. _headerTemplateInput: [{ type: Input, args: ['headerTemplate',] }],
  2096. _headerTemplateQuery: [{ type: ContentChild, args: [DataTableColumnHeaderDirective, { read: TemplateRef, static: true },] }],
  2097. _treeToggleTemplateInput: [{ type: Input, args: ['treeToggleTemplate',] }],
  2098. _treeToggleTemplateQuery: [{ type: ContentChild, args: [DataTableColumnCellTreeToggle, { read: TemplateRef, static: true },] }]
  2099. };
  2100. return DataTableColumnDirective;
  2101. }());
  2102. if (false) {
  2103. /** @type {?} */
  2104. DataTableColumnDirective.prototype.name;
  2105. /** @type {?} */
  2106. DataTableColumnDirective.prototype.prop;
  2107. /** @type {?} */
  2108. DataTableColumnDirective.prototype.frozenLeft;
  2109. /** @type {?} */
  2110. DataTableColumnDirective.prototype.frozenRight;
  2111. /** @type {?} */
  2112. DataTableColumnDirective.prototype.flexGrow;
  2113. /** @type {?} */
  2114. DataTableColumnDirective.prototype.resizeable;
  2115. /** @type {?} */
  2116. DataTableColumnDirective.prototype.comparator;
  2117. /** @type {?} */
  2118. DataTableColumnDirective.prototype.pipe;
  2119. /** @type {?} */
  2120. DataTableColumnDirective.prototype.sortable;
  2121. /** @type {?} */
  2122. DataTableColumnDirective.prototype.draggable;
  2123. /** @type {?} */
  2124. DataTableColumnDirective.prototype.canAutoResize;
  2125. /** @type {?} */
  2126. DataTableColumnDirective.prototype.minWidth;
  2127. /** @type {?} */
  2128. DataTableColumnDirective.prototype.width;
  2129. /** @type {?} */
  2130. DataTableColumnDirective.prototype.maxWidth;
  2131. /** @type {?} */
  2132. DataTableColumnDirective.prototype.checkboxable;
  2133. /** @type {?} */
  2134. DataTableColumnDirective.prototype.headerCheckboxable;
  2135. /** @type {?} */
  2136. DataTableColumnDirective.prototype.headerClass;
  2137. /** @type {?} */
  2138. DataTableColumnDirective.prototype.cellClass;
  2139. /** @type {?} */
  2140. DataTableColumnDirective.prototype.isTreeColumn;
  2141. /** @type {?} */
  2142. DataTableColumnDirective.prototype.treeLevelIndent;
  2143. /** @type {?} */
  2144. DataTableColumnDirective.prototype.summaryFunc;
  2145. /** @type {?} */
  2146. DataTableColumnDirective.prototype.summaryTemplate;
  2147. /** @type {?} */
  2148. DataTableColumnDirective.prototype._cellTemplateInput;
  2149. /** @type {?} */
  2150. DataTableColumnDirective.prototype._cellTemplateQuery;
  2151. /** @type {?} */
  2152. DataTableColumnDirective.prototype._headerTemplateInput;
  2153. /** @type {?} */
  2154. DataTableColumnDirective.prototype._headerTemplateQuery;
  2155. /** @type {?} */
  2156. DataTableColumnDirective.prototype._treeToggleTemplateInput;
  2157. /** @type {?} */
  2158. DataTableColumnDirective.prototype._treeToggleTemplateQuery;
  2159. /**
  2160. * @type {?}
  2161. * @private
  2162. */
  2163. DataTableColumnDirective.prototype.isFirstChange;
  2164. /**
  2165. * @type {?}
  2166. * @private
  2167. */
  2168. DataTableColumnDirective.prototype.columnChangesService;
  2169. }
  2170. /**
  2171. * @fileoverview added by tsickle
  2172. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  2173. */
  2174. var DatatableRowDetailTemplateDirective = /** @class */ (function () {
  2175. function DatatableRowDetailTemplateDirective(template) {
  2176. this.template = template;
  2177. }
  2178. DatatableRowDetailTemplateDirective.decorators = [
  2179. { type: Directive, args: [{
  2180. selector: '[ngx-datatable-row-detail-template]'
  2181. },] }
  2182. ];
  2183. /** @nocollapse */
  2184. DatatableRowDetailTemplateDirective.ctorParameters = function () { return [
  2185. { type: TemplateRef }
  2186. ]; };
  2187. return DatatableRowDetailTemplateDirective;
  2188. }());
  2189. if (false) {
  2190. /** @type {?} */
  2191. DatatableRowDetailTemplateDirective.prototype.template;
  2192. }
  2193. /**
  2194. * @fileoverview added by tsickle
  2195. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  2196. */
  2197. var DatatableRowDetailDirective = /** @class */ (function () {
  2198. function DatatableRowDetailDirective() {
  2199. /**
  2200. * The detail row height is required especially
  2201. * when virtual scroll is enabled.
  2202. */
  2203. this.rowHeight = 0;
  2204. /**
  2205. * Row detail row visbility was toggled.
  2206. */
  2207. this.toggle = new EventEmitter();
  2208. }
  2209. Object.defineProperty(DatatableRowDetailDirective.prototype, "template", {
  2210. get: /**
  2211. * @return {?}
  2212. */
  2213. function () {
  2214. return this._templateInput || this._templateQuery;
  2215. },
  2216. enumerable: true,
  2217. configurable: true
  2218. });
  2219. /**
  2220. * Toggle the expansion of the row
  2221. */
  2222. /**
  2223. * Toggle the expansion of the row
  2224. * @param {?} row
  2225. * @return {?}
  2226. */
  2227. DatatableRowDetailDirective.prototype.toggleExpandRow = /**
  2228. * Toggle the expansion of the row
  2229. * @param {?} row
  2230. * @return {?}
  2231. */
  2232. function (row) {
  2233. this.toggle.emit({
  2234. type: 'row',
  2235. value: row
  2236. });
  2237. };
  2238. /**
  2239. * API method to expand all the rows.
  2240. */
  2241. /**
  2242. * API method to expand all the rows.
  2243. * @return {?}
  2244. */
  2245. DatatableRowDetailDirective.prototype.expandAllRows = /**
  2246. * API method to expand all the rows.
  2247. * @return {?}
  2248. */
  2249. function () {
  2250. this.toggle.emit({
  2251. type: 'all',
  2252. value: true
  2253. });
  2254. };
  2255. /**
  2256. * API method to collapse all the rows.
  2257. */
  2258. /**
  2259. * API method to collapse all the rows.
  2260. * @return {?}
  2261. */
  2262. DatatableRowDetailDirective.prototype.collapseAllRows = /**
  2263. * API method to collapse all the rows.
  2264. * @return {?}
  2265. */
  2266. function () {
  2267. this.toggle.emit({
  2268. type: 'all',
  2269. value: false
  2270. });
  2271. };
  2272. DatatableRowDetailDirective.decorators = [
  2273. { type: Directive, args: [{ selector: 'ngx-datatable-row-detail' },] }
  2274. ];
  2275. DatatableRowDetailDirective.propDecorators = {
  2276. rowHeight: [{ type: Input }],
  2277. _templateInput: [{ type: Input, args: ['template',] }],
  2278. _templateQuery: [{ type: ContentChild, args: [DatatableRowDetailTemplateDirective, { read: TemplateRef, static: true },] }],
  2279. toggle: [{ type: Output }]
  2280. };
  2281. return DatatableRowDetailDirective;
  2282. }());
  2283. if (false) {
  2284. /**
  2285. * The detail row height is required especially
  2286. * when virtual scroll is enabled.
  2287. * @type {?}
  2288. */
  2289. DatatableRowDetailDirective.prototype.rowHeight;
  2290. /** @type {?} */
  2291. DatatableRowDetailDirective.prototype._templateInput;
  2292. /** @type {?} */
  2293. DatatableRowDetailDirective.prototype._templateQuery;
  2294. /**
  2295. * Row detail row visbility was toggled.
  2296. * @type {?}
  2297. */
  2298. DatatableRowDetailDirective.prototype.toggle;
  2299. }
  2300. /**
  2301. * @fileoverview added by tsickle
  2302. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  2303. */
  2304. var DatatableFooterDirective = /** @class */ (function () {
  2305. function DatatableFooterDirective() {
  2306. }
  2307. Object.defineProperty(DatatableFooterDirective.prototype, "template", {
  2308. get: /**
  2309. * @return {?}
  2310. */
  2311. function () {
  2312. return this._templateInput || this._templateQuery;
  2313. },
  2314. enumerable: true,
  2315. configurable: true
  2316. });
  2317. DatatableFooterDirective.decorators = [
  2318. { type: Directive, args: [{ selector: 'ngx-datatable-footer' },] }
  2319. ];
  2320. DatatableFooterDirective.propDecorators = {
  2321. footerHeight: [{ type: Input }],
  2322. totalMessage: [{ type: Input }],
  2323. selectedMessage: [{ type: Input }],
  2324. pagerLeftArrowIcon: [{ type: Input }],
  2325. pagerRightArrowIcon: [{ type: Input }],
  2326. pagerPreviousIcon: [{ type: Input }],
  2327. pagerNextIcon: [{ type: Input }],
  2328. _templateInput: [{ type: Input, args: ['template',] }],
  2329. _templateQuery: [{ type: ContentChild, args: [DataTableFooterTemplateDirective, { read: TemplateRef, static: false },] }]
  2330. };
  2331. return DatatableFooterDirective;
  2332. }());
  2333. if (false) {
  2334. /** @type {?} */
  2335. DatatableFooterDirective.prototype.footerHeight;
  2336. /** @type {?} */
  2337. DatatableFooterDirective.prototype.totalMessage;
  2338. /** @type {?} */
  2339. DatatableFooterDirective.prototype.selectedMessage;
  2340. /** @type {?} */
  2341. DatatableFooterDirective.prototype.pagerLeftArrowIcon;
  2342. /** @type {?} */
  2343. DatatableFooterDirective.prototype.pagerRightArrowIcon;
  2344. /** @type {?} */
  2345. DatatableFooterDirective.prototype.pagerPreviousIcon;
  2346. /** @type {?} */
  2347. DatatableFooterDirective.prototype.pagerNextIcon;
  2348. /** @type {?} */
  2349. DatatableFooterDirective.prototype._templateInput;
  2350. /** @type {?} */
  2351. DatatableFooterDirective.prototype._templateQuery;
  2352. }
  2353. /**
  2354. * @fileoverview added by tsickle
  2355. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  2356. */
  2357. /**
  2358. * Returns the columns by pin.
  2359. * @param {?} cols
  2360. * @return {?}
  2361. */
  2362. function columnsByPin(cols) {
  2363. var e_1, _a;
  2364. /** @type {?} */
  2365. var ret = {
  2366. left: [],
  2367. center: [],
  2368. right: []
  2369. };
  2370. if (cols) {
  2371. try {
  2372. for (var cols_1 = __values(cols), cols_1_1 = cols_1.next(); !cols_1_1.done; cols_1_1 = cols_1.next()) {
  2373. var col = cols_1_1.value;
  2374. if (col.frozenLeft) {
  2375. ret.left.push(col);
  2376. }
  2377. else if (col.frozenRight) {
  2378. ret.right.push(col);
  2379. }
  2380. else {
  2381. ret.center.push(col);
  2382. }
  2383. }
  2384. }
  2385. catch (e_1_1) { e_1 = { error: e_1_1 }; }
  2386. finally {
  2387. try {
  2388. if (cols_1_1 && !cols_1_1.done && (_a = cols_1.return)) _a.call(cols_1);
  2389. }
  2390. finally { if (e_1) throw e_1.error; }
  2391. }
  2392. }
  2393. return ret;
  2394. }
  2395. /**
  2396. * Returns the widths of all group sets of a column
  2397. * @param {?} groups
  2398. * @param {?} all
  2399. * @return {?}
  2400. */
  2401. function columnGroupWidths(groups, all) {
  2402. return {
  2403. left: columnTotalWidth(groups.left),
  2404. center: columnTotalWidth(groups.center),
  2405. right: columnTotalWidth(groups.right),
  2406. total: Math.floor(columnTotalWidth(all))
  2407. };
  2408. }
  2409. /**
  2410. * Calculates the total width of all columns and their groups
  2411. * @param {?} columns
  2412. * @param {?=} prop
  2413. * @return {?}
  2414. */
  2415. function columnTotalWidth(columns, prop) {
  2416. var e_2, _a;
  2417. /** @type {?} */
  2418. var totalWidth = 0;
  2419. if (columns) {
  2420. try {
  2421. for (var columns_1 = __values(columns), columns_1_1 = columns_1.next(); !columns_1_1.done; columns_1_1 = columns_1.next()) {
  2422. var c = columns_1_1.value;
  2423. /** @type {?} */
  2424. var has = prop && c[prop];
  2425. /** @type {?} */
  2426. var width = has ? c[prop] : c.width;
  2427. totalWidth = totalWidth + parseFloat(width);
  2428. }
  2429. }
  2430. catch (e_2_1) { e_2 = { error: e_2_1 }; }
  2431. finally {
  2432. try {
  2433. if (columns_1_1 && !columns_1_1.done && (_a = columns_1.return)) _a.call(columns_1);
  2434. }
  2435. finally { if (e_2) throw e_2.error; }
  2436. }
  2437. }
  2438. return totalWidth;
  2439. }
  2440. /**
  2441. * Calculates the total width of all columns and their groups
  2442. * @param {?} columns
  2443. * @param {?=} prop
  2444. * @return {?}
  2445. */
  2446. function columnsTotalWidth(columns, prop) {
  2447. var e_3, _a;
  2448. /** @type {?} */
  2449. var totalWidth = 0;
  2450. try {
  2451. for (var columns_2 = __values(columns), columns_2_1 = columns_2.next(); !columns_2_1.done; columns_2_1 = columns_2.next()) {
  2452. var column = columns_2_1.value;
  2453. /** @type {?} */
  2454. var has = prop && column[prop];
  2455. totalWidth = totalWidth + (has ? column[prop] : column.width);
  2456. }
  2457. }
  2458. catch (e_3_1) { e_3 = { error: e_3_1 }; }
  2459. finally {
  2460. try {
  2461. if (columns_2_1 && !columns_2_1.done && (_a = columns_2.return)) _a.call(columns_2);
  2462. }
  2463. finally { if (e_3) throw e_3.error; }
  2464. }
  2465. return totalWidth;
  2466. }
  2467. /**
  2468. * @param {?} val
  2469. * @return {?}
  2470. */
  2471. function columnsByPinArr(val) {
  2472. /** @type {?} */
  2473. var colsByPinArr = [];
  2474. /** @type {?} */
  2475. var colsByPin = columnsByPin(val);
  2476. colsByPinArr.push({ type: 'left', columns: colsByPin['left'] });
  2477. colsByPinArr.push({ type: 'center', columns: colsByPin['center'] });
  2478. colsByPinArr.push({ type: 'right', columns: colsByPin['right'] });
  2479. return colsByPinArr;
  2480. }
  2481. /**
  2482. * @fileoverview added by tsickle
  2483. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  2484. */
  2485. /**
  2486. * This object contains the cache of the various row heights that are present inside
  2487. * the data table. Its based on Fenwick tree data structure that helps with
  2488. * querying sums that have time complexity of log n.
  2489. *
  2490. * Fenwick Tree Credits: http://petr-mitrichev.blogspot.com/2013/05/fenwick-tree-range-updates.html
  2491. * https://github.com/mikolalysenko/fenwick-tree
  2492. *
  2493. */
  2494. var /**
  2495. * This object contains the cache of the various row heights that are present inside
  2496. * the data table. Its based on Fenwick tree data structure that helps with
  2497. * querying sums that have time complexity of log n.
  2498. *
  2499. * Fenwick Tree Credits: http://petr-mitrichev.blogspot.com/2013/05/fenwick-tree-range-updates.html
  2500. * https://github.com/mikolalysenko/fenwick-tree
  2501. *
  2502. */
  2503. RowHeightCache = /** @class */ (function () {
  2504. function RowHeightCache() {
  2505. /**
  2506. * Tree Array stores the cumulative information of the row heights to perform efficient
  2507. * range queries and updates. Currently the tree is initialized to the base row
  2508. * height instead of the detail row height.
  2509. */
  2510. this.treeArray = [];
  2511. }
  2512. /**
  2513. * Clear the Tree array.
  2514. */
  2515. /**
  2516. * Clear the Tree array.
  2517. * @return {?}
  2518. */
  2519. RowHeightCache.prototype.clearCache = /**
  2520. * Clear the Tree array.
  2521. * @return {?}
  2522. */
  2523. function () {
  2524. this.treeArray = [];
  2525. };
  2526. /**
  2527. * Initialize the Fenwick tree with row Heights.
  2528. *
  2529. * @param rows The array of rows which contain the expanded status.
  2530. * @param rowHeight The row height.
  2531. * @param detailRowHeight The detail row height.
  2532. */
  2533. /**
  2534. * Initialize the Fenwick tree with row Heights.
  2535. *
  2536. * @param {?} details
  2537. * @return {?}
  2538. */
  2539. RowHeightCache.prototype.initCache = /**
  2540. * Initialize the Fenwick tree with row Heights.
  2541. *
  2542. * @param {?} details
  2543. * @return {?}
  2544. */
  2545. function (details) {
  2546. var rows = details.rows, rowHeight = details.rowHeight, detailRowHeight = details.detailRowHeight, externalVirtual = details.externalVirtual, rowCount = details.rowCount, rowIndexes = details.rowIndexes, rowExpansions = details.rowExpansions;
  2547. /** @type {?} */
  2548. var isFn = typeof rowHeight === 'function';
  2549. /** @type {?} */
  2550. var isDetailFn = typeof detailRowHeight === 'function';
  2551. if (!isFn && isNaN(rowHeight)) {
  2552. throw new Error("Row Height cache initialization failed. Please ensure that 'rowHeight' is a\n valid number or function value: (" + rowHeight + ") when 'scrollbarV' is enabled.");
  2553. }
  2554. // Add this additional guard in case detailRowHeight is set to 'auto' as it wont work.
  2555. if (!isDetailFn && isNaN(detailRowHeight)) {
  2556. throw new Error("Row Height cache initialization failed. Please ensure that 'detailRowHeight' is a\n valid number or function value: (" + detailRowHeight + ") when 'scrollbarV' is enabled.");
  2557. }
  2558. /** @type {?} */
  2559. var n = externalVirtual ? rowCount : rows.length;
  2560. this.treeArray = new Array(n);
  2561. for (var i = 0; i < n; ++i) {
  2562. this.treeArray[i] = 0;
  2563. }
  2564. for (var i = 0; i < n; ++i) {
  2565. /** @type {?} */
  2566. var row = rows[i];
  2567. /** @type {?} */
  2568. var currentRowHeight = rowHeight;
  2569. if (isFn) {
  2570. currentRowHeight = rowHeight(row);
  2571. }
  2572. // Add the detail row height to the already expanded rows.
  2573. // This is useful for the table that goes through a filter or sort.
  2574. /** @type {?} */
  2575. var expanded = rowExpansions.has(row);
  2576. if (row && expanded) {
  2577. if (isDetailFn) {
  2578. /** @type {?} */
  2579. var index = rowIndexes.get(row);
  2580. currentRowHeight += detailRowHeight(row, index);
  2581. }
  2582. else {
  2583. currentRowHeight += detailRowHeight;
  2584. }
  2585. }
  2586. this.update(i, currentRowHeight);
  2587. }
  2588. };
  2589. /**
  2590. * Given the ScrollY position i.e. sum, provide the rowIndex
  2591. * that is present in the current view port. Below handles edge cases.
  2592. */
  2593. /**
  2594. * Given the ScrollY position i.e. sum, provide the rowIndex
  2595. * that is present in the current view port. Below handles edge cases.
  2596. * @param {?} scrollY
  2597. * @return {?}
  2598. */
  2599. RowHeightCache.prototype.getRowIndex = /**
  2600. * Given the ScrollY position i.e. sum, provide the rowIndex
  2601. * that is present in the current view port. Below handles edge cases.
  2602. * @param {?} scrollY
  2603. * @return {?}
  2604. */
  2605. function (scrollY) {
  2606. if (scrollY === 0)
  2607. return 0;
  2608. return this.calcRowIndex(scrollY);
  2609. };
  2610. /**
  2611. * When a row is expanded or rowHeight is changed, update the height. This can
  2612. * be utilized in future when Angular Data table supports dynamic row heights.
  2613. */
  2614. /**
  2615. * When a row is expanded or rowHeight is changed, update the height. This can
  2616. * be utilized in future when Angular Data table supports dynamic row heights.
  2617. * @param {?} atRowIndex
  2618. * @param {?} byRowHeight
  2619. * @return {?}
  2620. */
  2621. RowHeightCache.prototype.update = /**
  2622. * When a row is expanded or rowHeight is changed, update the height. This can
  2623. * be utilized in future when Angular Data table supports dynamic row heights.
  2624. * @param {?} atRowIndex
  2625. * @param {?} byRowHeight
  2626. * @return {?}
  2627. */
  2628. function (atRowIndex, byRowHeight) {
  2629. if (!this.treeArray.length) {
  2630. throw new Error("Update at index " + atRowIndex + " with value " + byRowHeight + " failed:\n Row Height cache not initialized.");
  2631. }
  2632. /** @type {?} */
  2633. var n = this.treeArray.length;
  2634. atRowIndex |= 0;
  2635. while (atRowIndex < n) {
  2636. this.treeArray[atRowIndex] += byRowHeight;
  2637. atRowIndex |= atRowIndex + 1;
  2638. }
  2639. };
  2640. /**
  2641. * Range Sum query from 1 to the rowIndex
  2642. */
  2643. /**
  2644. * Range Sum query from 1 to the rowIndex
  2645. * @param {?} atIndex
  2646. * @return {?}
  2647. */
  2648. RowHeightCache.prototype.query = /**
  2649. * Range Sum query from 1 to the rowIndex
  2650. * @param {?} atIndex
  2651. * @return {?}
  2652. */
  2653. function (atIndex) {
  2654. if (!this.treeArray.length) {
  2655. throw new Error("query at index " + atIndex + " failed: Fenwick tree array not initialized.");
  2656. }
  2657. /** @type {?} */
  2658. var sum = 0;
  2659. atIndex |= 0;
  2660. while (atIndex >= 0) {
  2661. sum += this.treeArray[atIndex];
  2662. atIndex = (atIndex & (atIndex + 1)) - 1;
  2663. }
  2664. return sum;
  2665. };
  2666. /**
  2667. * Find the total height between 2 row indexes
  2668. */
  2669. /**
  2670. * Find the total height between 2 row indexes
  2671. * @param {?} atIndexA
  2672. * @param {?} atIndexB
  2673. * @return {?}
  2674. */
  2675. RowHeightCache.prototype.queryBetween = /**
  2676. * Find the total height between 2 row indexes
  2677. * @param {?} atIndexA
  2678. * @param {?} atIndexB
  2679. * @return {?}
  2680. */
  2681. function (atIndexA, atIndexB) {
  2682. return this.query(atIndexB) - this.query(atIndexA - 1);
  2683. };
  2684. /**
  2685. * Given the ScrollY position i.e. sum, provide the rowIndex
  2686. * that is present in the current view port.
  2687. */
  2688. /**
  2689. * Given the ScrollY position i.e. sum, provide the rowIndex
  2690. * that is present in the current view port.
  2691. * @private
  2692. * @param {?} sum
  2693. * @return {?}
  2694. */
  2695. RowHeightCache.prototype.calcRowIndex = /**
  2696. * Given the ScrollY position i.e. sum, provide the rowIndex
  2697. * that is present in the current view port.
  2698. * @private
  2699. * @param {?} sum
  2700. * @return {?}
  2701. */
  2702. function (sum) {
  2703. if (!this.treeArray.length)
  2704. return 0;
  2705. /** @type {?} */
  2706. var pos = -1;
  2707. /** @type {?} */
  2708. var dataLength = this.treeArray.length;
  2709. // Get the highest bit for the block size.
  2710. /** @type {?} */
  2711. var highestBit = Math.pow(2, dataLength.toString(2).length - 1);
  2712. for (var blockSize = highestBit; blockSize !== 0; blockSize >>= 1) {
  2713. /** @type {?} */
  2714. var nextPos = pos + blockSize;
  2715. if (nextPos < dataLength && sum >= this.treeArray[nextPos]) {
  2716. sum -= this.treeArray[nextPos];
  2717. pos = nextPos;
  2718. }
  2719. }
  2720. return pos + 1;
  2721. };
  2722. return RowHeightCache;
  2723. }());
  2724. if (false) {
  2725. /**
  2726. * Tree Array stores the cumulative information of the row heights to perform efficient
  2727. * range queries and updates. Currently the tree is initialized to the base row
  2728. * height instead of the detail row height.
  2729. * @type {?}
  2730. * @private
  2731. */
  2732. RowHeightCache.prototype.treeArray;
  2733. }
  2734. /**
  2735. * @fileoverview added by tsickle
  2736. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  2737. */
  2738. /** @type {?} */
  2739. var cache = {};
  2740. /** @type {?} */
  2741. var testStyle = typeof document !== 'undefined' ? document.createElement('div').style : undefined;
  2742. // Get Prefix
  2743. // http://davidwalsh.name/vendor-prefix
  2744. var ɵ0 = /**
  2745. * @return {?}
  2746. */
  2747. function () {
  2748. /** @type {?} */
  2749. var styles = typeof window !== 'undefined' ? window.getComputedStyle(document.documentElement, '') : undefined;
  2750. /** @type {?} */
  2751. var match = typeof styles !== 'undefined'
  2752. ? Array.prototype.slice
  2753. .call(styles)
  2754. .join('')
  2755. .match(/-(moz|webkit|ms)-/)
  2756. : null;
  2757. /** @type {?} */
  2758. var pre = match !== null ? match[1] : undefined;
  2759. // tslint:disable-next-line: tsr-detect-non-literal-regexp
  2760. /** @type {?} */
  2761. var dom = typeof pre !== 'undefined' ? 'WebKit|Moz|MS|O'.match(new RegExp('(' + pre + ')', 'i'))[1] : undefined;
  2762. return dom
  2763. ? {
  2764. dom: dom,
  2765. lowercase: pre,
  2766. css: "-" + pre + "-",
  2767. js: pre[0].toUpperCase() + pre.substr(1)
  2768. }
  2769. : undefined;
  2770. };
  2771. /** @type {?} */
  2772. var prefix = ((ɵ0))();
  2773. /**
  2774. * @param {?} property
  2775. * @return {?}
  2776. */
  2777. function getVendorPrefixedName(property) {
  2778. /** @type {?} */
  2779. var name = camelCase(property);
  2780. if (!cache[name]) {
  2781. if (prefix !== undefined && testStyle[prefix.css + property] !== undefined) {
  2782. cache[name] = prefix.css + property;
  2783. }
  2784. else if (testStyle[property] !== undefined) {
  2785. cache[name] = property;
  2786. }
  2787. }
  2788. return cache[name];
  2789. }
  2790. /**
  2791. * @fileoverview added by tsickle
  2792. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  2793. */
  2794. // browser detection and prefixing tools
  2795. /** @type {?} */
  2796. var transform = typeof window !== 'undefined' ? getVendorPrefixedName('transform') : undefined;
  2797. /** @type {?} */
  2798. var backfaceVisibility = typeof window !== 'undefined' ? getVendorPrefixedName('backfaceVisibility') : undefined;
  2799. /** @type {?} */
  2800. var hasCSSTransforms = typeof window !== 'undefined' ? !!getVendorPrefixedName('transform') : undefined;
  2801. /** @type {?} */
  2802. var hasCSS3DTransforms = typeof window !== 'undefined' ? !!getVendorPrefixedName('perspective') : undefined;
  2803. /** @type {?} */
  2804. var ua = typeof window !== 'undefined' ? window.navigator.userAgent : 'Chrome';
  2805. /** @type {?} */
  2806. var isSafari = /Safari\//.test(ua) && !/Chrome\//.test(ua);
  2807. /**
  2808. * @param {?} styles
  2809. * @param {?} x
  2810. * @param {?} y
  2811. * @return {?}
  2812. */
  2813. function translateXY(styles, x, y) {
  2814. if (typeof transform !== 'undefined' && hasCSSTransforms) {
  2815. if (!isSafari && hasCSS3DTransforms) {
  2816. styles[transform] = "translate3d(" + x + "px, " + y + "px, 0)";
  2817. styles[backfaceVisibility] = 'hidden';
  2818. }
  2819. else {
  2820. styles[camelCase(transform)] = "translate(" + x + "px, " + y + "px)";
  2821. }
  2822. }
  2823. else {
  2824. styles.top = y + "px";
  2825. styles.left = x + "px";
  2826. }
  2827. }
  2828. /**
  2829. * @fileoverview added by tsickle
  2830. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  2831. */
  2832. var DataTableBodyComponent = /** @class */ (function () {
  2833. /**
  2834. * Creates an instance of DataTableBodyComponent.
  2835. */
  2836. function DataTableBodyComponent(cd) {
  2837. var _this = this;
  2838. this.cd = cd;
  2839. this.selected = [];
  2840. this.scroll = new EventEmitter();
  2841. this.page = new EventEmitter();
  2842. this.activate = new EventEmitter();
  2843. this.select = new EventEmitter();
  2844. this.detailToggle = new EventEmitter();
  2845. this.rowContextmenu = new EventEmitter(false);
  2846. this.treeAction = new EventEmitter();
  2847. this.rowHeightsCache = new RowHeightCache();
  2848. this.temp = [];
  2849. this.offsetY = 0;
  2850. this.indexes = {};
  2851. this.rowIndexes = new Map();
  2852. this.rowExpansions = [];
  2853. /**
  2854. * Get the height of the detail row.
  2855. */
  2856. this.getDetailRowHeight = (/**
  2857. * @param {?=} row
  2858. * @param {?=} index
  2859. * @return {?}
  2860. */
  2861. function (row, index) {
  2862. if (!_this.rowDetail) {
  2863. return 0;
  2864. }
  2865. /** @type {?} */
  2866. var rowHeight = _this.rowDetail.rowHeight;
  2867. return typeof rowHeight === 'function' ? rowHeight(row, index) : ((/** @type {?} */ (rowHeight)));
  2868. });
  2869. // declare fn here so we can get access to the `this` property
  2870. this.rowTrackingFn = (/**
  2871. * @param {?} index
  2872. * @param {?} row
  2873. * @return {?}
  2874. */
  2875. function (index, row) {
  2876. /** @type {?} */
  2877. var idx = _this.getRowIndex(row);
  2878. if (_this.trackByProp) {
  2879. return row[_this.trackByProp];
  2880. }
  2881. else {
  2882. return idx;
  2883. }
  2884. });
  2885. }
  2886. Object.defineProperty(DataTableBodyComponent.prototype, "pageSize", {
  2887. get: /**
  2888. * @return {?}
  2889. */
  2890. function () {
  2891. return this._pageSize;
  2892. },
  2893. set: /**
  2894. * @param {?} val
  2895. * @return {?}
  2896. */
  2897. function (val) {
  2898. this._pageSize = val;
  2899. this.recalcLayout();
  2900. },
  2901. enumerable: true,
  2902. configurable: true
  2903. });
  2904. Object.defineProperty(DataTableBodyComponent.prototype, "rows", {
  2905. get: /**
  2906. * @return {?}
  2907. */
  2908. function () {
  2909. return this._rows;
  2910. },
  2911. set: /**
  2912. * @param {?} val
  2913. * @return {?}
  2914. */
  2915. function (val) {
  2916. this._rows = val;
  2917. this.recalcLayout();
  2918. },
  2919. enumerable: true,
  2920. configurable: true
  2921. });
  2922. Object.defineProperty(DataTableBodyComponent.prototype, "columns", {
  2923. get: /**
  2924. * @return {?}
  2925. */
  2926. function () {
  2927. return this._columns;
  2928. },
  2929. set: /**
  2930. * @param {?} val
  2931. * @return {?}
  2932. */
  2933. function (val) {
  2934. this._columns = val;
  2935. /** @type {?} */
  2936. var colsByPin = columnsByPin(val);
  2937. this.columnGroupWidths = columnGroupWidths(colsByPin, val);
  2938. },
  2939. enumerable: true,
  2940. configurable: true
  2941. });
  2942. Object.defineProperty(DataTableBodyComponent.prototype, "offset", {
  2943. get: /**
  2944. * @return {?}
  2945. */
  2946. function () {
  2947. return this._offset;
  2948. },
  2949. set: /**
  2950. * @param {?} val
  2951. * @return {?}
  2952. */
  2953. function (val) {
  2954. this._offset = val;
  2955. if (!this.scrollbarV || (this.scrollbarV && !this.virtualization))
  2956. this.recalcLayout();
  2957. },
  2958. enumerable: true,
  2959. configurable: true
  2960. });
  2961. Object.defineProperty(DataTableBodyComponent.prototype, "rowCount", {
  2962. get: /**
  2963. * @return {?}
  2964. */
  2965. function () {
  2966. return this._rowCount;
  2967. },
  2968. set: /**
  2969. * @param {?} val
  2970. * @return {?}
  2971. */
  2972. function (val) {
  2973. this._rowCount = val;
  2974. this.recalcLayout();
  2975. },
  2976. enumerable: true,
  2977. configurable: true
  2978. });
  2979. Object.defineProperty(DataTableBodyComponent.prototype, "bodyWidth", {
  2980. get: /**
  2981. * @return {?}
  2982. */
  2983. function () {
  2984. if (this.scrollbarH) {
  2985. return this.innerWidth + 'px';
  2986. }
  2987. else {
  2988. return '100%';
  2989. }
  2990. },
  2991. enumerable: true,
  2992. configurable: true
  2993. });
  2994. Object.defineProperty(DataTableBodyComponent.prototype, "bodyHeight", {
  2995. get: /**
  2996. * @return {?}
  2997. */
  2998. function () {
  2999. return this._bodyHeight;
  3000. },
  3001. set: /**
  3002. * @param {?} val
  3003. * @return {?}
  3004. */
  3005. function (val) {
  3006. if (this.scrollbarV) {
  3007. this._bodyHeight = val + 'px';
  3008. }
  3009. else {
  3010. this._bodyHeight = 'auto';
  3011. }
  3012. this.recalcLayout();
  3013. },
  3014. enumerable: true,
  3015. configurable: true
  3016. });
  3017. Object.defineProperty(DataTableBodyComponent.prototype, "selectEnabled", {
  3018. /**
  3019. * Returns if selection is enabled.
  3020. */
  3021. get: /**
  3022. * Returns if selection is enabled.
  3023. * @return {?}
  3024. */
  3025. function () {
  3026. return !!this.selectionType;
  3027. },
  3028. enumerable: true,
  3029. configurable: true
  3030. });
  3031. Object.defineProperty(DataTableBodyComponent.prototype, "scrollHeight", {
  3032. /**
  3033. * Property that would calculate the height of scroll bar
  3034. * based on the row heights cache for virtual scroll and virtualization. Other scenarios
  3035. * calculate scroll height automatically (as height will be undefined).
  3036. */
  3037. get: /**
  3038. * Property that would calculate the height of scroll bar
  3039. * based on the row heights cache for virtual scroll and virtualization. Other scenarios
  3040. * calculate scroll height automatically (as height will be undefined).
  3041. * @return {?}
  3042. */
  3043. function () {
  3044. if (this.scrollbarV && this.virtualization && this.rowCount) {
  3045. return this.rowHeightsCache.query(this.rowCount - 1);
  3046. }
  3047. // avoid TS7030: Not all code paths return a value.
  3048. return undefined;
  3049. },
  3050. enumerable: true,
  3051. configurable: true
  3052. });
  3053. /**
  3054. * Called after the constructor, initializing input properties
  3055. */
  3056. /**
  3057. * Called after the constructor, initializing input properties
  3058. * @return {?}
  3059. */
  3060. DataTableBodyComponent.prototype.ngOnInit = /**
  3061. * Called after the constructor, initializing input properties
  3062. * @return {?}
  3063. */
  3064. function () {
  3065. var _this = this;
  3066. if (this.rowDetail) {
  3067. this.listener = this.rowDetail.toggle.subscribe((/**
  3068. * @param {?} __0
  3069. * @return {?}
  3070. */
  3071. function (_a) {
  3072. var type = _a.type, value = _a.value;
  3073. if (type === 'row') {
  3074. _this.toggleRowExpansion(value);
  3075. }
  3076. if (type === 'all') {
  3077. _this.toggleAllRows(value);
  3078. }
  3079. // Refresh rows after toggle
  3080. // Fixes #883
  3081. _this.updateIndexes();
  3082. _this.updateRows();
  3083. _this.cd.markForCheck();
  3084. }));
  3085. }
  3086. if (this.groupHeader) {
  3087. this.listener = this.groupHeader.toggle.subscribe((/**
  3088. * @param {?} __0
  3089. * @return {?}
  3090. */
  3091. function (_a) {
  3092. var type = _a.type, value = _a.value;
  3093. if (type === 'group') {
  3094. _this.toggleRowExpansion(value);
  3095. }
  3096. if (type === 'all') {
  3097. _this.toggleAllRows(value);
  3098. }
  3099. // Refresh rows after toggle
  3100. // Fixes #883
  3101. _this.updateIndexes();
  3102. _this.updateRows();
  3103. _this.cd.markForCheck();
  3104. }));
  3105. }
  3106. };
  3107. /**
  3108. * Called once, before the instance is destroyed.
  3109. */
  3110. /**
  3111. * Called once, before the instance is destroyed.
  3112. * @return {?}
  3113. */
  3114. DataTableBodyComponent.prototype.ngOnDestroy = /**
  3115. * Called once, before the instance is destroyed.
  3116. * @return {?}
  3117. */
  3118. function () {
  3119. if (this.rowDetail || this.groupHeader) {
  3120. this.listener.unsubscribe();
  3121. }
  3122. };
  3123. /**
  3124. * Updates the Y offset given a new offset.
  3125. */
  3126. /**
  3127. * Updates the Y offset given a new offset.
  3128. * @param {?=} offset
  3129. * @return {?}
  3130. */
  3131. DataTableBodyComponent.prototype.updateOffsetY = /**
  3132. * Updates the Y offset given a new offset.
  3133. * @param {?=} offset
  3134. * @return {?}
  3135. */
  3136. function (offset) {
  3137. // scroller is missing on empty table
  3138. if (!this.scroller) {
  3139. return;
  3140. }
  3141. if (this.scrollbarV && this.virtualization && offset) {
  3142. // First get the row Index that we need to move to.
  3143. /** @type {?} */
  3144. var rowIndex = this.pageSize * offset;
  3145. offset = this.rowHeightsCache.query(rowIndex - 1);
  3146. }
  3147. else if (this.scrollbarV && !this.virtualization) {
  3148. offset = 0;
  3149. }
  3150. this.scroller.setOffset(offset || 0);
  3151. };
  3152. /**
  3153. * Body was scrolled, this is mainly useful for
  3154. * when a user is server-side pagination via virtual scroll.
  3155. */
  3156. /**
  3157. * Body was scrolled, this is mainly useful for
  3158. * when a user is server-side pagination via virtual scroll.
  3159. * @param {?} event
  3160. * @return {?}
  3161. */
  3162. DataTableBodyComponent.prototype.onBodyScroll = /**
  3163. * Body was scrolled, this is mainly useful for
  3164. * when a user is server-side pagination via virtual scroll.
  3165. * @param {?} event
  3166. * @return {?}
  3167. */
  3168. function (event) {
  3169. /** @type {?} */
  3170. var scrollYPos = event.scrollYPos;
  3171. /** @type {?} */
  3172. var scrollXPos = event.scrollXPos;
  3173. // if scroll change, trigger update
  3174. // this is mainly used for header cell positions
  3175. if (this.offsetY !== scrollYPos || this.offsetX !== scrollXPos) {
  3176. this.scroll.emit({
  3177. offsetY: scrollYPos,
  3178. offsetX: scrollXPos
  3179. });
  3180. }
  3181. this.offsetY = scrollYPos;
  3182. this.offsetX = scrollXPos;
  3183. this.updateIndexes();
  3184. this.updatePage(event.direction);
  3185. this.updateRows();
  3186. };
  3187. /**
  3188. * Updates the page given a direction.
  3189. */
  3190. /**
  3191. * Updates the page given a direction.
  3192. * @param {?} direction
  3193. * @return {?}
  3194. */
  3195. DataTableBodyComponent.prototype.updatePage = /**
  3196. * Updates the page given a direction.
  3197. * @param {?} direction
  3198. * @return {?}
  3199. */
  3200. function (direction) {
  3201. /** @type {?} */
  3202. var offset = this.indexes.first / this.pageSize;
  3203. if (direction === 'up') {
  3204. offset = Math.ceil(offset);
  3205. }
  3206. else if (direction === 'down') {
  3207. offset = Math.floor(offset);
  3208. }
  3209. if (direction !== undefined && !isNaN(offset)) {
  3210. this.page.emit({ offset: offset });
  3211. }
  3212. };
  3213. /**
  3214. * Updates the rows in the view port
  3215. */
  3216. /**
  3217. * Updates the rows in the view port
  3218. * @return {?}
  3219. */
  3220. DataTableBodyComponent.prototype.updateRows = /**
  3221. * Updates the rows in the view port
  3222. * @return {?}
  3223. */
  3224. function () {
  3225. var _a = this.indexes, first = _a.first, last = _a.last;
  3226. /** @type {?} */
  3227. var rowIndex = first;
  3228. /** @type {?} */
  3229. var idx = 0;
  3230. /** @type {?} */
  3231. var temp = [];
  3232. this.rowIndexes.clear();
  3233. // if grouprowsby has been specified treat row paging
  3234. // parameters as group paging parameters ie if limit 10 has been
  3235. // specified treat it as 10 groups rather than 10 rows
  3236. if (this.groupedRows) {
  3237. /** @type {?} */
  3238. var maxRowsPerGroup = 3;
  3239. // if there is only one group set the maximum number of
  3240. // rows per group the same as the total number of rows
  3241. if (this.groupedRows.length === 1) {
  3242. maxRowsPerGroup = this.groupedRows[0].value.length;
  3243. }
  3244. while (rowIndex < last && rowIndex < this.groupedRows.length) {
  3245. // Add the groups into this page
  3246. /** @type {?} */
  3247. var group = this.groupedRows[rowIndex];
  3248. temp[idx] = group;
  3249. idx++;
  3250. // Group index in this context
  3251. rowIndex++;
  3252. }
  3253. }
  3254. else {
  3255. while (rowIndex < last && rowIndex < this.rowCount) {
  3256. /** @type {?} */
  3257. var row = this.rows[rowIndex];
  3258. if (row) {
  3259. this.rowIndexes.set(row, rowIndex);
  3260. temp[idx] = row;
  3261. }
  3262. idx++;
  3263. rowIndex++;
  3264. }
  3265. }
  3266. this.temp = temp;
  3267. };
  3268. /**
  3269. * Get the row height
  3270. */
  3271. /**
  3272. * Get the row height
  3273. * @param {?} row
  3274. * @return {?}
  3275. */
  3276. DataTableBodyComponent.prototype.getRowHeight = /**
  3277. * Get the row height
  3278. * @param {?} row
  3279. * @return {?}
  3280. */
  3281. function (row) {
  3282. // if its a function return it
  3283. if (typeof this.rowHeight === 'function') {
  3284. return this.rowHeight(row);
  3285. }
  3286. return (/** @type {?} */ (this.rowHeight));
  3287. };
  3288. /**
  3289. * @param group the group with all rows
  3290. */
  3291. /**
  3292. * @param {?} group the group with all rows
  3293. * @return {?}
  3294. */
  3295. DataTableBodyComponent.prototype.getGroupHeight = /**
  3296. * @param {?} group the group with all rows
  3297. * @return {?}
  3298. */
  3299. function (group) {
  3300. /** @type {?} */
  3301. var rowHeight = 0;
  3302. if (group.value) {
  3303. for (var index = 0; index < group.value.length; index++) {
  3304. rowHeight += this.getRowAndDetailHeight(group.value[index]);
  3305. }
  3306. }
  3307. return rowHeight;
  3308. };
  3309. /**
  3310. * Calculate row height based on the expanded state of the row.
  3311. */
  3312. /**
  3313. * Calculate row height based on the expanded state of the row.
  3314. * @param {?} row
  3315. * @return {?}
  3316. */
  3317. DataTableBodyComponent.prototype.getRowAndDetailHeight = /**
  3318. * Calculate row height based on the expanded state of the row.
  3319. * @param {?} row
  3320. * @return {?}
  3321. */
  3322. function (row) {
  3323. /** @type {?} */
  3324. var rowHeight = this.getRowHeight(row);
  3325. /** @type {?} */
  3326. var expanded = this.getRowExpanded(row);
  3327. // Adding detail row height if its expanded.
  3328. if (expanded) {
  3329. rowHeight += this.getDetailRowHeight(row);
  3330. }
  3331. return rowHeight;
  3332. };
  3333. /**
  3334. * Calculates the styles for the row so that the rows can be moved in 2D space
  3335. * during virtual scroll inside the DOM. In the below case the Y position is
  3336. * manipulated. As an example, if the height of row 0 is 30 px and row 1 is
  3337. * 100 px then following styles are generated:
  3338. *
  3339. * transform: translate3d(0px, 0px, 0px); -> row0
  3340. * transform: translate3d(0px, 30px, 0px); -> row1
  3341. * transform: translate3d(0px, 130px, 0px); -> row2
  3342. *
  3343. * Row heights have to be calculated based on the row heights cache as we wont
  3344. * be able to determine which row is of what height before hand. In the above
  3345. * case the positionY of the translate3d for row2 would be the sum of all the
  3346. * heights of the rows before it (i.e. row0 and row1).
  3347. *
  3348. * @param rows the row that needs to be placed in the 2D space.
  3349. * @returns the CSS3 style to be applied
  3350. *
  3351. * @memberOf DataTableBodyComponent
  3352. */
  3353. /**
  3354. * Calculates the styles for the row so that the rows can be moved in 2D space
  3355. * during virtual scroll inside the DOM. In the below case the Y position is
  3356. * manipulated. As an example, if the height of row 0 is 30 px and row 1 is
  3357. * 100 px then following styles are generated:
  3358. *
  3359. * transform: translate3d(0px, 0px, 0px); -> row0
  3360. * transform: translate3d(0px, 30px, 0px); -> row1
  3361. * transform: translate3d(0px, 130px, 0px); -> row2
  3362. *
  3363. * Row heights have to be calculated based on the row heights cache as we wont
  3364. * be able to determine which row is of what height before hand. In the above
  3365. * case the positionY of the translate3d for row2 would be the sum of all the
  3366. * heights of the rows before it (i.e. row0 and row1).
  3367. *
  3368. * \@memberOf DataTableBodyComponent
  3369. * @param {?} rows the row that needs to be placed in the 2D space.
  3370. * @return {?} the CSS3 style to be applied
  3371. *
  3372. */
  3373. DataTableBodyComponent.prototype.getRowsStyles = /**
  3374. * Calculates the styles for the row so that the rows can be moved in 2D space
  3375. * during virtual scroll inside the DOM. In the below case the Y position is
  3376. * manipulated. As an example, if the height of row 0 is 30 px and row 1 is
  3377. * 100 px then following styles are generated:
  3378. *
  3379. * transform: translate3d(0px, 0px, 0px); -> row0
  3380. * transform: translate3d(0px, 30px, 0px); -> row1
  3381. * transform: translate3d(0px, 130px, 0px); -> row2
  3382. *
  3383. * Row heights have to be calculated based on the row heights cache as we wont
  3384. * be able to determine which row is of what height before hand. In the above
  3385. * case the positionY of the translate3d for row2 would be the sum of all the
  3386. * heights of the rows before it (i.e. row0 and row1).
  3387. *
  3388. * \@memberOf DataTableBodyComponent
  3389. * @param {?} rows the row that needs to be placed in the 2D space.
  3390. * @return {?} the CSS3 style to be applied
  3391. *
  3392. */
  3393. function (rows) {
  3394. /** @type {?} */
  3395. var styles = {};
  3396. // only add styles for the group if there is a group
  3397. if (this.groupedRows) {
  3398. styles.width = this.columnGroupWidths.total;
  3399. }
  3400. if (this.scrollbarV && this.virtualization) {
  3401. /** @type {?} */
  3402. var idx = 0;
  3403. if (this.groupedRows) {
  3404. // Get the latest row rowindex in a group
  3405. /** @type {?} */
  3406. var row = rows[rows.length - 1];
  3407. idx = row ? this.getRowIndex(row) : 0;
  3408. }
  3409. else {
  3410. idx = this.getRowIndex(rows);
  3411. }
  3412. // const pos = idx * rowHeight;
  3413. // The position of this row would be the sum of all row heights
  3414. // until the previous row position.
  3415. /** @type {?} */
  3416. var pos = this.rowHeightsCache.query(idx - 1);
  3417. translateXY(styles, 0, pos);
  3418. }
  3419. return styles;
  3420. };
  3421. /**
  3422. * Calculate bottom summary row offset for scrollbar mode.
  3423. * For more information about cache and offset calculation
  3424. * see description for `getRowsStyles` method
  3425. *
  3426. * @returns the CSS3 style to be applied
  3427. *
  3428. * @memberOf DataTableBodyComponent
  3429. */
  3430. /**
  3431. * Calculate bottom summary row offset for scrollbar mode.
  3432. * For more information about cache and offset calculation
  3433. * see description for `getRowsStyles` method
  3434. *
  3435. * \@memberOf DataTableBodyComponent
  3436. * @return {?} the CSS3 style to be applied
  3437. *
  3438. */
  3439. DataTableBodyComponent.prototype.getBottomSummaryRowStyles = /**
  3440. * Calculate bottom summary row offset for scrollbar mode.
  3441. * For more information about cache and offset calculation
  3442. * see description for `getRowsStyles` method
  3443. *
  3444. * \@memberOf DataTableBodyComponent
  3445. * @return {?} the CSS3 style to be applied
  3446. *
  3447. */
  3448. function () {
  3449. if (!this.scrollbarV || !this.rows || !this.rows.length) {
  3450. return null;
  3451. }
  3452. /** @type {?} */
  3453. var styles = { position: 'absolute' };
  3454. /** @type {?} */
  3455. var pos = this.rowHeightsCache.query(this.rows.length - 1);
  3456. translateXY(styles, 0, pos);
  3457. return styles;
  3458. };
  3459. /**
  3460. * Hides the loading indicator
  3461. */
  3462. /**
  3463. * Hides the loading indicator
  3464. * @return {?}
  3465. */
  3466. DataTableBodyComponent.prototype.hideIndicator = /**
  3467. * Hides the loading indicator
  3468. * @return {?}
  3469. */
  3470. function () {
  3471. var _this = this;
  3472. setTimeout((/**
  3473. * @return {?}
  3474. */
  3475. function () { return (_this.loadingIndicator = false); }), 500);
  3476. };
  3477. /**
  3478. * Updates the index of the rows in the viewport
  3479. */
  3480. /**
  3481. * Updates the index of the rows in the viewport
  3482. * @return {?}
  3483. */
  3484. DataTableBodyComponent.prototype.updateIndexes = /**
  3485. * Updates the index of the rows in the viewport
  3486. * @return {?}
  3487. */
  3488. function () {
  3489. /** @type {?} */
  3490. var first = 0;
  3491. /** @type {?} */
  3492. var last = 0;
  3493. if (this.scrollbarV) {
  3494. if (this.virtualization) {
  3495. // Calculation of the first and last indexes will be based on where the
  3496. // scrollY position would be at. The last index would be the one
  3497. // that shows up inside the view port the last.
  3498. /** @type {?} */
  3499. var height = parseInt(this.bodyHeight, 0);
  3500. first = this.rowHeightsCache.getRowIndex(this.offsetY);
  3501. last = this.rowHeightsCache.getRowIndex(height + this.offsetY) + 1;
  3502. }
  3503. else {
  3504. // If virtual rows are not needed
  3505. // We render all in one go
  3506. first = 0;
  3507. last = this.rowCount;
  3508. }
  3509. }
  3510. else {
  3511. // The server is handling paging and will pass an array that begins with the
  3512. // element at a specified offset. first should always be 0 with external paging.
  3513. if (!this.externalPaging) {
  3514. first = Math.max(this.offset * this.pageSize, 0);
  3515. }
  3516. last = Math.min(first + this.pageSize, this.rowCount);
  3517. }
  3518. this.indexes = { first: first, last: last };
  3519. };
  3520. /**
  3521. * Refreshes the full Row Height cache. Should be used
  3522. * when the entire row array state has changed.
  3523. */
  3524. /**
  3525. * Refreshes the full Row Height cache. Should be used
  3526. * when the entire row array state has changed.
  3527. * @return {?}
  3528. */
  3529. DataTableBodyComponent.prototype.refreshRowHeightCache = /**
  3530. * Refreshes the full Row Height cache. Should be used
  3531. * when the entire row array state has changed.
  3532. * @return {?}
  3533. */
  3534. function () {
  3535. var e_1, _a;
  3536. if (!this.scrollbarV || (this.scrollbarV && !this.virtualization)) {
  3537. return;
  3538. }
  3539. // clear the previous row height cache if already present.
  3540. // this is useful during sorts, filters where the state of the
  3541. // rows array is changed.
  3542. this.rowHeightsCache.clearCache();
  3543. // Initialize the tree only if there are rows inside the tree.
  3544. if (this.rows && this.rows.length) {
  3545. /** @type {?} */
  3546. var rowExpansions = new Set();
  3547. try {
  3548. for (var _b = __values(this.rows), _c = _b.next(); !_c.done; _c = _b.next()) {
  3549. var row = _c.value;
  3550. if (this.getRowExpanded(row)) {
  3551. rowExpansions.add(row);
  3552. }
  3553. }
  3554. }
  3555. catch (e_1_1) { e_1 = { error: e_1_1 }; }
  3556. finally {
  3557. try {
  3558. if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
  3559. }
  3560. finally { if (e_1) throw e_1.error; }
  3561. }
  3562. this.rowHeightsCache.initCache({
  3563. rows: this.rows,
  3564. rowHeight: this.rowHeight,
  3565. detailRowHeight: this.getDetailRowHeight,
  3566. externalVirtual: this.scrollbarV && this.externalPaging,
  3567. rowCount: this.rowCount,
  3568. rowIndexes: this.rowIndexes,
  3569. rowExpansions: rowExpansions
  3570. });
  3571. }
  3572. };
  3573. /**
  3574. * Gets the index for the view port
  3575. */
  3576. /**
  3577. * Gets the index for the view port
  3578. * @return {?}
  3579. */
  3580. DataTableBodyComponent.prototype.getAdjustedViewPortIndex = /**
  3581. * Gets the index for the view port
  3582. * @return {?}
  3583. */
  3584. function () {
  3585. // Capture the row index of the first row that is visible on the viewport.
  3586. // If the scroll bar is just below the row which is highlighted then make that as the
  3587. // first index.
  3588. /** @type {?} */
  3589. var viewPortFirstRowIndex = this.indexes.first;
  3590. if (this.scrollbarV && this.virtualization) {
  3591. /** @type {?} */
  3592. var offsetScroll = this.rowHeightsCache.query(viewPortFirstRowIndex - 1);
  3593. return offsetScroll <= this.offsetY ? viewPortFirstRowIndex - 1 : viewPortFirstRowIndex;
  3594. }
  3595. return viewPortFirstRowIndex;
  3596. };
  3597. /**
  3598. * Toggle the Expansion of the row i.e. if the row is expanded then it will
  3599. * collapse and vice versa. Note that the expanded status is stored as
  3600. * a part of the row object itself as we have to preserve the expanded row
  3601. * status in case of sorting and filtering of the row set.
  3602. */
  3603. /**
  3604. * Toggle the Expansion of the row i.e. if the row is expanded then it will
  3605. * collapse and vice versa. Note that the expanded status is stored as
  3606. * a part of the row object itself as we have to preserve the expanded row
  3607. * status in case of sorting and filtering of the row set.
  3608. * @param {?} row
  3609. * @return {?}
  3610. */
  3611. DataTableBodyComponent.prototype.toggleRowExpansion = /**
  3612. * Toggle the Expansion of the row i.e. if the row is expanded then it will
  3613. * collapse and vice versa. Note that the expanded status is stored as
  3614. * a part of the row object itself as we have to preserve the expanded row
  3615. * status in case of sorting and filtering of the row set.
  3616. * @param {?} row
  3617. * @return {?}
  3618. */
  3619. function (row) {
  3620. // Capture the row index of the first row that is visible on the viewport.
  3621. /** @type {?} */
  3622. var viewPortFirstRowIndex = this.getAdjustedViewPortIndex();
  3623. /** @type {?} */
  3624. var rowExpandedIdx = this.getRowExpandedIdx(row, this.rowExpansions);
  3625. /** @type {?} */
  3626. var expanded = rowExpandedIdx > -1;
  3627. // If the detailRowHeight is auto --> only in case of non-virtualized scroll
  3628. if (this.scrollbarV && this.virtualization) {
  3629. /** @type {?} */
  3630. var detailRowHeight = this.getDetailRowHeight(row) * (expanded ? -1 : 1);
  3631. // const idx = this.rowIndexes.get(row) || 0;
  3632. /** @type {?} */
  3633. var idx = this.getRowIndex(row);
  3634. this.rowHeightsCache.update(idx, detailRowHeight);
  3635. }
  3636. // Update the toggled row and update thive nevere heights in the cache.
  3637. if (expanded) {
  3638. this.rowExpansions.splice(rowExpandedIdx, 1);
  3639. }
  3640. else {
  3641. this.rowExpansions.push(row);
  3642. }
  3643. this.detailToggle.emit({
  3644. rows: [row],
  3645. currentIndex: viewPortFirstRowIndex
  3646. });
  3647. };
  3648. /**
  3649. * Expand/Collapse all the rows no matter what their state is.
  3650. */
  3651. /**
  3652. * Expand/Collapse all the rows no matter what their state is.
  3653. * @param {?} expanded
  3654. * @return {?}
  3655. */
  3656. DataTableBodyComponent.prototype.toggleAllRows = /**
  3657. * Expand/Collapse all the rows no matter what their state is.
  3658. * @param {?} expanded
  3659. * @return {?}
  3660. */
  3661. function (expanded) {
  3662. var e_2, _a;
  3663. // clear prev expansions
  3664. this.rowExpansions = [];
  3665. // Capture the row index of the first row that is visible on the viewport.
  3666. /** @type {?} */
  3667. var viewPortFirstRowIndex = this.getAdjustedViewPortIndex();
  3668. if (expanded) {
  3669. try {
  3670. for (var _b = __values(this.rows), _c = _b.next(); !_c.done; _c = _b.next()) {
  3671. var row = _c.value;
  3672. this.rowExpansions.push(row);
  3673. }
  3674. }
  3675. catch (e_2_1) { e_2 = { error: e_2_1 }; }
  3676. finally {
  3677. try {
  3678. if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
  3679. }
  3680. finally { if (e_2) throw e_2.error; }
  3681. }
  3682. }
  3683. if (this.scrollbarV) {
  3684. // Refresh the full row heights cache since every row was affected.
  3685. this.recalcLayout();
  3686. }
  3687. // Emit all rows that have been expanded.
  3688. this.detailToggle.emit({
  3689. rows: this.rows,
  3690. currentIndex: viewPortFirstRowIndex
  3691. });
  3692. };
  3693. /**
  3694. * Recalculates the table
  3695. */
  3696. /**
  3697. * Recalculates the table
  3698. * @return {?}
  3699. */
  3700. DataTableBodyComponent.prototype.recalcLayout = /**
  3701. * Recalculates the table
  3702. * @return {?}
  3703. */
  3704. function () {
  3705. this.refreshRowHeightCache();
  3706. this.updateIndexes();
  3707. this.updateRows();
  3708. };
  3709. /**
  3710. * Tracks the column
  3711. */
  3712. /**
  3713. * Tracks the column
  3714. * @param {?} index
  3715. * @param {?} column
  3716. * @return {?}
  3717. */
  3718. DataTableBodyComponent.prototype.columnTrackingFn = /**
  3719. * Tracks the column
  3720. * @param {?} index
  3721. * @param {?} column
  3722. * @return {?}
  3723. */
  3724. function (index, column) {
  3725. return column.$$id;
  3726. };
  3727. /**
  3728. * Gets the row pinning group styles
  3729. */
  3730. /**
  3731. * Gets the row pinning group styles
  3732. * @param {?} group
  3733. * @return {?}
  3734. */
  3735. DataTableBodyComponent.prototype.stylesByGroup = /**
  3736. * Gets the row pinning group styles
  3737. * @param {?} group
  3738. * @return {?}
  3739. */
  3740. function (group) {
  3741. /** @type {?} */
  3742. var widths = this.columnGroupWidths;
  3743. /** @type {?} */
  3744. var offsetX = this.offsetX;
  3745. /** @type {?} */
  3746. var styles = {
  3747. width: widths[group] + "px"
  3748. };
  3749. if (group === 'left') {
  3750. translateXY(styles, offsetX, 0);
  3751. }
  3752. else if (group === 'right') {
  3753. /** @type {?} */
  3754. var bodyWidth = parseInt(this.innerWidth + '', 0);
  3755. /** @type {?} */
  3756. var totalDiff = widths.total - bodyWidth;
  3757. /** @type {?} */
  3758. var offsetDiff = totalDiff - offsetX;
  3759. /** @type {?} */
  3760. var offset = offsetDiff * -1;
  3761. translateXY(styles, offset, 0);
  3762. }
  3763. return styles;
  3764. };
  3765. /**
  3766. * Returns if the row was expanded and set default row expansion when row expansion is empty
  3767. */
  3768. /**
  3769. * Returns if the row was expanded and set default row expansion when row expansion is empty
  3770. * @param {?} row
  3771. * @return {?}
  3772. */
  3773. DataTableBodyComponent.prototype.getRowExpanded = /**
  3774. * Returns if the row was expanded and set default row expansion when row expansion is empty
  3775. * @param {?} row
  3776. * @return {?}
  3777. */
  3778. function (row) {
  3779. var e_3, _a;
  3780. if (this.rowExpansions.length === 0 && this.groupExpansionDefault) {
  3781. try {
  3782. for (var _b = __values(this.groupedRows), _c = _b.next(); !_c.done; _c = _b.next()) {
  3783. var group = _c.value;
  3784. this.rowExpansions.push(group);
  3785. }
  3786. }
  3787. catch (e_3_1) { e_3 = { error: e_3_1 }; }
  3788. finally {
  3789. try {
  3790. if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
  3791. }
  3792. finally { if (e_3) throw e_3.error; }
  3793. }
  3794. }
  3795. return this.getRowExpandedIdx(row, this.rowExpansions) > -1;
  3796. };
  3797. /**
  3798. * @param {?} row
  3799. * @param {?} expanded
  3800. * @return {?}
  3801. */
  3802. DataTableBodyComponent.prototype.getRowExpandedIdx = /**
  3803. * @param {?} row
  3804. * @param {?} expanded
  3805. * @return {?}
  3806. */
  3807. function (row, expanded) {
  3808. var _this = this;
  3809. if (!expanded || !expanded.length)
  3810. return -1;
  3811. /** @type {?} */
  3812. var rowId = this.rowIdentity(row);
  3813. return expanded.findIndex((/**
  3814. * @param {?} r
  3815. * @return {?}
  3816. */
  3817. function (r) {
  3818. /** @type {?} */
  3819. var id = _this.rowIdentity(r);
  3820. return id === rowId;
  3821. }));
  3822. };
  3823. /**
  3824. * Gets the row index given a row
  3825. */
  3826. /**
  3827. * Gets the row index given a row
  3828. * @param {?} row
  3829. * @return {?}
  3830. */
  3831. DataTableBodyComponent.prototype.getRowIndex = /**
  3832. * Gets the row index given a row
  3833. * @param {?} row
  3834. * @return {?}
  3835. */
  3836. function (row) {
  3837. return this.rowIndexes.get(row) || 0;
  3838. };
  3839. /**
  3840. * @param {?} row
  3841. * @return {?}
  3842. */
  3843. DataTableBodyComponent.prototype.onTreeAction = /**
  3844. * @param {?} row
  3845. * @return {?}
  3846. */
  3847. function (row) {
  3848. this.treeAction.emit({ row: row });
  3849. };
  3850. DataTableBodyComponent.decorators = [
  3851. { type: Component, args: [{
  3852. selector: 'datatable-body',
  3853. template: "\n <datatable-selection\n #selector\n [selected]=\"selected\"\n [rows]=\"rows\"\n [selectCheck]=\"selectCheck\"\n [selectEnabled]=\"selectEnabled\"\n [selectionType]=\"selectionType\"\n [rowIdentity]=\"rowIdentity\"\n (select)=\"select.emit($event)\"\n (activate)=\"activate.emit($event)\"\n >\n <datatable-progress *ngIf=\"loadingIndicator\"> </datatable-progress>\n <datatable-scroller\n *ngIf=\"rows?.length\"\n [scrollbarV]=\"scrollbarV\"\n [scrollbarH]=\"scrollbarH\"\n [scrollHeight]=\"scrollHeight\"\n [scrollWidth]=\"columnGroupWidths?.total\"\n (scroll)=\"onBodyScroll($event)\"\n >\n <datatable-summary-row\n *ngIf=\"summaryRow && summaryPosition === 'top'\"\n [rowHeight]=\"summaryHeight\"\n [offsetX]=\"offsetX\"\n [innerWidth]=\"innerWidth\"\n [rows]=\"rows\"\n [columns]=\"columns\"\n >\n </datatable-summary-row>\n <datatable-row-wrapper\n [groupedRows]=\"groupedRows\"\n *ngFor=\"let group of temp; let i = index; trackBy: rowTrackingFn\"\n [innerWidth]=\"innerWidth\"\n [ngStyle]=\"getRowsStyles(group)\"\n [rowDetail]=\"rowDetail\"\n [groupHeader]=\"groupHeader\"\n [offsetX]=\"offsetX\"\n [detailRowHeight]=\"getDetailRowHeight(group[i], i)\"\n [row]=\"group\"\n [expanded]=\"getRowExpanded(group)\"\n [rowIndex]=\"getRowIndex(group[i])\"\n (rowContextmenu)=\"rowContextmenu.emit($event)\"\n >\n <datatable-body-row\n *ngIf=\"!groupedRows; else groupedRowsTemplate\"\n tabindex=\"-1\"\n [isSelected]=\"selector.getRowSelected(group)\"\n [innerWidth]=\"innerWidth\"\n [offsetX]=\"offsetX\"\n [columns]=\"columns\"\n [rowHeight]=\"getRowHeight(group)\"\n [row]=\"group\"\n [rowIndex]=\"getRowIndex(group)\"\n [expanded]=\"getRowExpanded(group)\"\n [rowClass]=\"rowClass\"\n [displayCheck]=\"displayCheck\"\n [treeStatus]=\"group.treeStatus\"\n (treeAction)=\"onTreeAction(group)\"\n (activate)=\"selector.onActivate($event, indexes.first + i)\"\n >\n </datatable-body-row>\n <ng-template #groupedRowsTemplate>\n <datatable-body-row\n *ngFor=\"let row of group.value; let i = index; trackBy: rowTrackingFn\"\n tabindex=\"-1\"\n [isSelected]=\"selector.getRowSelected(row)\"\n [innerWidth]=\"innerWidth\"\n [offsetX]=\"offsetX\"\n [columns]=\"columns\"\n [rowHeight]=\"getRowHeight(row)\"\n [row]=\"row\"\n [group]=\"group.value\"\n [rowIndex]=\"getRowIndex(row)\"\n [expanded]=\"getRowExpanded(row)\"\n [rowClass]=\"rowClass\"\n (activate)=\"selector.onActivate($event, i)\"\n >\n </datatable-body-row>\n </ng-template>\n </datatable-row-wrapper>\n <datatable-summary-row\n *ngIf=\"summaryRow && summaryPosition === 'bottom'\"\n [ngStyle]=\"getBottomSummaryRowStyles()\"\n [rowHeight]=\"summaryHeight\"\n [offsetX]=\"offsetX\"\n [innerWidth]=\"innerWidth\"\n [rows]=\"rows\"\n [columns]=\"columns\"\n >\n </datatable-summary-row>\n </datatable-scroller>\n <div class=\"empty-row\" *ngIf=\"!rows?.length && !loadingIndicator\" [innerHTML]=\"emptyMessage\"></div>\n </datatable-selection>\n ",
  3854. changeDetection: ChangeDetectionStrategy.OnPush,
  3855. host: {
  3856. class: 'datatable-body'
  3857. }
  3858. }] }
  3859. ];
  3860. /** @nocollapse */
  3861. DataTableBodyComponent.ctorParameters = function () { return [
  3862. { type: ChangeDetectorRef }
  3863. ]; };
  3864. DataTableBodyComponent.propDecorators = {
  3865. scrollbarV: [{ type: Input }],
  3866. scrollbarH: [{ type: Input }],
  3867. loadingIndicator: [{ type: Input }],
  3868. externalPaging: [{ type: Input }],
  3869. rowHeight: [{ type: Input }],
  3870. offsetX: [{ type: Input }],
  3871. emptyMessage: [{ type: Input }],
  3872. selectionType: [{ type: Input }],
  3873. selected: [{ type: Input }],
  3874. rowIdentity: [{ type: Input }],
  3875. rowDetail: [{ type: Input }],
  3876. groupHeader: [{ type: Input }],
  3877. selectCheck: [{ type: Input }],
  3878. displayCheck: [{ type: Input }],
  3879. trackByProp: [{ type: Input }],
  3880. rowClass: [{ type: Input }],
  3881. groupedRows: [{ type: Input }],
  3882. groupExpansionDefault: [{ type: Input }],
  3883. innerWidth: [{ type: Input }],
  3884. groupRowsBy: [{ type: Input }],
  3885. virtualization: [{ type: Input }],
  3886. summaryRow: [{ type: Input }],
  3887. summaryPosition: [{ type: Input }],
  3888. summaryHeight: [{ type: Input }],
  3889. pageSize: [{ type: Input }],
  3890. rows: [{ type: Input }],
  3891. columns: [{ type: Input }],
  3892. offset: [{ type: Input }],
  3893. rowCount: [{ type: Input }],
  3894. bodyWidth: [{ type: HostBinding, args: ['style.width',] }],
  3895. bodyHeight: [{ type: Input }, { type: HostBinding, args: ['style.height',] }],
  3896. scroll: [{ type: Output }],
  3897. page: [{ type: Output }],
  3898. activate: [{ type: Output }],
  3899. select: [{ type: Output }],
  3900. detailToggle: [{ type: Output }],
  3901. rowContextmenu: [{ type: Output }],
  3902. treeAction: [{ type: Output }],
  3903. scroller: [{ type: ViewChild, args: [ScrollerComponent, { static: false },] }]
  3904. };
  3905. return DataTableBodyComponent;
  3906. }());
  3907. if (false) {
  3908. /** @type {?} */
  3909. DataTableBodyComponent.prototype.scrollbarV;
  3910. /** @type {?} */
  3911. DataTableBodyComponent.prototype.scrollbarH;
  3912. /** @type {?} */
  3913. DataTableBodyComponent.prototype.loadingIndicator;
  3914. /** @type {?} */
  3915. DataTableBodyComponent.prototype.externalPaging;
  3916. /** @type {?} */
  3917. DataTableBodyComponent.prototype.rowHeight;
  3918. /** @type {?} */
  3919. DataTableBodyComponent.prototype.offsetX;
  3920. /** @type {?} */
  3921. DataTableBodyComponent.prototype.emptyMessage;
  3922. /** @type {?} */
  3923. DataTableBodyComponent.prototype.selectionType;
  3924. /** @type {?} */
  3925. DataTableBodyComponent.prototype.selected;
  3926. /** @type {?} */
  3927. DataTableBodyComponent.prototype.rowIdentity;
  3928. /** @type {?} */
  3929. DataTableBodyComponent.prototype.rowDetail;
  3930. /** @type {?} */
  3931. DataTableBodyComponent.prototype.groupHeader;
  3932. /** @type {?} */
  3933. DataTableBodyComponent.prototype.selectCheck;
  3934. /** @type {?} */
  3935. DataTableBodyComponent.prototype.displayCheck;
  3936. /** @type {?} */
  3937. DataTableBodyComponent.prototype.trackByProp;
  3938. /** @type {?} */
  3939. DataTableBodyComponent.prototype.rowClass;
  3940. /** @type {?} */
  3941. DataTableBodyComponent.prototype.groupedRows;
  3942. /** @type {?} */
  3943. DataTableBodyComponent.prototype.groupExpansionDefault;
  3944. /** @type {?} */
  3945. DataTableBodyComponent.prototype.innerWidth;
  3946. /** @type {?} */
  3947. DataTableBodyComponent.prototype.groupRowsBy;
  3948. /** @type {?} */
  3949. DataTableBodyComponent.prototype.virtualization;
  3950. /** @type {?} */
  3951. DataTableBodyComponent.prototype.summaryRow;
  3952. /** @type {?} */
  3953. DataTableBodyComponent.prototype.summaryPosition;
  3954. /** @type {?} */
  3955. DataTableBodyComponent.prototype.summaryHeight;
  3956. /** @type {?} */
  3957. DataTableBodyComponent.prototype.scroll;
  3958. /** @type {?} */
  3959. DataTableBodyComponent.prototype.page;
  3960. /** @type {?} */
  3961. DataTableBodyComponent.prototype.activate;
  3962. /** @type {?} */
  3963. DataTableBodyComponent.prototype.select;
  3964. /** @type {?} */
  3965. DataTableBodyComponent.prototype.detailToggle;
  3966. /** @type {?} */
  3967. DataTableBodyComponent.prototype.rowContextmenu;
  3968. /** @type {?} */
  3969. DataTableBodyComponent.prototype.treeAction;
  3970. /** @type {?} */
  3971. DataTableBodyComponent.prototype.scroller;
  3972. /** @type {?} */
  3973. DataTableBodyComponent.prototype.rowHeightsCache;
  3974. /** @type {?} */
  3975. DataTableBodyComponent.prototype.temp;
  3976. /** @type {?} */
  3977. DataTableBodyComponent.prototype.offsetY;
  3978. /** @type {?} */
  3979. DataTableBodyComponent.prototype.indexes;
  3980. /** @type {?} */
  3981. DataTableBodyComponent.prototype.columnGroupWidths;
  3982. /** @type {?} */
  3983. DataTableBodyComponent.prototype.columnGroupWidthsWithoutGroup;
  3984. /** @type {?} */
  3985. DataTableBodyComponent.prototype.rowTrackingFn;
  3986. /** @type {?} */
  3987. DataTableBodyComponent.prototype.listener;
  3988. /** @type {?} */
  3989. DataTableBodyComponent.prototype.rowIndexes;
  3990. /** @type {?} */
  3991. DataTableBodyComponent.prototype.rowExpansions;
  3992. /** @type {?} */
  3993. DataTableBodyComponent.prototype._rows;
  3994. /** @type {?} */
  3995. DataTableBodyComponent.prototype._bodyHeight;
  3996. /** @type {?} */
  3997. DataTableBodyComponent.prototype._columns;
  3998. /** @type {?} */
  3999. DataTableBodyComponent.prototype._rowCount;
  4000. /** @type {?} */
  4001. DataTableBodyComponent.prototype._offset;
  4002. /** @type {?} */
  4003. DataTableBodyComponent.prototype._pageSize;
  4004. /**
  4005. * Get the height of the detail row.
  4006. * @type {?}
  4007. */
  4008. DataTableBodyComponent.prototype.getDetailRowHeight;
  4009. /**
  4010. * @type {?}
  4011. * @private
  4012. */
  4013. DataTableBodyComponent.prototype.cd;
  4014. }
  4015. /**
  4016. * @fileoverview added by tsickle
  4017. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  4018. */
  4019. var DataTableHeaderComponent = /** @class */ (function () {
  4020. function DataTableHeaderComponent(cd) {
  4021. this.cd = cd;
  4022. this.sort = new EventEmitter();
  4023. this.reorder = new EventEmitter();
  4024. this.resize = new EventEmitter();
  4025. this.select = new EventEmitter();
  4026. this.columnContextmenu = new EventEmitter(false);
  4027. this._columnGroupWidths = {
  4028. total: 100
  4029. };
  4030. this._styleByGroup = {
  4031. left: {},
  4032. center: {},
  4033. right: {}
  4034. };
  4035. this.destroyed = false;
  4036. }
  4037. Object.defineProperty(DataTableHeaderComponent.prototype, "innerWidth", {
  4038. get: /**
  4039. * @return {?}
  4040. */
  4041. function () {
  4042. return this._innerWidth;
  4043. },
  4044. set: /**
  4045. * @param {?} val
  4046. * @return {?}
  4047. */
  4048. function (val) {
  4049. var _this = this;
  4050. this._innerWidth = val;
  4051. setTimeout((/**
  4052. * @return {?}
  4053. */
  4054. function () {
  4055. if (_this._columns) {
  4056. /** @type {?} */
  4057. var colByPin = columnsByPin(_this._columns);
  4058. _this._columnGroupWidths = columnGroupWidths(colByPin, _this._columns);
  4059. _this.setStylesByGroup();
  4060. }
  4061. }));
  4062. },
  4063. enumerable: true,
  4064. configurable: true
  4065. });
  4066. Object.defineProperty(DataTableHeaderComponent.prototype, "headerHeight", {
  4067. get: /**
  4068. * @return {?}
  4069. */
  4070. function () {
  4071. return this._headerHeight;
  4072. },
  4073. set: /**
  4074. * @param {?} val
  4075. * @return {?}
  4076. */
  4077. function (val) {
  4078. if (val !== 'auto') {
  4079. this._headerHeight = val + "px";
  4080. }
  4081. else {
  4082. this._headerHeight = val;
  4083. }
  4084. },
  4085. enumerable: true,
  4086. configurable: true
  4087. });
  4088. Object.defineProperty(DataTableHeaderComponent.prototype, "columns", {
  4089. get: /**
  4090. * @return {?}
  4091. */
  4092. function () {
  4093. return this._columns;
  4094. },
  4095. set: /**
  4096. * @param {?} val
  4097. * @return {?}
  4098. */
  4099. function (val) {
  4100. var _this = this;
  4101. this._columns = val;
  4102. /** @type {?} */
  4103. var colsByPin = columnsByPin(val);
  4104. this._columnsByPin = columnsByPinArr(val);
  4105. setTimeout((/**
  4106. * @return {?}
  4107. */
  4108. function () {
  4109. _this._columnGroupWidths = columnGroupWidths(colsByPin, val);
  4110. _this.setStylesByGroup();
  4111. }));
  4112. },
  4113. enumerable: true,
  4114. configurable: true
  4115. });
  4116. Object.defineProperty(DataTableHeaderComponent.prototype, "offsetX", {
  4117. get: /**
  4118. * @return {?}
  4119. */
  4120. function () {
  4121. return this._offsetX;
  4122. },
  4123. set: /**
  4124. * @param {?} val
  4125. * @return {?}
  4126. */
  4127. function (val) {
  4128. this._offsetX = val;
  4129. this.setStylesByGroup();
  4130. },
  4131. enumerable: true,
  4132. configurable: true
  4133. });
  4134. /**
  4135. * @return {?}
  4136. */
  4137. DataTableHeaderComponent.prototype.ngOnDestroy = /**
  4138. * @return {?}
  4139. */
  4140. function () {
  4141. this.destroyed = true;
  4142. };
  4143. /**
  4144. * @param {?} __0
  4145. * @return {?}
  4146. */
  4147. DataTableHeaderComponent.prototype.onLongPressStart = /**
  4148. * @param {?} __0
  4149. * @return {?}
  4150. */
  4151. function (_a) {
  4152. var event = _a.event, model = _a.model;
  4153. model.dragging = true;
  4154. this.dragEventTarget = event;
  4155. };
  4156. /**
  4157. * @param {?} __0
  4158. * @return {?}
  4159. */
  4160. DataTableHeaderComponent.prototype.onLongPressEnd = /**
  4161. * @param {?} __0
  4162. * @return {?}
  4163. */
  4164. function (_a) {
  4165. var _this = this;
  4166. var event = _a.event, model = _a.model;
  4167. this.dragEventTarget = event;
  4168. // delay resetting so sort can be
  4169. // prevented if we were dragging
  4170. setTimeout((/**
  4171. * @return {?}
  4172. */
  4173. function () {
  4174. // datatable component creates copies from columns on reorder
  4175. // set dragging to false on new objects
  4176. /** @type {?} */
  4177. var column = _this._columns.find((/**
  4178. * @param {?} c
  4179. * @return {?}
  4180. */
  4181. function (c) { return c.$$id === model.$$id; }));
  4182. if (column) {
  4183. column.dragging = false;
  4184. }
  4185. }), 5);
  4186. };
  4187. Object.defineProperty(DataTableHeaderComponent.prototype, "headerWidth", {
  4188. get: /**
  4189. * @return {?}
  4190. */
  4191. function () {
  4192. if (this.scrollbarH) {
  4193. return this.innerWidth + 'px';
  4194. }
  4195. return '100%';
  4196. },
  4197. enumerable: true,
  4198. configurable: true
  4199. });
  4200. /**
  4201. * @param {?} index
  4202. * @param {?} colGroup
  4203. * @return {?}
  4204. */
  4205. DataTableHeaderComponent.prototype.trackByGroups = /**
  4206. * @param {?} index
  4207. * @param {?} colGroup
  4208. * @return {?}
  4209. */
  4210. function (index, colGroup) {
  4211. return colGroup.type;
  4212. };
  4213. /**
  4214. * @param {?} index
  4215. * @param {?} column
  4216. * @return {?}
  4217. */
  4218. DataTableHeaderComponent.prototype.columnTrackingFn = /**
  4219. * @param {?} index
  4220. * @param {?} column
  4221. * @return {?}
  4222. */
  4223. function (index, column) {
  4224. return column.$$id;
  4225. };
  4226. /**
  4227. * @param {?} width
  4228. * @param {?} column
  4229. * @return {?}
  4230. */
  4231. DataTableHeaderComponent.prototype.onColumnResized = /**
  4232. * @param {?} width
  4233. * @param {?} column
  4234. * @return {?}
  4235. */
  4236. function (width, column) {
  4237. if (width <= column.minWidth) {
  4238. width = column.minWidth;
  4239. }
  4240. else if (width >= column.maxWidth) {
  4241. width = column.maxWidth;
  4242. }
  4243. this.resize.emit({
  4244. column: column,
  4245. prevValue: column.width,
  4246. newValue: width
  4247. });
  4248. };
  4249. /**
  4250. * @param {?} __0
  4251. * @return {?}
  4252. */
  4253. DataTableHeaderComponent.prototype.onColumnReordered = /**
  4254. * @param {?} __0
  4255. * @return {?}
  4256. */
  4257. function (_a) {
  4258. var prevIndex = _a.prevIndex, newIndex = _a.newIndex, model = _a.model;
  4259. /** @type {?} */
  4260. var column = this.getColumn(newIndex);
  4261. column.isTarget = false;
  4262. column.targetMarkerContext = undefined;
  4263. this.reorder.emit({
  4264. column: model,
  4265. prevValue: prevIndex,
  4266. newValue: newIndex
  4267. });
  4268. };
  4269. /**
  4270. * @param {?} __0
  4271. * @return {?}
  4272. */
  4273. DataTableHeaderComponent.prototype.onTargetChanged = /**
  4274. * @param {?} __0
  4275. * @return {?}
  4276. */
  4277. function (_a) {
  4278. var prevIndex = _a.prevIndex, newIndex = _a.newIndex, initialIndex = _a.initialIndex;
  4279. if (prevIndex || prevIndex === 0) {
  4280. /** @type {?} */
  4281. var oldColumn = this.getColumn(prevIndex);
  4282. oldColumn.isTarget = false;
  4283. oldColumn.targetMarkerContext = undefined;
  4284. }
  4285. if (newIndex || newIndex === 0) {
  4286. /** @type {?} */
  4287. var newColumn = this.getColumn(newIndex);
  4288. newColumn.isTarget = true;
  4289. if (initialIndex !== newIndex) {
  4290. newColumn.targetMarkerContext = {
  4291. class: 'targetMarker '.concat(initialIndex > newIndex ? 'dragFromRight' : 'dragFromLeft')
  4292. };
  4293. }
  4294. }
  4295. };
  4296. /**
  4297. * @param {?} index
  4298. * @return {?}
  4299. */
  4300. DataTableHeaderComponent.prototype.getColumn = /**
  4301. * @param {?} index
  4302. * @return {?}
  4303. */
  4304. function (index) {
  4305. /** @type {?} */
  4306. var leftColumnCount = this._columnsByPin[0].columns.length;
  4307. if (index < leftColumnCount) {
  4308. return this._columnsByPin[0].columns[index];
  4309. }
  4310. /** @type {?} */
  4311. var centerColumnCount = this._columnsByPin[1].columns.length;
  4312. if (index < leftColumnCount + centerColumnCount) {
  4313. return this._columnsByPin[1].columns[index - leftColumnCount];
  4314. }
  4315. return this._columnsByPin[2].columns[index - leftColumnCount - centerColumnCount];
  4316. };
  4317. /**
  4318. * @param {?} __0
  4319. * @return {?}
  4320. */
  4321. DataTableHeaderComponent.prototype.onSort = /**
  4322. * @param {?} __0
  4323. * @return {?}
  4324. */
  4325. function (_a) {
  4326. var column = _a.column, prevValue = _a.prevValue, newValue = _a.newValue;
  4327. // if we are dragging don't sort!
  4328. if (column.dragging) {
  4329. return;
  4330. }
  4331. /** @type {?} */
  4332. var sorts = this.calcNewSorts(column, prevValue, newValue);
  4333. this.sort.emit({
  4334. sorts: sorts,
  4335. column: column,
  4336. prevValue: prevValue,
  4337. newValue: newValue
  4338. });
  4339. };
  4340. /**
  4341. * @param {?} column
  4342. * @param {?} prevValue
  4343. * @param {?} newValue
  4344. * @return {?}
  4345. */
  4346. DataTableHeaderComponent.prototype.calcNewSorts = /**
  4347. * @param {?} column
  4348. * @param {?} prevValue
  4349. * @param {?} newValue
  4350. * @return {?}
  4351. */
  4352. function (column, prevValue, newValue) {
  4353. /** @type {?} */
  4354. var idx = 0;
  4355. if (!this.sorts) {
  4356. this.sorts = [];
  4357. }
  4358. /** @type {?} */
  4359. var sorts = this.sorts.map((/**
  4360. * @param {?} s
  4361. * @param {?} i
  4362. * @return {?}
  4363. */
  4364. function (s, i) {
  4365. s = __assign({}, s);
  4366. if (s.prop === column.prop) {
  4367. idx = i;
  4368. }
  4369. return s;
  4370. }));
  4371. if (newValue === undefined) {
  4372. sorts.splice(idx, 1);
  4373. }
  4374. else if (prevValue) {
  4375. sorts[idx].dir = newValue;
  4376. }
  4377. else {
  4378. if (this.sortType === SortType.single) {
  4379. sorts.splice(0, this.sorts.length);
  4380. }
  4381. sorts.push({ dir: newValue, prop: column.prop });
  4382. }
  4383. return sorts;
  4384. };
  4385. /**
  4386. * @return {?}
  4387. */
  4388. DataTableHeaderComponent.prototype.setStylesByGroup = /**
  4389. * @return {?}
  4390. */
  4391. function () {
  4392. this._styleByGroup.left = this.calcStylesByGroup('left');
  4393. this._styleByGroup.center = this.calcStylesByGroup('center');
  4394. this._styleByGroup.right = this.calcStylesByGroup('right');
  4395. if (!this.destroyed) {
  4396. this.cd.detectChanges();
  4397. }
  4398. };
  4399. /**
  4400. * @param {?} group
  4401. * @return {?}
  4402. */
  4403. DataTableHeaderComponent.prototype.calcStylesByGroup = /**
  4404. * @param {?} group
  4405. * @return {?}
  4406. */
  4407. function (group) {
  4408. /** @type {?} */
  4409. var widths = this._columnGroupWidths;
  4410. /** @type {?} */
  4411. var offsetX = this.offsetX;
  4412. /** @type {?} */
  4413. var styles = {
  4414. width: widths[group] + "px"
  4415. };
  4416. if (group === 'center') {
  4417. translateXY(styles, offsetX * -1, 0);
  4418. }
  4419. else if (group === 'right') {
  4420. /** @type {?} */
  4421. var totalDiff = widths.total - this.innerWidth;
  4422. /** @type {?} */
  4423. var offset = totalDiff * -1;
  4424. translateXY(styles, offset, 0);
  4425. }
  4426. return styles;
  4427. };
  4428. DataTableHeaderComponent.decorators = [
  4429. { type: Component, args: [{
  4430. selector: 'datatable-header',
  4431. template: "\n <div\n orderable\n (reorder)=\"onColumnReordered($event)\"\n (targetChanged)=\"onTargetChanged($event)\"\n [style.width.px]=\"_columnGroupWidths.total\"\n class=\"datatable-header-inner\"\n >\n <div\n *ngFor=\"let colGroup of _columnsByPin; trackBy: trackByGroups\"\n [class]=\"'datatable-row-' + colGroup.type\"\n [ngStyle]=\"_styleByGroup[colGroup.type]\"\n >\n <datatable-header-cell\n *ngFor=\"let column of colGroup.columns; trackBy: columnTrackingFn\"\n resizeable\n [resizeEnabled]=\"column.resizeable\"\n (resize)=\"onColumnResized($event, column)\"\n long-press\n [pressModel]=\"column\"\n [pressEnabled]=\"reorderable && column.draggable\"\n (longPressStart)=\"onLongPressStart($event)\"\n (longPressEnd)=\"onLongPressEnd($event)\"\n draggable\n [dragX]=\"reorderable && column.draggable && column.dragging\"\n [dragY]=\"false\"\n [dragModel]=\"column\"\n [dragEventTarget]=\"dragEventTarget\"\n [headerHeight]=\"headerHeight\"\n [isTarget]=\"column.isTarget\"\n [targetMarkerTemplate]=\"targetMarkerTemplate\"\n [targetMarkerContext]=\"column.targetMarkerContext\"\n [column]=\"column\"\n [sortType]=\"sortType\"\n [sorts]=\"sorts\"\n [selectionType]=\"selectionType\"\n [sortAscendingIcon]=\"sortAscendingIcon\"\n [sortDescendingIcon]=\"sortDescendingIcon\"\n [allRowsSelected]=\"allRowsSelected\"\n (sort)=\"onSort($event)\"\n (select)=\"select.emit($event)\"\n (columnContextmenu)=\"columnContextmenu.emit($event)\"\n >\n </datatable-header-cell>\n </div>\n </div>\n ",
  4432. host: {
  4433. class: 'datatable-header'
  4434. },
  4435. changeDetection: ChangeDetectionStrategy.OnPush
  4436. }] }
  4437. ];
  4438. /** @nocollapse */
  4439. DataTableHeaderComponent.ctorParameters = function () { return [
  4440. { type: ChangeDetectorRef }
  4441. ]; };
  4442. DataTableHeaderComponent.propDecorators = {
  4443. sortAscendingIcon: [{ type: Input }],
  4444. sortDescendingIcon: [{ type: Input }],
  4445. scrollbarH: [{ type: Input }],
  4446. dealsWithGroup: [{ type: Input }],
  4447. targetMarkerTemplate: [{ type: Input }],
  4448. innerWidth: [{ type: Input }],
  4449. sorts: [{ type: Input }],
  4450. sortType: [{ type: Input }],
  4451. allRowsSelected: [{ type: Input }],
  4452. selectionType: [{ type: Input }],
  4453. reorderable: [{ type: Input }],
  4454. headerHeight: [{ type: HostBinding, args: ['style.height',] }, { type: Input }],
  4455. columns: [{ type: Input }],
  4456. offsetX: [{ type: Input }],
  4457. sort: [{ type: Output }],
  4458. reorder: [{ type: Output }],
  4459. resize: [{ type: Output }],
  4460. select: [{ type: Output }],
  4461. columnContextmenu: [{ type: Output }],
  4462. headerWidth: [{ type: HostBinding, args: ['style.width',] }]
  4463. };
  4464. return DataTableHeaderComponent;
  4465. }());
  4466. if (false) {
  4467. /** @type {?} */
  4468. DataTableHeaderComponent.prototype.sortAscendingIcon;
  4469. /** @type {?} */
  4470. DataTableHeaderComponent.prototype.sortDescendingIcon;
  4471. /** @type {?} */
  4472. DataTableHeaderComponent.prototype.scrollbarH;
  4473. /** @type {?} */
  4474. DataTableHeaderComponent.prototype.dealsWithGroup;
  4475. /** @type {?} */
  4476. DataTableHeaderComponent.prototype.targetMarkerTemplate;
  4477. /** @type {?} */
  4478. DataTableHeaderComponent.prototype.targetMarkerContext;
  4479. /** @type {?} */
  4480. DataTableHeaderComponent.prototype.sorts;
  4481. /** @type {?} */
  4482. DataTableHeaderComponent.prototype.sortType;
  4483. /** @type {?} */
  4484. DataTableHeaderComponent.prototype.allRowsSelected;
  4485. /** @type {?} */
  4486. DataTableHeaderComponent.prototype.selectionType;
  4487. /** @type {?} */
  4488. DataTableHeaderComponent.prototype.reorderable;
  4489. /** @type {?} */
  4490. DataTableHeaderComponent.prototype.dragEventTarget;
  4491. /** @type {?} */
  4492. DataTableHeaderComponent.prototype.sort;
  4493. /** @type {?} */
  4494. DataTableHeaderComponent.prototype.reorder;
  4495. /** @type {?} */
  4496. DataTableHeaderComponent.prototype.resize;
  4497. /** @type {?} */
  4498. DataTableHeaderComponent.prototype.select;
  4499. /** @type {?} */
  4500. DataTableHeaderComponent.prototype.columnContextmenu;
  4501. /** @type {?} */
  4502. DataTableHeaderComponent.prototype._columnsByPin;
  4503. /** @type {?} */
  4504. DataTableHeaderComponent.prototype._columnGroupWidths;
  4505. /** @type {?} */
  4506. DataTableHeaderComponent.prototype._innerWidth;
  4507. /** @type {?} */
  4508. DataTableHeaderComponent.prototype._offsetX;
  4509. /** @type {?} */
  4510. DataTableHeaderComponent.prototype._columns;
  4511. /** @type {?} */
  4512. DataTableHeaderComponent.prototype._headerHeight;
  4513. /** @type {?} */
  4514. DataTableHeaderComponent.prototype._styleByGroup;
  4515. /**
  4516. * @type {?}
  4517. * @private
  4518. */
  4519. DataTableHeaderComponent.prototype.destroyed;
  4520. /**
  4521. * @type {?}
  4522. * @private
  4523. */
  4524. DataTableHeaderComponent.prototype.cd;
  4525. }
  4526. /**
  4527. * @fileoverview added by tsickle
  4528. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  4529. */
  4530. /**
  4531. * Throttle a function
  4532. * @param {?} func
  4533. * @param {?} wait
  4534. * @param {?=} options
  4535. * @return {?}
  4536. */
  4537. function throttle(func, wait, options) {
  4538. options = options || {};
  4539. /** @type {?} */
  4540. var context;
  4541. /** @type {?} */
  4542. var args;
  4543. /** @type {?} */
  4544. var result;
  4545. /** @type {?} */
  4546. var timeout = null;
  4547. /** @type {?} */
  4548. var previous = 0;
  4549. /**
  4550. * @return {?}
  4551. */
  4552. function later() {
  4553. previous = options.leading === false ? 0 : +new Date();
  4554. timeout = null;
  4555. result = func.apply(context, args);
  4556. }
  4557. return (/**
  4558. * @this {?}
  4559. * @return {?}
  4560. */
  4561. function () {
  4562. /** @type {?} */
  4563. var now = +new Date();
  4564. if (!previous && options.leading === false) {
  4565. previous = now;
  4566. }
  4567. /** @type {?} */
  4568. var remaining = wait - (now - previous);
  4569. context = this;
  4570. args = arguments;
  4571. if (remaining <= 0) {
  4572. clearTimeout(timeout);
  4573. timeout = null;
  4574. previous = now;
  4575. result = func.apply(context, args);
  4576. }
  4577. else if (!timeout && options.trailing !== false) {
  4578. timeout = setTimeout(later, remaining);
  4579. }
  4580. return result;
  4581. });
  4582. }
  4583. /**
  4584. * Throttle decorator
  4585. *
  4586. * class MyClass {
  4587. * throttleable(10)
  4588. * myFn() { ... }
  4589. * }
  4590. * @param {?} duration
  4591. * @param {?=} options
  4592. * @return {?}
  4593. */
  4594. function throttleable(duration, options) {
  4595. return (/**
  4596. * @param {?} target
  4597. * @param {?} key
  4598. * @param {?} descriptor
  4599. * @return {?}
  4600. */
  4601. function innerDecorator(target, key, descriptor) {
  4602. return {
  4603. configurable: true,
  4604. enumerable: descriptor.enumerable,
  4605. get: (/**
  4606. * @return {?}
  4607. */
  4608. function getter() {
  4609. Object.defineProperty(this, key, {
  4610. configurable: true,
  4611. enumerable: descriptor.enumerable,
  4612. value: throttle(descriptor.value, duration, options)
  4613. });
  4614. return this[key];
  4615. })
  4616. };
  4617. });
  4618. }
  4619. /**
  4620. * @fileoverview added by tsickle
  4621. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  4622. */
  4623. /**
  4624. * Calculates the Total Flex Grow
  4625. * @param {?} columns
  4626. * @return {?}
  4627. */
  4628. function getTotalFlexGrow(columns) {
  4629. var e_1, _a;
  4630. /** @type {?} */
  4631. var totalFlexGrow = 0;
  4632. try {
  4633. for (var columns_1 = __values(columns), columns_1_1 = columns_1.next(); !columns_1_1.done; columns_1_1 = columns_1.next()) {
  4634. var c = columns_1_1.value;
  4635. totalFlexGrow += c.flexGrow || 0;
  4636. }
  4637. }
  4638. catch (e_1_1) { e_1 = { error: e_1_1 }; }
  4639. finally {
  4640. try {
  4641. if (columns_1_1 && !columns_1_1.done && (_a = columns_1.return)) _a.call(columns_1);
  4642. }
  4643. finally { if (e_1) throw e_1.error; }
  4644. }
  4645. return totalFlexGrow;
  4646. }
  4647. /**
  4648. * Adjusts the column widths.
  4649. * Inspired by: https://github.com/facebook/fixed-data-table/blob/master/src/FixedDataTableWidthHelper.js
  4650. * @param {?} allColumns
  4651. * @param {?} expectedWidth
  4652. * @return {?}
  4653. */
  4654. function adjustColumnWidths(allColumns, expectedWidth) {
  4655. /** @type {?} */
  4656. var columnsWidth = columnsTotalWidth(allColumns);
  4657. /** @type {?} */
  4658. var totalFlexGrow = getTotalFlexGrow(allColumns);
  4659. /** @type {?} */
  4660. var colsByGroup = columnsByPin(allColumns);
  4661. if (columnsWidth !== expectedWidth) {
  4662. scaleColumns(colsByGroup, expectedWidth, totalFlexGrow);
  4663. }
  4664. }
  4665. /**
  4666. * Resizes columns based on the flexGrow property, while respecting manually set widths
  4667. * @param {?} colsByGroup
  4668. * @param {?} maxWidth
  4669. * @param {?} totalFlexGrow
  4670. * @return {?}
  4671. */
  4672. function scaleColumns(colsByGroup, maxWidth, totalFlexGrow) {
  4673. var e_2, _a, e_3, _b;
  4674. // calculate total width and flexgrow points for coulumns that can be resized
  4675. for (var attr in colsByGroup) {
  4676. try {
  4677. for (var _c = (e_2 = void 0, __values(colsByGroup[attr])), _d = _c.next(); !_d.done; _d = _c.next()) {
  4678. var column = _d.value;
  4679. if (!column.canAutoResize) {
  4680. maxWidth -= column.width;
  4681. totalFlexGrow -= column.flexGrow ? column.flexGrow : 0;
  4682. }
  4683. else {
  4684. column.width = 0;
  4685. }
  4686. }
  4687. }
  4688. catch (e_2_1) { e_2 = { error: e_2_1 }; }
  4689. finally {
  4690. try {
  4691. if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
  4692. }
  4693. finally { if (e_2) throw e_2.error; }
  4694. }
  4695. }
  4696. /** @type {?} */
  4697. var hasMinWidth = {};
  4698. /** @type {?} */
  4699. var remainingWidth = maxWidth;
  4700. // resize columns until no width is left to be distributed
  4701. do {
  4702. /** @type {?} */
  4703. var widthPerFlexPoint = remainingWidth / totalFlexGrow;
  4704. remainingWidth = 0;
  4705. for (var attr in colsByGroup) {
  4706. try {
  4707. for (var _e = (e_3 = void 0, __values(colsByGroup[attr])), _f = _e.next(); !_f.done; _f = _e.next()) {
  4708. var column = _f.value;
  4709. // if the column can be resize and it hasn't reached its minimum width yet
  4710. if (column.canAutoResize && !hasMinWidth[column.prop]) {
  4711. /** @type {?} */
  4712. var newWidth = column.width + column.flexGrow * widthPerFlexPoint;
  4713. if (column.minWidth !== undefined && newWidth < column.minWidth) {
  4714. remainingWidth += newWidth - column.minWidth;
  4715. column.width = column.minWidth;
  4716. hasMinWidth[column.prop] = true;
  4717. }
  4718. else {
  4719. column.width = newWidth;
  4720. }
  4721. }
  4722. }
  4723. }
  4724. catch (e_3_1) { e_3 = { error: e_3_1 }; }
  4725. finally {
  4726. try {
  4727. if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
  4728. }
  4729. finally { if (e_3) throw e_3.error; }
  4730. }
  4731. }
  4732. } while (remainingWidth !== 0);
  4733. }
  4734. /**
  4735. * Forces the width of the columns to
  4736. * distribute equally but overflowing when necessary
  4737. *
  4738. * Rules:
  4739. *
  4740. * - If combined withs are less than the total width of the grid,
  4741. * proportion the widths given the min / max / normal widths to fill the width.
  4742. *
  4743. * - If the combined widths, exceed the total width of the grid,
  4744. * use the standard widths.
  4745. *
  4746. * - If a column is resized, it should always use that width
  4747. *
  4748. * - The proportional widths should never fall below min size if specified.
  4749. *
  4750. * - If the grid starts off small but then becomes greater than the size ( + / - )
  4751. * the width should use the original width; not the newly proportioned widths.
  4752. * @param {?} allColumns
  4753. * @param {?} expectedWidth
  4754. * @param {?} startIdx
  4755. * @param {?} allowBleed
  4756. * @param {?=} defaultColWidth
  4757. * @return {?}
  4758. */
  4759. function forceFillColumnWidths(allColumns, expectedWidth, startIdx, allowBleed, defaultColWidth) {
  4760. var e_4, _a, e_5, _b;
  4761. if (defaultColWidth === void 0) { defaultColWidth = 300; }
  4762. /** @type {?} */
  4763. var columnsToResize = allColumns.slice(startIdx + 1, allColumns.length).filter((/**
  4764. * @param {?} c
  4765. * @return {?}
  4766. */
  4767. function (c) {
  4768. return c.canAutoResize !== false;
  4769. }));
  4770. try {
  4771. for (var columnsToResize_1 = __values(columnsToResize), columnsToResize_1_1 = columnsToResize_1.next(); !columnsToResize_1_1.done; columnsToResize_1_1 = columnsToResize_1.next()) {
  4772. var column = columnsToResize_1_1.value;
  4773. if (!column.$$oldWidth) {
  4774. column.$$oldWidth = column.width;
  4775. }
  4776. }
  4777. }
  4778. catch (e_4_1) { e_4 = { error: e_4_1 }; }
  4779. finally {
  4780. try {
  4781. if (columnsToResize_1_1 && !columnsToResize_1_1.done && (_a = columnsToResize_1.return)) _a.call(columnsToResize_1);
  4782. }
  4783. finally { if (e_4) throw e_4.error; }
  4784. }
  4785. /** @type {?} */
  4786. var additionWidthPerColumn = 0;
  4787. /** @type {?} */
  4788. var exceedsWindow = false;
  4789. /** @type {?} */
  4790. var contentWidth = getContentWidth(allColumns, defaultColWidth);
  4791. /** @type {?} */
  4792. var remainingWidth = expectedWidth - contentWidth;
  4793. /** @type {?} */
  4794. var columnsProcessed = [];
  4795. /** @type {?} */
  4796. var remainingWidthLimit = 1;
  4797. // This loop takes care of the
  4798. do {
  4799. additionWidthPerColumn = remainingWidth / columnsToResize.length;
  4800. exceedsWindow = contentWidth >= expectedWidth;
  4801. try {
  4802. for (var columnsToResize_2 = (e_5 = void 0, __values(columnsToResize)), columnsToResize_2_1 = columnsToResize_2.next(); !columnsToResize_2_1.done; columnsToResize_2_1 = columnsToResize_2.next()) {
  4803. var column = columnsToResize_2_1.value;
  4804. if (exceedsWindow && allowBleed) {
  4805. column.width = column.$$oldWidth || column.width || defaultColWidth;
  4806. }
  4807. else {
  4808. /** @type {?} */
  4809. var newSize = (column.width || defaultColWidth) + additionWidthPerColumn;
  4810. if (column.minWidth && newSize < column.minWidth) {
  4811. column.width = column.minWidth;
  4812. columnsProcessed.push(column);
  4813. }
  4814. else if (column.maxWidth && newSize > column.maxWidth) {
  4815. column.width = column.maxWidth;
  4816. columnsProcessed.push(column);
  4817. }
  4818. else {
  4819. column.width = newSize;
  4820. }
  4821. }
  4822. column.width = Math.max(0, column.width);
  4823. }
  4824. }
  4825. catch (e_5_1) { e_5 = { error: e_5_1 }; }
  4826. finally {
  4827. try {
  4828. if (columnsToResize_2_1 && !columnsToResize_2_1.done && (_b = columnsToResize_2.return)) _b.call(columnsToResize_2);
  4829. }
  4830. finally { if (e_5) throw e_5.error; }
  4831. }
  4832. contentWidth = getContentWidth(allColumns);
  4833. remainingWidth = expectedWidth - contentWidth;
  4834. removeProcessedColumns(columnsToResize, columnsProcessed);
  4835. } while (remainingWidth > remainingWidthLimit && columnsToResize.length !== 0);
  4836. }
  4837. /**
  4838. * Remove the processed columns from the current active columns.
  4839. * @param {?} columnsToResize
  4840. * @param {?} columnsProcessed
  4841. * @return {?}
  4842. */
  4843. function removeProcessedColumns(columnsToResize, columnsProcessed) {
  4844. var e_6, _a;
  4845. try {
  4846. for (var columnsProcessed_1 = __values(columnsProcessed), columnsProcessed_1_1 = columnsProcessed_1.next(); !columnsProcessed_1_1.done; columnsProcessed_1_1 = columnsProcessed_1.next()) {
  4847. var column = columnsProcessed_1_1.value;
  4848. /** @type {?} */
  4849. var index = columnsToResize.indexOf(column);
  4850. columnsToResize.splice(index, 1);
  4851. }
  4852. }
  4853. catch (e_6_1) { e_6 = { error: e_6_1 }; }
  4854. finally {
  4855. try {
  4856. if (columnsProcessed_1_1 && !columnsProcessed_1_1.done && (_a = columnsProcessed_1.return)) _a.call(columnsProcessed_1);
  4857. }
  4858. finally { if (e_6) throw e_6.error; }
  4859. }
  4860. }
  4861. /**
  4862. * Gets the width of the columns
  4863. * @param {?} allColumns
  4864. * @param {?=} defaultColWidth
  4865. * @return {?}
  4866. */
  4867. function getContentWidth(allColumns, defaultColWidth) {
  4868. var e_7, _a;
  4869. if (defaultColWidth === void 0) { defaultColWidth = 300; }
  4870. /** @type {?} */
  4871. var contentWidth = 0;
  4872. try {
  4873. for (var allColumns_1 = __values(allColumns), allColumns_1_1 = allColumns_1.next(); !allColumns_1_1.done; allColumns_1_1 = allColumns_1.next()) {
  4874. var column = allColumns_1_1.value;
  4875. contentWidth += column.width || defaultColWidth;
  4876. }
  4877. }
  4878. catch (e_7_1) { e_7 = { error: e_7_1 }; }
  4879. finally {
  4880. try {
  4881. if (allColumns_1_1 && !allColumns_1_1.done && (_a = allColumns_1.return)) _a.call(allColumns_1);
  4882. }
  4883. finally { if (e_7) throw e_7.error; }
  4884. }
  4885. return contentWidth;
  4886. }
  4887. /**
  4888. * @fileoverview added by tsickle
  4889. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  4890. */
  4891. /** @enum {string} */
  4892. var SortDirection = {
  4893. asc: 'asc',
  4894. desc: 'desc',
  4895. };
  4896. /**
  4897. * @fileoverview added by tsickle
  4898. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  4899. */
  4900. /**
  4901. * Gets the next sort direction
  4902. * @param {?} sortType
  4903. * @param {?} current
  4904. * @return {?}
  4905. */
  4906. function nextSortDir(sortType, current) {
  4907. if (sortType === SortType.single) {
  4908. if (current === SortDirection.asc) {
  4909. return SortDirection.desc;
  4910. }
  4911. else {
  4912. return SortDirection.asc;
  4913. }
  4914. }
  4915. else {
  4916. if (!current) {
  4917. return SortDirection.asc;
  4918. }
  4919. else if (current === SortDirection.asc) {
  4920. return SortDirection.desc;
  4921. }
  4922. else if (current === SortDirection.desc) {
  4923. return undefined;
  4924. }
  4925. // avoid TS7030: Not all code paths return a value.
  4926. return undefined;
  4927. }
  4928. }
  4929. /**
  4930. * Adapted from fueld-ui on 6/216
  4931. * https://github.com/FuelInteractive/fuel-ui/tree/master/src/pipes/OrderBy
  4932. * @param {?} a
  4933. * @param {?} b
  4934. * @return {?}
  4935. */
  4936. function orderByComparator(a, b) {
  4937. if (a === null || typeof a === 'undefined')
  4938. a = 0;
  4939. if (b === null || typeof b === 'undefined')
  4940. b = 0;
  4941. if (a instanceof Date && b instanceof Date) {
  4942. if (a < b)
  4943. return -1;
  4944. if (a > b)
  4945. return 1;
  4946. }
  4947. else if (isNaN(parseFloat(a)) || !isFinite(a) || (isNaN(parseFloat(b)) || !isFinite(b))) {
  4948. // Convert to string in case of a=0 or b=0
  4949. a = String(a);
  4950. b = String(b);
  4951. // Isn't a number so lowercase the string to properly compare
  4952. if (a.toLowerCase() < b.toLowerCase())
  4953. return -1;
  4954. if (a.toLowerCase() > b.toLowerCase())
  4955. return 1;
  4956. }
  4957. else {
  4958. // Parse strings as numbers to compare properly
  4959. if (parseFloat(a) < parseFloat(b))
  4960. return -1;
  4961. if (parseFloat(a) > parseFloat(b))
  4962. return 1;
  4963. }
  4964. // equal each other
  4965. return 0;
  4966. }
  4967. /**
  4968. * creates a shallow copy of the `rows` input and returns the sorted copy. this function
  4969. * does not sort the `rows` argument in place
  4970. * @param {?} rows
  4971. * @param {?} columns
  4972. * @param {?} dirs
  4973. * @return {?}
  4974. */
  4975. function sortRows(rows, columns, dirs) {
  4976. if (!rows)
  4977. return [];
  4978. if (!dirs || !dirs.length || !columns)
  4979. return __spread(rows);
  4980. /**
  4981. * record the row ordering of results from prior sort operations (if applicable)
  4982. * this is necessary to guarantee stable sorting behavior
  4983. * @type {?}
  4984. */
  4985. var rowToIndexMap = new Map();
  4986. rows.forEach((/**
  4987. * @param {?} row
  4988. * @param {?} index
  4989. * @return {?}
  4990. */
  4991. function (row, index) { return rowToIndexMap.set(row, index); }));
  4992. /** @type {?} */
  4993. var temp = __spread(rows);
  4994. /** @type {?} */
  4995. var cols = columns.reduce((/**
  4996. * @param {?} obj
  4997. * @param {?} col
  4998. * @return {?}
  4999. */
  5000. function (obj, col) {
  5001. if (col.comparator && typeof col.comparator === 'function') {
  5002. obj[col.prop] = col.comparator;
  5003. }
  5004. return obj;
  5005. }), {});
  5006. // cache valueGetter and compareFn so that they
  5007. // do not need to be looked-up in the sort function body
  5008. /** @type {?} */
  5009. var cachedDirs = dirs.map((/**
  5010. * @param {?} dir
  5011. * @return {?}
  5012. */
  5013. function (dir) {
  5014. /** @type {?} */
  5015. var prop = dir.prop;
  5016. return {
  5017. prop: prop,
  5018. dir: dir.dir,
  5019. valueGetter: getterForProp(prop),
  5020. compareFn: cols[prop] || orderByComparator
  5021. };
  5022. }));
  5023. return temp.sort((/**
  5024. * @param {?} rowA
  5025. * @param {?} rowB
  5026. * @return {?}
  5027. */
  5028. function (rowA, rowB) {
  5029. var e_1, _a;
  5030. try {
  5031. for (var cachedDirs_1 = __values(cachedDirs), cachedDirs_1_1 = cachedDirs_1.next(); !cachedDirs_1_1.done; cachedDirs_1_1 = cachedDirs_1.next()) {
  5032. var cachedDir = cachedDirs_1_1.value;
  5033. // Get property and valuegetters for column to be sorted
  5034. var prop = cachedDir.prop, valueGetter = cachedDir.valueGetter;
  5035. // Get A and B cell values from rows based on properties of the columns
  5036. /** @type {?} */
  5037. var propA = valueGetter(rowA, prop);
  5038. /** @type {?} */
  5039. var propB = valueGetter(rowB, prop);
  5040. // Compare function gets five parameters:
  5041. // Two cell values to be compared as propA and propB
  5042. // Two rows corresponding to the cells as rowA and rowB
  5043. // Direction of the sort for this column as SortDirection
  5044. // Compare can be a standard JS comparison function (a,b) => -1|0|1
  5045. // as additional parameters are silently ignored. The whole row and sort
  5046. // direction enable more complex sort logic.
  5047. /** @type {?} */
  5048. var comparison = cachedDir.dir !== SortDirection.desc
  5049. ? cachedDir.compareFn(propA, propB, rowA, rowB, cachedDir.dir)
  5050. : -cachedDir.compareFn(propA, propB, rowA, rowB, cachedDir.dir);
  5051. // Don't return 0 yet in case of needing to sort by next property
  5052. if (comparison !== 0)
  5053. return comparison;
  5054. }
  5055. }
  5056. catch (e_1_1) { e_1 = { error: e_1_1 }; }
  5057. finally {
  5058. try {
  5059. if (cachedDirs_1_1 && !cachedDirs_1_1.done && (_a = cachedDirs_1.return)) _a.call(cachedDirs_1);
  5060. }
  5061. finally { if (e_1) throw e_1.error; }
  5062. }
  5063. if (!(rowToIndexMap.has(rowA) && rowToIndexMap.has(rowB)))
  5064. return 0;
  5065. /**
  5066. * all else being equal, preserve original order of the rows (stable sort)
  5067. */
  5068. return rowToIndexMap.get(rowA) < rowToIndexMap.get(rowB) ? -1 : 1;
  5069. }));
  5070. }
  5071. /**
  5072. * @fileoverview added by tsickle
  5073. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  5074. */
  5075. var DatatableComponent = /** @class */ (function () {
  5076. function DatatableComponent(scrollbarHelper, dimensionsHelper, cd, element, differs, columnChangesService, configuration) {
  5077. var _this = this;
  5078. this.scrollbarHelper = scrollbarHelper;
  5079. this.dimensionsHelper = dimensionsHelper;
  5080. this.cd = cd;
  5081. this.columnChangesService = columnChangesService;
  5082. this.configuration = configuration;
  5083. /**
  5084. * List of row objects that should be
  5085. * represented as selected in the grid.
  5086. * Default value: `[]`
  5087. */
  5088. this.selected = [];
  5089. /**
  5090. * Enable vertical scrollbars
  5091. */
  5092. this.scrollbarV = false;
  5093. /**
  5094. * Enable horz scrollbars
  5095. */
  5096. this.scrollbarH = false;
  5097. /**
  5098. * The row height; which is necessary
  5099. * to calculate the height for the lazy rendering.
  5100. */
  5101. this.rowHeight = 30;
  5102. /**
  5103. * Type of column width distribution formula.
  5104. * Example: flex, force, standard
  5105. */
  5106. this.columnMode = ColumnMode.standard;
  5107. /**
  5108. * The minimum header height in pixels.
  5109. * Pass a falsey for no header
  5110. */
  5111. this.headerHeight = 30;
  5112. /**
  5113. * The minimum footer height in pixels.
  5114. * Pass falsey for no footer
  5115. */
  5116. this.footerHeight = 0;
  5117. /**
  5118. * If the table should use external paging
  5119. * otherwise its assumed that all data is preloaded.
  5120. */
  5121. this.externalPaging = false;
  5122. /**
  5123. * If the table should use external sorting or
  5124. * the built-in basic sorting.
  5125. */
  5126. this.externalSorting = false;
  5127. /**
  5128. * Show the linear loading bar.
  5129. * Default value: `false`
  5130. */
  5131. this.loadingIndicator = false;
  5132. /**
  5133. * Enable/Disable ability to re-order columns
  5134. * by dragging them.
  5135. */
  5136. this.reorderable = true;
  5137. /**
  5138. * Swap columns on re-order columns or
  5139. * move them.
  5140. */
  5141. this.swapColumns = true;
  5142. /**
  5143. * The type of sorting
  5144. */
  5145. this.sortType = SortType.single;
  5146. /**
  5147. * Array of sorted columns by property and type.
  5148. * Default value: `[]`
  5149. */
  5150. this.sorts = [];
  5151. /**
  5152. * Css class overrides
  5153. */
  5154. this.cssClasses = {
  5155. sortAscending: 'datatable-icon-up',
  5156. sortDescending: 'datatable-icon-down',
  5157. pagerLeftArrow: 'datatable-icon-left',
  5158. pagerRightArrow: 'datatable-icon-right',
  5159. pagerPrevious: 'datatable-icon-prev',
  5160. pagerNext: 'datatable-icon-skip'
  5161. };
  5162. /**
  5163. * Message overrides for localization
  5164. *
  5165. * emptyMessage [default] = 'No data to display'
  5166. * totalMessage [default] = 'total'
  5167. * selectedMessage [default] = 'selected'
  5168. */
  5169. this.messages = {
  5170. // Message to show when array is presented
  5171. // but contains no values
  5172. emptyMessage: 'No data to display',
  5173. // Footer total message
  5174. totalMessage: 'total',
  5175. // Footer selected message
  5176. selectedMessage: 'selected'
  5177. };
  5178. /**
  5179. * A boolean you can use to set the detault behaviour of rows and groups
  5180. * whether they will start expanded or not. If ommited the default is NOT expanded.
  5181. *
  5182. */
  5183. this.groupExpansionDefault = false;
  5184. /**
  5185. * Property to which you can use for determining select all
  5186. * rows on current page or not.
  5187. *
  5188. * \@memberOf DatatableComponent
  5189. */
  5190. this.selectAllRowsOnPage = false;
  5191. /**
  5192. * A flag for row virtualization on / off
  5193. */
  5194. this.virtualization = true;
  5195. /**
  5196. * A flag for switching summary row on / off
  5197. */
  5198. this.summaryRow = false;
  5199. /**
  5200. * A height of summary row
  5201. */
  5202. this.summaryHeight = 30;
  5203. /**
  5204. * A property holds a summary row position: top/bottom
  5205. */
  5206. this.summaryPosition = 'top';
  5207. /**
  5208. * Body was scrolled typically in a `scrollbarV:true` scenario.
  5209. */
  5210. this.scroll = new EventEmitter();
  5211. /**
  5212. * A cell or row was focused via keyboard or mouse click.
  5213. */
  5214. this.activate = new EventEmitter();
  5215. /**
  5216. * A cell or row was selected.
  5217. */
  5218. this.select = new EventEmitter();
  5219. /**
  5220. * Column sort was invoked.
  5221. */
  5222. this.sort = new EventEmitter();
  5223. /**
  5224. * The table was paged either triggered by the pager or the body scroll.
  5225. */
  5226. this.page = new EventEmitter();
  5227. /**
  5228. * Columns were re-ordered.
  5229. */
  5230. this.reorder = new EventEmitter();
  5231. /**
  5232. * Column was resized.
  5233. */
  5234. this.resize = new EventEmitter();
  5235. /**
  5236. * The context menu was invoked on the table.
  5237. * type indicates whether the header or the body was clicked.
  5238. * content contains either the column or the row that was clicked.
  5239. */
  5240. this.tableContextmenu = new EventEmitter(false);
  5241. /**
  5242. * A row was expanded ot collapsed for tree
  5243. */
  5244. this.treeAction = new EventEmitter();
  5245. this.rowCount = 0;
  5246. this._offsetX = new BehaviorSubject(0);
  5247. this._count = 0;
  5248. this._offset = 0;
  5249. this._subscriptions = [];
  5250. /**
  5251. * This will be used when displaying or selecting rows.
  5252. * when tracking/comparing them, we'll use the value of this fn,
  5253. *
  5254. * (`fn(x) === fn(y)` instead of `x === y`)
  5255. */
  5256. this.rowIdentity = (/**
  5257. * @param {?} x
  5258. * @return {?}
  5259. */
  5260. function (x) {
  5261. if (_this._groupRowsBy) {
  5262. // each group in groupedRows are stored as {key, value: [rows]},
  5263. // where key is the groupRowsBy index
  5264. return x.key;
  5265. }
  5266. else {
  5267. return x;
  5268. }
  5269. });
  5270. // get ref to elm for measuring
  5271. this.element = element.nativeElement;
  5272. this.rowDiffer = differs.find({}).create();
  5273. // apply global settings from Module.forRoot
  5274. if (this.configuration && this.configuration.messages) {
  5275. this.messages = __assign({}, this.configuration.messages);
  5276. }
  5277. }
  5278. Object.defineProperty(DatatableComponent.prototype, "rows", {
  5279. /**
  5280. * Gets the rows.
  5281. */
  5282. get: /**
  5283. * Gets the rows.
  5284. * @return {?}
  5285. */
  5286. function () {
  5287. return this._rows;
  5288. },
  5289. /**
  5290. * Rows that are displayed in the table.
  5291. */
  5292. set: /**
  5293. * Rows that are displayed in the table.
  5294. * @param {?} val
  5295. * @return {?}
  5296. */
  5297. function (val) {
  5298. this._rows = val;
  5299. if (val) {
  5300. this._internalRows = __spread(val);
  5301. }
  5302. // auto sort on new updates
  5303. if (!this.externalSorting) {
  5304. this.sortInternalRows();
  5305. }
  5306. // auto group by parent on new update
  5307. this._internalRows = groupRowsByParents(this._internalRows, optionalGetterForProp(this.treeFromRelation), optionalGetterForProp(this.treeToRelation));
  5308. // recalculate sizes/etc
  5309. this.recalculate();
  5310. if (this._rows && this._groupRowsBy) {
  5311. // If a column has been specified in _groupRowsBy created a new array with the data grouped by that row
  5312. this.groupedRows = this.groupArrayBy(this._rows, this._groupRowsBy);
  5313. }
  5314. this.cd.markForCheck();
  5315. },
  5316. enumerable: true,
  5317. configurable: true
  5318. });
  5319. Object.defineProperty(DatatableComponent.prototype, "groupRowsBy", {
  5320. get: /**
  5321. * @return {?}
  5322. */
  5323. function () {
  5324. return this._groupRowsBy;
  5325. },
  5326. /**
  5327. * This attribute allows the user to set the name of the column to group the data with
  5328. */
  5329. set: /**
  5330. * This attribute allows the user to set the name of the column to group the data with
  5331. * @param {?} val
  5332. * @return {?}
  5333. */
  5334. function (val) {
  5335. if (val) {
  5336. this._groupRowsBy = val;
  5337. if (this._rows && this._groupRowsBy) {
  5338. // cretes a new array with the data grouped
  5339. this.groupedRows = this.groupArrayBy(this._rows, this._groupRowsBy);
  5340. }
  5341. }
  5342. },
  5343. enumerable: true,
  5344. configurable: true
  5345. });
  5346. Object.defineProperty(DatatableComponent.prototype, "columns", {
  5347. /**
  5348. * Get the columns.
  5349. */
  5350. get: /**
  5351. * Get the columns.
  5352. * @return {?}
  5353. */
  5354. function () {
  5355. return this._columns;
  5356. },
  5357. /**
  5358. * Columns to be displayed.
  5359. */
  5360. set: /**
  5361. * Columns to be displayed.
  5362. * @param {?} val
  5363. * @return {?}
  5364. */
  5365. function (val) {
  5366. if (val) {
  5367. this._internalColumns = __spread(val);
  5368. setColumnDefaults(this._internalColumns);
  5369. this.recalculateColumns();
  5370. }
  5371. this._columns = val;
  5372. },
  5373. enumerable: true,
  5374. configurable: true
  5375. });
  5376. Object.defineProperty(DatatableComponent.prototype, "limit", {
  5377. /**
  5378. * Gets the limit.
  5379. */
  5380. get: /**
  5381. * Gets the limit.
  5382. * @return {?}
  5383. */
  5384. function () {
  5385. return this._limit;
  5386. },
  5387. /**
  5388. * The page size to be shown.
  5389. * Default value: `undefined`
  5390. */
  5391. set: /**
  5392. * The page size to be shown.
  5393. * Default value: `undefined`
  5394. * @param {?} val
  5395. * @return {?}
  5396. */
  5397. function (val) {
  5398. this._limit = val;
  5399. // recalculate sizes/etc
  5400. this.recalculate();
  5401. },
  5402. enumerable: true,
  5403. configurable: true
  5404. });
  5405. Object.defineProperty(DatatableComponent.prototype, "count", {
  5406. /**
  5407. * Gets the count.
  5408. */
  5409. get: /**
  5410. * Gets the count.
  5411. * @return {?}
  5412. */
  5413. function () {
  5414. return this._count;
  5415. },
  5416. /**
  5417. * The total count of all rows.
  5418. * Default value: `0`
  5419. */
  5420. set: /**
  5421. * The total count of all rows.
  5422. * Default value: `0`
  5423. * @param {?} val
  5424. * @return {?}
  5425. */
  5426. function (val) {
  5427. this._count = val;
  5428. // recalculate sizes/etc
  5429. this.recalculate();
  5430. },
  5431. enumerable: true,
  5432. configurable: true
  5433. });
  5434. Object.defineProperty(DatatableComponent.prototype, "offset", {
  5435. get: /**
  5436. * @return {?}
  5437. */
  5438. function () {
  5439. return Math.max(Math.min(this._offset, Math.ceil(this.rowCount / this.pageSize) - 1), 0);
  5440. },
  5441. /**
  5442. * The current offset ( page - 1 ) shown.
  5443. * Default value: `0`
  5444. */
  5445. set: /**
  5446. * The current offset ( page - 1 ) shown.
  5447. * Default value: `0`
  5448. * @param {?} val
  5449. * @return {?}
  5450. */
  5451. function (val) {
  5452. this._offset = val;
  5453. },
  5454. enumerable: true,
  5455. configurable: true
  5456. });
  5457. Object.defineProperty(DatatableComponent.prototype, "isFixedHeader", {
  5458. /**
  5459. * CSS class applied if the header height if fixed height.
  5460. */
  5461. get: /**
  5462. * CSS class applied if the header height if fixed height.
  5463. * @return {?}
  5464. */
  5465. function () {
  5466. /** @type {?} */
  5467. var headerHeight = this.headerHeight;
  5468. return typeof headerHeight === 'string' ? (/** @type {?} */ (headerHeight)) !== 'auto' : true;
  5469. },
  5470. enumerable: true,
  5471. configurable: true
  5472. });
  5473. Object.defineProperty(DatatableComponent.prototype, "isFixedRow", {
  5474. /**
  5475. * CSS class applied to the root element if
  5476. * the row heights are fixed heights.
  5477. */
  5478. get: /**
  5479. * CSS class applied to the root element if
  5480. * the row heights are fixed heights.
  5481. * @return {?}
  5482. */
  5483. function () {
  5484. return this.rowHeight !== 'auto';
  5485. },
  5486. enumerable: true,
  5487. configurable: true
  5488. });
  5489. Object.defineProperty(DatatableComponent.prototype, "isVertScroll", {
  5490. /**
  5491. * CSS class applied to root element if
  5492. * vertical scrolling is enabled.
  5493. */
  5494. get: /**
  5495. * CSS class applied to root element if
  5496. * vertical scrolling is enabled.
  5497. * @return {?}
  5498. */
  5499. function () {
  5500. return this.scrollbarV;
  5501. },
  5502. enumerable: true,
  5503. configurable: true
  5504. });
  5505. Object.defineProperty(DatatableComponent.prototype, "isVirtualized", {
  5506. /**
  5507. * CSS class applied to root element if
  5508. * virtualization is enabled.
  5509. */
  5510. get: /**
  5511. * CSS class applied to root element if
  5512. * virtualization is enabled.
  5513. * @return {?}
  5514. */
  5515. function () {
  5516. return this.virtualization;
  5517. },
  5518. enumerable: true,
  5519. configurable: true
  5520. });
  5521. Object.defineProperty(DatatableComponent.prototype, "isHorScroll", {
  5522. /**
  5523. * CSS class applied to the root element
  5524. * if the horziontal scrolling is enabled.
  5525. */
  5526. get: /**
  5527. * CSS class applied to the root element
  5528. * if the horziontal scrolling is enabled.
  5529. * @return {?}
  5530. */
  5531. function () {
  5532. return this.scrollbarH;
  5533. },
  5534. enumerable: true,
  5535. configurable: true
  5536. });
  5537. Object.defineProperty(DatatableComponent.prototype, "isSelectable", {
  5538. /**
  5539. * CSS class applied to root element is selectable.
  5540. */
  5541. get: /**
  5542. * CSS class applied to root element is selectable.
  5543. * @return {?}
  5544. */
  5545. function () {
  5546. return this.selectionType !== undefined;
  5547. },
  5548. enumerable: true,
  5549. configurable: true
  5550. });
  5551. Object.defineProperty(DatatableComponent.prototype, "isCheckboxSelection", {
  5552. /**
  5553. * CSS class applied to root is checkbox selection.
  5554. */
  5555. get: /**
  5556. * CSS class applied to root is checkbox selection.
  5557. * @return {?}
  5558. */
  5559. function () {
  5560. return this.selectionType === SelectionType.checkbox;
  5561. },
  5562. enumerable: true,
  5563. configurable: true
  5564. });
  5565. Object.defineProperty(DatatableComponent.prototype, "isCellSelection", {
  5566. /**
  5567. * CSS class applied to root if cell selection.
  5568. */
  5569. get: /**
  5570. * CSS class applied to root if cell selection.
  5571. * @return {?}
  5572. */
  5573. function () {
  5574. return this.selectionType === SelectionType.cell;
  5575. },
  5576. enumerable: true,
  5577. configurable: true
  5578. });
  5579. Object.defineProperty(DatatableComponent.prototype, "isSingleSelection", {
  5580. /**
  5581. * CSS class applied to root if single select.
  5582. */
  5583. get: /**
  5584. * CSS class applied to root if single select.
  5585. * @return {?}
  5586. */
  5587. function () {
  5588. return this.selectionType === SelectionType.single;
  5589. },
  5590. enumerable: true,
  5591. configurable: true
  5592. });
  5593. Object.defineProperty(DatatableComponent.prototype, "isMultiSelection", {
  5594. /**
  5595. * CSS class added to root element if mulit select
  5596. */
  5597. get: /**
  5598. * CSS class added to root element if mulit select
  5599. * @return {?}
  5600. */
  5601. function () {
  5602. return this.selectionType === SelectionType.multi;
  5603. },
  5604. enumerable: true,
  5605. configurable: true
  5606. });
  5607. Object.defineProperty(DatatableComponent.prototype, "isMultiClickSelection", {
  5608. /**
  5609. * CSS class added to root element if mulit click select
  5610. */
  5611. get: /**
  5612. * CSS class added to root element if mulit click select
  5613. * @return {?}
  5614. */
  5615. function () {
  5616. return this.selectionType === SelectionType.multiClick;
  5617. },
  5618. enumerable: true,
  5619. configurable: true
  5620. });
  5621. Object.defineProperty(DatatableComponent.prototype, "columnTemplates", {
  5622. /**
  5623. * Returns the column templates.
  5624. */
  5625. get: /**
  5626. * Returns the column templates.
  5627. * @return {?}
  5628. */
  5629. function () {
  5630. return this._columnTemplates;
  5631. },
  5632. /**
  5633. * Column templates gathered from `ContentChildren`
  5634. * if described in your markup.
  5635. */
  5636. set: /**
  5637. * Column templates gathered from `ContentChildren`
  5638. * if described in your markup.
  5639. * @param {?} val
  5640. * @return {?}
  5641. */
  5642. function (val) {
  5643. this._columnTemplates = val;
  5644. this.translateColumns(val);
  5645. },
  5646. enumerable: true,
  5647. configurable: true
  5648. });
  5649. Object.defineProperty(DatatableComponent.prototype, "allRowsSelected", {
  5650. /**
  5651. * Returns if all rows are selected.
  5652. */
  5653. get: /**
  5654. * Returns if all rows are selected.
  5655. * @return {?}
  5656. */
  5657. function () {
  5658. /** @type {?} */
  5659. var allRowsSelected = this.rows && this.selected && this.selected.length === this.rows.length;
  5660. if (this.selectAllRowsOnPage) {
  5661. /** @type {?} */
  5662. var indexes = this.bodyComponent.indexes;
  5663. /** @type {?} */
  5664. var rowsOnPage = indexes.last - indexes.first;
  5665. allRowsSelected = this.selected.length === rowsOnPage;
  5666. }
  5667. return this.selected && this.rows && this.rows.length !== 0 && allRowsSelected;
  5668. },
  5669. enumerable: true,
  5670. configurable: true
  5671. });
  5672. /**
  5673. * Lifecycle hook that is called after data-bound
  5674. * properties of a directive are initialized.
  5675. */
  5676. /**
  5677. * Lifecycle hook that is called after data-bound
  5678. * properties of a directive are initialized.
  5679. * @return {?}
  5680. */
  5681. DatatableComponent.prototype.ngOnInit = /**
  5682. * Lifecycle hook that is called after data-bound
  5683. * properties of a directive are initialized.
  5684. * @return {?}
  5685. */
  5686. function () {
  5687. // need to call this immediatly to size
  5688. // if the table is hidden the visibility
  5689. // listener will invoke this itself upon show
  5690. this.recalculate();
  5691. };
  5692. /**
  5693. * Lifecycle hook that is called after a component's
  5694. * view has been fully initialized.
  5695. */
  5696. /**
  5697. * Lifecycle hook that is called after a component's
  5698. * view has been fully initialized.
  5699. * @return {?}
  5700. */
  5701. DatatableComponent.prototype.ngAfterViewInit = /**
  5702. * Lifecycle hook that is called after a component's
  5703. * view has been fully initialized.
  5704. * @return {?}
  5705. */
  5706. function () {
  5707. var _this = this;
  5708. if (!this.externalSorting) {
  5709. this.sortInternalRows();
  5710. }
  5711. // this has to be done to prevent the change detection
  5712. // tree from freaking out because we are readjusting
  5713. if (typeof requestAnimationFrame === 'undefined') {
  5714. return;
  5715. }
  5716. requestAnimationFrame((/**
  5717. * @return {?}
  5718. */
  5719. function () {
  5720. _this.recalculate();
  5721. // emit page for virtual server-side kickoff
  5722. if (_this.externalPaging && _this.scrollbarV) {
  5723. _this.page.emit({
  5724. count: _this.count,
  5725. pageSize: _this.pageSize,
  5726. limit: _this.limit,
  5727. offset: 0
  5728. });
  5729. }
  5730. }));
  5731. };
  5732. /**
  5733. * Lifecycle hook that is called after a component's
  5734. * content has been fully initialized.
  5735. */
  5736. /**
  5737. * Lifecycle hook that is called after a component's
  5738. * content has been fully initialized.
  5739. * @return {?}
  5740. */
  5741. DatatableComponent.prototype.ngAfterContentInit = /**
  5742. * Lifecycle hook that is called after a component's
  5743. * content has been fully initialized.
  5744. * @return {?}
  5745. */
  5746. function () {
  5747. var _this = this;
  5748. this.columnTemplates.changes.subscribe((/**
  5749. * @param {?} v
  5750. * @return {?}
  5751. */
  5752. function (v) { return _this.translateColumns(v); }));
  5753. this.listenForColumnInputChanges();
  5754. };
  5755. /**
  5756. * Translates the templates to the column objects
  5757. */
  5758. /**
  5759. * Translates the templates to the column objects
  5760. * @param {?} val
  5761. * @return {?}
  5762. */
  5763. DatatableComponent.prototype.translateColumns = /**
  5764. * Translates the templates to the column objects
  5765. * @param {?} val
  5766. * @return {?}
  5767. */
  5768. function (val) {
  5769. if (val) {
  5770. /** @type {?} */
  5771. var arr = val.toArray();
  5772. if (arr.length) {
  5773. this._internalColumns = translateTemplates(arr);
  5774. setColumnDefaults(this._internalColumns);
  5775. this.recalculateColumns();
  5776. this.sortInternalRows();
  5777. this.cd.markForCheck();
  5778. }
  5779. }
  5780. };
  5781. /**
  5782. * Creates a map with the data grouped by the user choice of grouping index
  5783. *
  5784. * @param originalArray the original array passed via parameter
  5785. * @param groupByIndex the index of the column to group the data by
  5786. */
  5787. /**
  5788. * Creates a map with the data grouped by the user choice of grouping index
  5789. *
  5790. * @param {?} originalArray the original array passed via parameter
  5791. * @param {?} groupBy
  5792. * @return {?}
  5793. */
  5794. DatatableComponent.prototype.groupArrayBy = /**
  5795. * Creates a map with the data grouped by the user choice of grouping index
  5796. *
  5797. * @param {?} originalArray the original array passed via parameter
  5798. * @param {?} groupBy
  5799. * @return {?}
  5800. */
  5801. function (originalArray, groupBy) {
  5802. // create a map to hold groups with their corresponding results
  5803. /** @type {?} */
  5804. var map = new Map();
  5805. /** @type {?} */
  5806. var i = 0;
  5807. originalArray.forEach((/**
  5808. * @param {?} item
  5809. * @return {?}
  5810. */
  5811. function (item) {
  5812. /** @type {?} */
  5813. var key = item[groupBy];
  5814. if (!map.has(key)) {
  5815. map.set(key, [item]);
  5816. }
  5817. else {
  5818. map.get(key).push(item);
  5819. }
  5820. i++;
  5821. }));
  5822. /** @type {?} */
  5823. var addGroup = (/**
  5824. * @param {?} key
  5825. * @param {?} value
  5826. * @return {?}
  5827. */
  5828. function (key, value) {
  5829. return { key: key, value: value };
  5830. });
  5831. // convert map back to a simple array of objects
  5832. return Array.from(map, (/**
  5833. * @param {?} x
  5834. * @return {?}
  5835. */
  5836. function (x) { return addGroup(x[0], x[1]); }));
  5837. };
  5838. /*
  5839. * Lifecycle hook that is called when Angular dirty checks a directive.
  5840. */
  5841. /*
  5842. * Lifecycle hook that is called when Angular dirty checks a directive.
  5843. */
  5844. /**
  5845. * @return {?}
  5846. */
  5847. DatatableComponent.prototype.ngDoCheck = /*
  5848. * Lifecycle hook that is called when Angular dirty checks a directive.
  5849. */
  5850. /**
  5851. * @return {?}
  5852. */
  5853. function () {
  5854. if (this.rowDiffer.diff(this.rows)) {
  5855. if (!this.externalSorting) {
  5856. this.sortInternalRows();
  5857. }
  5858. else {
  5859. this._internalRows = __spread(this.rows);
  5860. }
  5861. // auto group by parent on new update
  5862. this._internalRows = groupRowsByParents(this._internalRows, optionalGetterForProp(this.treeFromRelation), optionalGetterForProp(this.treeToRelation));
  5863. this.recalculatePages();
  5864. this.cd.markForCheck();
  5865. }
  5866. };
  5867. /**
  5868. * Recalc's the sizes of the grid.
  5869. *
  5870. * Updated automatically on changes to:
  5871. *
  5872. * - Columns
  5873. * - Rows
  5874. * - Paging related
  5875. *
  5876. * Also can be manually invoked or upon window resize.
  5877. */
  5878. /**
  5879. * Recalc's the sizes of the grid.
  5880. *
  5881. * Updated automatically on changes to:
  5882. *
  5883. * - Columns
  5884. * - Rows
  5885. * - Paging related
  5886. *
  5887. * Also can be manually invoked or upon window resize.
  5888. * @return {?}
  5889. */
  5890. DatatableComponent.prototype.recalculate = /**
  5891. * Recalc's the sizes of the grid.
  5892. *
  5893. * Updated automatically on changes to:
  5894. *
  5895. * - Columns
  5896. * - Rows
  5897. * - Paging related
  5898. *
  5899. * Also can be manually invoked or upon window resize.
  5900. * @return {?}
  5901. */
  5902. function () {
  5903. this.recalculateDims();
  5904. this.recalculateColumns();
  5905. };
  5906. /**
  5907. * Window resize handler to update sizes.
  5908. */
  5909. /**
  5910. * Window resize handler to update sizes.
  5911. * @return {?}
  5912. */
  5913. DatatableComponent.prototype.onWindowResize = /**
  5914. * Window resize handler to update sizes.
  5915. * @return {?}
  5916. */
  5917. function () {
  5918. this.recalculate();
  5919. };
  5920. /**
  5921. * Recalulcates the column widths based on column width
  5922. * distribution mode and scrollbar offsets.
  5923. */
  5924. /**
  5925. * Recalulcates the column widths based on column width
  5926. * distribution mode and scrollbar offsets.
  5927. * @param {?=} columns
  5928. * @param {?=} forceIdx
  5929. * @param {?=} allowBleed
  5930. * @return {?}
  5931. */
  5932. DatatableComponent.prototype.recalculateColumns = /**
  5933. * Recalulcates the column widths based on column width
  5934. * distribution mode and scrollbar offsets.
  5935. * @param {?=} columns
  5936. * @param {?=} forceIdx
  5937. * @param {?=} allowBleed
  5938. * @return {?}
  5939. */
  5940. function (columns, forceIdx, allowBleed) {
  5941. if (columns === void 0) { columns = this._internalColumns; }
  5942. if (forceIdx === void 0) { forceIdx = -1; }
  5943. if (allowBleed === void 0) { allowBleed = this.scrollbarH; }
  5944. if (!columns)
  5945. return undefined;
  5946. /** @type {?} */
  5947. var width = this._innerWidth;
  5948. if (this.scrollbarV) {
  5949. width = width - this.scrollbarHelper.width;
  5950. }
  5951. if (this.columnMode === ColumnMode.force) {
  5952. forceFillColumnWidths(columns, width, forceIdx, allowBleed);
  5953. }
  5954. else if (this.columnMode === ColumnMode.flex) {
  5955. adjustColumnWidths(columns, width);
  5956. }
  5957. return columns;
  5958. };
  5959. /**
  5960. * Recalculates the dimensions of the table size.
  5961. * Internally calls the page size and row count calcs too.
  5962. *
  5963. */
  5964. /**
  5965. * Recalculates the dimensions of the table size.
  5966. * Internally calls the page size and row count calcs too.
  5967. *
  5968. * @return {?}
  5969. */
  5970. DatatableComponent.prototype.recalculateDims = /**
  5971. * Recalculates the dimensions of the table size.
  5972. * Internally calls the page size and row count calcs too.
  5973. *
  5974. * @return {?}
  5975. */
  5976. function () {
  5977. /** @type {?} */
  5978. var dims = this.dimensionsHelper.getDimensions(this.element);
  5979. this._innerWidth = Math.floor(dims.width);
  5980. if (this.scrollbarV) {
  5981. /** @type {?} */
  5982. var height = dims.height;
  5983. if (this.headerHeight)
  5984. height = height - this.headerHeight;
  5985. if (this.footerHeight)
  5986. height = height - this.footerHeight;
  5987. this.bodyHeight = height;
  5988. }
  5989. this.recalculatePages();
  5990. };
  5991. /**
  5992. * Recalculates the pages after a update.
  5993. */
  5994. /**
  5995. * Recalculates the pages after a update.
  5996. * @return {?}
  5997. */
  5998. DatatableComponent.prototype.recalculatePages = /**
  5999. * Recalculates the pages after a update.
  6000. * @return {?}
  6001. */
  6002. function () {
  6003. this.pageSize = this.calcPageSize();
  6004. this.rowCount = this.calcRowCount();
  6005. };
  6006. /**
  6007. * Body triggered a page event.
  6008. */
  6009. /**
  6010. * Body triggered a page event.
  6011. * @param {?} __0
  6012. * @return {?}
  6013. */
  6014. DatatableComponent.prototype.onBodyPage = /**
  6015. * Body triggered a page event.
  6016. * @param {?} __0
  6017. * @return {?}
  6018. */
  6019. function (_a) {
  6020. var offset = _a.offset;
  6021. // Avoid pagination caming from body events like scroll when the table
  6022. // has no virtualization and the external paging is enable.
  6023. // This means, let's the developer handle pagination by my him(her) self
  6024. if (this.externalPaging && !this.virtualization) {
  6025. return;
  6026. }
  6027. this.offset = offset;
  6028. this.page.emit({
  6029. count: this.count,
  6030. pageSize: this.pageSize,
  6031. limit: this.limit,
  6032. offset: this.offset
  6033. });
  6034. };
  6035. /**
  6036. * The body triggered a scroll event.
  6037. */
  6038. /**
  6039. * The body triggered a scroll event.
  6040. * @param {?} event
  6041. * @return {?}
  6042. */
  6043. DatatableComponent.prototype.onBodyScroll = /**
  6044. * The body triggered a scroll event.
  6045. * @param {?} event
  6046. * @return {?}
  6047. */
  6048. function (event) {
  6049. this._offsetX.next(event.offsetX);
  6050. this.scroll.emit(event);
  6051. this.cd.detectChanges();
  6052. };
  6053. /**
  6054. * The footer triggered a page event.
  6055. */
  6056. /**
  6057. * The footer triggered a page event.
  6058. * @param {?} event
  6059. * @return {?}
  6060. */
  6061. DatatableComponent.prototype.onFooterPage = /**
  6062. * The footer triggered a page event.
  6063. * @param {?} event
  6064. * @return {?}
  6065. */
  6066. function (event) {
  6067. this.offset = event.page - 1;
  6068. this.bodyComponent.updateOffsetY(this.offset);
  6069. this.page.emit({
  6070. count: this.count,
  6071. pageSize: this.pageSize,
  6072. limit: this.limit,
  6073. offset: this.offset
  6074. });
  6075. if (this.selectAllRowsOnPage) {
  6076. this.selected = [];
  6077. this.select.emit({
  6078. selected: this.selected
  6079. });
  6080. }
  6081. };
  6082. /**
  6083. * Recalculates the sizes of the page
  6084. */
  6085. /**
  6086. * Recalculates the sizes of the page
  6087. * @param {?=} val
  6088. * @return {?}
  6089. */
  6090. DatatableComponent.prototype.calcPageSize = /**
  6091. * Recalculates the sizes of the page
  6092. * @param {?=} val
  6093. * @return {?}
  6094. */
  6095. function (val) {
  6096. if (val === void 0) { val = this.rows; }
  6097. // Keep the page size constant even if the row has been expanded.
  6098. // This is because an expanded row is still considered to be a child of
  6099. // the original row. Hence calculation would use rowHeight only.
  6100. if (this.scrollbarV && this.virtualization) {
  6101. /** @type {?} */
  6102. var size = Math.ceil(this.bodyHeight / ((/** @type {?} */ (this.rowHeight))));
  6103. return Math.max(size, 0);
  6104. }
  6105. // if limit is passed, we are paging
  6106. if (this.limit !== undefined) {
  6107. return this.limit;
  6108. }
  6109. // otherwise use row length
  6110. if (val) {
  6111. return val.length;
  6112. }
  6113. // other empty :(
  6114. return 0;
  6115. };
  6116. /**
  6117. * Calculates the row count.
  6118. */
  6119. /**
  6120. * Calculates the row count.
  6121. * @param {?=} val
  6122. * @return {?}
  6123. */
  6124. DatatableComponent.prototype.calcRowCount = /**
  6125. * Calculates the row count.
  6126. * @param {?=} val
  6127. * @return {?}
  6128. */
  6129. function (val) {
  6130. if (val === void 0) { val = this.rows; }
  6131. if (!this.externalPaging) {
  6132. if (!val)
  6133. return 0;
  6134. if (this.groupedRows) {
  6135. return this.groupedRows.length;
  6136. }
  6137. else if (this.treeFromRelation != null && this.treeToRelation != null) {
  6138. return this._internalRows.length;
  6139. }
  6140. else {
  6141. return val.length;
  6142. }
  6143. }
  6144. return this.count;
  6145. };
  6146. /**
  6147. * The header triggered a contextmenu event.
  6148. */
  6149. /**
  6150. * The header triggered a contextmenu event.
  6151. * @param {?} __0
  6152. * @return {?}
  6153. */
  6154. DatatableComponent.prototype.onColumnContextmenu = /**
  6155. * The header triggered a contextmenu event.
  6156. * @param {?} __0
  6157. * @return {?}
  6158. */
  6159. function (_a) {
  6160. var event = _a.event, column = _a.column;
  6161. this.tableContextmenu.emit({ event: event, type: ContextmenuType.header, content: column });
  6162. };
  6163. /**
  6164. * The body triggered a contextmenu event.
  6165. */
  6166. /**
  6167. * The body triggered a contextmenu event.
  6168. * @param {?} __0
  6169. * @return {?}
  6170. */
  6171. DatatableComponent.prototype.onRowContextmenu = /**
  6172. * The body triggered a contextmenu event.
  6173. * @param {?} __0
  6174. * @return {?}
  6175. */
  6176. function (_a) {
  6177. var event = _a.event, row = _a.row;
  6178. this.tableContextmenu.emit({ event: event, type: ContextmenuType.body, content: row });
  6179. };
  6180. /**
  6181. * The header triggered a column resize event.
  6182. */
  6183. /**
  6184. * The header triggered a column resize event.
  6185. * @param {?} __0
  6186. * @return {?}
  6187. */
  6188. DatatableComponent.prototype.onColumnResize = /**
  6189. * The header triggered a column resize event.
  6190. * @param {?} __0
  6191. * @return {?}
  6192. */
  6193. function (_a) {
  6194. var column = _a.column, newValue = _a.newValue;
  6195. /* Safari/iOS 10.2 workaround */
  6196. if (column === undefined) {
  6197. return;
  6198. }
  6199. /** @type {?} */
  6200. var idx;
  6201. /** @type {?} */
  6202. var cols = this._internalColumns.map((/**
  6203. * @param {?} c
  6204. * @param {?} i
  6205. * @return {?}
  6206. */
  6207. function (c, i) {
  6208. c = __assign({}, c);
  6209. if (c.$$id === column.$$id) {
  6210. idx = i;
  6211. c.width = newValue;
  6212. // set this so we can force the column
  6213. // width distribution to be to this value
  6214. c.$$oldWidth = newValue;
  6215. }
  6216. return c;
  6217. }));
  6218. this.recalculateColumns(cols, idx);
  6219. this._internalColumns = cols;
  6220. this.resize.emit({
  6221. column: column,
  6222. newValue: newValue
  6223. });
  6224. };
  6225. /**
  6226. * The header triggered a column re-order event.
  6227. */
  6228. /**
  6229. * The header triggered a column re-order event.
  6230. * @param {?} __0
  6231. * @return {?}
  6232. */
  6233. DatatableComponent.prototype.onColumnReorder = /**
  6234. * The header triggered a column re-order event.
  6235. * @param {?} __0
  6236. * @return {?}
  6237. */
  6238. function (_a) {
  6239. var column = _a.column, newValue = _a.newValue, prevValue = _a.prevValue;
  6240. /** @type {?} */
  6241. var cols = this._internalColumns.map((/**
  6242. * @param {?} c
  6243. * @return {?}
  6244. */
  6245. function (c) {
  6246. return __assign({}, c);
  6247. }));
  6248. if (this.swapColumns) {
  6249. /** @type {?} */
  6250. var prevCol = cols[newValue];
  6251. cols[newValue] = column;
  6252. cols[prevValue] = prevCol;
  6253. }
  6254. else {
  6255. if (newValue > prevValue) {
  6256. /** @type {?} */
  6257. var movedCol = cols[prevValue];
  6258. for (var i = prevValue; i < newValue; i++) {
  6259. cols[i] = cols[i + 1];
  6260. }
  6261. cols[newValue] = movedCol;
  6262. }
  6263. else {
  6264. /** @type {?} */
  6265. var movedCol = cols[prevValue];
  6266. for (var i = prevValue; i > newValue; i--) {
  6267. cols[i] = cols[i - 1];
  6268. }
  6269. cols[newValue] = movedCol;
  6270. }
  6271. }
  6272. this._internalColumns = cols;
  6273. this.reorder.emit({
  6274. column: column,
  6275. newValue: newValue,
  6276. prevValue: prevValue
  6277. });
  6278. };
  6279. /**
  6280. * The header triggered a column sort event.
  6281. */
  6282. /**
  6283. * The header triggered a column sort event.
  6284. * @param {?} event
  6285. * @return {?}
  6286. */
  6287. DatatableComponent.prototype.onColumnSort = /**
  6288. * The header triggered a column sort event.
  6289. * @param {?} event
  6290. * @return {?}
  6291. */
  6292. function (event) {
  6293. // clean selected rows
  6294. if (this.selectAllRowsOnPage) {
  6295. this.selected = [];
  6296. this.select.emit({
  6297. selected: this.selected
  6298. });
  6299. }
  6300. this.sorts = event.sorts;
  6301. // this could be optimized better since it will resort
  6302. // the rows again on the 'push' detection...
  6303. if (this.externalSorting === false) {
  6304. // don't use normal setter so we don't resort
  6305. this.sortInternalRows();
  6306. }
  6307. // auto group by parent on new update
  6308. this._internalRows = groupRowsByParents(this._internalRows, optionalGetterForProp(this.treeFromRelation), optionalGetterForProp(this.treeToRelation));
  6309. // Always go to first page when sorting to see the newly sorted data
  6310. this.offset = 0;
  6311. this.bodyComponent.updateOffsetY(this.offset);
  6312. this.sort.emit(event);
  6313. };
  6314. /**
  6315. * Toggle all row selection
  6316. */
  6317. /**
  6318. * Toggle all row selection
  6319. * @param {?} event
  6320. * @return {?}
  6321. */
  6322. DatatableComponent.prototype.onHeaderSelect = /**
  6323. * Toggle all row selection
  6324. * @param {?} event
  6325. * @return {?}
  6326. */
  6327. function (event) {
  6328. var _a, _b;
  6329. if (this.selectAllRowsOnPage) {
  6330. // before we splice, chk if we currently have all selected
  6331. /** @type {?} */
  6332. var first = this.bodyComponent.indexes.first;
  6333. /** @type {?} */
  6334. var last = this.bodyComponent.indexes.last;
  6335. /** @type {?} */
  6336. var allSelected = this.selected.length === last - first;
  6337. // remove all existing either way
  6338. this.selected = [];
  6339. // do the opposite here
  6340. if (!allSelected) {
  6341. (_a = this.selected).push.apply(_a, __spread(this._internalRows.slice(first, last)));
  6342. }
  6343. }
  6344. else {
  6345. // before we splice, chk if we currently have all selected
  6346. /** @type {?} */
  6347. var allSelected = this.selected.length === this.rows.length;
  6348. // remove all existing either way
  6349. this.selected = [];
  6350. // do the opposite here
  6351. if (!allSelected) {
  6352. (_b = this.selected).push.apply(_b, __spread(this.rows));
  6353. }
  6354. }
  6355. this.select.emit({
  6356. selected: this.selected
  6357. });
  6358. };
  6359. /**
  6360. * A row was selected from body
  6361. */
  6362. /**
  6363. * A row was selected from body
  6364. * @param {?} event
  6365. * @return {?}
  6366. */
  6367. DatatableComponent.prototype.onBodySelect = /**
  6368. * A row was selected from body
  6369. * @param {?} event
  6370. * @return {?}
  6371. */
  6372. function (event) {
  6373. this.select.emit(event);
  6374. };
  6375. /**
  6376. * A row was expanded or collapsed for tree
  6377. */
  6378. /**
  6379. * A row was expanded or collapsed for tree
  6380. * @param {?} event
  6381. * @return {?}
  6382. */
  6383. DatatableComponent.prototype.onTreeAction = /**
  6384. * A row was expanded or collapsed for tree
  6385. * @param {?} event
  6386. * @return {?}
  6387. */
  6388. function (event) {
  6389. var _this = this;
  6390. /** @type {?} */
  6391. var row = event.row;
  6392. // TODO: For duplicated items this will not work
  6393. /** @type {?} */
  6394. var rowIndex = this._rows.findIndex((/**
  6395. * @param {?} r
  6396. * @return {?}
  6397. */
  6398. function (r) { return r[_this.treeToRelation] === event.row[_this.treeToRelation]; }));
  6399. this.treeAction.emit({ row: row, rowIndex: rowIndex });
  6400. };
  6401. /**
  6402. * @return {?}
  6403. */
  6404. DatatableComponent.prototype.ngOnDestroy = /**
  6405. * @return {?}
  6406. */
  6407. function () {
  6408. this._subscriptions.forEach((/**
  6409. * @param {?} subscription
  6410. * @return {?}
  6411. */
  6412. function (subscription) { return subscription.unsubscribe(); }));
  6413. };
  6414. /**
  6415. * listen for changes to input bindings of all DataTableColumnDirective and
  6416. * trigger the columnTemplates.changes observable to emit
  6417. */
  6418. /**
  6419. * listen for changes to input bindings of all DataTableColumnDirective and
  6420. * trigger the columnTemplates.changes observable to emit
  6421. * @private
  6422. * @return {?}
  6423. */
  6424. DatatableComponent.prototype.listenForColumnInputChanges = /**
  6425. * listen for changes to input bindings of all DataTableColumnDirective and
  6426. * trigger the columnTemplates.changes observable to emit
  6427. * @private
  6428. * @return {?}
  6429. */
  6430. function () {
  6431. var _this = this;
  6432. this._subscriptions.push(this.columnChangesService.columnInputChanges$.subscribe((/**
  6433. * @return {?}
  6434. */
  6435. function () {
  6436. if (_this.columnTemplates) {
  6437. _this.columnTemplates.notifyOnChanges();
  6438. }
  6439. })));
  6440. };
  6441. /**
  6442. * @private
  6443. * @return {?}
  6444. */
  6445. DatatableComponent.prototype.sortInternalRows = /**
  6446. * @private
  6447. * @return {?}
  6448. */
  6449. function () {
  6450. this._internalRows = sortRows(this._internalRows, this._internalColumns, this.sorts);
  6451. };
  6452. DatatableComponent.decorators = [
  6453. { type: Component, args: [{
  6454. selector: 'ngx-datatable',
  6455. template: "<div visibilityObserver (visible)=\"recalculate()\">\n <datatable-header\n *ngIf=\"headerHeight\"\n [sorts]=\"sorts\"\n [sortType]=\"sortType\"\n [scrollbarH]=\"scrollbarH\"\n [innerWidth]=\"_innerWidth\"\n [offsetX]=\"_offsetX | async\"\n [dealsWithGroup]=\"groupedRows !== undefined\"\n [columns]=\"_internalColumns\"\n [headerHeight]=\"headerHeight\"\n [reorderable]=\"reorderable\"\n [targetMarkerTemplate]=\"targetMarkerTemplate\"\n [sortAscendingIcon]=\"cssClasses.sortAscending\"\n [sortDescendingIcon]=\"cssClasses.sortDescending\"\n [allRowsSelected]=\"allRowsSelected\"\n [selectionType]=\"selectionType\"\n (sort)=\"onColumnSort($event)\"\n (resize)=\"onColumnResize($event)\"\n (reorder)=\"onColumnReorder($event)\"\n (select)=\"onHeaderSelect($event)\"\n (columnContextmenu)=\"onColumnContextmenu($event)\"\n >\n </datatable-header>\n <datatable-body\n [groupRowsBy]=\"groupRowsBy\"\n [groupedRows]=\"groupedRows\"\n [rows]=\"_internalRows\"\n [groupExpansionDefault]=\"groupExpansionDefault\"\n [scrollbarV]=\"scrollbarV\"\n [scrollbarH]=\"scrollbarH\"\n [virtualization]=\"virtualization\"\n [loadingIndicator]=\"loadingIndicator\"\n [externalPaging]=\"externalPaging\"\n [rowHeight]=\"rowHeight\"\n [rowCount]=\"rowCount\"\n [offset]=\"offset\"\n [trackByProp]=\"trackByProp\"\n [columns]=\"_internalColumns\"\n [pageSize]=\"pageSize\"\n [offsetX]=\"_offsetX | async\"\n [rowDetail]=\"rowDetail\"\n [groupHeader]=\"groupHeader\"\n [selected]=\"selected\"\n [innerWidth]=\"_innerWidth\"\n [bodyHeight]=\"bodyHeight\"\n [selectionType]=\"selectionType\"\n [emptyMessage]=\"messages.emptyMessage\"\n [rowIdentity]=\"rowIdentity\"\n [rowClass]=\"rowClass\"\n [selectCheck]=\"selectCheck\"\n [displayCheck]=\"displayCheck\"\n [summaryRow]=\"summaryRow\"\n [summaryHeight]=\"summaryHeight\"\n [summaryPosition]=\"summaryPosition\"\n (page)=\"onBodyPage($event)\"\n (activate)=\"activate.emit($event)\"\n (rowContextmenu)=\"onRowContextmenu($event)\"\n (select)=\"onBodySelect($event)\"\n (scroll)=\"onBodyScroll($event)\"\n (treeAction)=\"onTreeAction($event)\"\n >\n </datatable-body>\n <datatable-footer\n *ngIf=\"footerHeight\"\n [rowCount]=\"rowCount\"\n [pageSize]=\"pageSize\"\n [offset]=\"offset\"\n [footerHeight]=\"footerHeight\"\n [footerTemplate]=\"footer\"\n [totalMessage]=\"messages.totalMessage\"\n [pagerLeftArrowIcon]=\"cssClasses.pagerLeftArrow\"\n [pagerRightArrowIcon]=\"cssClasses.pagerRightArrow\"\n [pagerPreviousIcon]=\"cssClasses.pagerPrevious\"\n [selectedCount]=\"selected.length\"\n [selectedMessage]=\"!!selectionType && messages.selectedMessage\"\n [pagerNextIcon]=\"cssClasses.pagerNext\"\n (page)=\"onFooterPage($event)\"\n >\n </datatable-footer>\n</div>\n",
  6456. changeDetection: ChangeDetectionStrategy.OnPush,
  6457. encapsulation: ViewEncapsulation.None,
  6458. host: {
  6459. class: 'ngx-datatable'
  6460. },
  6461. styles: [".ngx-datatable{display:block;overflow:hidden;justify-content:center;position:relative;-webkit-transform:translate3d(0,0,0)}.ngx-datatable [hidden]{display:none!important}.ngx-datatable *,.ngx-datatable :after,.ngx-datatable :before{box-sizing:border-box}.ngx-datatable.scroll-vertical .datatable-body{overflow-y:auto}.ngx-datatable.scroll-vertical.virtualized .datatable-body .datatable-row-wrapper{position:absolute}.ngx-datatable.scroll-horz .datatable-body{overflow-x:auto;-webkit-overflow-scrolling:touch}.ngx-datatable.fixed-header .datatable-header .datatable-header-inner{white-space:nowrap}.ngx-datatable.fixed-header .datatable-header .datatable-header-inner .datatable-header-cell{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.ngx-datatable.fixed-row .datatable-scroll,.ngx-datatable.fixed-row .datatable-scroll .datatable-body-row{white-space:nowrap}.ngx-datatable.fixed-row .datatable-scroll .datatable-body-row .datatable-body-cell,.ngx-datatable.fixed-row .datatable-scroll .datatable-body-row .datatable-body-group-cell{overflow:hidden;white-space:nowrap;text-overflow:ellipsis}.ngx-datatable .datatable-body-row,.ngx-datatable .datatable-header-inner,.ngx-datatable .datatable-row-center{display:flex;flex-direction:row;-o-flex-flow:row;flex-flow:row}.ngx-datatable .datatable-body-cell,.ngx-datatable .datatable-header-cell{overflow-x:hidden;vertical-align:top;display:inline-block;line-height:1.625}.ngx-datatable .datatable-body-cell:focus,.ngx-datatable .datatable-header-cell:focus{outline:0}.ngx-datatable .datatable-row-left,.ngx-datatable .datatable-row-right{z-index:9}.ngx-datatable .datatable-row-center,.ngx-datatable .datatable-row-group,.ngx-datatable .datatable-row-left,.ngx-datatable .datatable-row-right{position:relative}.ngx-datatable .datatable-header{display:block;overflow:hidden}.ngx-datatable .datatable-header .datatable-header-inner{align-items:stretch;-webkit-align-items:stretch}.ngx-datatable .datatable-header .datatable-header-cell{position:relative;display:inline-block}.ngx-datatable .datatable-header .datatable-header-cell.sortable .datatable-header-cell-wrapper{cursor:pointer}.ngx-datatable .datatable-header .datatable-header-cell.longpress .datatable-header-cell-wrapper{cursor:move}.ngx-datatable .datatable-header .datatable-header-cell .sort-btn{line-height:100%;vertical-align:middle;display:inline-block;cursor:pointer}.ngx-datatable .datatable-header .datatable-header-cell .resize-handle,.ngx-datatable .datatable-header .datatable-header-cell .resize-handle--not-resizable{display:inline-block;position:absolute;right:0;top:0;bottom:0;width:5px;padding:0 4px;visibility:hidden}.ngx-datatable .datatable-header .datatable-header-cell .resize-handle{cursor:ew-resize}.ngx-datatable .datatable-header .datatable-header-cell.resizeable:hover .resize-handle,.ngx-datatable .datatable-header .datatable-header-cell:hover .resize-handle--not-resizable{visibility:visible}.ngx-datatable .datatable-header .datatable-header-cell .targetMarker{position:absolute;top:0;bottom:0}.ngx-datatable .datatable-header .datatable-header-cell .targetMarker.dragFromLeft{right:0}.ngx-datatable .datatable-header .datatable-header-cell .targetMarker.dragFromRight{left:0}.ngx-datatable .datatable-header .datatable-header-cell .datatable-header-cell-template-wrap{height:inherit}.ngx-datatable .datatable-body{position:relative;z-index:10;display:block}.ngx-datatable .datatable-body .datatable-scroll{display:inline-block}.ngx-datatable .datatable-body .datatable-row-detail{overflow-y:hidden}.ngx-datatable .datatable-body .datatable-row-wrapper{display:flex;flex-direction:column}.ngx-datatable .datatable-body .datatable-body-row{outline:0}.ngx-datatable .datatable-body .datatable-body-row>div{display:flex}.ngx-datatable .datatable-footer{display:block;width:100%;overflow:auto}.ngx-datatable .datatable-footer .datatable-footer-inner{display:flex;align-items:center;width:100%}.ngx-datatable .datatable-footer .selected-count .page-count{flex:1 1 40%}.ngx-datatable .datatable-footer .selected-count .datatable-pager{flex:1 1 60%}.ngx-datatable .datatable-footer .page-count{flex:1 1 20%}.ngx-datatable .datatable-footer .datatable-pager{flex:1 1 80%;text-align:right}.ngx-datatable .datatable-footer .datatable-pager .pager,.ngx-datatable .datatable-footer .datatable-pager .pager li{padding:0;margin:0;display:inline-block;list-style:none}.ngx-datatable .datatable-footer .datatable-pager .pager li,.ngx-datatable .datatable-footer .datatable-pager .pager li a{outline:0}.ngx-datatable .datatable-footer .datatable-pager .pager li a{cursor:pointer;display:inline-block}.ngx-datatable .datatable-footer .datatable-pager .pager li.disabled a{cursor:not-allowed}"]
  6462. }] }
  6463. ];
  6464. /** @nocollapse */
  6465. DatatableComponent.ctorParameters = function () { return [
  6466. { type: ScrollbarHelper, decorators: [{ type: SkipSelf }] },
  6467. { type: DimensionsHelper, decorators: [{ type: SkipSelf }] },
  6468. { type: ChangeDetectorRef },
  6469. { type: ElementRef },
  6470. { type: KeyValueDiffers },
  6471. { type: ColumnChangesService },
  6472. { type: undefined, decorators: [{ type: Optional }, { type: Inject, args: ['configuration',] }] }
  6473. ]; };
  6474. DatatableComponent.propDecorators = {
  6475. targetMarkerTemplate: [{ type: Input }],
  6476. rows: [{ type: Input }],
  6477. groupRowsBy: [{ type: Input }],
  6478. groupedRows: [{ type: Input }],
  6479. columns: [{ type: Input }],
  6480. selected: [{ type: Input }],
  6481. scrollbarV: [{ type: Input }],
  6482. scrollbarH: [{ type: Input }],
  6483. rowHeight: [{ type: Input }],
  6484. columnMode: [{ type: Input }],
  6485. headerHeight: [{ type: Input }],
  6486. footerHeight: [{ type: Input }],
  6487. externalPaging: [{ type: Input }],
  6488. externalSorting: [{ type: Input }],
  6489. limit: [{ type: Input }],
  6490. count: [{ type: Input }],
  6491. offset: [{ type: Input }],
  6492. loadingIndicator: [{ type: Input }],
  6493. selectionType: [{ type: Input }],
  6494. reorderable: [{ type: Input }],
  6495. swapColumns: [{ type: Input }],
  6496. sortType: [{ type: Input }],
  6497. sorts: [{ type: Input }],
  6498. cssClasses: [{ type: Input }],
  6499. messages: [{ type: Input }],
  6500. rowClass: [{ type: Input }],
  6501. selectCheck: [{ type: Input }],
  6502. displayCheck: [{ type: Input }],
  6503. groupExpansionDefault: [{ type: Input }],
  6504. trackByProp: [{ type: Input }],
  6505. selectAllRowsOnPage: [{ type: Input }],
  6506. virtualization: [{ type: Input }],
  6507. treeFromRelation: [{ type: Input }],
  6508. treeToRelation: [{ type: Input }],
  6509. summaryRow: [{ type: Input }],
  6510. summaryHeight: [{ type: Input }],
  6511. summaryPosition: [{ type: Input }],
  6512. scroll: [{ type: Output }],
  6513. activate: [{ type: Output }],
  6514. select: [{ type: Output }],
  6515. sort: [{ type: Output }],
  6516. page: [{ type: Output }],
  6517. reorder: [{ type: Output }],
  6518. resize: [{ type: Output }],
  6519. tableContextmenu: [{ type: Output }],
  6520. treeAction: [{ type: Output }],
  6521. isFixedHeader: [{ type: HostBinding, args: ['class.fixed-header',] }],
  6522. isFixedRow: [{ type: HostBinding, args: ['class.fixed-row',] }],
  6523. isVertScroll: [{ type: HostBinding, args: ['class.scroll-vertical',] }],
  6524. isVirtualized: [{ type: HostBinding, args: ['class.virtualized',] }],
  6525. isHorScroll: [{ type: HostBinding, args: ['class.scroll-horz',] }],
  6526. isSelectable: [{ type: HostBinding, args: ['class.selectable',] }],
  6527. isCheckboxSelection: [{ type: HostBinding, args: ['class.checkbox-selection',] }],
  6528. isCellSelection: [{ type: HostBinding, args: ['class.cell-selection',] }],
  6529. isSingleSelection: [{ type: HostBinding, args: ['class.single-selection',] }],
  6530. isMultiSelection: [{ type: HostBinding, args: ['class.multi-selection',] }],
  6531. isMultiClickSelection: [{ type: HostBinding, args: ['class.multi-click-selection',] }],
  6532. columnTemplates: [{ type: ContentChildren, args: [DataTableColumnDirective,] }],
  6533. rowDetail: [{ type: ContentChild, args: [DatatableRowDetailDirective, { static: false },] }],
  6534. groupHeader: [{ type: ContentChild, args: [DatatableGroupHeaderDirective, { static: false },] }],
  6535. footer: [{ type: ContentChild, args: [DatatableFooterDirective, { static: false },] }],
  6536. bodyComponent: [{ type: ViewChild, args: [DataTableBodyComponent, { static: false },] }],
  6537. headerComponent: [{ type: ViewChild, args: [DataTableHeaderComponent, { static: false },] }],
  6538. rowIdentity: [{ type: Input }],
  6539. onWindowResize: [{ type: HostListener, args: ['window:resize',] }]
  6540. };
  6541. __decorate([
  6542. throttleable(5),
  6543. __metadata("design:type", Function),
  6544. __metadata("design:paramtypes", []),
  6545. __metadata("design:returntype", void 0)
  6546. ], DatatableComponent.prototype, "onWindowResize", null);
  6547. return DatatableComponent;
  6548. }());
  6549. if (false) {
  6550. /**
  6551. * Template for the target marker of drag target columns.
  6552. * @type {?}
  6553. */
  6554. DatatableComponent.prototype.targetMarkerTemplate;
  6555. /**
  6556. * This attribute allows the user to set a grouped array in the following format:
  6557. * [
  6558. * {groupid=1} [
  6559. * {id=1 name="test1"},
  6560. * {id=2 name="test2"},
  6561. * {id=3 name="test3"}
  6562. * ]},
  6563. * {groupid=2>[
  6564. * {id=4 name="test4"},
  6565. * {id=5 name="test5"},
  6566. * {id=6 name="test6"}
  6567. * ]}
  6568. * ]
  6569. * @type {?}
  6570. */
  6571. DatatableComponent.prototype.groupedRows;
  6572. /**
  6573. * List of row objects that should be
  6574. * represented as selected in the grid.
  6575. * Default value: `[]`
  6576. * @type {?}
  6577. */
  6578. DatatableComponent.prototype.selected;
  6579. /**
  6580. * Enable vertical scrollbars
  6581. * @type {?}
  6582. */
  6583. DatatableComponent.prototype.scrollbarV;
  6584. /**
  6585. * Enable horz scrollbars
  6586. * @type {?}
  6587. */
  6588. DatatableComponent.prototype.scrollbarH;
  6589. /**
  6590. * The row height; which is necessary
  6591. * to calculate the height for the lazy rendering.
  6592. * @type {?}
  6593. */
  6594. DatatableComponent.prototype.rowHeight;
  6595. /**
  6596. * Type of column width distribution formula.
  6597. * Example: flex, force, standard
  6598. * @type {?}
  6599. */
  6600. DatatableComponent.prototype.columnMode;
  6601. /**
  6602. * The minimum header height in pixels.
  6603. * Pass a falsey for no header
  6604. * @type {?}
  6605. */
  6606. DatatableComponent.prototype.headerHeight;
  6607. /**
  6608. * The minimum footer height in pixels.
  6609. * Pass falsey for no footer
  6610. * @type {?}
  6611. */
  6612. DatatableComponent.prototype.footerHeight;
  6613. /**
  6614. * If the table should use external paging
  6615. * otherwise its assumed that all data is preloaded.
  6616. * @type {?}
  6617. */
  6618. DatatableComponent.prototype.externalPaging;
  6619. /**
  6620. * If the table should use external sorting or
  6621. * the built-in basic sorting.
  6622. * @type {?}
  6623. */
  6624. DatatableComponent.prototype.externalSorting;
  6625. /**
  6626. * Show the linear loading bar.
  6627. * Default value: `false`
  6628. * @type {?}
  6629. */
  6630. DatatableComponent.prototype.loadingIndicator;
  6631. /**
  6632. * Type of row selection. Options are:
  6633. *
  6634. * - `single`
  6635. * - `multi`
  6636. * - `checkbox`
  6637. * - `multiClick`
  6638. * - `cell`
  6639. *
  6640. * For no selection pass a `falsey`.
  6641. * Default value: `undefined`
  6642. * @type {?}
  6643. */
  6644. DatatableComponent.prototype.selectionType;
  6645. /**
  6646. * Enable/Disable ability to re-order columns
  6647. * by dragging them.
  6648. * @type {?}
  6649. */
  6650. DatatableComponent.prototype.reorderable;
  6651. /**
  6652. * Swap columns on re-order columns or
  6653. * move them.
  6654. * @type {?}
  6655. */
  6656. DatatableComponent.prototype.swapColumns;
  6657. /**
  6658. * The type of sorting
  6659. * @type {?}
  6660. */
  6661. DatatableComponent.prototype.sortType;
  6662. /**
  6663. * Array of sorted columns by property and type.
  6664. * Default value: `[]`
  6665. * @type {?}
  6666. */
  6667. DatatableComponent.prototype.sorts;
  6668. /**
  6669. * Css class overrides
  6670. * @type {?}
  6671. */
  6672. DatatableComponent.prototype.cssClasses;
  6673. /**
  6674. * Message overrides for localization
  6675. *
  6676. * emptyMessage [default] = 'No data to display'
  6677. * totalMessage [default] = 'total'
  6678. * selectedMessage [default] = 'selected'
  6679. * @type {?}
  6680. */
  6681. DatatableComponent.prototype.messages;
  6682. /**
  6683. * Row specific classes.
  6684. * Similar implementation to ngClass.
  6685. *
  6686. * [rowClass]="'first second'"
  6687. * [rowClass]="{ 'first': true, 'second': true, 'third': false }"
  6688. * @type {?}
  6689. */
  6690. DatatableComponent.prototype.rowClass;
  6691. /**
  6692. * A boolean/function you can use to check whether you want
  6693. * to select a particular row based on a criteria. Example:
  6694. *
  6695. * (selection) => {
  6696. * return selection !== 'Ethel Price';
  6697. * }
  6698. * @type {?}
  6699. */
  6700. DatatableComponent.prototype.selectCheck;
  6701. /**
  6702. * A function you can use to check whether you want
  6703. * to show the checkbox for a particular row based on a criteria. Example:
  6704. *
  6705. * (row, column, value) => {
  6706. * return row.name !== 'Ethel Price';
  6707. * }
  6708. * @type {?}
  6709. */
  6710. DatatableComponent.prototype.displayCheck;
  6711. /**
  6712. * A boolean you can use to set the detault behaviour of rows and groups
  6713. * whether they will start expanded or not. If ommited the default is NOT expanded.
  6714. *
  6715. * @type {?}
  6716. */
  6717. DatatableComponent.prototype.groupExpansionDefault;
  6718. /**
  6719. * Property to which you can use for custom tracking of rows.
  6720. * Example: 'name'
  6721. * @type {?}
  6722. */
  6723. DatatableComponent.prototype.trackByProp;
  6724. /**
  6725. * Property to which you can use for determining select all
  6726. * rows on current page or not.
  6727. *
  6728. * \@memberOf DatatableComponent
  6729. * @type {?}
  6730. */
  6731. DatatableComponent.prototype.selectAllRowsOnPage;
  6732. /**
  6733. * A flag for row virtualization on / off
  6734. * @type {?}
  6735. */
  6736. DatatableComponent.prototype.virtualization;
  6737. /**
  6738. * Tree from relation
  6739. * @type {?}
  6740. */
  6741. DatatableComponent.prototype.treeFromRelation;
  6742. /**
  6743. * Tree to relation
  6744. * @type {?}
  6745. */
  6746. DatatableComponent.prototype.treeToRelation;
  6747. /**
  6748. * A flag for switching summary row on / off
  6749. * @type {?}
  6750. */
  6751. DatatableComponent.prototype.summaryRow;
  6752. /**
  6753. * A height of summary row
  6754. * @type {?}
  6755. */
  6756. DatatableComponent.prototype.summaryHeight;
  6757. /**
  6758. * A property holds a summary row position: top/bottom
  6759. * @type {?}
  6760. */
  6761. DatatableComponent.prototype.summaryPosition;
  6762. /**
  6763. * Body was scrolled typically in a `scrollbarV:true` scenario.
  6764. * @type {?}
  6765. */
  6766. DatatableComponent.prototype.scroll;
  6767. /**
  6768. * A cell or row was focused via keyboard or mouse click.
  6769. * @type {?}
  6770. */
  6771. DatatableComponent.prototype.activate;
  6772. /**
  6773. * A cell or row was selected.
  6774. * @type {?}
  6775. */
  6776. DatatableComponent.prototype.select;
  6777. /**
  6778. * Column sort was invoked.
  6779. * @type {?}
  6780. */
  6781. DatatableComponent.prototype.sort;
  6782. /**
  6783. * The table was paged either triggered by the pager or the body scroll.
  6784. * @type {?}
  6785. */
  6786. DatatableComponent.prototype.page;
  6787. /**
  6788. * Columns were re-ordered.
  6789. * @type {?}
  6790. */
  6791. DatatableComponent.prototype.reorder;
  6792. /**
  6793. * Column was resized.
  6794. * @type {?}
  6795. */
  6796. DatatableComponent.prototype.resize;
  6797. /**
  6798. * The context menu was invoked on the table.
  6799. * type indicates whether the header or the body was clicked.
  6800. * content contains either the column or the row that was clicked.
  6801. * @type {?}
  6802. */
  6803. DatatableComponent.prototype.tableContextmenu;
  6804. /**
  6805. * A row was expanded ot collapsed for tree
  6806. * @type {?}
  6807. */
  6808. DatatableComponent.prototype.treeAction;
  6809. /**
  6810. * Row Detail templates gathered from the ContentChild
  6811. * @type {?}
  6812. */
  6813. DatatableComponent.prototype.rowDetail;
  6814. /**
  6815. * Group Header templates gathered from the ContentChild
  6816. * @type {?}
  6817. */
  6818. DatatableComponent.prototype.groupHeader;
  6819. /**
  6820. * Footer template gathered from the ContentChild
  6821. * @type {?}
  6822. */
  6823. DatatableComponent.prototype.footer;
  6824. /**
  6825. * Reference to the body component for manually
  6826. * invoking functions on the body.
  6827. * @type {?}
  6828. */
  6829. DatatableComponent.prototype.bodyComponent;
  6830. /**
  6831. * Reference to the header component for manually
  6832. * invoking functions on the header.
  6833. *
  6834. * \@memberOf DatatableComponent
  6835. * @type {?}
  6836. */
  6837. DatatableComponent.prototype.headerComponent;
  6838. /** @type {?} */
  6839. DatatableComponent.prototype.element;
  6840. /** @type {?} */
  6841. DatatableComponent.prototype._innerWidth;
  6842. /** @type {?} */
  6843. DatatableComponent.prototype.pageSize;
  6844. /** @type {?} */
  6845. DatatableComponent.prototype.bodyHeight;
  6846. /** @type {?} */
  6847. DatatableComponent.prototype.rowCount;
  6848. /** @type {?} */
  6849. DatatableComponent.prototype.rowDiffer;
  6850. /** @type {?} */
  6851. DatatableComponent.prototype._offsetX;
  6852. /** @type {?} */
  6853. DatatableComponent.prototype._limit;
  6854. /** @type {?} */
  6855. DatatableComponent.prototype._count;
  6856. /** @type {?} */
  6857. DatatableComponent.prototype._offset;
  6858. /** @type {?} */
  6859. DatatableComponent.prototype._rows;
  6860. /** @type {?} */
  6861. DatatableComponent.prototype._groupRowsBy;
  6862. /** @type {?} */
  6863. DatatableComponent.prototype._internalRows;
  6864. /** @type {?} */
  6865. DatatableComponent.prototype._internalColumns;
  6866. /** @type {?} */
  6867. DatatableComponent.prototype._columns;
  6868. /** @type {?} */
  6869. DatatableComponent.prototype._columnTemplates;
  6870. /** @type {?} */
  6871. DatatableComponent.prototype._subscriptions;
  6872. /**
  6873. * This will be used when displaying or selecting rows.
  6874. * when tracking/comparing them, we'll use the value of this fn,
  6875. *
  6876. * (`fn(x) === fn(y)` instead of `x === y`)
  6877. * @type {?}
  6878. */
  6879. DatatableComponent.prototype.rowIdentity;
  6880. /**
  6881. * @type {?}
  6882. * @private
  6883. */
  6884. DatatableComponent.prototype.scrollbarHelper;
  6885. /**
  6886. * @type {?}
  6887. * @private
  6888. */
  6889. DatatableComponent.prototype.dimensionsHelper;
  6890. /**
  6891. * @type {?}
  6892. * @private
  6893. */
  6894. DatatableComponent.prototype.cd;
  6895. /**
  6896. * @type {?}
  6897. * @private
  6898. */
  6899. DatatableComponent.prototype.columnChangesService;
  6900. /**
  6901. * @type {?}
  6902. * @private
  6903. */
  6904. DatatableComponent.prototype.configuration;
  6905. }
  6906. /**
  6907. * @fileoverview added by tsickle
  6908. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  6909. */
  6910. var DataTableHeaderCellComponent = /** @class */ (function () {
  6911. function DataTableHeaderCellComponent(cd) {
  6912. this.cd = cd;
  6913. this.sort = new EventEmitter();
  6914. this.select = new EventEmitter();
  6915. this.columnContextmenu = new EventEmitter(false);
  6916. this.sortFn = this.onSort.bind(this);
  6917. this.selectFn = this.select.emit.bind(this.select);
  6918. this.cellContext = {
  6919. column: this.column,
  6920. sortDir: this.sortDir,
  6921. sortFn: this.sortFn,
  6922. allRowsSelected: this.allRowsSelected,
  6923. selectFn: this.selectFn
  6924. };
  6925. }
  6926. Object.defineProperty(DataTableHeaderCellComponent.prototype, "allRowsSelected", {
  6927. get: /**
  6928. * @return {?}
  6929. */
  6930. function () {
  6931. return this._allRowsSelected;
  6932. },
  6933. set: /**
  6934. * @param {?} value
  6935. * @return {?}
  6936. */
  6937. function (value) {
  6938. this._allRowsSelected = value;
  6939. this.cellContext.allRowsSelected = value;
  6940. },
  6941. enumerable: true,
  6942. configurable: true
  6943. });
  6944. Object.defineProperty(DataTableHeaderCellComponent.prototype, "column", {
  6945. get: /**
  6946. * @return {?}
  6947. */
  6948. function () {
  6949. return this._column;
  6950. },
  6951. set: /**
  6952. * @param {?} column
  6953. * @return {?}
  6954. */
  6955. function (column) {
  6956. this._column = column;
  6957. this.cellContext.column = column;
  6958. this.cd.markForCheck();
  6959. },
  6960. enumerable: true,
  6961. configurable: true
  6962. });
  6963. Object.defineProperty(DataTableHeaderCellComponent.prototype, "sorts", {
  6964. get: /**
  6965. * @return {?}
  6966. */
  6967. function () {
  6968. return this._sorts;
  6969. },
  6970. set: /**
  6971. * @param {?} val
  6972. * @return {?}
  6973. */
  6974. function (val) {
  6975. this._sorts = val;
  6976. this.sortDir = this.calcSortDir(val);
  6977. this.cellContext.sortDir = this.sortDir;
  6978. this.sortClass = this.calcSortClass(this.sortDir);
  6979. this.cd.markForCheck();
  6980. },
  6981. enumerable: true,
  6982. configurable: true
  6983. });
  6984. Object.defineProperty(DataTableHeaderCellComponent.prototype, "columnCssClasses", {
  6985. get: /**
  6986. * @return {?}
  6987. */
  6988. function () {
  6989. var e_1, _a;
  6990. /** @type {?} */
  6991. var cls = 'datatable-header-cell';
  6992. if (this.column.sortable)
  6993. cls += ' sortable';
  6994. if (this.column.resizeable)
  6995. cls += ' resizeable';
  6996. if (this.column.headerClass) {
  6997. if (typeof this.column.headerClass === 'string') {
  6998. cls += ' ' + this.column.headerClass;
  6999. }
  7000. else if (typeof this.column.headerClass === 'function') {
  7001. /** @type {?} */
  7002. var res = this.column.headerClass({
  7003. column: this.column
  7004. });
  7005. if (typeof res === 'string') {
  7006. cls += res;
  7007. }
  7008. else if (typeof res === 'object') {
  7009. /** @type {?} */
  7010. var keys = Object.keys(res);
  7011. try {
  7012. for (var keys_1 = __values(keys), keys_1_1 = keys_1.next(); !keys_1_1.done; keys_1_1 = keys_1.next()) {
  7013. var k = keys_1_1.value;
  7014. if (res[k] === true)
  7015. cls += " " + k;
  7016. }
  7017. }
  7018. catch (e_1_1) { e_1 = { error: e_1_1 }; }
  7019. finally {
  7020. try {
  7021. if (keys_1_1 && !keys_1_1.done && (_a = keys_1.return)) _a.call(keys_1);
  7022. }
  7023. finally { if (e_1) throw e_1.error; }
  7024. }
  7025. }
  7026. }
  7027. }
  7028. /** @type {?} */
  7029. var sortDir = this.sortDir;
  7030. if (sortDir) {
  7031. cls += " sort-active sort-" + sortDir;
  7032. }
  7033. return cls;
  7034. },
  7035. enumerable: true,
  7036. configurable: true
  7037. });
  7038. Object.defineProperty(DataTableHeaderCellComponent.prototype, "name", {
  7039. get: /**
  7040. * @return {?}
  7041. */
  7042. function () {
  7043. // guaranteed to have a value by setColumnDefaults() in column-helper.ts
  7044. return this.column.headerTemplate === undefined ? this.column.name : undefined;
  7045. },
  7046. enumerable: true,
  7047. configurable: true
  7048. });
  7049. Object.defineProperty(DataTableHeaderCellComponent.prototype, "minWidth", {
  7050. get: /**
  7051. * @return {?}
  7052. */
  7053. function () {
  7054. return this.column.minWidth;
  7055. },
  7056. enumerable: true,
  7057. configurable: true
  7058. });
  7059. Object.defineProperty(DataTableHeaderCellComponent.prototype, "maxWidth", {
  7060. get: /**
  7061. * @return {?}
  7062. */
  7063. function () {
  7064. return this.column.maxWidth;
  7065. },
  7066. enumerable: true,
  7067. configurable: true
  7068. });
  7069. Object.defineProperty(DataTableHeaderCellComponent.prototype, "width", {
  7070. get: /**
  7071. * @return {?}
  7072. */
  7073. function () {
  7074. return this.column.width;
  7075. },
  7076. enumerable: true,
  7077. configurable: true
  7078. });
  7079. Object.defineProperty(DataTableHeaderCellComponent.prototype, "isCheckboxable", {
  7080. get: /**
  7081. * @return {?}
  7082. */
  7083. function () {
  7084. return this.column.checkboxable && this.column.headerCheckboxable && this.selectionType === SelectionType.checkbox;
  7085. },
  7086. enumerable: true,
  7087. configurable: true
  7088. });
  7089. /**
  7090. * @param {?} $event
  7091. * @return {?}
  7092. */
  7093. DataTableHeaderCellComponent.prototype.onContextmenu = /**
  7094. * @param {?} $event
  7095. * @return {?}
  7096. */
  7097. function ($event) {
  7098. this.columnContextmenu.emit({ event: $event, column: this.column });
  7099. };
  7100. /**
  7101. * @param {?} sorts
  7102. * @return {?}
  7103. */
  7104. DataTableHeaderCellComponent.prototype.calcSortDir = /**
  7105. * @param {?} sorts
  7106. * @return {?}
  7107. */
  7108. function (sorts) {
  7109. var _this = this;
  7110. if (sorts && this.column) {
  7111. /** @type {?} */
  7112. var sort = sorts.find((/**
  7113. * @param {?} s
  7114. * @return {?}
  7115. */
  7116. function (s) {
  7117. return s.prop === _this.column.prop;
  7118. }));
  7119. if (sort)
  7120. return sort.dir;
  7121. }
  7122. };
  7123. /**
  7124. * @return {?}
  7125. */
  7126. DataTableHeaderCellComponent.prototype.onSort = /**
  7127. * @return {?}
  7128. */
  7129. function () {
  7130. if (!this.column.sortable)
  7131. return;
  7132. /** @type {?} */
  7133. var newValue = nextSortDir(this.sortType, this.sortDir);
  7134. this.sort.emit({
  7135. column: this.column,
  7136. prevValue: this.sortDir,
  7137. newValue: newValue
  7138. });
  7139. };
  7140. /**
  7141. * @param {?} sortDir
  7142. * @return {?}
  7143. */
  7144. DataTableHeaderCellComponent.prototype.calcSortClass = /**
  7145. * @param {?} sortDir
  7146. * @return {?}
  7147. */
  7148. function (sortDir) {
  7149. if (sortDir === SortDirection.asc) {
  7150. return "sort-btn sort-asc " + this.sortAscendingIcon;
  7151. }
  7152. else if (sortDir === SortDirection.desc) {
  7153. return "sort-btn sort-desc " + this.sortDescendingIcon;
  7154. }
  7155. else {
  7156. return "sort-btn";
  7157. }
  7158. };
  7159. DataTableHeaderCellComponent.decorators = [
  7160. { type: Component, args: [{
  7161. selector: 'datatable-header-cell',
  7162. template: "\n <div class=\"datatable-header-cell-template-wrap\">\n <ng-template\n *ngIf=\"isTarget\"\n [ngTemplateOutlet]=\"targetMarkerTemplate\"\n [ngTemplateOutletContext]=\"targetMarkerContext\"\n >\n </ng-template>\n <label *ngIf=\"isCheckboxable\" class=\"datatable-checkbox\">\n <input type=\"checkbox\" [checked]=\"allRowsSelected\" (change)=\"select.emit(!allRowsSelected)\" />\n </label>\n <span *ngIf=\"!column.headerTemplate\" class=\"datatable-header-cell-wrapper\">\n <span class=\"datatable-header-cell-label draggable\" (click)=\"onSort()\" [innerHTML]=\"name\"> </span>\n </span>\n <ng-template\n *ngIf=\"column.headerTemplate\"\n [ngTemplateOutlet]=\"column.headerTemplate\"\n [ngTemplateOutletContext]=\"cellContext\"\n >\n </ng-template>\n <span (click)=\"onSort()\" [class]=\"sortClass\"> </span>\n </div>\n ",
  7163. host: {
  7164. class: 'datatable-header-cell'
  7165. },
  7166. changeDetection: ChangeDetectionStrategy.OnPush
  7167. }] }
  7168. ];
  7169. /** @nocollapse */
  7170. DataTableHeaderCellComponent.ctorParameters = function () { return [
  7171. { type: ChangeDetectorRef }
  7172. ]; };
  7173. DataTableHeaderCellComponent.propDecorators = {
  7174. sortType: [{ type: Input }],
  7175. sortAscendingIcon: [{ type: Input }],
  7176. sortDescendingIcon: [{ type: Input }],
  7177. isTarget: [{ type: Input }],
  7178. targetMarkerTemplate: [{ type: Input }],
  7179. targetMarkerContext: [{ type: Input }],
  7180. allRowsSelected: [{ type: Input }],
  7181. selectionType: [{ type: Input }],
  7182. column: [{ type: Input }],
  7183. headerHeight: [{ type: HostBinding, args: ['style.height.px',] }, { type: Input }],
  7184. sorts: [{ type: Input }],
  7185. sort: [{ type: Output }],
  7186. select: [{ type: Output }],
  7187. columnContextmenu: [{ type: Output }],
  7188. columnCssClasses: [{ type: HostBinding, args: ['class',] }],
  7189. name: [{ type: HostBinding, args: ['attr.title',] }],
  7190. minWidth: [{ type: HostBinding, args: ['style.minWidth.px',] }],
  7191. maxWidth: [{ type: HostBinding, args: ['style.maxWidth.px',] }],
  7192. width: [{ type: HostBinding, args: ['style.width.px',] }],
  7193. onContextmenu: [{ type: HostListener, args: ['contextmenu', ['$event'],] }]
  7194. };
  7195. return DataTableHeaderCellComponent;
  7196. }());
  7197. if (false) {
  7198. /** @type {?} */
  7199. DataTableHeaderCellComponent.prototype.sortType;
  7200. /** @type {?} */
  7201. DataTableHeaderCellComponent.prototype.sortAscendingIcon;
  7202. /** @type {?} */
  7203. DataTableHeaderCellComponent.prototype.sortDescendingIcon;
  7204. /** @type {?} */
  7205. DataTableHeaderCellComponent.prototype.isTarget;
  7206. /** @type {?} */
  7207. DataTableHeaderCellComponent.prototype.targetMarkerTemplate;
  7208. /** @type {?} */
  7209. DataTableHeaderCellComponent.prototype.targetMarkerContext;
  7210. /** @type {?} */
  7211. DataTableHeaderCellComponent.prototype._allRowsSelected;
  7212. /** @type {?} */
  7213. DataTableHeaderCellComponent.prototype.selectionType;
  7214. /** @type {?} */
  7215. DataTableHeaderCellComponent.prototype.headerHeight;
  7216. /** @type {?} */
  7217. DataTableHeaderCellComponent.prototype.sort;
  7218. /** @type {?} */
  7219. DataTableHeaderCellComponent.prototype.select;
  7220. /** @type {?} */
  7221. DataTableHeaderCellComponent.prototype.columnContextmenu;
  7222. /** @type {?} */
  7223. DataTableHeaderCellComponent.prototype.sortFn;
  7224. /** @type {?} */
  7225. DataTableHeaderCellComponent.prototype.sortClass;
  7226. /** @type {?} */
  7227. DataTableHeaderCellComponent.prototype.sortDir;
  7228. /** @type {?} */
  7229. DataTableHeaderCellComponent.prototype.selectFn;
  7230. /** @type {?} */
  7231. DataTableHeaderCellComponent.prototype.cellContext;
  7232. /**
  7233. * @type {?}
  7234. * @private
  7235. */
  7236. DataTableHeaderCellComponent.prototype._column;
  7237. /**
  7238. * @type {?}
  7239. * @private
  7240. */
  7241. DataTableHeaderCellComponent.prototype._sorts;
  7242. /**
  7243. * @type {?}
  7244. * @private
  7245. */
  7246. DataTableHeaderCellComponent.prototype.cd;
  7247. }
  7248. /**
  7249. * @fileoverview added by tsickle
  7250. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  7251. */
  7252. var DataTableFooterComponent = /** @class */ (function () {
  7253. function DataTableFooterComponent() {
  7254. this.selectedCount = 0;
  7255. this.page = new EventEmitter();
  7256. }
  7257. Object.defineProperty(DataTableFooterComponent.prototype, "isVisible", {
  7258. get: /**
  7259. * @return {?}
  7260. */
  7261. function () {
  7262. return this.rowCount / this.pageSize > 1;
  7263. },
  7264. enumerable: true,
  7265. configurable: true
  7266. });
  7267. Object.defineProperty(DataTableFooterComponent.prototype, "curPage", {
  7268. get: /**
  7269. * @return {?}
  7270. */
  7271. function () {
  7272. return this.offset + 1;
  7273. },
  7274. enumerable: true,
  7275. configurable: true
  7276. });
  7277. DataTableFooterComponent.decorators = [
  7278. { type: Component, args: [{
  7279. selector: 'datatable-footer',
  7280. template: "\n <div\n class=\"datatable-footer-inner\"\n [ngClass]=\"{ 'selected-count': selectedMessage }\"\n [style.height.px]=\"footerHeight\"\n >\n <ng-template\n *ngIf=\"footerTemplate\"\n [ngTemplateOutlet]=\"footerTemplate.template\"\n [ngTemplateOutletContext]=\"{\n rowCount: rowCount,\n pageSize: pageSize,\n selectedCount: selectedCount,\n curPage: curPage,\n offset: offset\n }\"\n >\n </ng-template>\n <div class=\"page-count\" *ngIf=\"!footerTemplate\">\n <span *ngIf=\"selectedMessage\"> {{ selectedCount?.toLocaleString() }} {{ selectedMessage }} / </span>\n {{ rowCount?.toLocaleString() }} {{ totalMessage }}\n </div>\n <datatable-pager\n *ngIf=\"!footerTemplate\"\n [pagerLeftArrowIcon]=\"pagerLeftArrowIcon\"\n [pagerRightArrowIcon]=\"pagerRightArrowIcon\"\n [pagerPreviousIcon]=\"pagerPreviousIcon\"\n [pagerNextIcon]=\"pagerNextIcon\"\n [page]=\"curPage\"\n [size]=\"pageSize\"\n [count]=\"rowCount\"\n [hidden]=\"!isVisible\"\n (change)=\"page.emit($event)\"\n >\n </datatable-pager>\n </div>\n ",
  7281. host: {
  7282. class: 'datatable-footer'
  7283. },
  7284. changeDetection: ChangeDetectionStrategy.OnPush
  7285. }] }
  7286. ];
  7287. DataTableFooterComponent.propDecorators = {
  7288. footerHeight: [{ type: Input }],
  7289. rowCount: [{ type: Input }],
  7290. pageSize: [{ type: Input }],
  7291. offset: [{ type: Input }],
  7292. pagerLeftArrowIcon: [{ type: Input }],
  7293. pagerRightArrowIcon: [{ type: Input }],
  7294. pagerPreviousIcon: [{ type: Input }],
  7295. pagerNextIcon: [{ type: Input }],
  7296. totalMessage: [{ type: Input }],
  7297. footerTemplate: [{ type: Input }],
  7298. selectedCount: [{ type: Input }],
  7299. selectedMessage: [{ type: Input }],
  7300. page: [{ type: Output }]
  7301. };
  7302. return DataTableFooterComponent;
  7303. }());
  7304. if (false) {
  7305. /** @type {?} */
  7306. DataTableFooterComponent.prototype.footerHeight;
  7307. /** @type {?} */
  7308. DataTableFooterComponent.prototype.rowCount;
  7309. /** @type {?} */
  7310. DataTableFooterComponent.prototype.pageSize;
  7311. /** @type {?} */
  7312. DataTableFooterComponent.prototype.offset;
  7313. /** @type {?} */
  7314. DataTableFooterComponent.prototype.pagerLeftArrowIcon;
  7315. /** @type {?} */
  7316. DataTableFooterComponent.prototype.pagerRightArrowIcon;
  7317. /** @type {?} */
  7318. DataTableFooterComponent.prototype.pagerPreviousIcon;
  7319. /** @type {?} */
  7320. DataTableFooterComponent.prototype.pagerNextIcon;
  7321. /** @type {?} */
  7322. DataTableFooterComponent.prototype.totalMessage;
  7323. /** @type {?} */
  7324. DataTableFooterComponent.prototype.footerTemplate;
  7325. /** @type {?} */
  7326. DataTableFooterComponent.prototype.selectedCount;
  7327. /** @type {?} */
  7328. DataTableFooterComponent.prototype.selectedMessage;
  7329. /** @type {?} */
  7330. DataTableFooterComponent.prototype.page;
  7331. }
  7332. /**
  7333. * @fileoverview added by tsickle
  7334. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  7335. */
  7336. var DataTablePagerComponent = /** @class */ (function () {
  7337. function DataTablePagerComponent() {
  7338. this.change = new EventEmitter();
  7339. this._count = 0;
  7340. this._page = 1;
  7341. this._size = 0;
  7342. }
  7343. Object.defineProperty(DataTablePagerComponent.prototype, "size", {
  7344. get: /**
  7345. * @return {?}
  7346. */
  7347. function () {
  7348. return this._size;
  7349. },
  7350. set: /**
  7351. * @param {?} val
  7352. * @return {?}
  7353. */
  7354. function (val) {
  7355. this._size = val;
  7356. this.pages = this.calcPages();
  7357. },
  7358. enumerable: true,
  7359. configurable: true
  7360. });
  7361. Object.defineProperty(DataTablePagerComponent.prototype, "count", {
  7362. get: /**
  7363. * @return {?}
  7364. */
  7365. function () {
  7366. return this._count;
  7367. },
  7368. set: /**
  7369. * @param {?} val
  7370. * @return {?}
  7371. */
  7372. function (val) {
  7373. this._count = val;
  7374. this.pages = this.calcPages();
  7375. },
  7376. enumerable: true,
  7377. configurable: true
  7378. });
  7379. Object.defineProperty(DataTablePagerComponent.prototype, "page", {
  7380. get: /**
  7381. * @return {?}
  7382. */
  7383. function () {
  7384. return this._page;
  7385. },
  7386. set: /**
  7387. * @param {?} val
  7388. * @return {?}
  7389. */
  7390. function (val) {
  7391. this._page = val;
  7392. this.pages = this.calcPages();
  7393. },
  7394. enumerable: true,
  7395. configurable: true
  7396. });
  7397. Object.defineProperty(DataTablePagerComponent.prototype, "totalPages", {
  7398. get: /**
  7399. * @return {?}
  7400. */
  7401. function () {
  7402. /** @type {?} */
  7403. var count = this.size < 1 ? 1 : Math.ceil(this.count / this.size);
  7404. return Math.max(count || 0, 1);
  7405. },
  7406. enumerable: true,
  7407. configurable: true
  7408. });
  7409. /**
  7410. * @return {?}
  7411. */
  7412. DataTablePagerComponent.prototype.canPrevious = /**
  7413. * @return {?}
  7414. */
  7415. function () {
  7416. return this.page > 1;
  7417. };
  7418. /**
  7419. * @return {?}
  7420. */
  7421. DataTablePagerComponent.prototype.canNext = /**
  7422. * @return {?}
  7423. */
  7424. function () {
  7425. return this.page < this.totalPages;
  7426. };
  7427. /**
  7428. * @return {?}
  7429. */
  7430. DataTablePagerComponent.prototype.prevPage = /**
  7431. * @return {?}
  7432. */
  7433. function () {
  7434. this.selectPage(this.page - 1);
  7435. };
  7436. /**
  7437. * @return {?}
  7438. */
  7439. DataTablePagerComponent.prototype.nextPage = /**
  7440. * @return {?}
  7441. */
  7442. function () {
  7443. this.selectPage(this.page + 1);
  7444. };
  7445. /**
  7446. * @param {?} page
  7447. * @return {?}
  7448. */
  7449. DataTablePagerComponent.prototype.selectPage = /**
  7450. * @param {?} page
  7451. * @return {?}
  7452. */
  7453. function (page) {
  7454. if (page > 0 && page <= this.totalPages && page !== this.page) {
  7455. this.page = page;
  7456. this.change.emit({
  7457. page: page
  7458. });
  7459. }
  7460. };
  7461. /**
  7462. * @param {?=} page
  7463. * @return {?}
  7464. */
  7465. DataTablePagerComponent.prototype.calcPages = /**
  7466. * @param {?=} page
  7467. * @return {?}
  7468. */
  7469. function (page) {
  7470. /** @type {?} */
  7471. var pages = [];
  7472. /** @type {?} */
  7473. var startPage = 1;
  7474. /** @type {?} */
  7475. var endPage = this.totalPages;
  7476. /** @type {?} */
  7477. var maxSize = 5;
  7478. /** @type {?} */
  7479. var isMaxSized = maxSize < this.totalPages;
  7480. page = page || this.page;
  7481. if (isMaxSized) {
  7482. startPage = page - Math.floor(maxSize / 2);
  7483. endPage = page + Math.floor(maxSize / 2);
  7484. if (startPage < 1) {
  7485. startPage = 1;
  7486. endPage = Math.min(startPage + maxSize - 1, this.totalPages);
  7487. }
  7488. else if (endPage > this.totalPages) {
  7489. startPage = Math.max(this.totalPages - maxSize + 1, 1);
  7490. endPage = this.totalPages;
  7491. }
  7492. }
  7493. for (var num = startPage; num <= endPage; num++) {
  7494. pages.push({
  7495. number: num,
  7496. text: (/** @type {?} */ (((/** @type {?} */ (num)))))
  7497. });
  7498. }
  7499. return pages;
  7500. };
  7501. DataTablePagerComponent.decorators = [
  7502. { type: Component, args: [{
  7503. selector: 'datatable-pager',
  7504. template: "\n <ul class=\"pager\">\n <li [class.disabled]=\"!canPrevious()\">\n <a role=\"button\" aria-label=\"go to first page\" href=\"javascript:void(0)\" (click)=\"selectPage(1)\">\n <i class=\"{{ pagerPreviousIcon }}\"></i>\n </a>\n </li>\n <li [class.disabled]=\"!canPrevious()\">\n <a role=\"button\" aria-label=\"go to previous page\" href=\"javascript:void(0)\" (click)=\"prevPage()\">\n <i class=\"{{ pagerLeftArrowIcon }}\"></i>\n </a>\n </li>\n <li\n role=\"button\"\n [attr.aria-label]=\"'page ' + pg.number\"\n class=\"pages\"\n *ngFor=\"let pg of pages\"\n [class.active]=\"pg.number === page\"\n >\n <a href=\"javascript:void(0)\" (click)=\"selectPage(pg.number)\">\n {{ pg.text }}\n </a>\n </li>\n <li [class.disabled]=\"!canNext()\">\n <a role=\"button\" aria-label=\"go to next page\" href=\"javascript:void(0)\" (click)=\"nextPage()\">\n <i class=\"{{ pagerRightArrowIcon }}\"></i>\n </a>\n </li>\n <li [class.disabled]=\"!canNext()\">\n <a role=\"button\" aria-label=\"go to last page\" href=\"javascript:void(0)\" (click)=\"selectPage(totalPages)\">\n <i class=\"{{ pagerNextIcon }}\"></i>\n </a>\n </li>\n </ul>\n ",
  7505. host: {
  7506. class: 'datatable-pager'
  7507. },
  7508. changeDetection: ChangeDetectionStrategy.OnPush
  7509. }] }
  7510. ];
  7511. DataTablePagerComponent.propDecorators = {
  7512. pagerLeftArrowIcon: [{ type: Input }],
  7513. pagerRightArrowIcon: [{ type: Input }],
  7514. pagerPreviousIcon: [{ type: Input }],
  7515. pagerNextIcon: [{ type: Input }],
  7516. size: [{ type: Input }],
  7517. count: [{ type: Input }],
  7518. page: [{ type: Input }],
  7519. change: [{ type: Output }]
  7520. };
  7521. return DataTablePagerComponent;
  7522. }());
  7523. if (false) {
  7524. /** @type {?} */
  7525. DataTablePagerComponent.prototype.pagerLeftArrowIcon;
  7526. /** @type {?} */
  7527. DataTablePagerComponent.prototype.pagerRightArrowIcon;
  7528. /** @type {?} */
  7529. DataTablePagerComponent.prototype.pagerPreviousIcon;
  7530. /** @type {?} */
  7531. DataTablePagerComponent.prototype.pagerNextIcon;
  7532. /** @type {?} */
  7533. DataTablePagerComponent.prototype.change;
  7534. /** @type {?} */
  7535. DataTablePagerComponent.prototype._count;
  7536. /** @type {?} */
  7537. DataTablePagerComponent.prototype._page;
  7538. /** @type {?} */
  7539. DataTablePagerComponent.prototype._size;
  7540. /** @type {?} */
  7541. DataTablePagerComponent.prototype.pages;
  7542. }
  7543. /**
  7544. * @fileoverview added by tsickle
  7545. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  7546. */
  7547. var ProgressBarComponent = /** @class */ (function () {
  7548. function ProgressBarComponent() {
  7549. }
  7550. ProgressBarComponent.decorators = [
  7551. { type: Component, args: [{
  7552. selector: 'datatable-progress',
  7553. template: "\n <div class=\"progress-linear\" role=\"progressbar\">\n <div class=\"container\">\n <div class=\"bar\"></div>\n </div>\n </div>\n ",
  7554. changeDetection: ChangeDetectionStrategy.OnPush
  7555. }] }
  7556. ];
  7557. return ProgressBarComponent;
  7558. }());
  7559. /**
  7560. * @fileoverview added by tsickle
  7561. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  7562. */
  7563. /** @enum {number} */
  7564. var Keys = {
  7565. up: 38,
  7566. down: 40,
  7567. return: 13,
  7568. escape: 27,
  7569. left: 37,
  7570. right: 39,
  7571. };
  7572. Keys[Keys.up] = 'up';
  7573. Keys[Keys.down] = 'down';
  7574. Keys[Keys.return] = 'return';
  7575. Keys[Keys.escape] = 'escape';
  7576. Keys[Keys.left] = 'left';
  7577. Keys[Keys.right] = 'right';
  7578. /**
  7579. * @fileoverview added by tsickle
  7580. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  7581. */
  7582. var DataTableBodyRowComponent = /** @class */ (function () {
  7583. function DataTableBodyRowComponent(differs, scrollbarHelper, cd, element) {
  7584. this.differs = differs;
  7585. this.scrollbarHelper = scrollbarHelper;
  7586. this.cd = cd;
  7587. this.treeStatus = 'collapsed';
  7588. this.activate = new EventEmitter();
  7589. this.treeAction = new EventEmitter();
  7590. this._groupStyles = {
  7591. left: {},
  7592. center: {},
  7593. right: {}
  7594. };
  7595. this._element = element.nativeElement;
  7596. this._rowDiffer = differs.find({}).create();
  7597. }
  7598. Object.defineProperty(DataTableBodyRowComponent.prototype, "columns", {
  7599. get: /**
  7600. * @return {?}
  7601. */
  7602. function () {
  7603. return this._columns;
  7604. },
  7605. set: /**
  7606. * @param {?} val
  7607. * @return {?}
  7608. */
  7609. function (val) {
  7610. this._columns = val;
  7611. this.recalculateColumns(val);
  7612. this.buildStylesByGroup();
  7613. },
  7614. enumerable: true,
  7615. configurable: true
  7616. });
  7617. Object.defineProperty(DataTableBodyRowComponent.prototype, "innerWidth", {
  7618. get: /**
  7619. * @return {?}
  7620. */
  7621. function () {
  7622. return this._innerWidth;
  7623. },
  7624. set: /**
  7625. * @param {?} val
  7626. * @return {?}
  7627. */
  7628. function (val) {
  7629. if (this._columns) {
  7630. /** @type {?} */
  7631. var colByPin = columnsByPin(this._columns);
  7632. this._columnGroupWidths = columnGroupWidths(colByPin, this._columns);
  7633. }
  7634. this._innerWidth = val;
  7635. this.recalculateColumns();
  7636. this.buildStylesByGroup();
  7637. },
  7638. enumerable: true,
  7639. configurable: true
  7640. });
  7641. Object.defineProperty(DataTableBodyRowComponent.prototype, "offsetX", {
  7642. get: /**
  7643. * @return {?}
  7644. */
  7645. function () {
  7646. return this._offsetX;
  7647. },
  7648. set: /**
  7649. * @param {?} val
  7650. * @return {?}
  7651. */
  7652. function (val) {
  7653. this._offsetX = val;
  7654. this.buildStylesByGroup();
  7655. },
  7656. enumerable: true,
  7657. configurable: true
  7658. });
  7659. Object.defineProperty(DataTableBodyRowComponent.prototype, "cssClass", {
  7660. get: /**
  7661. * @return {?}
  7662. */
  7663. function () {
  7664. var e_1, _a;
  7665. /** @type {?} */
  7666. var cls = 'datatable-body-row';
  7667. if (this.isSelected) {
  7668. cls += ' active';
  7669. }
  7670. if (this.rowIndex % 2 !== 0) {
  7671. cls += ' datatable-row-odd';
  7672. }
  7673. if (this.rowIndex % 2 === 0) {
  7674. cls += ' datatable-row-even';
  7675. }
  7676. if (this.rowClass) {
  7677. /** @type {?} */
  7678. var res = this.rowClass(this.row);
  7679. if (typeof res === 'string') {
  7680. cls += " " + res;
  7681. }
  7682. else if (typeof res === 'object') {
  7683. /** @type {?} */
  7684. var keys = Object.keys(res);
  7685. try {
  7686. for (var keys_1 = __values(keys), keys_1_1 = keys_1.next(); !keys_1_1.done; keys_1_1 = keys_1.next()) {
  7687. var k = keys_1_1.value;
  7688. if (res[k] === true) {
  7689. cls += " " + k;
  7690. }
  7691. }
  7692. }
  7693. catch (e_1_1) { e_1 = { error: e_1_1 }; }
  7694. finally {
  7695. try {
  7696. if (keys_1_1 && !keys_1_1.done && (_a = keys_1.return)) _a.call(keys_1);
  7697. }
  7698. finally { if (e_1) throw e_1.error; }
  7699. }
  7700. }
  7701. }
  7702. return cls;
  7703. },
  7704. enumerable: true,
  7705. configurable: true
  7706. });
  7707. Object.defineProperty(DataTableBodyRowComponent.prototype, "columnsTotalWidths", {
  7708. get: /**
  7709. * @return {?}
  7710. */
  7711. function () {
  7712. return this._columnGroupWidths.total;
  7713. },
  7714. enumerable: true,
  7715. configurable: true
  7716. });
  7717. /**
  7718. * @return {?}
  7719. */
  7720. DataTableBodyRowComponent.prototype.ngDoCheck = /**
  7721. * @return {?}
  7722. */
  7723. function () {
  7724. if (this._rowDiffer.diff(this.row)) {
  7725. this.cd.markForCheck();
  7726. }
  7727. };
  7728. /**
  7729. * @param {?} index
  7730. * @param {?} colGroup
  7731. * @return {?}
  7732. */
  7733. DataTableBodyRowComponent.prototype.trackByGroups = /**
  7734. * @param {?} index
  7735. * @param {?} colGroup
  7736. * @return {?}
  7737. */
  7738. function (index, colGroup) {
  7739. return colGroup.type;
  7740. };
  7741. /**
  7742. * @param {?} index
  7743. * @param {?} column
  7744. * @return {?}
  7745. */
  7746. DataTableBodyRowComponent.prototype.columnTrackingFn = /**
  7747. * @param {?} index
  7748. * @param {?} column
  7749. * @return {?}
  7750. */
  7751. function (index, column) {
  7752. return column.$$id;
  7753. };
  7754. /**
  7755. * @return {?}
  7756. */
  7757. DataTableBodyRowComponent.prototype.buildStylesByGroup = /**
  7758. * @return {?}
  7759. */
  7760. function () {
  7761. this._groupStyles.left = this.calcStylesByGroup('left');
  7762. this._groupStyles.center = this.calcStylesByGroup('center');
  7763. this._groupStyles.right = this.calcStylesByGroup('right');
  7764. this.cd.markForCheck();
  7765. };
  7766. /**
  7767. * @param {?} group
  7768. * @return {?}
  7769. */
  7770. DataTableBodyRowComponent.prototype.calcStylesByGroup = /**
  7771. * @param {?} group
  7772. * @return {?}
  7773. */
  7774. function (group) {
  7775. /** @type {?} */
  7776. var widths = this._columnGroupWidths;
  7777. /** @type {?} */
  7778. var offsetX = this.offsetX;
  7779. /** @type {?} */
  7780. var styles = {
  7781. width: widths[group] + "px"
  7782. };
  7783. if (group === 'left') {
  7784. translateXY(styles, offsetX, 0);
  7785. }
  7786. else if (group === 'right') {
  7787. /** @type {?} */
  7788. var bodyWidth = parseInt(this.innerWidth + '', 0);
  7789. /** @type {?} */
  7790. var totalDiff = widths.total - bodyWidth;
  7791. /** @type {?} */
  7792. var offsetDiff = totalDiff - offsetX;
  7793. /** @type {?} */
  7794. var offset = (offsetDiff + this.scrollbarHelper.width) * -1;
  7795. translateXY(styles, offset, 0);
  7796. }
  7797. return styles;
  7798. };
  7799. /**
  7800. * @param {?} event
  7801. * @param {?} index
  7802. * @return {?}
  7803. */
  7804. DataTableBodyRowComponent.prototype.onActivate = /**
  7805. * @param {?} event
  7806. * @param {?} index
  7807. * @return {?}
  7808. */
  7809. function (event, index) {
  7810. event.cellIndex = index;
  7811. event.rowElement = this._element;
  7812. this.activate.emit(event);
  7813. };
  7814. /**
  7815. * @param {?} event
  7816. * @return {?}
  7817. */
  7818. DataTableBodyRowComponent.prototype.onKeyDown = /**
  7819. * @param {?} event
  7820. * @return {?}
  7821. */
  7822. function (event) {
  7823. /** @type {?} */
  7824. var keyCode = event.keyCode;
  7825. /** @type {?} */
  7826. var isTargetRow = event.target === this._element;
  7827. /** @type {?} */
  7828. var isAction = keyCode === Keys.return ||
  7829. keyCode === Keys.down ||
  7830. keyCode === Keys.up ||
  7831. keyCode === Keys.left ||
  7832. keyCode === Keys.right;
  7833. if (isAction && isTargetRow) {
  7834. event.preventDefault();
  7835. event.stopPropagation();
  7836. this.activate.emit({
  7837. type: 'keydown',
  7838. event: event,
  7839. row: this.row,
  7840. rowElement: this._element
  7841. });
  7842. }
  7843. };
  7844. /**
  7845. * @param {?} event
  7846. * @return {?}
  7847. */
  7848. DataTableBodyRowComponent.prototype.onMouseenter = /**
  7849. * @param {?} event
  7850. * @return {?}
  7851. */
  7852. function (event) {
  7853. this.activate.emit({
  7854. type: 'mouseenter',
  7855. event: event,
  7856. row: this.row,
  7857. rowElement: this._element
  7858. });
  7859. };
  7860. /**
  7861. * @param {?=} val
  7862. * @return {?}
  7863. */
  7864. DataTableBodyRowComponent.prototype.recalculateColumns = /**
  7865. * @param {?=} val
  7866. * @return {?}
  7867. */
  7868. function (val) {
  7869. if (val === void 0) { val = this.columns; }
  7870. this._columns = val;
  7871. /** @type {?} */
  7872. var colsByPin = columnsByPin(this._columns);
  7873. this._columnsByPin = columnsByPinArr(this._columns);
  7874. this._columnGroupWidths = columnGroupWidths(colsByPin, this._columns);
  7875. };
  7876. /**
  7877. * @return {?}
  7878. */
  7879. DataTableBodyRowComponent.prototype.onTreeAction = /**
  7880. * @return {?}
  7881. */
  7882. function () {
  7883. this.treeAction.emit();
  7884. };
  7885. DataTableBodyRowComponent.decorators = [
  7886. { type: Component, args: [{
  7887. selector: 'datatable-body-row',
  7888. changeDetection: ChangeDetectionStrategy.OnPush,
  7889. template: "\n <div\n *ngFor=\"let colGroup of _columnsByPin; let i = index; trackBy: trackByGroups\"\n class=\"datatable-row-{{ colGroup.type }} datatable-row-group\"\n [ngStyle]=\"_groupStyles[colGroup.type]\"\n >\n <datatable-body-cell\n *ngFor=\"let column of colGroup.columns; let ii = index; trackBy: columnTrackingFn\"\n tabindex=\"-1\"\n [row]=\"row\"\n [group]=\"group\"\n [expanded]=\"expanded\"\n [isSelected]=\"isSelected\"\n [rowIndex]=\"rowIndex\"\n [column]=\"column\"\n [rowHeight]=\"rowHeight\"\n [displayCheck]=\"displayCheck\"\n [treeStatus]=\"treeStatus\"\n (activate)=\"onActivate($event, ii)\"\n (treeAction)=\"onTreeAction()\"\n >\n </datatable-body-cell>\n </div>\n "
  7890. }] }
  7891. ];
  7892. /** @nocollapse */
  7893. DataTableBodyRowComponent.ctorParameters = function () { return [
  7894. { type: KeyValueDiffers },
  7895. { type: ScrollbarHelper, decorators: [{ type: SkipSelf }] },
  7896. { type: ChangeDetectorRef },
  7897. { type: ElementRef }
  7898. ]; };
  7899. DataTableBodyRowComponent.propDecorators = {
  7900. columns: [{ type: Input }],
  7901. innerWidth: [{ type: Input }],
  7902. expanded: [{ type: Input }],
  7903. rowClass: [{ type: Input }],
  7904. row: [{ type: Input }],
  7905. group: [{ type: Input }],
  7906. isSelected: [{ type: Input }],
  7907. rowIndex: [{ type: Input }],
  7908. displayCheck: [{ type: Input }],
  7909. treeStatus: [{ type: Input }],
  7910. offsetX: [{ type: Input }],
  7911. cssClass: [{ type: HostBinding, args: ['class',] }],
  7912. rowHeight: [{ type: HostBinding, args: ['style.height.px',] }, { type: Input }],
  7913. columnsTotalWidths: [{ type: HostBinding, args: ['style.width.px',] }],
  7914. activate: [{ type: Output }],
  7915. treeAction: [{ type: Output }],
  7916. onKeyDown: [{ type: HostListener, args: ['keydown', ['$event'],] }],
  7917. onMouseenter: [{ type: HostListener, args: ['mouseenter', ['$event'],] }]
  7918. };
  7919. return DataTableBodyRowComponent;
  7920. }());
  7921. if (false) {
  7922. /** @type {?} */
  7923. DataTableBodyRowComponent.prototype.expanded;
  7924. /** @type {?} */
  7925. DataTableBodyRowComponent.prototype.rowClass;
  7926. /** @type {?} */
  7927. DataTableBodyRowComponent.prototype.row;
  7928. /** @type {?} */
  7929. DataTableBodyRowComponent.prototype.group;
  7930. /** @type {?} */
  7931. DataTableBodyRowComponent.prototype.isSelected;
  7932. /** @type {?} */
  7933. DataTableBodyRowComponent.prototype.rowIndex;
  7934. /** @type {?} */
  7935. DataTableBodyRowComponent.prototype.displayCheck;
  7936. /** @type {?} */
  7937. DataTableBodyRowComponent.prototype.treeStatus;
  7938. /** @type {?} */
  7939. DataTableBodyRowComponent.prototype.rowHeight;
  7940. /** @type {?} */
  7941. DataTableBodyRowComponent.prototype.activate;
  7942. /** @type {?} */
  7943. DataTableBodyRowComponent.prototype.treeAction;
  7944. /** @type {?} */
  7945. DataTableBodyRowComponent.prototype._element;
  7946. /** @type {?} */
  7947. DataTableBodyRowComponent.prototype._columnGroupWidths;
  7948. /** @type {?} */
  7949. DataTableBodyRowComponent.prototype._columnsByPin;
  7950. /** @type {?} */
  7951. DataTableBodyRowComponent.prototype._offsetX;
  7952. /** @type {?} */
  7953. DataTableBodyRowComponent.prototype._columns;
  7954. /** @type {?} */
  7955. DataTableBodyRowComponent.prototype._innerWidth;
  7956. /** @type {?} */
  7957. DataTableBodyRowComponent.prototype._groupStyles;
  7958. /**
  7959. * @type {?}
  7960. * @private
  7961. */
  7962. DataTableBodyRowComponent.prototype._rowDiffer;
  7963. /**
  7964. * @type {?}
  7965. * @private
  7966. */
  7967. DataTableBodyRowComponent.prototype.differs;
  7968. /**
  7969. * @type {?}
  7970. * @private
  7971. */
  7972. DataTableBodyRowComponent.prototype.scrollbarHelper;
  7973. /**
  7974. * @type {?}
  7975. * @private
  7976. */
  7977. DataTableBodyRowComponent.prototype.cd;
  7978. }
  7979. /**
  7980. * @fileoverview added by tsickle
  7981. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  7982. */
  7983. var DataTableRowWrapperComponent = /** @class */ (function () {
  7984. function DataTableRowWrapperComponent(cd, differs) {
  7985. this.cd = cd;
  7986. this.differs = differs;
  7987. this.rowContextmenu = new EventEmitter(false);
  7988. this.groupContext = {
  7989. group: this.row,
  7990. expanded: this.expanded,
  7991. rowIndex: this.rowIndex
  7992. };
  7993. this.rowContext = {
  7994. row: this.row,
  7995. expanded: this.expanded,
  7996. rowIndex: this.rowIndex
  7997. };
  7998. this._expanded = false;
  7999. this.rowDiffer = differs.find({}).create();
  8000. }
  8001. Object.defineProperty(DataTableRowWrapperComponent.prototype, "rowIndex", {
  8002. get: /**
  8003. * @return {?}
  8004. */
  8005. function () {
  8006. return this._rowIndex;
  8007. },
  8008. set: /**
  8009. * @param {?} val
  8010. * @return {?}
  8011. */
  8012. function (val) {
  8013. this._rowIndex = val;
  8014. this.rowContext.rowIndex = val;
  8015. this.groupContext.rowIndex = val;
  8016. this.cd.markForCheck();
  8017. },
  8018. enumerable: true,
  8019. configurable: true
  8020. });
  8021. Object.defineProperty(DataTableRowWrapperComponent.prototype, "expanded", {
  8022. get: /**
  8023. * @return {?}
  8024. */
  8025. function () {
  8026. return this._expanded;
  8027. },
  8028. set: /**
  8029. * @param {?} val
  8030. * @return {?}
  8031. */
  8032. function (val) {
  8033. this._expanded = val;
  8034. this.groupContext.expanded = val;
  8035. this.rowContext.expanded = val;
  8036. this.cd.markForCheck();
  8037. },
  8038. enumerable: true,
  8039. configurable: true
  8040. });
  8041. /**
  8042. * @return {?}
  8043. */
  8044. DataTableRowWrapperComponent.prototype.ngDoCheck = /**
  8045. * @return {?}
  8046. */
  8047. function () {
  8048. if (this.rowDiffer.diff(this.row)) {
  8049. this.rowContext.row = this.row;
  8050. this.groupContext.group = this.row;
  8051. this.cd.markForCheck();
  8052. }
  8053. };
  8054. /**
  8055. * @param {?} $event
  8056. * @return {?}
  8057. */
  8058. DataTableRowWrapperComponent.prototype.onContextmenu = /**
  8059. * @param {?} $event
  8060. * @return {?}
  8061. */
  8062. function ($event) {
  8063. this.rowContextmenu.emit({ event: $event, row: this.row });
  8064. };
  8065. /**
  8066. * @return {?}
  8067. */
  8068. DataTableRowWrapperComponent.prototype.getGroupHeaderStyle = /**
  8069. * @return {?}
  8070. */
  8071. function () {
  8072. /** @type {?} */
  8073. var styles = {};
  8074. styles['transform'] = 'translate3d(' + this.offsetX + 'px, 0px, 0px)';
  8075. styles['backface-visibility'] = 'hidden';
  8076. styles['width'] = this.innerWidth;
  8077. return styles;
  8078. };
  8079. DataTableRowWrapperComponent.decorators = [
  8080. { type: Component, args: [{
  8081. selector: 'datatable-row-wrapper',
  8082. changeDetection: ChangeDetectionStrategy.OnPush,
  8083. template: "\n <div *ngIf=\"groupHeader && groupHeader.template\" class=\"datatable-group-header\" [ngStyle]=\"getGroupHeaderStyle()\">\n <ng-template\n *ngIf=\"groupHeader && groupHeader.template\"\n [ngTemplateOutlet]=\"groupHeader.template\"\n [ngTemplateOutletContext]=\"groupContext\"\n >\n </ng-template>\n </div>\n <ng-content *ngIf=\"(groupHeader && groupHeader.template && expanded) || (!groupHeader || !groupHeader.template)\">\n </ng-content>\n <div\n *ngIf=\"rowDetail && rowDetail.template && expanded\"\n [style.height.px]=\"detailRowHeight\"\n class=\"datatable-row-detail\"\n >\n <ng-template\n *ngIf=\"rowDetail && rowDetail.template\"\n [ngTemplateOutlet]=\"rowDetail.template\"\n [ngTemplateOutletContext]=\"rowContext\"\n >\n </ng-template>\n </div>\n ",
  8084. host: {
  8085. class: 'datatable-row-wrapper'
  8086. }
  8087. }] }
  8088. ];
  8089. /** @nocollapse */
  8090. DataTableRowWrapperComponent.ctorParameters = function () { return [
  8091. { type: ChangeDetectorRef },
  8092. { type: KeyValueDiffers }
  8093. ]; };
  8094. DataTableRowWrapperComponent.propDecorators = {
  8095. innerWidth: [{ type: Input }],
  8096. rowDetail: [{ type: Input }],
  8097. groupHeader: [{ type: Input }],
  8098. offsetX: [{ type: Input }],
  8099. detailRowHeight: [{ type: Input }],
  8100. row: [{ type: Input }],
  8101. groupedRows: [{ type: Input }],
  8102. rowContextmenu: [{ type: Output }],
  8103. rowIndex: [{ type: Input }],
  8104. expanded: [{ type: Input }],
  8105. onContextmenu: [{ type: HostListener, args: ['contextmenu', ['$event'],] }]
  8106. };
  8107. return DataTableRowWrapperComponent;
  8108. }());
  8109. if (false) {
  8110. /** @type {?} */
  8111. DataTableRowWrapperComponent.prototype.innerWidth;
  8112. /** @type {?} */
  8113. DataTableRowWrapperComponent.prototype.rowDetail;
  8114. /** @type {?} */
  8115. DataTableRowWrapperComponent.prototype.groupHeader;
  8116. /** @type {?} */
  8117. DataTableRowWrapperComponent.prototype.offsetX;
  8118. /** @type {?} */
  8119. DataTableRowWrapperComponent.prototype.detailRowHeight;
  8120. /** @type {?} */
  8121. DataTableRowWrapperComponent.prototype.row;
  8122. /** @type {?} */
  8123. DataTableRowWrapperComponent.prototype.groupedRows;
  8124. /** @type {?} */
  8125. DataTableRowWrapperComponent.prototype.rowContextmenu;
  8126. /** @type {?} */
  8127. DataTableRowWrapperComponent.prototype.groupContext;
  8128. /** @type {?} */
  8129. DataTableRowWrapperComponent.prototype.rowContext;
  8130. /**
  8131. * @type {?}
  8132. * @private
  8133. */
  8134. DataTableRowWrapperComponent.prototype.rowDiffer;
  8135. /**
  8136. * @type {?}
  8137. * @private
  8138. */
  8139. DataTableRowWrapperComponent.prototype._expanded;
  8140. /**
  8141. * @type {?}
  8142. * @private
  8143. */
  8144. DataTableRowWrapperComponent.prototype._rowIndex;
  8145. /**
  8146. * @type {?}
  8147. * @private
  8148. */
  8149. DataTableRowWrapperComponent.prototype.cd;
  8150. /**
  8151. * @type {?}
  8152. * @private
  8153. */
  8154. DataTableRowWrapperComponent.prototype.differs;
  8155. }
  8156. /**
  8157. * @fileoverview added by tsickle
  8158. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  8159. */
  8160. var DataTableBodyCellComponent = /** @class */ (function () {
  8161. function DataTableBodyCellComponent(element, cd) {
  8162. this.cd = cd;
  8163. this.activate = new EventEmitter();
  8164. this.treeAction = new EventEmitter();
  8165. this.isFocused = false;
  8166. this.onCheckboxChangeFn = this.onCheckboxChange.bind(this);
  8167. this.activateFn = this.activate.emit.bind(this.activate);
  8168. this.cellContext = {
  8169. onCheckboxChangeFn: this.onCheckboxChangeFn,
  8170. activateFn: this.activateFn,
  8171. row: this.row,
  8172. group: this.group,
  8173. value: this.value,
  8174. column: this.column,
  8175. rowHeight: this.rowHeight,
  8176. isSelected: this.isSelected,
  8177. rowIndex: this.rowIndex,
  8178. treeStatus: this.treeStatus,
  8179. onTreeAction: this.onTreeAction.bind(this)
  8180. };
  8181. this._element = element.nativeElement;
  8182. }
  8183. Object.defineProperty(DataTableBodyCellComponent.prototype, "group", {
  8184. get: /**
  8185. * @return {?}
  8186. */
  8187. function () {
  8188. return this._group;
  8189. },
  8190. set: /**
  8191. * @param {?} group
  8192. * @return {?}
  8193. */
  8194. function (group) {
  8195. this._group = group;
  8196. this.cellContext.group = group;
  8197. this.checkValueUpdates();
  8198. this.cd.markForCheck();
  8199. },
  8200. enumerable: true,
  8201. configurable: true
  8202. });
  8203. Object.defineProperty(DataTableBodyCellComponent.prototype, "rowHeight", {
  8204. get: /**
  8205. * @return {?}
  8206. */
  8207. function () {
  8208. return this._rowHeight;
  8209. },
  8210. set: /**
  8211. * @param {?} val
  8212. * @return {?}
  8213. */
  8214. function (val) {
  8215. this._rowHeight = val;
  8216. this.cellContext.rowHeight = val;
  8217. this.checkValueUpdates();
  8218. this.cd.markForCheck();
  8219. },
  8220. enumerable: true,
  8221. configurable: true
  8222. });
  8223. Object.defineProperty(DataTableBodyCellComponent.prototype, "isSelected", {
  8224. get: /**
  8225. * @return {?}
  8226. */
  8227. function () {
  8228. return this._isSelected;
  8229. },
  8230. set: /**
  8231. * @param {?} val
  8232. * @return {?}
  8233. */
  8234. function (val) {
  8235. this._isSelected = val;
  8236. this.cellContext.isSelected = val;
  8237. this.cd.markForCheck();
  8238. },
  8239. enumerable: true,
  8240. configurable: true
  8241. });
  8242. Object.defineProperty(DataTableBodyCellComponent.prototype, "expanded", {
  8243. get: /**
  8244. * @return {?}
  8245. */
  8246. function () {
  8247. return this._expanded;
  8248. },
  8249. set: /**
  8250. * @param {?} val
  8251. * @return {?}
  8252. */
  8253. function (val) {
  8254. this._expanded = val;
  8255. this.cellContext.expanded = val;
  8256. this.cd.markForCheck();
  8257. },
  8258. enumerable: true,
  8259. configurable: true
  8260. });
  8261. Object.defineProperty(DataTableBodyCellComponent.prototype, "rowIndex", {
  8262. get: /**
  8263. * @return {?}
  8264. */
  8265. function () {
  8266. return this._rowIndex;
  8267. },
  8268. set: /**
  8269. * @param {?} val
  8270. * @return {?}
  8271. */
  8272. function (val) {
  8273. this._rowIndex = val;
  8274. this.cellContext.rowIndex = val;
  8275. this.checkValueUpdates();
  8276. this.cd.markForCheck();
  8277. },
  8278. enumerable: true,
  8279. configurable: true
  8280. });
  8281. Object.defineProperty(DataTableBodyCellComponent.prototype, "column", {
  8282. get: /**
  8283. * @return {?}
  8284. */
  8285. function () {
  8286. return this._column;
  8287. },
  8288. set: /**
  8289. * @param {?} column
  8290. * @return {?}
  8291. */
  8292. function (column) {
  8293. this._column = column;
  8294. this.cellContext.column = column;
  8295. this.checkValueUpdates();
  8296. this.cd.markForCheck();
  8297. },
  8298. enumerable: true,
  8299. configurable: true
  8300. });
  8301. Object.defineProperty(DataTableBodyCellComponent.prototype, "row", {
  8302. get: /**
  8303. * @return {?}
  8304. */
  8305. function () {
  8306. return this._row;
  8307. },
  8308. set: /**
  8309. * @param {?} row
  8310. * @return {?}
  8311. */
  8312. function (row) {
  8313. this._row = row;
  8314. this.cellContext.row = row;
  8315. this.checkValueUpdates();
  8316. this.cd.markForCheck();
  8317. },
  8318. enumerable: true,
  8319. configurable: true
  8320. });
  8321. Object.defineProperty(DataTableBodyCellComponent.prototype, "sorts", {
  8322. get: /**
  8323. * @return {?}
  8324. */
  8325. function () {
  8326. return this._sorts;
  8327. },
  8328. set: /**
  8329. * @param {?} val
  8330. * @return {?}
  8331. */
  8332. function (val) {
  8333. this._sorts = val;
  8334. this.calcSortDir = this.calcSortDir(val);
  8335. },
  8336. enumerable: true,
  8337. configurable: true
  8338. });
  8339. Object.defineProperty(DataTableBodyCellComponent.prototype, "treeStatus", {
  8340. get: /**
  8341. * @return {?}
  8342. */
  8343. function () {
  8344. return this._treeStatus;
  8345. },
  8346. set: /**
  8347. * @param {?} status
  8348. * @return {?}
  8349. */
  8350. function (status) {
  8351. if (status !== 'collapsed' && status !== 'expanded' && status !== 'loading' && status !== 'disabled') {
  8352. this._treeStatus = 'collapsed';
  8353. }
  8354. else {
  8355. this._treeStatus = status;
  8356. }
  8357. this.cellContext.treeStatus = this._treeStatus;
  8358. this.checkValueUpdates();
  8359. this.cd.markForCheck();
  8360. },
  8361. enumerable: true,
  8362. configurable: true
  8363. });
  8364. Object.defineProperty(DataTableBodyCellComponent.prototype, "columnCssClasses", {
  8365. get: /**
  8366. * @return {?}
  8367. */
  8368. function () {
  8369. var e_1, _a;
  8370. /** @type {?} */
  8371. var cls = 'datatable-body-cell';
  8372. if (this.column.cellClass) {
  8373. if (typeof this.column.cellClass === 'string') {
  8374. cls += ' ' + this.column.cellClass;
  8375. }
  8376. else if (typeof this.column.cellClass === 'function') {
  8377. /** @type {?} */
  8378. var res = this.column.cellClass({
  8379. row: this.row,
  8380. group: this.group,
  8381. column: this.column,
  8382. value: this.value,
  8383. rowHeight: this.rowHeight
  8384. });
  8385. if (typeof res === 'string') {
  8386. cls += res;
  8387. }
  8388. else if (typeof res === 'object') {
  8389. /** @type {?} */
  8390. var keys = Object.keys(res);
  8391. try {
  8392. for (var keys_1 = __values(keys), keys_1_1 = keys_1.next(); !keys_1_1.done; keys_1_1 = keys_1.next()) {
  8393. var k = keys_1_1.value;
  8394. if (res[k] === true) {
  8395. cls += " " + k;
  8396. }
  8397. }
  8398. }
  8399. catch (e_1_1) { e_1 = { error: e_1_1 }; }
  8400. finally {
  8401. try {
  8402. if (keys_1_1 && !keys_1_1.done && (_a = keys_1.return)) _a.call(keys_1);
  8403. }
  8404. finally { if (e_1) throw e_1.error; }
  8405. }
  8406. }
  8407. }
  8408. }
  8409. if (!this.sortDir) {
  8410. cls += ' sort-active';
  8411. }
  8412. if (this.isFocused) {
  8413. cls += ' active';
  8414. }
  8415. if (this.sortDir === SortDirection.asc) {
  8416. cls += ' sort-asc';
  8417. }
  8418. if (this.sortDir === SortDirection.desc) {
  8419. cls += ' sort-desc';
  8420. }
  8421. return cls;
  8422. },
  8423. enumerable: true,
  8424. configurable: true
  8425. });
  8426. Object.defineProperty(DataTableBodyCellComponent.prototype, "width", {
  8427. get: /**
  8428. * @return {?}
  8429. */
  8430. function () {
  8431. return this.column.width;
  8432. },
  8433. enumerable: true,
  8434. configurable: true
  8435. });
  8436. Object.defineProperty(DataTableBodyCellComponent.prototype, "minWidth", {
  8437. get: /**
  8438. * @return {?}
  8439. */
  8440. function () {
  8441. return this.column.minWidth;
  8442. },
  8443. enumerable: true,
  8444. configurable: true
  8445. });
  8446. Object.defineProperty(DataTableBodyCellComponent.prototype, "maxWidth", {
  8447. get: /**
  8448. * @return {?}
  8449. */
  8450. function () {
  8451. return this.column.maxWidth;
  8452. },
  8453. enumerable: true,
  8454. configurable: true
  8455. });
  8456. Object.defineProperty(DataTableBodyCellComponent.prototype, "height", {
  8457. get: /**
  8458. * @return {?}
  8459. */
  8460. function () {
  8461. /** @type {?} */
  8462. var height = this.rowHeight;
  8463. if (isNaN(height)) {
  8464. return height;
  8465. }
  8466. return height + 'px';
  8467. },
  8468. enumerable: true,
  8469. configurable: true
  8470. });
  8471. /**
  8472. * @return {?}
  8473. */
  8474. DataTableBodyCellComponent.prototype.ngDoCheck = /**
  8475. * @return {?}
  8476. */
  8477. function () {
  8478. this.checkValueUpdates();
  8479. };
  8480. /**
  8481. * @return {?}
  8482. */
  8483. DataTableBodyCellComponent.prototype.ngOnDestroy = /**
  8484. * @return {?}
  8485. */
  8486. function () {
  8487. if (this.cellTemplate) {
  8488. this.cellTemplate.clear();
  8489. }
  8490. };
  8491. /**
  8492. * @return {?}
  8493. */
  8494. DataTableBodyCellComponent.prototype.checkValueUpdates = /**
  8495. * @return {?}
  8496. */
  8497. function () {
  8498. /** @type {?} */
  8499. var value = '';
  8500. if (!this.row || !this.column) {
  8501. value = '';
  8502. }
  8503. else {
  8504. /** @type {?} */
  8505. var val = this.column.$$valueGetter(this.row, this.column.prop);
  8506. /** @type {?} */
  8507. var userPipe = this.column.pipe;
  8508. if (userPipe) {
  8509. value = userPipe.transform(val);
  8510. }
  8511. else if (value !== undefined) {
  8512. value = val;
  8513. }
  8514. }
  8515. if (this.value !== value) {
  8516. this.value = value;
  8517. this.cellContext.value = value;
  8518. this.sanitizedValue = value !== null && value !== undefined ? this.stripHtml(value) : value;
  8519. this.cd.markForCheck();
  8520. }
  8521. };
  8522. /**
  8523. * @return {?}
  8524. */
  8525. DataTableBodyCellComponent.prototype.onFocus = /**
  8526. * @return {?}
  8527. */
  8528. function () {
  8529. this.isFocused = true;
  8530. };
  8531. /**
  8532. * @return {?}
  8533. */
  8534. DataTableBodyCellComponent.prototype.onBlur = /**
  8535. * @return {?}
  8536. */
  8537. function () {
  8538. this.isFocused = false;
  8539. };
  8540. /**
  8541. * @param {?} event
  8542. * @return {?}
  8543. */
  8544. DataTableBodyCellComponent.prototype.onClick = /**
  8545. * @param {?} event
  8546. * @return {?}
  8547. */
  8548. function (event) {
  8549. this.activate.emit({
  8550. type: 'click',
  8551. event: event,
  8552. row: this.row,
  8553. group: this.group,
  8554. rowHeight: this.rowHeight,
  8555. column: this.column,
  8556. value: this.value,
  8557. cellElement: this._element
  8558. });
  8559. };
  8560. /**
  8561. * @param {?} event
  8562. * @return {?}
  8563. */
  8564. DataTableBodyCellComponent.prototype.onDblClick = /**
  8565. * @param {?} event
  8566. * @return {?}
  8567. */
  8568. function (event) {
  8569. this.activate.emit({
  8570. type: 'dblclick',
  8571. event: event,
  8572. row: this.row,
  8573. group: this.group,
  8574. rowHeight: this.rowHeight,
  8575. column: this.column,
  8576. value: this.value,
  8577. cellElement: this._element
  8578. });
  8579. };
  8580. /**
  8581. * @param {?} event
  8582. * @return {?}
  8583. */
  8584. DataTableBodyCellComponent.prototype.onKeyDown = /**
  8585. * @param {?} event
  8586. * @return {?}
  8587. */
  8588. function (event) {
  8589. /** @type {?} */
  8590. var keyCode = event.keyCode;
  8591. /** @type {?} */
  8592. var isTargetCell = event.target === this._element;
  8593. /** @type {?} */
  8594. var isAction = keyCode === Keys.return ||
  8595. keyCode === Keys.down ||
  8596. keyCode === Keys.up ||
  8597. keyCode === Keys.left ||
  8598. keyCode === Keys.right;
  8599. if (isAction && isTargetCell) {
  8600. event.preventDefault();
  8601. event.stopPropagation();
  8602. this.activate.emit({
  8603. type: 'keydown',
  8604. event: event,
  8605. row: this.row,
  8606. group: this.group,
  8607. rowHeight: this.rowHeight,
  8608. column: this.column,
  8609. value: this.value,
  8610. cellElement: this._element
  8611. });
  8612. }
  8613. };
  8614. /**
  8615. * @param {?} event
  8616. * @return {?}
  8617. */
  8618. DataTableBodyCellComponent.prototype.onCheckboxChange = /**
  8619. * @param {?} event
  8620. * @return {?}
  8621. */
  8622. function (event) {
  8623. this.activate.emit({
  8624. type: 'checkbox',
  8625. event: event,
  8626. row: this.row,
  8627. group: this.group,
  8628. rowHeight: this.rowHeight,
  8629. column: this.column,
  8630. value: this.value,
  8631. cellElement: this._element,
  8632. treeStatus: 'collapsed'
  8633. });
  8634. };
  8635. /**
  8636. * @param {?} sorts
  8637. * @return {?}
  8638. */
  8639. DataTableBodyCellComponent.prototype.calcSortDir = /**
  8640. * @param {?} sorts
  8641. * @return {?}
  8642. */
  8643. function (sorts) {
  8644. var _this = this;
  8645. if (!sorts) {
  8646. return;
  8647. }
  8648. /** @type {?} */
  8649. var sort = sorts.find((/**
  8650. * @param {?} s
  8651. * @return {?}
  8652. */
  8653. function (s) {
  8654. return s.prop === _this.column.prop;
  8655. }));
  8656. if (sort) {
  8657. return sort.dir;
  8658. }
  8659. };
  8660. /**
  8661. * @param {?} html
  8662. * @return {?}
  8663. */
  8664. DataTableBodyCellComponent.prototype.stripHtml = /**
  8665. * @param {?} html
  8666. * @return {?}
  8667. */
  8668. function (html) {
  8669. if (!html.replace) {
  8670. return html;
  8671. }
  8672. return html.replace(/<\/?[^>]+(>|$)/g, '');
  8673. };
  8674. /**
  8675. * @return {?}
  8676. */
  8677. DataTableBodyCellComponent.prototype.onTreeAction = /**
  8678. * @return {?}
  8679. */
  8680. function () {
  8681. this.treeAction.emit(this.row);
  8682. };
  8683. /**
  8684. * @param {?} column
  8685. * @param {?} row
  8686. * @return {?}
  8687. */
  8688. DataTableBodyCellComponent.prototype.calcLeftMargin = /**
  8689. * @param {?} column
  8690. * @param {?} row
  8691. * @return {?}
  8692. */
  8693. function (column, row) {
  8694. /** @type {?} */
  8695. var levelIndent = column.treeLevelIndent != null ? column.treeLevelIndent : 50;
  8696. return column.isTreeColumn ? row.level * levelIndent : 0;
  8697. };
  8698. DataTableBodyCellComponent.decorators = [
  8699. { type: Component, args: [{
  8700. selector: 'datatable-body-cell',
  8701. changeDetection: ChangeDetectionStrategy.OnPush,
  8702. template: "\n <div class=\"datatable-body-cell-label\" [style.margin-left.px]=\"calcLeftMargin(column, row)\">\n <label\n *ngIf=\"column.checkboxable && (!displayCheck || displayCheck(row, column, value))\"\n class=\"datatable-checkbox\"\n >\n <input type=\"checkbox\" [checked]=\"isSelected\" (click)=\"onCheckboxChange($event)\" />\n </label>\n <ng-container *ngIf=\"column.isTreeColumn\">\n <button\n *ngIf=\"!column.treeToggleTemplate\"\n class=\"datatable-tree-button\"\n [disabled]=\"treeStatus === 'disabled'\"\n (click)=\"onTreeAction()\"\n >\n <span>\n <i *ngIf=\"treeStatus === 'loading'\" class=\"icon datatable-icon-collapse\"></i>\n <i *ngIf=\"treeStatus === 'collapsed'\" class=\"icon datatable-icon-up\"></i>\n <i *ngIf=\"treeStatus === 'expanded' || treeStatus === 'disabled'\" class=\"icon datatable-icon-down\"></i>\n </span>\n </button>\n <ng-template\n *ngIf=\"column.treeToggleTemplate\"\n [ngTemplateOutlet]=\"column.treeToggleTemplate\"\n [ngTemplateOutletContext]=\"{ cellContext: cellContext }\"\n >\n </ng-template>\n </ng-container>\n\n <span *ngIf=\"!column.cellTemplate\" [title]=\"sanitizedValue\" [innerHTML]=\"value\"> </span>\n <ng-template\n #cellTemplate\n *ngIf=\"column.cellTemplate\"\n [ngTemplateOutlet]=\"column.cellTemplate\"\n [ngTemplateOutletContext]=\"cellContext\"\n >\n </ng-template>\n </div>\n "
  8703. }] }
  8704. ];
  8705. /** @nocollapse */
  8706. DataTableBodyCellComponent.ctorParameters = function () { return [
  8707. { type: ElementRef },
  8708. { type: ChangeDetectorRef }
  8709. ]; };
  8710. DataTableBodyCellComponent.propDecorators = {
  8711. displayCheck: [{ type: Input }],
  8712. group: [{ type: Input }],
  8713. rowHeight: [{ type: Input }],
  8714. isSelected: [{ type: Input }],
  8715. expanded: [{ type: Input }],
  8716. rowIndex: [{ type: Input }],
  8717. column: [{ type: Input }],
  8718. row: [{ type: Input }],
  8719. sorts: [{ type: Input }],
  8720. treeStatus: [{ type: Input }],
  8721. activate: [{ type: Output }],
  8722. treeAction: [{ type: Output }],
  8723. cellTemplate: [{ type: ViewChild, args: ['cellTemplate', { read: ViewContainerRef, static: true },] }],
  8724. columnCssClasses: [{ type: HostBinding, args: ['class',] }],
  8725. width: [{ type: HostBinding, args: ['style.width.px',] }],
  8726. minWidth: [{ type: HostBinding, args: ['style.minWidth.px',] }],
  8727. maxWidth: [{ type: HostBinding, args: ['style.maxWidth.px',] }],
  8728. height: [{ type: HostBinding, args: ['style.height',] }],
  8729. onFocus: [{ type: HostListener, args: ['focus',] }],
  8730. onBlur: [{ type: HostListener, args: ['blur',] }],
  8731. onClick: [{ type: HostListener, args: ['click', ['$event'],] }],
  8732. onDblClick: [{ type: HostListener, args: ['dblclick', ['$event'],] }],
  8733. onKeyDown: [{ type: HostListener, args: ['keydown', ['$event'],] }]
  8734. };
  8735. return DataTableBodyCellComponent;
  8736. }());
  8737. if (false) {
  8738. /** @type {?} */
  8739. DataTableBodyCellComponent.prototype.displayCheck;
  8740. /** @type {?} */
  8741. DataTableBodyCellComponent.prototype.activate;
  8742. /** @type {?} */
  8743. DataTableBodyCellComponent.prototype.treeAction;
  8744. /** @type {?} */
  8745. DataTableBodyCellComponent.prototype.cellTemplate;
  8746. /** @type {?} */
  8747. DataTableBodyCellComponent.prototype.sanitizedValue;
  8748. /** @type {?} */
  8749. DataTableBodyCellComponent.prototype.value;
  8750. /** @type {?} */
  8751. DataTableBodyCellComponent.prototype.sortDir;
  8752. /** @type {?} */
  8753. DataTableBodyCellComponent.prototype.isFocused;
  8754. /** @type {?} */
  8755. DataTableBodyCellComponent.prototype.onCheckboxChangeFn;
  8756. /** @type {?} */
  8757. DataTableBodyCellComponent.prototype.activateFn;
  8758. /** @type {?} */
  8759. DataTableBodyCellComponent.prototype.cellContext;
  8760. /**
  8761. * @type {?}
  8762. * @private
  8763. */
  8764. DataTableBodyCellComponent.prototype._isSelected;
  8765. /**
  8766. * @type {?}
  8767. * @private
  8768. */
  8769. DataTableBodyCellComponent.prototype._sorts;
  8770. /**
  8771. * @type {?}
  8772. * @private
  8773. */
  8774. DataTableBodyCellComponent.prototype._column;
  8775. /**
  8776. * @type {?}
  8777. * @private
  8778. */
  8779. DataTableBodyCellComponent.prototype._row;
  8780. /**
  8781. * @type {?}
  8782. * @private
  8783. */
  8784. DataTableBodyCellComponent.prototype._group;
  8785. /**
  8786. * @type {?}
  8787. * @private
  8788. */
  8789. DataTableBodyCellComponent.prototype._rowHeight;
  8790. /**
  8791. * @type {?}
  8792. * @private
  8793. */
  8794. DataTableBodyCellComponent.prototype._rowIndex;
  8795. /**
  8796. * @type {?}
  8797. * @private
  8798. */
  8799. DataTableBodyCellComponent.prototype._expanded;
  8800. /**
  8801. * @type {?}
  8802. * @private
  8803. */
  8804. DataTableBodyCellComponent.prototype._element;
  8805. /**
  8806. * @type {?}
  8807. * @private
  8808. */
  8809. DataTableBodyCellComponent.prototype._treeStatus;
  8810. /**
  8811. * @type {?}
  8812. * @private
  8813. */
  8814. DataTableBodyCellComponent.prototype.cd;
  8815. }
  8816. /**
  8817. * @fileoverview added by tsickle
  8818. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  8819. */
  8820. /**
  8821. * @param {?} selected
  8822. * @param {?} row
  8823. * @param {?} comparefn
  8824. * @return {?}
  8825. */
  8826. function selectRows(selected, row, comparefn) {
  8827. /** @type {?} */
  8828. var selectedIndex = comparefn(row, selected);
  8829. if (selectedIndex > -1) {
  8830. selected.splice(selectedIndex, 1);
  8831. }
  8832. else {
  8833. selected.push(row);
  8834. }
  8835. return selected;
  8836. }
  8837. /**
  8838. * @param {?} selected
  8839. * @param {?} rows
  8840. * @param {?} index
  8841. * @param {?} prevIndex
  8842. * @param {?} comparefn
  8843. * @return {?}
  8844. */
  8845. function selectRowsBetween(selected, rows, index, prevIndex, comparefn) {
  8846. /** @type {?} */
  8847. var reverse = index < prevIndex;
  8848. for (var i = 0; i < rows.length; i++) {
  8849. /** @type {?} */
  8850. var row = rows[i];
  8851. /** @type {?} */
  8852. var greater = i >= prevIndex && i <= index;
  8853. /** @type {?} */
  8854. var lesser = i <= prevIndex && i >= index;
  8855. /** @type {?} */
  8856. var range = { start: 0, end: 0 };
  8857. if (reverse) {
  8858. range = {
  8859. start: index,
  8860. end: prevIndex
  8861. };
  8862. }
  8863. else {
  8864. range = {
  8865. start: prevIndex,
  8866. end: index + 1
  8867. };
  8868. }
  8869. if ((reverse && lesser) || (!reverse && greater)) {
  8870. // if in the positive range to be added to `selected`, and
  8871. // not already in the selected array, add it
  8872. if (i >= range.start && i <= range.end) {
  8873. selected.push(row);
  8874. }
  8875. }
  8876. }
  8877. return selected;
  8878. }
  8879. /**
  8880. * @fileoverview added by tsickle
  8881. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  8882. */
  8883. /**
  8884. * @record
  8885. */
  8886. function Model() { }
  8887. if (false) {
  8888. /** @type {?} */
  8889. Model.prototype.type;
  8890. /** @type {?} */
  8891. Model.prototype.event;
  8892. /** @type {?} */
  8893. Model.prototype.row;
  8894. /** @type {?} */
  8895. Model.prototype.rowElement;
  8896. /** @type {?} */
  8897. Model.prototype.cellElement;
  8898. /** @type {?} */
  8899. Model.prototype.cellIndex;
  8900. }
  8901. var DataTableSelectionComponent = /** @class */ (function () {
  8902. function DataTableSelectionComponent() {
  8903. this.activate = new EventEmitter();
  8904. this.select = new EventEmitter();
  8905. }
  8906. /**
  8907. * @param {?} event
  8908. * @param {?} index
  8909. * @param {?} row
  8910. * @return {?}
  8911. */
  8912. DataTableSelectionComponent.prototype.selectRow = /**
  8913. * @param {?} event
  8914. * @param {?} index
  8915. * @param {?} row
  8916. * @return {?}
  8917. */
  8918. function (event, index, row) {
  8919. var _a;
  8920. if (!this.selectEnabled)
  8921. return;
  8922. /** @type {?} */
  8923. var chkbox = this.selectionType === SelectionType.checkbox;
  8924. /** @type {?} */
  8925. var multi = this.selectionType === SelectionType.multi;
  8926. /** @type {?} */
  8927. var multiClick = this.selectionType === SelectionType.multiClick;
  8928. /** @type {?} */
  8929. var selected = [];
  8930. if (multi || chkbox || multiClick) {
  8931. if (event.shiftKey) {
  8932. selected = selectRowsBetween([], this.rows, index, this.prevIndex, this.getRowSelectedIdx.bind(this));
  8933. }
  8934. else if (event.ctrlKey || event.metaKey || multiClick || chkbox) {
  8935. selected = selectRows(__spread(this.selected), row, this.getRowSelectedIdx.bind(this));
  8936. }
  8937. else {
  8938. selected = selectRows([], row, this.getRowSelectedIdx.bind(this));
  8939. }
  8940. }
  8941. else {
  8942. selected = selectRows([], row, this.getRowSelectedIdx.bind(this));
  8943. }
  8944. if (typeof this.selectCheck === 'function') {
  8945. selected = selected.filter(this.selectCheck.bind(this));
  8946. }
  8947. this.selected.splice(0, this.selected.length);
  8948. (_a = this.selected).push.apply(_a, __spread(selected));
  8949. this.prevIndex = index;
  8950. this.select.emit({
  8951. selected: selected
  8952. });
  8953. };
  8954. /**
  8955. * @param {?} model
  8956. * @param {?} index
  8957. * @return {?}
  8958. */
  8959. DataTableSelectionComponent.prototype.onActivate = /**
  8960. * @param {?} model
  8961. * @param {?} index
  8962. * @return {?}
  8963. */
  8964. function (model, index) {
  8965. var type = model.type, event = model.event, row = model.row;
  8966. /** @type {?} */
  8967. var chkbox = this.selectionType === SelectionType.checkbox;
  8968. /** @type {?} */
  8969. var select = (!chkbox && (type === 'click' || type === 'dblclick')) || (chkbox && type === 'checkbox');
  8970. if (select) {
  8971. this.selectRow(event, index, row);
  8972. }
  8973. else if (type === 'keydown') {
  8974. if (((/** @type {?} */ (event))).keyCode === Keys.return) {
  8975. this.selectRow(event, index, row);
  8976. }
  8977. else {
  8978. this.onKeyboardFocus(model);
  8979. }
  8980. }
  8981. this.activate.emit(model);
  8982. };
  8983. /**
  8984. * @param {?} model
  8985. * @return {?}
  8986. */
  8987. DataTableSelectionComponent.prototype.onKeyboardFocus = /**
  8988. * @param {?} model
  8989. * @return {?}
  8990. */
  8991. function (model) {
  8992. var keyCode = (/** @type {?} */ (model.event)).keyCode;
  8993. /** @type {?} */
  8994. var shouldFocus = keyCode === Keys.up || keyCode === Keys.down || keyCode === Keys.right || keyCode === Keys.left;
  8995. if (shouldFocus) {
  8996. /** @type {?} */
  8997. var isCellSelection = this.selectionType === SelectionType.cell;
  8998. if (!model.cellElement || !isCellSelection) {
  8999. this.focusRow(model.rowElement, keyCode);
  9000. }
  9001. else if (isCellSelection) {
  9002. this.focusCell(model.cellElement, model.rowElement, keyCode, model.cellIndex);
  9003. }
  9004. }
  9005. };
  9006. /**
  9007. * @param {?} rowElement
  9008. * @param {?} keyCode
  9009. * @return {?}
  9010. */
  9011. DataTableSelectionComponent.prototype.focusRow = /**
  9012. * @param {?} rowElement
  9013. * @param {?} keyCode
  9014. * @return {?}
  9015. */
  9016. function (rowElement, keyCode) {
  9017. /** @type {?} */
  9018. var nextRowElement = this.getPrevNextRow(rowElement, keyCode);
  9019. if (nextRowElement)
  9020. nextRowElement.focus();
  9021. };
  9022. /**
  9023. * @param {?} rowElement
  9024. * @param {?} keyCode
  9025. * @return {?}
  9026. */
  9027. DataTableSelectionComponent.prototype.getPrevNextRow = /**
  9028. * @param {?} rowElement
  9029. * @param {?} keyCode
  9030. * @return {?}
  9031. */
  9032. function (rowElement, keyCode) {
  9033. /** @type {?} */
  9034. var parentElement = rowElement.parentElement;
  9035. if (parentElement) {
  9036. /** @type {?} */
  9037. var focusElement = void 0;
  9038. if (keyCode === Keys.up) {
  9039. focusElement = parentElement.previousElementSibling;
  9040. }
  9041. else if (keyCode === Keys.down) {
  9042. focusElement = parentElement.nextElementSibling;
  9043. }
  9044. if (focusElement && focusElement.children.length) {
  9045. return focusElement.children[0];
  9046. }
  9047. }
  9048. };
  9049. /**
  9050. * @param {?} cellElement
  9051. * @param {?} rowElement
  9052. * @param {?} keyCode
  9053. * @param {?} cellIndex
  9054. * @return {?}
  9055. */
  9056. DataTableSelectionComponent.prototype.focusCell = /**
  9057. * @param {?} cellElement
  9058. * @param {?} rowElement
  9059. * @param {?} keyCode
  9060. * @param {?} cellIndex
  9061. * @return {?}
  9062. */
  9063. function (cellElement, rowElement, keyCode, cellIndex) {
  9064. /** @type {?} */
  9065. var nextCellElement;
  9066. if (keyCode === Keys.left) {
  9067. nextCellElement = cellElement.previousElementSibling;
  9068. }
  9069. else if (keyCode === Keys.right) {
  9070. nextCellElement = cellElement.nextElementSibling;
  9071. }
  9072. else if (keyCode === Keys.up || keyCode === Keys.down) {
  9073. /** @type {?} */
  9074. var nextRowElement = this.getPrevNextRow(rowElement, keyCode);
  9075. if (nextRowElement) {
  9076. /** @type {?} */
  9077. var children = nextRowElement.getElementsByClassName('datatable-body-cell');
  9078. if (children.length)
  9079. nextCellElement = children[cellIndex];
  9080. }
  9081. }
  9082. if (nextCellElement)
  9083. nextCellElement.focus();
  9084. };
  9085. /**
  9086. * @param {?} row
  9087. * @return {?}
  9088. */
  9089. DataTableSelectionComponent.prototype.getRowSelected = /**
  9090. * @param {?} row
  9091. * @return {?}
  9092. */
  9093. function (row) {
  9094. return this.getRowSelectedIdx(row, this.selected) > -1;
  9095. };
  9096. /**
  9097. * @param {?} row
  9098. * @param {?} selected
  9099. * @return {?}
  9100. */
  9101. DataTableSelectionComponent.prototype.getRowSelectedIdx = /**
  9102. * @param {?} row
  9103. * @param {?} selected
  9104. * @return {?}
  9105. */
  9106. function (row, selected) {
  9107. var _this = this;
  9108. if (!selected || !selected.length)
  9109. return -1;
  9110. /** @type {?} */
  9111. var rowId = this.rowIdentity(row);
  9112. return selected.findIndex((/**
  9113. * @param {?} r
  9114. * @return {?}
  9115. */
  9116. function (r) {
  9117. /** @type {?} */
  9118. var id = _this.rowIdentity(r);
  9119. return id === rowId;
  9120. }));
  9121. };
  9122. DataTableSelectionComponent.decorators = [
  9123. { type: Component, args: [{
  9124. selector: 'datatable-selection',
  9125. template: "\n <ng-content></ng-content>\n ",
  9126. changeDetection: ChangeDetectionStrategy.OnPush
  9127. }] }
  9128. ];
  9129. DataTableSelectionComponent.propDecorators = {
  9130. rows: [{ type: Input }],
  9131. selected: [{ type: Input }],
  9132. selectEnabled: [{ type: Input }],
  9133. selectionType: [{ type: Input }],
  9134. rowIdentity: [{ type: Input }],
  9135. selectCheck: [{ type: Input }],
  9136. activate: [{ type: Output }],
  9137. select: [{ type: Output }]
  9138. };
  9139. return DataTableSelectionComponent;
  9140. }());
  9141. if (false) {
  9142. /** @type {?} */
  9143. DataTableSelectionComponent.prototype.rows;
  9144. /** @type {?} */
  9145. DataTableSelectionComponent.prototype.selected;
  9146. /** @type {?} */
  9147. DataTableSelectionComponent.prototype.selectEnabled;
  9148. /** @type {?} */
  9149. DataTableSelectionComponent.prototype.selectionType;
  9150. /** @type {?} */
  9151. DataTableSelectionComponent.prototype.rowIdentity;
  9152. /** @type {?} */
  9153. DataTableSelectionComponent.prototype.selectCheck;
  9154. /** @type {?} */
  9155. DataTableSelectionComponent.prototype.activate;
  9156. /** @type {?} */
  9157. DataTableSelectionComponent.prototype.select;
  9158. /** @type {?} */
  9159. DataTableSelectionComponent.prototype.prevIndex;
  9160. }
  9161. /**
  9162. * @fileoverview added by tsickle
  9163. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  9164. */
  9165. /**
  9166. * @record
  9167. */
  9168. function ISummaryColumn() { }
  9169. if (false) {
  9170. /** @type {?|undefined} */
  9171. ISummaryColumn.prototype.summaryFunc;
  9172. /** @type {?|undefined} */
  9173. ISummaryColumn.prototype.summaryTemplate;
  9174. /** @type {?} */
  9175. ISummaryColumn.prototype.prop;
  9176. /** @type {?|undefined} */
  9177. ISummaryColumn.prototype.pipe;
  9178. }
  9179. /**
  9180. * @param {?} cells
  9181. * @return {?}
  9182. */
  9183. function defaultSumFunc(cells) {
  9184. /** @type {?} */
  9185. var cellsWithValues = cells.filter((/**
  9186. * @param {?} cell
  9187. * @return {?}
  9188. */
  9189. function (cell) { return !!cell; }));
  9190. if (!cellsWithValues.length) {
  9191. return null;
  9192. }
  9193. if (cellsWithValues.some((/**
  9194. * @param {?} cell
  9195. * @return {?}
  9196. */
  9197. function (cell) { return typeof cell !== 'number'; }))) {
  9198. return null;
  9199. }
  9200. return cellsWithValues.reduce((/**
  9201. * @param {?} res
  9202. * @param {?} cell
  9203. * @return {?}
  9204. */
  9205. function (res, cell) { return res + cell; }));
  9206. }
  9207. /**
  9208. * @param {?} cells
  9209. * @return {?}
  9210. */
  9211. function noopSumFunc(cells) {
  9212. return null;
  9213. }
  9214. var DataTableSummaryRowComponent = /** @class */ (function () {
  9215. function DataTableSummaryRowComponent() {
  9216. this.summaryRow = {};
  9217. }
  9218. /**
  9219. * @return {?}
  9220. */
  9221. DataTableSummaryRowComponent.prototype.ngOnChanges = /**
  9222. * @return {?}
  9223. */
  9224. function () {
  9225. if (!this.columns || !this.rows) {
  9226. return;
  9227. }
  9228. this.updateInternalColumns();
  9229. this.updateValues();
  9230. };
  9231. /**
  9232. * @private
  9233. * @return {?}
  9234. */
  9235. DataTableSummaryRowComponent.prototype.updateInternalColumns = /**
  9236. * @private
  9237. * @return {?}
  9238. */
  9239. function () {
  9240. this._internalColumns = this.columns.map((/**
  9241. * @param {?} col
  9242. * @return {?}
  9243. */
  9244. function (col) { return (__assign({}, col, { cellTemplate: col.summaryTemplate })); }));
  9245. };
  9246. /**
  9247. * @private
  9248. * @return {?}
  9249. */
  9250. DataTableSummaryRowComponent.prototype.updateValues = /**
  9251. * @private
  9252. * @return {?}
  9253. */
  9254. function () {
  9255. var _this = this;
  9256. this.summaryRow = {};
  9257. this.columns
  9258. .filter((/**
  9259. * @param {?} col
  9260. * @return {?}
  9261. */
  9262. function (col) { return !col.summaryTemplate; }))
  9263. .forEach((/**
  9264. * @param {?} col
  9265. * @return {?}
  9266. */
  9267. function (col) {
  9268. /** @type {?} */
  9269. var cellsFromSingleColumn = _this.rows.map((/**
  9270. * @param {?} row
  9271. * @return {?}
  9272. */
  9273. function (row) { return row[col.prop]; }));
  9274. /** @type {?} */
  9275. var sumFunc = _this.getSummaryFunction(col);
  9276. _this.summaryRow[col.prop] = col.pipe
  9277. ? col.pipe.transform(sumFunc(cellsFromSingleColumn))
  9278. : sumFunc(cellsFromSingleColumn);
  9279. }));
  9280. };
  9281. /**
  9282. * @private
  9283. * @param {?} column
  9284. * @return {?}
  9285. */
  9286. DataTableSummaryRowComponent.prototype.getSummaryFunction = /**
  9287. * @private
  9288. * @param {?} column
  9289. * @return {?}
  9290. */
  9291. function (column) {
  9292. if (column.summaryFunc === undefined) {
  9293. return defaultSumFunc;
  9294. }
  9295. else if (column.summaryFunc === null) {
  9296. return noopSumFunc;
  9297. }
  9298. else {
  9299. return column.summaryFunc;
  9300. }
  9301. };
  9302. DataTableSummaryRowComponent.decorators = [
  9303. { type: Component, args: [{
  9304. selector: 'datatable-summary-row',
  9305. template: "\n <datatable-body-row\n *ngIf=\"summaryRow && _internalColumns\"\n tabindex=\"-1\"\n [innerWidth]=\"innerWidth\"\n [offsetX]=\"offsetX\"\n [columns]=\"_internalColumns\"\n [rowHeight]=\"rowHeight\"\n [row]=\"summaryRow\"\n [rowIndex]=\"-1\"\n >\n </datatable-body-row>\n ",
  9306. host: {
  9307. class: 'datatable-summary-row'
  9308. }
  9309. }] }
  9310. ];
  9311. DataTableSummaryRowComponent.propDecorators = {
  9312. rows: [{ type: Input }],
  9313. columns: [{ type: Input }],
  9314. rowHeight: [{ type: Input }],
  9315. offsetX: [{ type: Input }],
  9316. innerWidth: [{ type: Input }]
  9317. };
  9318. return DataTableSummaryRowComponent;
  9319. }());
  9320. if (false) {
  9321. /** @type {?} */
  9322. DataTableSummaryRowComponent.prototype.rows;
  9323. /** @type {?} */
  9324. DataTableSummaryRowComponent.prototype.columns;
  9325. /** @type {?} */
  9326. DataTableSummaryRowComponent.prototype.rowHeight;
  9327. /** @type {?} */
  9328. DataTableSummaryRowComponent.prototype.offsetX;
  9329. /** @type {?} */
  9330. DataTableSummaryRowComponent.prototype.innerWidth;
  9331. /** @type {?} */
  9332. DataTableSummaryRowComponent.prototype._internalColumns;
  9333. /** @type {?} */
  9334. DataTableSummaryRowComponent.prototype.summaryRow;
  9335. }
  9336. /**
  9337. * @fileoverview added by tsickle
  9338. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  9339. */
  9340. var NgxDatatableModule = /** @class */ (function () {
  9341. function NgxDatatableModule() {
  9342. }
  9343. /**
  9344. * Configure global configuration via INgxDatatableConfig
  9345. * @param configuration
  9346. */
  9347. /**
  9348. * Configure global configuration via INgxDatatableConfig
  9349. * @param {?} configuration
  9350. * @return {?}
  9351. */
  9352. NgxDatatableModule.forRoot = /**
  9353. * Configure global configuration via INgxDatatableConfig
  9354. * @param {?} configuration
  9355. * @return {?}
  9356. */
  9357. function (configuration) {
  9358. return {
  9359. ngModule: NgxDatatableModule,
  9360. providers: [{ provide: 'configuration', useValue: configuration }]
  9361. };
  9362. };
  9363. NgxDatatableModule.decorators = [
  9364. { type: NgModule, args: [{
  9365. imports: [CommonModule],
  9366. providers: [ScrollbarHelper, DimensionsHelper, ColumnChangesService],
  9367. declarations: [
  9368. DataTableFooterTemplateDirective,
  9369. VisibilityDirective,
  9370. DraggableDirective,
  9371. ResizeableDirective,
  9372. OrderableDirective,
  9373. LongPressDirective,
  9374. ScrollerComponent,
  9375. DatatableComponent,
  9376. DataTableColumnDirective,
  9377. DataTableHeaderComponent,
  9378. DataTableHeaderCellComponent,
  9379. DataTableBodyComponent,
  9380. DataTableFooterComponent,
  9381. DataTablePagerComponent,
  9382. ProgressBarComponent,
  9383. DataTableBodyRowComponent,
  9384. DataTableRowWrapperComponent,
  9385. DatatableRowDetailDirective,
  9386. DatatableGroupHeaderDirective,
  9387. DatatableRowDetailTemplateDirective,
  9388. DataTableBodyCellComponent,
  9389. DataTableSelectionComponent,
  9390. DataTableColumnHeaderDirective,
  9391. DataTableColumnCellDirective,
  9392. DataTableColumnCellTreeToggle,
  9393. DatatableFooterDirective,
  9394. DatatableGroupHeaderTemplateDirective,
  9395. DataTableSummaryRowComponent
  9396. ],
  9397. exports: [
  9398. DatatableComponent,
  9399. DatatableRowDetailDirective,
  9400. DatatableGroupHeaderDirective,
  9401. DatatableRowDetailTemplateDirective,
  9402. DataTableColumnDirective,
  9403. DataTableColumnHeaderDirective,
  9404. DataTableColumnCellDirective,
  9405. DataTableColumnCellTreeToggle,
  9406. DataTableFooterTemplateDirective,
  9407. DatatableFooterDirective,
  9408. DataTablePagerComponent,
  9409. DatatableGroupHeaderTemplateDirective
  9410. ]
  9411. },] }
  9412. ];
  9413. return NgxDatatableModule;
  9414. }());
  9415. /**
  9416. * Interface definition for INgxDatatableConfig global configuration
  9417. * @record
  9418. */
  9419. function INgxDatatableConfig() { }
  9420. if (false) {
  9421. /** @type {?} */
  9422. INgxDatatableConfig.prototype.messages;
  9423. }
  9424. /**
  9425. * @fileoverview added by tsickle
  9426. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  9427. */
  9428. /** @enum {string} */
  9429. var ClickType = {
  9430. single: 'single',
  9431. double: 'double',
  9432. };
  9433. /**
  9434. * @fileoverview added by tsickle
  9435. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  9436. */
  9437. /**
  9438. * Column Type
  9439. * @record
  9440. */
  9441. function TableColumn() { }
  9442. if (false) {
  9443. /**
  9444. * Internal unique id
  9445. *
  9446. * \@memberOf TableColumn
  9447. * @type {?|undefined}
  9448. */
  9449. TableColumn.prototype.$$id;
  9450. /**
  9451. * Internal for column width distributions
  9452. *
  9453. * \@memberOf TableColumn
  9454. * @type {?|undefined}
  9455. */
  9456. TableColumn.prototype.$$oldWidth;
  9457. /**
  9458. * Internal for setColumnDefaults
  9459. *
  9460. * \@memberOf TableColumn
  9461. * @type {?|undefined}
  9462. */
  9463. TableColumn.prototype.$$valueGetter;
  9464. /**
  9465. * Determines if column is checkbox
  9466. *
  9467. * \@memberOf TableColumn
  9468. * @type {?|undefined}
  9469. */
  9470. TableColumn.prototype.checkboxable;
  9471. /**
  9472. * Determines if the column is frozen to the left
  9473. *
  9474. * \@memberOf TableColumn
  9475. * @type {?|undefined}
  9476. */
  9477. TableColumn.prototype.frozenLeft;
  9478. /**
  9479. * Determines if the column is frozen to the right
  9480. *
  9481. * \@memberOf TableColumn
  9482. * @type {?|undefined}
  9483. */
  9484. TableColumn.prototype.frozenRight;
  9485. /**
  9486. * The grow factor relative to other columns. Same as the flex-grow
  9487. * API from http =//www.w3.org/TR/css3-flexbox/. Basically;
  9488. * take any available extra width and distribute it proportionally
  9489. * according to all columns' flexGrow values.
  9490. *
  9491. * \@memberOf TableColumn
  9492. * @type {?|undefined}
  9493. */
  9494. TableColumn.prototype.flexGrow;
  9495. /**
  9496. * Min width of the column
  9497. *
  9498. * \@memberOf TableColumn
  9499. * @type {?|undefined}
  9500. */
  9501. TableColumn.prototype.minWidth;
  9502. /**
  9503. * Max width of the column
  9504. *
  9505. * \@memberOf TableColumn
  9506. * @type {?|undefined}
  9507. */
  9508. TableColumn.prototype.maxWidth;
  9509. /**
  9510. * The default width of the column, in pixels
  9511. *
  9512. * \@memberOf TableColumn
  9513. * @type {?|undefined}
  9514. */
  9515. TableColumn.prototype.width;
  9516. /**
  9517. * Can the column be resized
  9518. *
  9519. * \@memberOf TableColumn
  9520. * @type {?|undefined}
  9521. */
  9522. TableColumn.prototype.resizeable;
  9523. /**
  9524. * Custom sort comparator
  9525. *
  9526. * \@memberOf TableColumn
  9527. * @type {?|undefined}
  9528. */
  9529. TableColumn.prototype.comparator;
  9530. /**
  9531. * Custom pipe transforms
  9532. *
  9533. * \@memberOf TableColumn
  9534. * @type {?|undefined}
  9535. */
  9536. TableColumn.prototype.pipe;
  9537. /**
  9538. * Can the column be sorted
  9539. *
  9540. * \@memberOf TableColumn
  9541. * @type {?|undefined}
  9542. */
  9543. TableColumn.prototype.sortable;
  9544. /**
  9545. * Can the column be re-arranged by dragging
  9546. *
  9547. * \@memberOf TableColumn
  9548. * @type {?|undefined}
  9549. */
  9550. TableColumn.prototype.draggable;
  9551. /**
  9552. * Whether the column can automatically resize to fill space in the table.
  9553. *
  9554. * \@memberOf TableColumn
  9555. * @type {?|undefined}
  9556. */
  9557. TableColumn.prototype.canAutoResize;
  9558. /**
  9559. * Column name or label
  9560. *
  9561. * \@memberOf TableColumn
  9562. * @type {?|undefined}
  9563. */
  9564. TableColumn.prototype.name;
  9565. /**
  9566. * Property to bind to the row. Example:
  9567. *
  9568. * `someField` or `some.field.nested`, 0 (numeric)
  9569. *
  9570. * If left blank, will use the name as camel case conversion
  9571. *
  9572. * \@memberOf TableColumn
  9573. * @type {?|undefined}
  9574. */
  9575. TableColumn.prototype.prop;
  9576. /**
  9577. * Cell template ref
  9578. *
  9579. * \@memberOf TableColumn
  9580. * @type {?|undefined}
  9581. */
  9582. TableColumn.prototype.cellTemplate;
  9583. /**
  9584. * Header template ref
  9585. *
  9586. * \@memberOf TableColumn
  9587. * @type {?|undefined}
  9588. */
  9589. TableColumn.prototype.headerTemplate;
  9590. /**
  9591. * Tree toggle template ref
  9592. *
  9593. * \@memberOf TableColumn
  9594. * @type {?|undefined}
  9595. */
  9596. TableColumn.prototype.treeToggleTemplate;
  9597. /**
  9598. * CSS Classes for the cell
  9599. *
  9600. *
  9601. * \@memberOf TableColumn
  9602. * @type {?|undefined}
  9603. */
  9604. TableColumn.prototype.cellClass;
  9605. /**
  9606. * CSS classes for the header
  9607. *
  9608. *
  9609. * \@memberOf TableColumn
  9610. * @type {?|undefined}
  9611. */
  9612. TableColumn.prototype.headerClass;
  9613. /**
  9614. * Header checkbox enabled
  9615. *
  9616. * \@memberOf TableColumn
  9617. * @type {?|undefined}
  9618. */
  9619. TableColumn.prototype.headerCheckboxable;
  9620. /**
  9621. * Is tree displayed on this column
  9622. *
  9623. * \@memberOf TableColumn
  9624. * @type {?|undefined}
  9625. */
  9626. TableColumn.prototype.isTreeColumn;
  9627. /**
  9628. * Width of the tree level indent
  9629. *
  9630. * \@memberOf TableColumn
  9631. * @type {?|undefined}
  9632. */
  9633. TableColumn.prototype.treeLevelIndent;
  9634. /**
  9635. * Summary function
  9636. *
  9637. * \@memberOf TableColumn
  9638. * @type {?|undefined}
  9639. */
  9640. TableColumn.prototype.summaryFunc;
  9641. /**
  9642. * Summary cell template ref
  9643. *
  9644. * \@memberOf TableColumn
  9645. * @type {?|undefined}
  9646. */
  9647. TableColumn.prototype.summaryTemplate;
  9648. }
  9649. /**
  9650. * @fileoverview added by tsickle
  9651. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  9652. */
  9653. /**
  9654. * @record
  9655. */
  9656. function SortPropDir() { }
  9657. if (false) {
  9658. /** @type {?} */
  9659. SortPropDir.prototype.dir;
  9660. /** @type {?} */
  9661. SortPropDir.prototype.prop;
  9662. }
  9663. /**
  9664. * @fileoverview added by tsickle
  9665. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  9666. */
  9667. if (typeof document !== 'undefined' && !document.elementsFromPoint) {
  9668. document.elementsFromPoint = elementsFromPoint;
  9669. }
  9670. /*tslint:disable*/
  9671. /**
  9672. * Polyfill for `elementsFromPoint`
  9673. *
  9674. * https://developer.mozilla.org/en-US/docs/Web/API/Document/elementsFromPoint
  9675. * https://gist.github.com/iddan/54d5d9e58311b0495a91bf06de661380
  9676. * https://gist.github.com/oslego/7265412
  9677. * @param {?} x
  9678. * @param {?} y
  9679. * @return {?}
  9680. */
  9681. function elementsFromPoint(x, y) {
  9682. /** @type {?} */
  9683. var elements = [];
  9684. /** @type {?} */
  9685. var previousPointerEvents = [];
  9686. /** @type {?} */
  9687. var current;
  9688. // TODO: window.getComputedStyle should be used with inferred type (Element)
  9689. /** @type {?} */
  9690. var i;
  9691. /** @type {?} */
  9692. var d;
  9693. //if (document === undefined) return elements;
  9694. // get all elements via elementFromPoint, and remove them from hit-testing in order
  9695. while ((current = document.elementFromPoint(x, y)) && elements.indexOf(current) === -1 && current != null) {
  9696. // push the element and its current style
  9697. elements.push(current);
  9698. previousPointerEvents.push({
  9699. value: current.style.getPropertyValue('pointer-events'),
  9700. priority: current.style.getPropertyPriority('pointer-events')
  9701. });
  9702. // add "pointer-events: none", to get to the underlying element
  9703. current.style.setProperty('pointer-events', 'none', 'important');
  9704. }
  9705. // restore the previous pointer-events values
  9706. for (i = previousPointerEvents.length; (d = previousPointerEvents[--i]);) {
  9707. elements[i].style.setProperty('pointer-events', d.value ? d.value : '', d.priority);
  9708. }
  9709. // return our results
  9710. return elements;
  9711. }
  9712. /**
  9713. * @fileoverview added by tsickle
  9714. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  9715. */
  9716. /**
  9717. * @fileoverview added by tsickle
  9718. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  9719. */
  9720. export { ClickType, ColumnChangesService, ColumnMode, ContextmenuType, DataTableBodyCellComponent, DataTableBodyComponent, DataTableBodyRowComponent, DataTableColumnCellDirective, DataTableColumnCellTreeToggle, DataTableColumnDirective, DataTableColumnHeaderDirective, DataTableFooterComponent, DataTableFooterTemplateDirective, DataTableHeaderCellComponent, DataTableHeaderComponent, DataTablePagerComponent, DataTableRowWrapperComponent, DataTableSelectionComponent, DataTableSummaryRowComponent, DatatableComponent, DatatableFooterDirective, DatatableGroupHeaderDirective, DatatableGroupHeaderTemplateDirective, DatatableRowDetailDirective, DatatableRowDetailTemplateDirective, DimensionsHelper, DraggableDirective, Keys, LongPressDirective, NgxDatatableModule, OrderableDirective, ProgressBarComponent, ResizeableDirective, RowHeightCache, ScrollbarHelper, ScrollerComponent, SelectionType, SortDirection, SortType, VisibilityDirective, adjustColumnWidths, camelCase, columnGroupWidths, columnTotalWidth, columnsByPin, columnsByPinArr, columnsTotalWidth, deCamelCase, deepValueGetter, elementsFromPoint, emptyStringGetter, forceFillColumnWidths, getTotalFlexGrow, getVendorPrefixedName, getterForProp, groupRowsByParents, id, isNullOrUndefined, nextSortDir, numericIndexGetter, optionalGetterForProp, orderByComparator, selectRows, selectRowsBetween, setColumnDefaults, shallowValueGetter, sortRows, throttle, throttleable, translateTemplates, translateXY };
  9721. //# sourceMappingURL=swimlane-ngx-datatable.js.map