swimlane-ngx-datatable.js 251 KB

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