swimlane-ngx-datatable.umd.js 367 KB

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